Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
57,777,104 | There is an image with an insecure URL loaded in the code of my wordpress site but I cannot find i to delete as it? | <p>I have a woocommerce WP website and I previously installed a currency converter plugin so my website could display multiple currencies.</p>
<p>I uploaded some flag images of different countries to the plugin so that it would display the relevant flags next to each currency.</p>
<p>I later decided to uninstall the currency switcher plugin and then after I did that I installed a letsencrypt SSL certificate. After a few months I decided to re-install the currency switcher plugin and after activating it my SSL certificate dissapeared.</p>
<p>I went to www.whynopadlock.com and I tested my website to find out why the SSL padlock had dissapeared and the results advised that there are two images with insecure URL's which are causing the security failure.</p>
<p>It appears that when I deleted the currency switcher plugin the flag images I uploaded with insecure url's did not actually get deleted and when I reinstalled the plugin it is somehow using them again.</p>
<p>I have searched the theme editor, I also looked in File manager to see if I could locate these images so I could delete them but cannot find them anywhere.</p>
<p>I also looked in the media library and they are not there either.</p>
<p>When I am on the homepage of my website in Firefox and I click F12, if I scroll through the HTML which appears I can find the image URL's which are causing the problem but do not know where that file would be located so I can edit it.</p>
<p>Could anybody please advise?</p>
<p>Thank you</p>
| <php><html><wordpress><wordpress-theming> | 2019-09-03 18:37:11 | LQ_CLOSE |
57,777,915 | SwiftUI Preview canvas and Core Data | <p>Preview canvas is is crashing but in simulator everything working fine. I assuming it related to @ObservedObject and @Fetchrequest...</p>
<p>tried solution for here <a href="https://stackoverflow.com/questions/57700304/previewing-contentview-with-coredata">Previewing ContentView with CoreData</a></p>
<p>doesn't work</p>
<pre><code> import SwiftUI
import CoreData
struct TemplateEditor: View {
@Environment(\.managedObjectContext) var managedObjectContext
@FetchRequest(
entity: GlobalPlaceholders.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \GlobalPlaceholders.category, ascending: false),
]
) var placeholders: FetchedResults<GlobalPlaceholders>
@ObservedObject var documentTemplate: Templates
@State private var documentTemplateDraft = DocumentTemplateDraft()
@Binding var editing: Bool
var body: some View {
VStack(){
HStack(){
cancelButton
Spacer()
saveButton
}.padding()
addButton
ForEach(placeholders) {placeholder in
Text(placeholder.name)
}
TextField("Title", text: $documentTemplateDraft.title)
TextField("Body", text: $documentTemplateDraft.body)
.padding()
.frame(width: 100, height:400)
Spacer()
}
...
}
struct TemplateEditor_Previews: PreviewProvider {
static var previews: some View {
let managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Templates")
request.sortDescriptors = [NSSortDescriptor(keyPath: \Templates.created, ascending: false)]
let documentTemplate = try! managedObjectContext.fetch(request).first as! Templates
return TemplateEditor(documentTemplate: documentTemplate, editing: .constant(true)).environment(\.managedObjectContext, managedObjectContext).environmentObject(documentTemplate)
}
}
</code></pre>
<p>Expected to generate preview</p>
| <core-data><swiftui> | 2019-09-03 19:48:39 | HQ |
57,778,460 | How to Write an or statement with Int | i have tried to run it multiple ways, but the dialog box comes up even if one is selected. How do i get the dialog box to come up if only one of the buttons is not selected?
if (!shapesButtons[0].isSelected())
{
JOptionPane.showMessageDialog(null,"Please select one of the Buttons ");
}
else if (!shapesButtons[1].isSelected())
{
JOptionPane.showMessageDialog(null,"Please select one of the Buttons ");
}
else
{
return;
} | <java> | 2019-09-03 20:39:34 | LQ_EDIT |
57,779,959 | Why do both promise .then() and .catch() are called? | <p>I'm beginning to write a discord bot with the Discord.js library (version 11.5.1). Promises returned by methods don't work as expected because then() and catch() callbacks are both called if it's successful.</p>
<p>I'm using nodejs version 11.15.0.</p>
<p>In this example, I send a message in the test-bot channel when the bot in logged.</p>
<pre><code>const Discord = require('discord.js');
const client = new Discord.Client();
const auth = require('./auth.json');
client.on('ready', () => {
const guild = client.guilds.find(
guild => guild.name === 'test');
const channel = guild.channels.find(
ch => ch.name === 'test-bot');
if (!channel) {
console.error('no channel found');
return ;
}
channel.send('heeeello')
.then(console.log('cool'))
.catch(console.error('grrr'));
});
client.login(auth.token);
</code></pre>
<p>The message is well sended on the discord channel and the console output is:</p>
<pre><code>cool
grrr
</code></pre>
<p>but I don't expect <code>grrr</code> in the output.</p>
| <javascript><node.js><discord.js> | 2019-09-04 00:03:35 | LQ_CLOSE |
57,780,757 | What are the truthy and falsy values in Perl 6? | <p>While it is always possible to use mixins or method overrides to modify the Bool coercions, <em>by default</em> what values are considered to be truthy and what values are considered to be falsy?</p>
<p>Note: this question was <a href="https://stackoverflow.com/questions/125265/how-does-perl-6-evaluate-truthiness">asked previously</a>, but unfortunately it is so old its content is completely out of date and useless is modern Perl 6.</p>
| <raku><truthiness> | 2019-09-04 02:33:41 | HQ |
57,781,181 | How can I save an email attachment to SharePoint using MS Flow | I need to save the email attachment (excel) to SharePoint list or library when I receive new email | <sharepoint><power-automate> | 2019-09-04 03:39:26 | LQ_EDIT |
57,782,690 | How to calculate the percentage of word using SQL Query? | Actual case is to read the total count difference in percentage basis. Since hello comes in first word its count-'1' but in the 3rd rows Hello count -2. Now i need to calculate the percentage of the word usage like previously it is 1, now it is 2 percentage is 50% increased. so i have to calculate percentage for particular word from previous and current.
No, Text, Word, Totalcount
1, Hello Welcome,Hello,1
2, Hello Text, Text,1
3, Hello Text! Hello, Hello,2
I have formed the following SQL query to calculate the percentage but it leads error.
select Totalcount * 100/SUM(TotalCount) from table where Word = 'Hello'
it leads following issue .
Word is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Am googling but not found the better solution for it.
Suggest me the way the sql querying to do this. Any help appreciated.
| <sql><sql-server> | 2019-09-04 06:31:53 | LQ_EDIT |
57,784,257 | White label fonts in iOS application | <p>My task is to white label iOS application.</p>
<p>I've done a lot of things for Assets and for Info.plist, I just left to manage a white-label solution for the <strong>fonts</strong>.</p>
<p>For example, Every customer wants to have their fonts for titles. So I got in my mind some solutions.</p>
<blockquote>
<p>1) There will be some Config files we can write customers fonts in the
config file and when Application will run I will read font from that
config file and apply them but didn't know how to to that on every
screen dynamically.</p>
<p>2) Create some base ViewController class and apply here fonts, then
every viewController class will be the child of that base class and
apply view controllers specific title fonts to my base fonts.</p>
</blockquote>
<p>I don't know if those solutions are good and the reason for this question is to get some advice and some better solutions. </p>
<p>Maybe someone is more experienced than me and maybe someone has a better idea than me. Every single advice and help will be very valuable for me.</p>
<p>Thank you.</p>
| <ios><objective-c><swift><white-labelling> | 2019-09-04 08:18:20 | LQ_CLOSE |
57,788,324 | How to delete lines in a file based on an the indices in a list | I have a txt file which is of this format:
1 2 [2, 3, 5]
2 5 [3, 4]
5 6 [4, 5]
4 9 [1, 6]
I need to write a programme such that it would delete the lines having the first column equals to the indices in the list of each line. but, if a line has been processed, then it is safe.
For example, when it goes to the first line, read the list first, the indices inside is 2, 3 and 5. so it would delete line with first column 2, 3 and 5. so the second and third line are deleted. when it comes to the fourth line, it has indices 1 and 6. However, this time, line 1 has been processed so it would not delete the first line but the line starts with 6. | <python><python-3.x> | 2019-09-04 12:22:16 | LQ_EDIT |
57,788,878 | Android 10: What are my options to save files on external storage into a directory called "/sdcard/my-app/" | <p>Up until Android Pie I always stored files which the app needed to get stored on <code>/sdcard/my-app/</code>, which I got via</p>
<p><code>File fBaseDir = new File(Environment.getExternalStorageDirectory(), "my-app");</code></p>
<p>One of my App stores hundreds (up to multiple thousands) of favicons in <code>/sdcard/my-app/favicons</code>, and when the user creates a backup of the app, it gets stored in <code>/sdcard/my-app/backups</code>. Webpage-Screenshots taken by Google Chrome when shared with my app are stored in <code>/sdcard/my-app/screenshots</code>, and so on.</p>
<p>When I uninstall the app, I can reinstall it later and still have all the favicons, screenshots and the backups available for restoring the state and not having to re-download all the favicons (and possibly having lost all the other data).</p>
<p>I can also easily create a backup of the <code>/sdcard/my-app/</code> directory by copying it to my PC, and restore it on another phone, for example when I migrate to a new device.</p>
<p>I can also use a file explorer to see which files are in that directory, and select and email them or copy them to Google Drive, or delete some of them specifically (like old backup files).</p>
<p>With Android 10 this approach has collapsed. I cannot add the favicons to the Images Media-Folder, because they are no real images, they would clutter the view unnecessarily and possibly ban my developer account from the Play Store for doing this. I also don't want to store all this data in an App-Private directory, because it will get deleted when the app gets uninstalled, and because other apps like an explorer cannot access them.</p>
<p>What are my options? Manually selecting files or directories is not an option, unless the directory only needs to be selected once and then access is granted forever (to read and write files).</p>
<p>I never read or write outside of <code>/sdcard/my-app/</code>.</p>
| <android><android-external-storage><file-access><android-10.0> | 2019-09-04 12:54:54 | HQ |
57,790,105 | why cannot properly add jar library | I have added a jar file as the library,and i know their existence by importing class of it,but somehow it cannot compile properly.
screenshot:
https://photos.app.goo.gl/3VxWfKv1muuwgTuL8 | <android><import><jar> | 2019-09-04 14:00:19 | LQ_EDIT |
57,791,423 | Match Price with different Currency | Just start learning VBA
I want to match the product price with the currency to get a new price
No Name Quantity Price Product Currency OrderID Currency $
1 Tim 5 5 A HKD RX12 HKD 1
2 Alan 6 5 A HKD PR22 USD 7.8
3 Alan 2 6 B USD PR22 CAN 6
4 Bob 3 5 A HKD ED45
5 Bob 8 8 C CAN ED45
6 Tim 10 6 B USD AS63
7 Rose 12 8 C CAN LM36
8 Cathy 15 6 B USD JI48
9 Rose 2 5 A HKD HG54
10 Tim 8 6 B USD VB87
Sub NP()
Dim NP, i As Integer
NP = Range("L2:L11").Value
For i = 1 To 10
P = Cells(4, i)
curr = Cells(6, i)
If curr = "HKD" Then
NP = Range("J2").Value * P
ElseIf curr = "USD" Then
NP = Range("J3").Value * P
Else
NP = Range("J4").Value * P
End If
Next i
End Sub | <excel><vba><excel-formula> | 2019-09-04 15:18:51 | LQ_EDIT |
57,793,170 | Why I cannot receive the content of arraylist | <p>I am currently struggling to fix the outcome of my code.</p>
<p>I am supposed to add a list from menu and then display the list. However, I cannot retrieve its content, rather I receive its memory value (I guess?).</p>
<p>Studentclass </p>
<pre><code> private int number;
private String author;
private String title;
public Student() {
}
public Student(int number, String title, String author) {
this.number = number;
this.title = title;
this.author = author;
}
public int getNumber() {
return number;
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public void setNumber(int number) {
this.number = number;
}
public void setTitle(String title) {
this.title = title;
}
public void setAuthor(String author) {
this.author = author;
}
public String ToString() {
return "Number: " + number + "\tTitle: " + title + "\tAuthor: " + author;
}
</code></pre>
<p>Mainclass</p>
<pre><code>import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
ArrayList<Student> newStudents = new ArrayList<Student>();
System.out.println("Please select a number from the options below \n");
while (true) {
// Give the user a list of their options
System.out.println("1: Add a student to the list.");
System.out.println("2: Remove a student from the list.");
System.out.println("3: Display all students in the list.");
// Get the user input
int userChoice = input.nextInt();
switch (userChoice) {
case 1:
addStudents(newStudents);
break;
case 2:
//removeStudent(newStudents);
break;
case 3:
displayStudent(newStudents);
break;
}
}
}
public static void addStudents(ArrayList<Student> newStudents) {
Scanner input = new Scanner(System.in);
Student newStudent = new Student();
System.out.print("Please enter number: ");
newStudent.setNumber(input.nextInt());
System.out.print("Please enter title: ");
newStudent.setTitle(input.next());
System.out.print("Please enter author: ");
newStudent.setAuthor(input.next());
if (newStudents.size() <= 100) {
newStudents.add(newStudent);
System.out.println("Student added\n");
} else {
System.out.println("\n Student interface is full!");
}
}
}
private static void displayStudent(ArrayList<Student> newStudents) {
for (Student e : newStudents) {
System.out.println(e);
}
}
}
</code></pre>
<p>Output:</p>
<blockquote>
<p>1: Add a student to the list.</p>
<p>2: Remove a student from the list.</p>
<p>3: Display all students in the list.</p>
<p>3</p>
<p><strong>Student@6b2acb7a</strong></p>
</blockquote>
<p>Why @6b2babc7a?</p>
<p>Thank you for your kind help and attention. I'm roughly new to programming, and Java is my first language. So, I'd highly appreciate the help and clarification.</p>
| <java><arraylist> | 2019-09-04 17:22:48 | LQ_CLOSE |
57,794,596 | Parse error: syntax error, unexpected end of file Issue | <p>I am getting the <code>Parse error: syntax error, unexpected end of file</code> regardless of what I change/add to my code, the error constantly tells me that there is something wrong with my last line.</p>
<p>My PHP file should be saving form input to the database but this error seems to be getting in the way and I cannot figure out what is causing it.</p>
<p>PHP Code</p>
<pre><code><?php
function so56917978_upload_callback() {
//Register variables
$adddate = $_POST['adddate'];
$addcontact = $_POST['addcontact'];
$adda = $_POST['adda'];
$addb = $_POST['addb'];
$addincome = $_POST['addincome'];
$addpayment = $_POST['adddate'];
$addsubbie = $_POST['addsubbie'];
$addcust = $POST['addcust'];
//connect with Database
$host_name = 'zzz.hosting-data.io';
$database = 'zzz';
$user_name = 'zysql_connect($host_name, $user_name, $password);
if(!$connect) {
die('Not Connected To Server');
}
//Connection to database
if(!mysql_select_db($connect, $database)) {
echo 'Database Not Selected';
}
$query = mysql_query($connect,"SELECT * FROM table WHERE adddate = '$adddate' OR addcontact = '$addcontact' OR adda= '$adda' OR addb = '$addb' OR addincome = '$addincome' OR addpayment = '$addpayment' OR addsubbie = '$addsubbie' OR addcust = '$addcust'");
$sql = "INSERT INTO table (adddate, addcontact, adda, addb, addincome, addpayment, addsubbie, addcust) VALUES ('$adddate', '$addcontact', '$adda', '$addb', '$addincome', '$addpayment', '$addsubbie', '$addcust')";
if (!mysql_query($connect,$sql)) {
die('Error: ' . mysql_error($connect));
}
echo "1 record added";
mysql_close($connect);
</code></pre>
| <php><html><wordpress><parse-error> | 2019-09-04 19:17:14 | LQ_CLOSE |
57,796,328 | How can I read an images from a folder but we start by image 10 for exemple with VideoCapture() in python? | I want to read a sequence of images from a folder , I find: cap=cv2.VideoCapture("in%6d.jpg") ,but I must start by image10 not by the first. How can I do this?? | <python><opencv> | 2019-09-04 22:29:06 | LQ_EDIT |
57,796,750 | HTML5 Multiple File Upload. Return lastinsertid through jQuery AJAX and PHP? | <p>I have an html multiple file upload:</p>
<pre><code><input type="file" multiple="multiple">
</code></pre>
<p>I'm successfully uploading files, and writing to my db table:</p>
<p><strong>jQuery</strong></p>
<pre><code>function uploadFile() {
//some other stuff done here...
var ajaxRequest =
$.ajax({
url: '../inc/ajax-upload.php',
type: 'POST',
cache: false,
processData: false, // important
contentType: false, // important
data: formData,
});
ajaxRequest.done(function(data) {
console.log(data);
lastid = 'this comes from data';
$.each(files, function(i, file) {
$('div#files').append('<div class="file-name" id="'+ file['name'] +'">'+file['name']+'<button class="file-delete" id="' + lastid +'">delete</button>');
});
})
ajaxRequest.fail(function(jqXHR) { console.log(jqXHR); })
}
</code></pre>
<p><strong>php</strong></p>
<pre><code>//CRUD stuff in another file
function pdoInsert($sql, $args) {
$pdo = dbConnect();
$stmt = $pdo->prepare($sql);
$stmt->execute($args);
echo $pdo->lastInsertId();
}
function addFile($filename){
$sql = 'INSERT INTO tbl_files (filename) VALUES (?)';
$args = array($filename);
echo pdoInsert($sql, $args);
}
//ajax.php file
$lastid = array();
foreach($_FILES as $file) {
//do filesystem stuff
//insert to db, get last insert id
$lastid[] = addFile($filename);
}
echo json_encode($lastid);
</code></pre>
<p>I want the <code>$lastid</code> from my PHP to be in JSON format like, however, it's returning a concatenated string of the insert id's, e.g. <code>123124[null,null]</code> or something like that. What could be wrong here?</p>
| <php><jquery><ajax><multiple-file-upload> | 2019-09-04 23:37:45 | LQ_CLOSE |
57,797,355 | CUDA kernel performance is bad using a for-loop | I have a 1D array in C-code that I would like to convert to a corresponding CUDA kernel that can execute with good performance on a GPU DEVICE. The architecture is Nvidia CUDA 10.x
I have tried the naive approach whereby the C-code is applied directly to a CUDA kernel and got correct results.
```CUDA
#include <cuda.h>
#include <cuComplex.h>
#include <stdio.h>
// DEVICE code:
__global__ void myKern(const int N, cuComplex *d_a, cuComplex *d_b){
// global thread ID
int i = blockIdx.x * blockDim.x + threadIdx.x;
// check range
if(i >= N) return;
// *****************************************************
// This appears to work, but is VERY bad performance
// - can this for-loop be removed or defined differently
// for better performance ?
for(; i < N; ++i){
d_b[0].x *= d_a[i].x;
d_b[0].y *= d_a[i].y;
}
// *****************************************************
}
// HOST code:
int main() {
cuComplex *h_a, h_b;
cuComplex *d_a, *d_b, chk;
const int N = 5;
h_b.x = 0.0f;
h_b.y = 0.0f;
// allocate HOST and DEVICE memory
h_a = (cuComplex*)malloc(N*sizeof(cuComplex));
cudaMalloc((void**)&d_a, N*sizeof(cuComplex));
cudaMalloc((void**)&d_b, sizeof(cuComplex));
// initialize input array
for(int i = 0; i < N; ++i){
h_a[i].x = (float)(i + 1);
h_a[i].y = 1.0f
}
// copy to DEVICE
cudaMemcpy(d_a, h_a, N*sizeof(cuComplex), cudaMemcpyHostToDevice);
cudaMemcpy(d_b, &h_b, sizeof(cuComplex), cudaMemcpyHostToDevice);
// call CUDA kernel
int tpb = 1024;
int nblocks = (N + tpb - 1) / tpb;
myKern<<<nblocks,tpb>>>(N, d_a, d_b);
// ******************************************
// PROBLEM: I would like to convert this
// for-loop to CUDA kernel that is optimized
// for performance
// ******************************************
for(int i = 0; i < N; ++i){
h_b.x *= h_a[i].x;
h_b.y *= h_a[i].y;
}
// ******************************************
// get results from DEVICE
cudaMemcpy(&chk, d_b, sizeof(cuComplex), cudaMemcpyDeviceToHost);
// compare HOST and DEVICE
printf("HOST: %0.4f, DEVICE: %0.4f\n", h_b.x, chk.x);
// free memory
free(h_a);
cudaFree(d_a); cudaFree(d_b);
```
The results from HOST and DEVICE appear same, but performance is degraded on DEVICE due to the for-loop inside the CUDA kernel. I don't get an error and would just like to create a CUDA kernel that will properly execute the for-loop in C HOST code that has good performance for the DEVICE. | <cuda><gpu> | 2019-09-05 01:30:08 | LQ_EDIT |
57,797,466 | After I create my code, how do I give it a database? | <p>I'd say I know how to code fairly well.
I've made 2 recent successful programs for work from using just javascript and html.
But I only know how to create them to where every program I make and share have individual copies.
There's no single database that I can edit the code and in result, subsequently all of my coworkers copies update as well.
Instead, any time I make changes to a program, I have to email them all the updated versions and have them update the programs on their computers.
What's my next steps to making all copies of my programs be manipulated by one database?</p>
| <javascript><html><css><database> | 2019-09-05 01:51:32 | LQ_CLOSE |
57,797,729 | Need CSS for half filled Circle (at the bottom) with border | <p>I have already refered to this url and tried to tweak it but wasn't able to get it to work.
<a href="https://stackoverflow.com/questions/42514884/need-css-for-half-filled-circle-with-complete-border">Need css for half filled circle with complete border</a></p>
<p>I need css for below style (bottom half of circle filled)</p>
<p><a href="https://i.stack.imgur.com/cjcsW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cjcsW.png" alt="enter image description here"></a></p>
<p>Please help! Thanks. </p>
| <html><css><sass> | 2019-09-05 02:35:47 | LQ_CLOSE |
57,799,179 | Generating AWS signature in groovy for soapui | am new to groovy scripting and i required to test AWS Rest API for which Authorization(consist of access_key and signature) is required, Request if anyone have working code available. It is PUT call on AWS S3.
I have tried searching and unable to find the same | <amazon-web-services><groovy><soapui> | 2019-09-05 05:55:02 | LQ_EDIT |
57,799,848 | Concatenate word of a column with every other words from other column python | <p>Here is the dataset</p>
<pre><code>pd.DataFrame({'Word':['Iron','copper','nickel'],'Sentence':['An Apple a day','Roses are red','Skies are blue']})
</code></pre>
<p>I'm trying to concatenate one word with every other word and append that into a new column such that my output will look like</p>
<pre><code> Word Sentence New_Sentence
0 Iron An Apple a day An_Iron Apple_Iron a_Iron day_Iron
1 copper Roses are red Roses_copper are_copper red_copper
2 nickel Skies are blue skies_nickel are_nickel blue_nickel
</code></pre>
<p>Any suggestions?</p>
| <python><pandas><dataframe><concatenation> | 2019-09-05 06:47:54 | LQ_CLOSE |
57,800,848 | Create a function which takes in a float as input and returns a string containing a number | <p>Create a function called format_currency which takes in a float as input and returns a string containing the number with a $ in front of it, with 2 decimal places. </p>
<p>i got no idea what i have done</p>
<pre><code>def format_currency()
format("format_currency")
format_currency = float(input("Enter amount"))
print ("$" , format_currency)
</code></pre>
| <python> | 2019-09-05 07:54:08 | LQ_CLOSE |
57,802,420 | How to create page curl effect | <p>I want to apply a page curl transformation to PageView's pages similar to the attached screenshots.</p>
<p>Here you can see a video of the effect: <a href="https://www.youtube.com/watch?v=JqvtZwIJMLo" rel="noreferrer">https://www.youtube.com/watch?v=JqvtZwIJMLo</a></p>
<p><a href="https://i.stack.imgur.com/ZKMg4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZKMg4.png" alt="page curl previews"></a></p>
<p><a href="https://i.stack.imgur.com/4qtyn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4qtyn.png" alt="last page curl"></a></p>
<p>Not sure if this is possible to reproduce in Flutter by just applying a transformation matrix because as you can see it's using a <strong>A*sin(2*π/wav*x)</strong> equation.</p>
| <flutter><flutter-animation> | 2019-09-05 09:29:27 | HQ |
57,804,015 | How to get average, minimum and maximum with fewer database round-trips? | <p>In an ASP.NET Core Razor Pages application, using Entity Framework Core, I'm using the code below to populate a list with average, minimum and maximum values from a database. While this works OK with the relatively small volume of data recorded so far, I don't think it's going to scale well as the volume of data grows. Is there a more efficient way to do this in the application, or should I forget about doing it in the application code and get it from a stored procedure instead?</p>
<pre class="lang-cs prettyprint-override"><code>ServerStatsList = _context
.PerfLog
.Select(l => new ServerStats {
CompanyName = l.CompanyName,
ServerName = l.ServerName,
Average = 0,
Minimum = 0,
Maximum = 0
})
.Distinct()
.ToList();
foreach (ServerStats s in ServerStatsList)
{
s.Average = _context
.PerfLog
.Where(l => l.CompanyName == s.CompanyName && l.ServerName == s.ServerName)
.Average(l => l.MemoryAvailableMBytes);
s.Minimum = _context
.PerfLog
.Where(l => l.CompanyName == s.CompanyName && l.ServerName == s.ServerName)
.Min(l => l.MemoryAvailableMBytes);
s.Maximum = _context
.PerfLog
.Where(l => l.CompanyName == s.CompanyName && l.ServerName == s.ServerName)
.Max(l => l.MemoryAvailableMBytes);
}
</code></pre>
| <c#><linq><asp.net-core><entity-framework-core> | 2019-09-05 11:00:47 | LQ_CLOSE |
57,805,740 | WatchOS app cannot start with error Domain: "IDELaunchErrorDomain Code: 15" on Xcode 11 beta | <p>Want to run app under watchOS getting error under Xcode beta:
Domain: IDELaunchErrorDomain Code: 15 Failure Reason: Build and Run launch failed as the app to run does not appear to be known by the system.</p>
| <watchos-5> | 2019-09-05 12:41:01 | HQ |
57,807,334 | Can`t load jQuery libary | <p>Im trying to load jQuery libary following videos but it does not work. When im trying to load some jQuery function, it writes that "jquery is not defined". I also tried CDN. Thanks</p>
<pre><code> <title>
GRID
</title>
<link rel="stylesheet" href="grid.css">
<link href="https://fonts.googleapis.com/css?
family=Ubuntu&display=swap" rel="stylesheet">
<script src="jquery-2.1.1.min.js"></script>
<script src="script.js"></script>
</head>```
</code></pre>
| <javascript><html> | 2019-09-05 14:08:03 | LQ_CLOSE |
57,809,131 | NEED SQL QUERY FOR DESIRED OUTPUT | <p>Below is the sample data which gets filled into sql server database from PLC machine. DATETIME, CYCLETIME(TIME TAKEN TO PRODUCE THAT MATERIAL) AND SHIFT</p>
<p><a href="https://i.stack.imgur.com/T1UMw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T1UMw.png" alt="enter image description here"></a></p>
<p>There are 3 shifts in company A(6:30Am to 2:30PM), B(2:30 to 10:30), C(10:30 to 6:30AM).Only C shift sample data is shown above </p>
<p>when i take C Shift count, my query should take next day data also till 6:30AM time. Where as A shift should take current day data starting from 6:30Am to 2:30Pm.Where as B shift should take current day data starting from 2:31pm to 10:30PM.</p>
<p>QUANITY shown below IS COUNT OF ROWS in each shift.</p>
<p>DESIRED OUTPUT 1: SHIFTWISE DATA
<a href="https://i.stack.imgur.com/dMRDL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dMRDL.png" alt="enter image description here"></a></p>
<p>DESIRED OUTPUT 2: DAYWISE DATA
<a href="https://i.stack.imgur.com/twvxf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/twvxf.png" alt="enter image description here"></a></p>
| <sql-server> | 2019-09-05 15:54:32 | LQ_CLOSE |
57,809,861 | SonarQube rule: "Using command line arguments is security-sensitive" in Spring Boot application | <p>SonarQube is just showing a Critical security issue in the very basic Spring Boot application. In the main method.</p>
<pre><code>@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
</code></pre>
<p>SonarQube wants me to <code>Make sure that command line arguments are used safely here.</code></p>
<p>I searched this on both StackOverflow and Google, and I am surprised that I couldn't find any single comment about this issue. I am almost sure that there are some security checks inside the <code>SpringApplication.run</code> method already. And also, I don't even remember that anyone sanitizes the main method arguments before calling <code>SpringApplication.run</code>. I simply want to tag it as <strong>false positive</strong> and move on.</p>
<p>Part of this question is also asked here: <a href="https://stackoverflow.com/questions/54856544/sonarqube-shows-a-secuirty-error-in-spring-framework-controllers-and-in-spring-f">SonarQube shows a secuirty error in Spring Framework controllers and in Spring Framework Application main class</a></p>
<p>Is it false positive?</p>
| <java><spring-boot><sonarqube> | 2019-09-05 16:46:14 | HQ |
57,810,339 | website is showing up as part text and part html on pc | I was searching for c programs on the net and i landed on this program-
<http://www.c4learn.com/c-programs/calculating-area-of-circle-using.html>
I opened it on my phone and it opened properly but it shows some part text and some part html on my pc.
I wanted to know why this was happening.
thanks in advance. | <javascript><html><css><firefox> | 2019-09-05 17:22:44 | LQ_EDIT |
57,810,532 | Is there any way to create a class instance name by a string taken as user input? | <p>In C++, I want to create a class instance which name will be a string taken as input.</p>
<p>Consider the following code segment.</p>
<pre><code>class my_class{
int a;
};
int main()
{
string name;
getline(cin, name); //let the input "tom"
my_class name; // expecting an instance of my_class named as tom
}
</code></pre>
<p>As it should, I am getting error. Is there any way to do it.</p>
| <c++><class> | 2019-09-05 17:36:00 | LQ_CLOSE |
57,811,514 | I want to create an array of objects at runtime | <p>I am creating a version of the Tower of Hanoi puzzle. The way it is represented in the Unity hierarchy is</p>
<p>-Game Objects<br>
-----PegA<br>
---------Arm<br>
---------Base<br></p>
<p>Sorry I didn't know how to represent the hierarchy.</p>
<p>There are 3 "pegs" and have 7 "rings" as objects in the scene. The pegs and rings are on the same level in the hierarchy.</p>
<p>It is obvious that I can "SerializeField" the ring class and just click and drag each Peg onto them in the inspector but what I want to do is just add them at runtime in the code. This is what I tried.</p>
<p>This is part of my ring class</p>
<pre><code>public class ring : MonoBehaviour
{
public bool locked, resting;
private float startX, startY, deltaX, deltaY;
private Vector3 mousePos, beforeDrag;
private List<GameObject> pegs;
// Start is called before the first frame update
void Start()
{
startX = transform.position.x;
startY = transform.position.y;
locked = false;
pegs.Add(GameObject.Find("PegA"));
pegs.Add(GameObject.Find("PegB"));
pegs.Add(GameObject.Find("PegC"));
}
}
</code></pre>
<p>The error I'm getting is "Object reference not set to an instance of an object"</p>
<p>Can someone possibly explain?</p>
| <c#><unity3d> | 2019-09-05 18:55:56 | LQ_CLOSE |
57,812,994 | How to refactor those quite similar arrow functions? | <p>I'm refactoring some code in a react file, and I have two functions which almost does the same thing... but one return a function and the other one execute some code.</p>
<p>I'm not really good for now with ES6 and arrow function. And I don't understand how to refactor this.</p>
<pre><code> switchEventSelectedSchedule = cb => option => {
this.setState(
// Mutate the state
() => ({
eventSelected: option.id,
isLoading: true
}),
// Callback to fire when the state has been mutated with the new event id
async () => {
await this.longPollingAllMatches();
this.setState(() => ({
isLoading: false
}));
const { currentRoundId, rounds } = this.state;
cb(rounds, currentRoundId);
}
);
};
switchEventSelectedRoundTable = option => {
this.setState(
// Mutate the state
() => ({
eventSelected: option.id,
isLoading: true
}),
// Callback to fire when the state has been mutated with the new event id
async () => {
await this.longPollingAllMatches();
this.setState(() => ({
isLoading: false
}));
}
);
};
</code></pre>
<p>in one case (imagine if(schedule)) I need to return the cb function else I must just execute the rest of the code.</p>
<p>Sorry seems dumb but I think I misunderstood something in the ES6 syntax to achieve this....</p>
<p>Many thx !</p>
| <javascript><ecmascript-6><arrow-functions> | 2019-09-05 21:07:40 | LQ_CLOSE |
57,814,895 | How add new fields to the existing type in another package | I have a AUTH package and there i have USER STRUCT and i want to extend the user struct without modifying the package code.
package auth
type User struct {
gorm.Model
UserEmail string
UserPass string
Test string
}
Now i have main.go
package main
import "auth"
// WANT TO OVERRIDE OR EXTEND THE USER STRUCT
function main() {
}
| <go> | 2019-09-06 02:08:57 | LQ_EDIT |
57,816,057 | Is this nested function problem solvable in C? | <p>Given g(x) = cos(log(2.21-x)) and that x = 0.99, estimate the value given by the nested g(g(g(x)... equation as the nesting approaches infinity (you don't have to actually go to infinity, but just set up a way to recurse this nesting n times or so).</p>
<p>I've tried some basic stuff like g(x) = cos(log(2.21-x))
and then creating a for loop defined by g(x) = g(g(x)). None of this works. </p>
<p>In these attempts I've gotten end of void errors and overflow errors. If anyone can figure out if this question is viable in C, even though C doesn't support "nested" functions, I will be amazed and very thankful.</p>
| <c><recursion><nested> | 2019-09-06 05:09:52 | LQ_CLOSE |
57,816,806 | Unknown cron range value 11 for "50 11/2 * * *" | <p>ERROR - Unknown cron range value "11"
while running
job.setall('30 11/2 * * *') in python script</p>
| <linux><cron> | 2019-09-06 06:31:37 | LQ_CLOSE |
57,816,881 | How to redirect a web page using HTML, CSS and JavaScript with help of buttons |
<div class="navbar">
<a>
<div class="grid__item theme-1">
<button class="action"></button>
<button class="particles-button">Home</button>
</div>
</a>
// In this Effect applied how to redirect it after the effect completed
| <javascript><html><css> | 2019-09-06 06:37:11 | LQ_EDIT |
57,817,573 | `createStackNavigator()` has been moved to `react-navigation-stack` | <p>I'm using react-navigation in my project, and this error pops up.</p>
<p>I googled this error message and found no result.</p>
<p>(I can't post images yet)</p>
<p>The error message reads:</p>
<pre><code>`createStackNavigator()` has been moved to `react-navigation-stack`. See https://reactnavigation.org/docs/4.x/stack-navigator.html for more details.
</code></pre>
<p>The code worked on my friend's machine, somehow</p>
| <react-native> | 2019-09-06 07:29:56 | HQ |
57,817,775 | iOS must run pod install after every checkup | <p>I am using cocoapods for an iOS project and every time I checkout a new branch I have to run <code>pod install</code>, as the pods don't run. </p>
<p>Is there a solution to not have to run <code>pod install</code> every time?</p>
| <ios><swift><cocoapods><dependency-management> | 2019-09-06 07:46:04 | LQ_CLOSE |
57,820,342 | iOS 13 Set UISearchTextField placeholder color | <p>How do you set the placeholder color of iOS 13's <code>UISearchTextField</code>?</p>
<p>I tried the following with no success:</p>
<pre><code>searchField.attributedPlaceholder = NSAttributedString(string: "Some placeholder", attributes: [NSAttributedString.Key.foregroundColor: UIColor.red])
</code></pre>
<p>Is this a bug in the current beta or do I miss something? I am using Xcode 11, beta 7.</p>
| <ios><xcode><placeholder><ios13> | 2019-09-06 10:30:38 | HQ |
57,820,408 | Draw Perpendicular line between two lines in iOS | <p>I want to draw a perpendicular line between P1 and P2 corresponding to P3.
I have P1 and P2, when I touch on UIView P3 will make.
Now I want to draw perpendicular line from P3 corresponding to P1 and P2.</p>
<p><a href="https://i.stack.imgur.com/pXXyO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pXXyO.jpg" alt="enter image description here"></a></p>
| <ios><swift> | 2019-09-06 10:35:42 | LQ_CLOSE |
57,821,219 | How to remove escape-sequence from list elements in python? | <p>I have a list and every element of list consists of an escape sequence "\n" .. How to remove these "\n" from the elements?</p>
| <python><escaping> | 2019-09-06 11:32:43 | LQ_CLOSE |
57,822,043 | How to get the basic example Shiny app working? | <p>I can't make the first example of the first Shiny Tutorial to work.... on windows 10, R 3.6.1</p>
<p>I followed : <a href="https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/" rel="nofollow noreferrer">https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/</a></p>
<p>I get some part of the app : title / input field... no CSS, not working... only the title as shown below : :-( </p>
<p><a href="https://i.stack.imgur.com/5drvp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5drvp.png" alt="enter image description here"></a></p>
| <r><shiny> | 2019-09-06 12:27:10 | LQ_CLOSE |
57,822,125 | How to get the `next` element of `e.target`? | <p>I have an <code>input</code> tag, which is then followed by a <code>label</code> tag. I am trying to get the value of the <code>label</code> after the <code>input</code> has been clicked. My trial was <code>e.target.next.val;</code> but that seems to be wrong. Any ideas how I could achieve that? </p>
| <javascript><jquery> | 2019-09-06 12:32:44 | LQ_CLOSE |
57,822,512 | What is equivalent to `MapSpaFallbackRoute` for ASP.NET Core 3.0 endpoints? | <p>In ASP.NET Core 2.x I used standard routes registation <code>Configure</code> method of <code>Startup</code> class to <strong>register fallback route</strong> for SPA application using <code>MapSpaFallbackRoute</code> extension method from <code>Microsoft.AspNetCore.SpaServices.Extensions</code> Nuget package:</p>
<pre class="lang-cs prettyprint-override"><code>public void Configure(IApplicationBuilder app)
{
// ...
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
</code></pre>
<p>I cannot find similar extension method when using ASP.NET Core 3.0 recommended <code>UseEndpoints</code> extension method for endpoints registration.</p>
| <c#><asp.net-core-3.0> | 2019-09-06 12:57:55 | HQ |
57,823,085 | My linear map function is not giving right answers | <p>This formula kinda don't work</p>
<p>I tried to use this formula but it looks like it won't give me right answers, I hope that I can use all values for a linear mapping I hope you guys can help me :) if I need to rewrite this post I would not mind</p>
<blockquote>
<p>All of the input is: map(200,1, value,0,1);
It never gives between 0 1.
Thank you again, guys, here is code </p>
</blockquote>
<pre><code>function map(max_value, first_bottom, first_top, second_top, second_bottom){
y=(max_value - first_bottom) / (first_top - first_bottom) *
(second_top - second_bottom) + second_bottom;
}
</code></pre>
| <c#><dictionary><math><mapping> | 2019-09-06 13:36:19 | LQ_CLOSE |
57,823,454 | Problems on adding RecyclerView Android Studio | I needed recycler view in my project and I decided to implement it, also changed targetSDK and compileSDK from 29 to 27. After compiling the app there appeared some errors, can you help me?

Or you can just show me another way of implementing e.t.c | <android> | 2019-09-06 13:58:44 | LQ_EDIT |
57,824,601 | I need a modal with a form inside to close only if submission is succesfull | <p>I have a form in a modal.
I'm using standard mvc form validation and have set an event so that when a button is pressed the modal shows up and after the user submits the form the modal re-hides. The problem with that is that if the form is not valid the modal still closes and the error messages show only if it re-opens. I need a way to trigger the event only if the form is accepted as valid by the controller.</p>
<p>The event looks for clicks on button that have the .toggleMOD class(too lazy to create 2 events per id)</p>
<p>If you guys need to see any code i will include it but the trigger i want to create is about default mvc submission validation aka "if (ModelState.IsValid)"</p>
| <c#><jquery><asp.net-mvc><submit> | 2019-09-06 15:11:08 | LQ_CLOSE |
57,825,628 | Regular expression to get a string between two strings in Javascript. The 2 strings are bookended by quotes | I have the below string that I need help pulling an ID from in Presto. Presto uses the javascript regex.
I need to pull the GA Client ID which looks like this:
```75714ae471df63202106404675dasd800097erer1849995367```
Below is a snipped where it sits in the string.
The struggle is that the "s:38:" is not constant. The number can be anything. For example, it could be s:40: or s:1000: etc. I need it to return just the alphanumeric id.
String Snippet
```
"GA_ClientID__c";s:38:"75714ae471df63202106404675dasd800097erer1849995367";
```
Full string listed below
```
99524";s:9:"FirstName";s:2:"John";s:8:"LastName";s:8:"Doe";s:7:"Company";s:10:"Sample";s:5:"Email";s:20:"xxxxx@gmail.com";s:5:"Phone";s:10:"8888888888";s:7:"Country";s:13:"United States";s:5:"Title";s:8:"Creative";s:5:"State";s:2:"NC";s:13:"Last_Asset__c";s:40:"White Paper: Be a More Strategic Partner";s:16:"Last_Campaign__c";s:18:"70160000000q6TgAAI";s:16:"Referring_URL__c";s:8:"[direct]";s:19:"leadPriorityMarketo";s:2:"P2";s:18:"ProductInterest__c";s:9:"sample";s:14:"landingpageurl";s:359:"https://www.sample.com;mkt_tok=samplesamplesamplesample";s:14:"GA_ClientID__c";s:38:"75714ae471df63202106404675dasd800097erer1849995367";s:13:"Drupal_SID__c";s:36:"e1380c07-0258-47de-aaf8-82d4d8061e1a";s:4:"form";s:4:"1046";} ```
| <javascript><regex><presto> | 2019-09-06 16:26:40 | LQ_EDIT |
57,826,430 | SwiftUI and MVVM - Communication between model and view model | <p>I've been experimenting with the MVVM model that's used in <code>SwiftUI</code> and there are some things I don't quite get yet.</p>
<p><code>SwiftUI</code> uses <code>@ObservableObject</code>/<code>@ObservedObject</code> to detect changes in a view model that trigger a recalculation of the <code>body</code> property to update the view.</p>
<p>In the MVVM model, that's the communication between the view and the view model. What I don't quite understand is how the model and the view model communicate.</p>
<p>When the model changes, how is the view model supposed to know that? I thought about manually using the new <code>Combine</code> framework to create publishers inside the model that the view model can subscribe to.</p>
<p>However, I created a simple example that makes this approach pretty tedious, I think. There's a model called <code>Game</code> that holds an array of <code>Game.Character</code> objects. A character has a <code>strength</code> property that can change.</p>
<p>So what if a view model changes that <code>strength</code> property of a character? To detect that change, the model would have to subscribe to every single character that the game has (among possibly many other things). Isn't that a little too much? Or is it normal to have many publishers and subscribers?</p>
<p>Or is my example not properly following MVVM? Should my view model not have the actual model <code>game</code> as property? If so, what would be a better way?</p>
<pre class="lang-swift prettyprint-override"><code>// My Model
class Game {
class Character {
let name: String
var strength: Int
init(name: String, strength: Int) {
self.name = name
self.strength = strength
}
}
var characters: [Character]
init(characters: [Character]) {
self.characters = characters
}
}
// ...
// My view model
class ViewModel: ObservableObject {
let objectWillChange = PassthroughSubject<ViewModel, Never>()
let game: Game
init(game: Game) {
self.game = game
}
public func changeCharacter() {
self.game.characters[0].strength += 20
}
}
// Now I create a demo instance of the model Game.
let bob = Game.Character(name: "Bob", strength: 10)
let alice = Game.Character(name: "Alice", strength: 42)
let game = Game(characters: [bob, alice])
// ..
// Then for one of my views, I initialize its view model like this:
MyView(viewModel: ViewModel(game: game))
// When I now make changes to a character, e.g. by calling the ViewModel's method "changeCharacter()", how do I trigger the view (and every other active view that displays the character) to redraw?
</code></pre>
<p>I hope it's clear what I mean. It's difficult to explain because it is confusing</p>
<p>Thanks!</p>
| <swift><swiftui><combine> | 2019-09-06 17:36:30 | HQ |
57,827,676 | How to get time in seconds from d-m-y h:i:s? | <p>I found this:</p>
<pre><code>$minutes = (strtotime("2012-09-21 12:12:22") - time()) / 60;
</code></pre>
<p><a href="https://stackoverflow.com/questions/12520145/number-of-minutes-between-two-dates/12520198">In this question</a></p>
<p>But the string from the API that I took is like 06-09-19 | 16:23:17 and this code don't work at all.</p>
<p>How can I do?</p>
<p>Thanks.</p>
| <php><date><time><minute> | 2019-09-06 19:38:06 | LQ_CLOSE |
57,828,911 | How to print floats with for loop without other functions BUT range() | <p>I want to Print all the numbers between 5 to 8, with jumps of 0.3.
I got 2 problems doing it:</p>
<ol>
<li><p>It's not very accurate (I know the reason, what I dont know is how to get 5.89999999999 to become 5.9)</p></li>
<li><p>I dont know how to do it without any imports and functions (without numpy and without xrange which btw does not exist in python 3.x anymore as I understood)</p></li>
</ol>
<p>This is just for a Homework question, I'm a new python learner, so I dont realy know ALL the tools and tricks of python.</p>
<pre><code>max = 9
min = 5
step = 0.3
while min <= max:
min += step
print(min)
Expected:
5,
5.3,
5.6,
5.9,
6.2,
...
Actual reasults:
5.3,
5.6,
5.89999999995,
6.1999999999,
6.4999999999,
...
</code></pre>
| <python-3.x> | 2019-09-06 21:53:15 | LQ_CLOSE |
57,829,481 | split students by success | <p>i have 5 region that students wants to go. Every region has quota.
For example </p>
<ul>
<li>region A has 3 </li>
<li>region B has 2 </li>
<li>region C has 1 </li>
<li>region D has 2 </li>
<li>region E has 1</li>
</ul>
<p>And i have 9 students. (total quota and student number is same ) and student list is ordered by their success.
My problem is i will send students to region with order like first student needs to go A if quote is not full second will go to B if quote is not full</p>
<p>For the example above i need a string like;
A,B,C,D,E,A,B,D,A
This means</p>
<ul>
<li>1st, 5th and 9th student will go region A</li>
<li>2,7 -> B</li>
<li>c -> C</li>
<li>4,8 -> D</li>
<li>5 -> E</li>
</ul>
<p>i did already an algorithm for this but it works really slow for 100k student.</p>
<pre><code>public String split(int quotoA, int quotoB, int quotoC, int quotoD, int quotoE) {
boolean AdidNotGetYet = true, BdidNotGetYet = true, CdidNotGetYet = true, DdidNotGetYet = true, EdidNotGetYet = true;
StringBuffer list = new StringBuffer();
while (true) {
if (quotoA > 0 && AdidNotGetYet) {
list.append(",A");
AdidNotGetYet = false;
quotoA--;
} else if (quotoB > 0 && BdidNotGetYet) {
list.append(",B");
BdidNotGetYet = false;
quotoB--;
} else if (quotoC > 0 && CdidNotGetYet) {
list.append(",C");
CdidNotGetYet = false;
quotoC--;
} else if (quotoD > 0 && DdidNotGetYet) {
list.append(",D");
DdidNotGetYet = false;
quotoD--;
} else if (quotoE > 0 && EdidNotGetYet) {
list.append(",E");
EdidNotGetYet = false;
quotoE--;
} else {
AdidNotGetYet = true;
BdidNotGetYet = true;
CdidNotGetYet = true;
DdidNotGetYet = true;
EdidNotGetYet = true;
}
if (quotoA == 0 && quotoB == 0 && quotoC == 0 && quotoD == 0 && quotoE == 0) {
break;
}
}
list.deleteCharAt(0);
return list.toString();
}
</code></pre>
| <java><algorithm><sorting> | 2019-09-06 23:20:56 | LQ_CLOSE |
57,831,308 | importing a method from a class in another code | <p>I want to import a specific method of a class in a file to another file of course in the same directory, so i tried this following way</p>
<pre class="lang-py prettyprint-override"><code>from file1 import Class1
from file1 import Class1.method
</code></pre>
<p>it doesn't work and it shows me a syntax error on the python kernel on the level of the dot between Class1 and method</p>
<p><code>SyntaxError: invalid syntax</code></p>
| <python> | 2019-09-07 06:35:54 | LQ_CLOSE |
57,831,499 | How to Calculating Scientific Method Using PHP | <p>I'm New in PHP I just ask simply question.I have calculating number without any formula. this is working fine.Now I have using formula in calculation.Check my example..</p>
<pre><code><?php
$calculation = (350/ (1+(18/100)) ;
?>
</code></pre>
<p>i have getting error this
how to calculate this method </p>
| <php> | 2019-09-07 07:09:04 | LQ_CLOSE |
57,832,752 | La cascade ne marche pas sur doctrine | Je suis sous symfony 4.2.11 et j'ai besoin d'enregistrer une entité PageTemplate. Or cette entité contient des entités PageTemplateBlock qui doivent être mis à jour en base. L'entité PageTemplateBlock contient des entités PageTemplateBlockProfiled, PageTemplateBlockView et PageBlockItemVersion qui doivent aussi être mis à jour.
Au début tout marchait bien sauf que les entités PageBockItemVersion étaient supprimés par cascade..
Du coup, j'ai essayé de récupérer la liste de mes PageBlockItemVersion pour les persister (c'est sale)..
Et là je suis bloqué pour un contrainte d'intégrité SQL... Doctrine supprime mes entités correctement mais il insert un PageTemplateBlock avant le PageTemplate --'
Bref aidez-moi s'il vous plait, je doit régler ce problème rapidement et je n'ai plus d'espoirs
Résultat:
[Requêtes exécutés][1]
[Message d'erreur][2]
PageTemplate
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var string
* @ORM\Column(type="string")
*/
private $name;
/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
*/
private $description;
/**
* @var Site
* @ORM\ManyToOne(targetEntity="Site", inversedBy="pageTemplates")
*/
private $site;
/**
* @var PageTemplateBlock[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageTemplateBlock", mappedBy="template", cascade={"remove", "persist"}, orphanRemoval=true)
* @ORM\OrderBy({"order"="ASC"})
*/
private $blocks;
/**
* @var PageVersion[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageVersion", mappedBy="pageTemplate", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $pageVersions;
` ``
PageTemplateBlock
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageTemplate
* @ORM\ManyToOne(targetEntity="PageTemplate", inversedBy="blocks")
*/
private $template;
/**
* @var integer
* @ORM\Column(type="integer", name="_order")
*/
private $order;
/**
* @var string
* @ORM\Column(type="string")
*/
private $name;
/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
*/
private $description;
/**
* @var PageTemplateBlockProfiled[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageTemplateBlockProfiled", mappedBy="block", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $profiledData;
/**
* @var PageTemplateBlockView[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageTemplateBlockView", mappedBy="block", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $views;
/**
* @var PageBlockItemVersion[]|ArrayCollection
* @ORM\OneToMany(targetEntity="PageBlockItemVersion", mappedBy="pageTemplateBlock", cascade={"remove", "persist"}, orphanRemoval=true, fetch="EAGER")
*/
private $pageItems;
` ``
PageTemplateBlockProfiled
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageTemplateBlock
* @ORM\ManyToOne(targetEntity="PageTemplateBlock", inversedBy="profiledData")
* @ORM\JoinColumn(name="block_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $block;
/**
* @var Profile
* @ORM\ManyToOne(targetEntity="Profile", inversedBy="profiledItems")
*/
private $profile;
/**
* @var string|null
* @ORM\Column(type="string", nullable=true)
*/
private $node;
` ``
PageTemplateBlockView
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageTemplateBlock
* @ORM\ManyToOne(targetEntity="PageTemplateBlock", inversedBy="views")
* @ORM\JoinColumn(name="block_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $block;
/**
* @var View
* @ORM\ManyToOne(targetEntity="View", inversedBy="pageTemplateBlock")
*/
private $view;
/**
* @var integer
* @ORM\Column(type="integer", name="_order")
*/
private $order;
/**
* @var bool
* @ORM\Column(type="boolean")
*/
private $locked;
/**
* @var array|null
* @ORM\Column(type="array", nullable=true)
*/
private $data;
` ``
PageBlockItemVersion
`` `php
/**
* @var int
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var PageVersion
* @ORM\ManyToOne(targetEntity="PageVersion", inversedBy="items")
*/
private $pageVersion;
/**
* @var PageTemplateBlock
* @ORM\ManyToOne(targetEntity="PageTemplateBlock", inversedBy="pageVersions")
* @ORM\JoinColumn(name="page_template_block_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $pageTemplateBlock;
/**
* @var int
* @ORM\Column(type="integer", name="_order")
*/
private $order;
/**
* @var array
* @ORM\Column(type="array")
*/
private $data;
/**
* @var View
* @ORM\ManyToOne(targetEntity="View", inversedBy="pageBlockItems")
*/
private $view;
``
[1]: https://i.stack.imgur.com/kXr4K.png
[2]: https://i.stack.imgur.com/R2VO7.png | <php><mysql><symfony><doctrine><symfony4> | 2019-09-07 10:18:05 | LQ_EDIT |
57,833,496 | Is it really necessary to call delete on this pointer | <p>I have a pointer to a very large static array of objects that don't have any destructors nor they inherit from any class. This array is allocated at the beginning of the program and never allocated/relocated again (by design). This array needs to be destroyed only at the very end of the program. Do I really need to call delete for the array, or is it OK to let the OS (Windows) clean up? Deleting delays exiting of program by 5-10sec. Without calling delete, OS will do that for us and program exits immediately.</p>
| <c++><memory-management> | 2019-09-07 12:02:23 | LQ_CLOSE |
57,834,348 | Array transformation in JS | <p>I have array transformation required as below in JS.</p>
<p>Source Array</p>
<pre><code>var numbers =
[
[0,0,4],
[0,1,9],
[0,2,16] ,
[0,2,7] ,
[0,2,5] ,
[1,0,1],
[1,1,2],
[1,1,4],
[1,2,3]
];
</code></pre>
<p>Here first value in the source array represents row of target array, second value represents column of target array.</p>
<p>So the expected result array looks like</p>
<pre><code>var result = [
[4, 9, [16, 7, 5]],
[1, [2, 4], 3]
];
</code></pre>
<p>Note:
1.Source/Target array can contain N number of rows & columns.</p>
| <javascript> | 2019-09-07 13:55:56 | LQ_CLOSE |
57,834,381 | Clearing an array in 2019 | So a few years ago it was bad practice to do
array = [];
because if the array was referenced somewhere that reference wasn't updated or smth like that.
The correct way was supposed to be `array.length = 0;`
Anyway, javascript has been updated now, and there's a framework called Vue.js
Vue does not catch `array.length = 0;` so the property won't be reactive. But it does catch `array = [];`
My question is, can we use now `array = [];`, or is javascript still broken? | <javascript><arrays><vue.js><vuejs2> | 2019-09-07 14:00:30 | LQ_EDIT |
57,836,019 | Scrabble Description Assume that you are trying to complete a crossword puzzle | In a crossword puzzle, some letters are given and you have to figure out which complete word can you make out of it.
For example, given letters "cwd"in the same order, you can make the word "crossword" or "cr
I have written a code :
x = re.search(letters, guess)
if (x):
print("yes")
else:
print("no")
but when not getting correct output | <python><regex> | 2019-09-07 17:32:49 | LQ_EDIT |
57,836,065 | Split an array into columns in javascript | <p>I want to reduce array so I have its' values in 'columns' where the first value lives in the first column, the second one in the second, etc. until it wraps, so that for example the fourth value is in the first of three columns.</p>
<pre><code>>> [1, 2, 3, 4, 5, 6, 7].in_columns(3)
=> [[1, 4, 7], [2, 5], [3, 6]]
</code></pre>
| <javascript><arrays><ecmascript-6> | 2019-09-07 17:41:50 | LQ_CLOSE |
57,836,937 | How to call a List(names) which is inside in main(), names.stream().filter(Filter.nameStartingWithPrefix(scanner.nextLine()) in another class Filter) | 1. I want to call method name nameStartingWithPrefix() which is inside filter and its definition will be in Filter class.
All ArrayList describes in main(), but the list is not passed as in an argument, how can I call in List of names inside Filter.nameStartingWithPrefix().
Syntax is given like: names is name of ArrayList which is inside main()
names.stream()
.filter(Filter.nameStartingWithPrefix(scanner.nextLine()))
.map(Mapper.getDistinctCharactersCount())
.forEachOrdered(System.out::println);
public class FilterMapper {
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
List<String> names = Arrays.asList(
"aaryanna",
"aayanna",
"airianna",
"alassandra",
"allanna",
"allannah",
"allessandra",
"allianna",
"allyanna",
"anastaisa",
"anastashia",
"anastasia",
"annabella",
"annabelle",
"annebelle"
);
names.stream()
.filter(Filter.nameStartingWithPrefix(scanner.nextLine()))
.map(Mapper.getDistinctCharactersCount())
.forEachOrdered(System.out::println);
}
}
class Filter{
public static String nameStartingWithPrefix(String prefix)
{
}
}
2. Expected like, I have to write a code on Filter method which filters the names on the basis of prefix given by the user in runtime.
But I am unable to access list on the basis of given code. can you please help me how to access List of names inside the Filter class.
3. I think List should be passed in arguments of (Filter.nameStartingWithPrefix(scanner.nextLine()))
but its not there.
| <java><lambda><collections><java-8><java-stream> | 2019-09-07 19:39:41 | LQ_EDIT |
57,837,524 | Why bother with dotnet build before dotnet publish? | <p>Welp. This seems like the type of question where I'll facepalm seeing the answer.</p>
<p>So...</p>
<p>Why bother with <code>dotnet build</code> before doing a <code>dotnet publish</code>?</p>
<p><code>build</code> automatically does a <code>restore</code>. Cool. </p>
<p>It seems <code>publish</code> does a <code>build</code> (unless you tell it not to). So... Why bother doing the build if you're going to publish right after? Why not just publish and everything happens in one step?</p>
<p>For further clarity... </p>
<p>I am asking in a basic scenario like:</p>
<ul>
<li><code>dotnet build -c Release MyProj</code></li>
<li><code>dotnet publish -c Release -o /somedir MyProj</code></li>
</ul>
<p>versus just</p>
<ul>
<li><code>dotnet publish -c Release -o /somedir MyProj</code></li>
</ul>
<p>They seem to do the same thing.</p>
| <build><.net-core> | 2019-09-07 21:16:22 | HQ |
57,838,876 | How to create random number every minute | <p>I have a question.
"random number of customers arriving for a check out is between 5 and 10 every minute."
I need to put these customers in a list based on their order of their arrival time. </p>
<p>I don't know how to generate a random numbers of customers every minute, and I don't know how to assume their arrival time. </p>
<p>this is for Nachos server using c++ code and using threadtest.c code</p>
| <c++><nachos> | 2019-09-08 02:58:34 | LQ_CLOSE |
57,839,968 | what does if(index(i,$2)==1 indicate | Jus come across an awk script
awk 'BEGIN {OFS=FS} NR==FNR {a[$1]=($2" "$3);next} {for (i in a) if(index(i,$12)==1) print $0,a[$12]}'
in this script what does
if(index(i,$12)==1
means. Is it indicating true/false condition on just numerical equal to 1. | <if-statement><indexing><awk> | 2019-09-08 07:30:47 | LQ_EDIT |
57,840,042 | Why doesn't For loop iterate without compound assignment operators | Sorry for noob question, I am trying to replace every character of source string with "🥃". If I remove += from my code For loop iterates only once, can't seem to follow logic behind this?
However, if I use '+=' For loop iterates. Shouldn't iterations have equalled number of characters in String? I mean my understanding always was "For every “item” in “items”, execute this code."
```
let stringExample = "Hello, Playground"
var emptyString = ""
for _ in stringExample {
emptyString = "🥃"
}
print(emptyString)
```
🥃 | <swift><for-loop> | 2019-09-08 07:46:00 | LQ_EDIT |
57,840,493 | Different pages under different tabs in WPF | <p>I have a tabcontrol in my mainwindow and I have tabs like users, transactions, etc. I created a page individually to show under each tab. But I'm not sure how to plugin each page under each tab. Can somebody help me?</p>
| <c#><wpf><xaml> | 2019-09-08 08:59:27 | LQ_CLOSE |
57,840,835 | `createDraweerNavigation()` has been moved to `react-navigation-drawer` | [createDrawerNavigation() has been moved to react-navigation-drawer. See https://reactnavigation.org/docs/4.x/drawer-navigator.html for more details][1]
[1]: https://i.stack.imgur.com/yoadY.jpg | <react-native><react-navigation><react-navigation-drawer> | 2019-09-08 09:47:57 | LQ_EDIT |
57,842,609 | Best data-binding practice in Combine + SwiftUI? | <p>In RxSwift it's pretty easy to bind a <code>Driver</code> or an <code>Observable</code> in a <code>View Model</code> to some observer in a <code>ViewController</code> (i.e. a <code>UILabel</code>).</p>
<p>I usually prefer to build a pipeline, with observables <strong>created from other observables</strong>, instead of "imperatively" pushing values, say via a <code>PublishSubject</code>).</p>
<p>Let's use this example: <strong>update a <code>UILabel</code> after fetching some data from the network</strong></p>
<hr>
<h2>RxSwift + RxCocoa example</h2>
<pre class="lang-swift prettyprint-override"><code>final class RxViewModel {
private var dataObservable: Observable<Data>
let stringDriver: Driver<String>
init() {
let request = URLRequest(url: URL(string:"https://www.google.com")!)
self.dataObservable = URLSession.shared
.rx.data(request: request).asObservable()
self.stringDriver = dataObservable
.asDriver(onErrorJustReturn: Data())
.map { _ in return "Network data received!" }
}
}
</code></pre>
<pre class="lang-swift prettyprint-override"><code>final class RxViewController: UIViewController {
private let disposeBag = DisposeBag()
let rxViewModel = RxViewModel()
@IBOutlet weak var rxLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
rxViewModel.stringDriver.drive(rxLabel.rx.text).disposed(by: disposeBag)
}
}
</code></pre>
<hr>
<h2>Combine + UIKit example</h2>
<p>In a UIKit-based project it seems like you can keep the same pattern:</p>
<ul>
<li>view model exposes publishers</li>
<li>view controller binds its UI elements to those publishers</li>
</ul>
<pre class="lang-swift prettyprint-override"><code>final class CombineViewModel: ObservableObject {
private var dataPublisher: AnyPublisher<URLSession.DataTaskPublisher.Output, URLSession.DataTaskPublisher.Failure>
var stringPublisher: AnyPublisher<String, Never>
init() {
self.dataPublisher = URLSession.shared
.dataTaskPublisher(for: URL(string: "https://www.google.it")!)
.eraseToAnyPublisher()
self.stringPublisher = dataPublisher
.map { (_, _) in return "Network data received!" }
.replaceError(with: "Oh no, error!")
.receive(on: DispatchQueue.main)
.eraseToAnyPublisher()
}
}
</code></pre>
<pre class="lang-swift prettyprint-override"><code>final class CombineViewController: UIViewController {
private var cancellableBag = Set<AnyCancellable>()
let combineViewModel = CombineViewModel()
@IBOutlet weak var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
combineViewModel.stringPublisher
.flatMap { Just($0) }
.assign(to: \.text, on: self.label)
.store(in: &cancellableBag)
}
}
</code></pre>
<hr>
<h2>What about SwiftUI?</h2>
<p>SwiftUI relies on property wrappers like <code>@Published</code> and protocols like <code>ObservableObject</code>, <code>ObservedObject</code> to automagically take care of bindings (As of <em>Xcode 11b7</em>).</p>
<p>Since (AFAIK) property wrappers cannot be "created on the fly", there's no way you can re-create the example above using to the same pattern.
The following <strong>does not compile</strong></p>
<pre class="lang-swift prettyprint-override"><code>final class WrongViewModel: ObservableObject {
private var dataPublisher: AnyPublisher<URLSession.DataTaskPublisher.Output, URLSession.DataTaskPublisher.Failure>
@Published var stringValue: String
init() {
self.dataPublisher = URLSession.shared
.dataTaskPublisher(for: URL(string: "https://www.google.it")!)
.eraseToAnyPublisher()
self.stringValue = dataPublisher.map { ... }. ??? <--- WRONG!
}
}
</code></pre>
<p>The closest I could come up with is <strong>subscribing in your view model (UGH!)</strong> and <strong>imperatively update your property</strong>, which does not feel right and reactive at all.</p>
<pre class="lang-swift prettyprint-override"><code>final class SwiftUIViewModel: ObservableObject {
private var cancellableBag = Set<AnyCancellable>()
private var dataPublisher: AnyPublisher<URLSession.DataTaskPublisher.Output, URLSession.DataTaskPublisher.Failure>
@Published var stringValue: String = ""
init() {
self.dataPublisher = URLSession.shared
.dataTaskPublisher(for: URL(string: "https://www.google.it")!)
.eraseToAnyPublisher()
dataPublisher
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: {_ in }) { (_, _) in
self.stringValue = "Network data received!"
}.store(in: &cancellableBag)
}
}
</code></pre>
<pre class="lang-swift prettyprint-override"><code>struct ContentView: View {
@ObservedObject var viewModel = SwiftUIViewModel()
var body: some View {
Text(viewModel.stringValue)
}
}
</code></pre>
<p>Is the "old way of doing bindings" to be forgotten and replaced, in this new <strong>UIViewController-less</strong> world?</p>
| <ios><swift><swiftui><rx-swift><combine> | 2019-09-08 13:58:18 | HQ |
57,843,999 | Why npm init is used in any JS projects? | <p>Recently I started learning typescript and little new to NPM, wants know about why npm init is used. can anyone please explain real time example. and most importantly please don't say question is asked here, there i am not satisfied with those answers so i am asking again here.</p>
<p>$ npm init</p>
| <javascript><typescript> | 2019-09-08 17:02:34 | LQ_CLOSE |
57,844,028 | How to link HTML CSS and PHP together? | <p>I created a new PHP project using Netbeans and i have some trouble referencing the very same css file to all my links in the project.</p>
<p>This is what I have:
<a href="https://i.stack.imgur.com/32huH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32huH.png" alt="enter image description here"></a></p>
<p>If you know why this is happening please let me know.</p>
| <php><html><css><netbeans> | 2019-09-08 17:05:56 | LQ_CLOSE |
57,844,744 | Use module as text in Python | I have a dictionary that contains modules, now I would like to use the string value of the module (see example). Is this possible or am I better of just creating a second dictionary?
```python
import module1
import module2
import module3
module_dict = {
'module1' = module1
'module2' = module2
}
user_input = input()
module_dict[user_input].function()
#module3.function requires two strings to work, one of the string happens to be the name of the module
module3.function('foo', module_dict[user_input])
```
This is a really simplified version, forgive me if it looks confussing. I can not use the built-in ```str``` function since it will result in ```module 'modulename' at 'path'``` which is not what I am after. | <python> | 2019-09-08 18:37:19 | LQ_EDIT |
57,845,333 | Dart - how _InternalLinkedHashMap<String, dynamic> convert to Map<String, dynamic>? | <p>I use <a href="https://pub.dev/packages/dio" rel="noreferrer">package dio</a> in my flutter app. A get response from my api question.
response.data get type _InternalLinkedHashMap. I need convert this value to Map. I tried many options but this does not work.</p>
<p>I have no way to change the server response. Any advice?</p>
| <json><flutter><dart> | 2019-09-08 20:00:04 | HQ |
57,845,645 | Binomial coefficient in C# | <p>Hi I need to find an algorithm to compute the binomial coefficient.
<a href="https://imgur.com/a/nGCw4n7" rel="nofollow noreferrer">https://imgur.com/a/nGCw4n7</a>
n is 3, while k must go from 0 to 3. </p>
<p>I found this link with the code which explains how to calculate the binomial coefficient <a href="http://csharphelper.com/blog/2014/08/calculate-the-binomial-coefficient-n-choose-k-efficiently-in-c/" rel="nofollow noreferrer">http://csharphelper.com/blog/2014/08/calculate-the-binomial-coefficient-n-choose-k-efficiently-in-c/</a> but I don't know how to do when k is not assigned. </p>
<p>This is the code I found:</p>
<pre><code>decimal result = 1;
for (int i = 1; i <= K; i++)
{
result *= N - (K - i);
result /= i;
}
return result;
</code></pre>
| <c#> | 2019-09-08 20:47:00 | LQ_CLOSE |
57,846,388 | How to make a counter start at 1 and go to three after a button is clicked in javascript? | <p>I'm trying to make a counter that starts at 1 and after you click a button it will display an alert and then the counter will go to 2 and wait until you click the button again and then give you a different alert and so on.</p>
<pre><code>I have tried something along the lines of
//html
<input id="button" type="submit" name="button" value="enter"/>
//javascript
function count()
{
var counter = 1;
if(counter = 1 && button.click)
{
alert("something"(counter++));
}
if(counter = 2 && button.click)
{
alert("something else"(counter++));
}
if(counter = 3 && button.click)
{
alert("something else else");
}
}
</code></pre>
<p>I know that the syntax isn't correct but that's the main idea. The expected output should be a new alert after each button click.</p>
| <javascript> | 2019-09-08 23:05:29 | LQ_CLOSE |
57,847,664 | can anyone tell me please why are these number are concatenating, | <p>I am a beginner at programming, i always stumble upon this problem whenever i am trying to add numbers, instead of adding, it concatenates. Please someone explain what is happening here and some solutions so that i would not come across these type of problems again thanks ^^ </p>
<pre><code>function add(x,n) {
let result = x + n;
return result;
}
let x = prompt();
let n = prompt();
alert ( add(x,n) );
</code></pre>
<p>if i have x=5 and n=2 it should alert 7, but it shows 52. however if i use different arithmetic operators, it works. if i use -, it subtracts.</p>
| <javascript> | 2019-09-09 03:50:20 | LQ_CLOSE |
57,847,705 | Place JSON data in label in Swift | <p>I am able to capture my data through GET method. But I wanted to display my data in a label</p>
<pre><code>if let data = data, let dataString = String(data: data, encoding: .utf8) {
print("data: \(dataString)")
}
</code></pre>
<p><code>dataString</code> displays </p>
<p><code>data: {"data":{"id":1,"user_id":1,"month":9,"date":"2019-09-09 10:48:50","time_in":"09:00:00","time_out":"18:00:00","attendance":"\u25cf","reason":null,"estimated_time":null,"created_at":"2019-08-30 09:56:31","updated_at":"2019-09-09 10:49:48","deleted_at":null}}</code></p>
<p>I wanted to get the value of "time_in" and "time_out" and display both in a label</p>
| <ios><json><swift> | 2019-09-09 03:58:39 | LQ_CLOSE |
57,848,423 | Having a little trouble with this Number Sorter | <p>I'm trying to sort numbers in ascending or descending order, depending on the user input. I sorted the numbers in the text fields into an array and using an if-else statement to sort in ascending or descending order depending on the value of the select tag. However, the code only sorts in ascending order and does not sort in descending order when told to. I'm just wondering what I can do to fix this. </p>
<p>This is my first coding in HTML and Javascript, let alone coding at all so this code is probably very inefficient, but I'm willing to accept any tips.</p>
<pre><code>function sortingFunction() {
var arr = [];
arr.push(document.getElementById("one").value);
arr.push(document.getElementById("two").value);
arr.push(document.getElementById("three").value);
arr.push(document.getElementById("four").value);
arr.push(document.getElementById("five").value);
arr.push(document.getElementById("six").value);
arr.push(document.getElementById("seven").value);
arr.push(document.getElementById("eight").value);
arr.push(document.getElementById("nine").value);
arr.push(document.getElementById("ten").value);
var filtered = arr.filter(Boolean);
var x = document.getElementById("mySelect").value;
if (x = "ascending") {
document.getElementById("answer").innerHTML = "Answer: " + filtered.sort(function(a,b) { return a - b;});
} else {
document.getElementById("answer").innerHTML = "Answer: " + filtered.sort(function(a,b) { return b - a;});
}
}
//Text Fields Here with id="one" to "ten"
<button onclick="sortingFunction()">Submit</button>
<select name="test" id="mySelect">
<option value="ascending">Ascending Order</option>
<option value="descending">Descending Order</option>
</select>
<p id="answer"></p>
</code></pre>
| <javascript><html><sorting> | 2019-09-09 05:43:53 | LQ_CLOSE |
57,848,570 | How to put minus (-) before some specific columns in R | I have a data frame containing 2000 columns. Majority of the columns have "X111, X222 ,X123" , all of this X111, X222, X333 are all numeric variables,
and I want to convert all the positive values to negative values
Before:
¦ 1COL1 ¦ 2COL ¦ 3COL ¦ XCOL ¦ 4COL ¦ XXCOL ¦
All (+)ve values.
After:
¦ 1COL1 ¦ 2COL ¦ 3COL ¦ XCOL ¦ 4COL ¦ XXCOL ¦
+ + + _ + _ | <r> | 2019-09-09 06:02:50 | LQ_EDIT |
57,849,211 | why it's impossible to sort a string just like a sorting of a c++ array? | <p>can't we sort a string just like a classical sorting(bubble sort or something..) of an array?I tried. But it's not working.</p>
<pre><code>string newstr = "dcba";
for(int i = 0; i < (newstr.size())-1; i++)
{
for(int k = i+1; k < newstr.size(); k++)
{
if(newstr[i] > newstr[k])
{
temp = newstr[i];
newstr[k] = newstr[i];
newstr[i] = temp;
}
}
}
</code></pre>
| <c++> | 2019-09-09 07:02:22 | LQ_CLOSE |
57,849,592 | How do I return in a function two different lists? (Phyton) | How do I return two different lists in a function I made?
def eolist(num1):
li_1 = []
li_2 = []
for i in range(1, num1+1):
if i % 2 != 0:
li_2.append(i)
else:
li_1.append(i)
return li_1, li_2 | <python-3.x> | 2019-09-09 07:32:41 | LQ_EDIT |
57,849,744 | How to store tokens on the client side using node js on backend? | <p>I'm using passport.js for local authentication and express-session for managing session of a user but express-session is storing cookies on the client side. Since cookies are less secure, I want to send and receive jwt tokens in the client side but I don't know how to do that.
I'm using mongodb for the database, express framework and node js</p>
| <node.js><mongodb><express><jwt><passport.js> | 2019-09-09 07:45:00 | LQ_CLOSE |
57,850,332 | Which Class should inherit a QMainWindow? | <p>I am new to Qt and this is probably a very stupid question. I am working on a Project with several sub-projects in Visual Studio (C++). The whole project has a single User-interface (UI), and for that, the Qt is used. </p>
<p>Among all the sub-projects, only 2 classes are inherited from QMainWindow.</p>
<p>As a newbie, I am wondering, which classes should inherit QMainWindow?</p>
| <c++><qt> | 2019-09-09 08:28:29 | LQ_CLOSE |
57,850,760 | I wand to use OverridependingTransition in fragment but I am getting an error | Here is my code
med=(LinearLayout) getView().findViewById(R.id.second);
med.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i= new Intent(getContext(),SecondActivity.class);
i.putExtra("table_name","questCompFunda");
startActivity(i);
overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
}
}); | <java><android> | 2019-09-09 08:57:33 | LQ_EDIT |
57,850,953 | Installing python packages offline | <p>I have a python virtual environment created using virtualenv.
Now I want to install different python packages like pandas or numpy. But is there any way to install these packages offline. Given, I already have these packages in base environment. </p>
| <python><pandas> | 2019-09-09 09:09:44 | LQ_CLOSE |
57,853,457 | Parsing a string to a usable formate and compare it to current date & time (C#) | I'm trying to parse a string that looks like this (20190903T114500,000) to a formate and compare it to the current time and date. It's supposed to give an allert, when the date and time are only 5 minutes appart.
Yet I'm struggeling with every part of that task. The formate makes no sense, I cant change it because of that "T" in the middle... Im kind of lost tbh.. It would be so nice if someone could help me, I'm just started learning to code... | <c#><datetime><date-format> | 2019-09-09 11:48:11 | LQ_EDIT |
57,853,874 | pronlem after generating the released apk file in flutter | I was generate the released apk file in flutter using android studio.but after generating the file it was installed in real time mobile but not working .it shows host name error in the console.how to resolve this error? | <flutter><apk> | 2019-09-09 12:14:45 | LQ_EDIT |
57,855,393 | change the shape of a button | <p>i want to change the shape of the button but the text inside of it also changes</p>
<p>i've trid to to put a span inside of it but it didn't work</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-css lang-css prettyprint-override"><code>
.btn {
border-radius: 0px;
border: none;
padding: 0.66em 4em;
color: rgb(68, 114, 241);
cursor: pointer;
background-color: #FFF;
border: 1px solid rgb(45, 110, 206);
font-size: 1em;
transform: skewX(-18deg);
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <button class="btn">click me</button></code></pre>
</div>
</div>
</p>
| <html><css><transform> | 2019-09-09 13:50:15 | LQ_CLOSE |
57,855,947 | How to make links follow the cursor for a defined distance on hover state? | <p>I want to reproduce the link "attraction" effect as shown in the following theme : <a href="http://preview.themeforest.net/item/grenada-creative-ajax-portfolio-showcase-slider-theme/full_screen_preview/22712618?_ga=2.243139466.922598619.1568038769-663244003.1563974355" rel="nofollow noreferrer">http://preview.themeforest.net/item/grenada-creative-ajax-portfolio-showcase-slider-theme/full_screen_preview/22712618?_ga=2.243139466.922598619.1568038769-663244003.1563974355</a></p>
<p>Hover "follow us" on the bottom right of the page to see it in action.</p>
<p>Thanks a lot for your help !</p>
| <javascript><css><gsap> | 2019-09-09 14:23:24 | LQ_CLOSE |
57,856,450 | How return object that has specific value in string? | <p>So I have array with object inside. That object has a property call name that is a string of values</p>
<p>How can I return object that has "apples" in the name properties </p>
<pre><code>fruits = [
{
name: 'apples, lemon',
quantity: 2
},
{
name: 'bananas, pearl',
quantity: 0
},
{
name: 'cherries,
pineapple',
quantity: 5
}
];
</code></pre>
| <javascript><arrays><string> | 2019-09-09 14:51:14 | LQ_CLOSE |
57,856,621 | I want to develop my own Dat Grid View for Win Form | <p>i want to develop my own data grid for Win From from scratch.
Data grid with features like
Grouping
sorting
filtering
adding text row
adding subtotal in between rows</p>
<p>I have tried using custom control but it becomes too slow when i add grouping and sorting and designing features</p>
<p>Now i am finding a way to design my own control.
In which basic language the win form controls are made.
like telerik dev express ? in which language these controls are made?</p>
| <c#><.net><winforms> | 2019-09-09 15:01:40 | LQ_CLOSE |
57,856,774 | How to detect C# (not CLR) version programmatically? | <p>I use C# for .NET. I know how to programmatically detect CLR version of a .NET assembly, but can’t find out how to programmatically detect the C# version in my code. Anyone has idea? TIA.</p>
| <c#><.net> | 2019-09-09 15:11:03 | LQ_CLOSE |
57,859,448 | How can I make my website send email after checking captcha | <p>I'm trying to setup a service for my friend where he will post an email request from his site to mine with html form tag and then my site will request a captcha check it's valid then send him the email but I'm not sure how to </p>
<p>I tried some online options but I can't find anything that will request the captcha then redirect to send the message check it's valid then send it</p>
| <php><html> | 2019-09-09 18:31:17 | LQ_CLOSE |
57,860,775 | pandas pd.options.display.max_rows not working as expected | <p>I’m using pandas 0.25.1 in Jupyter Lab and the maximum number of rows I can display is 10, regardless of what <code>pd.options.display.max_rows</code> is set to. </p>
<p>However, if <code>pd.options.display.max_rows</code> is set to less than 10 it takes effect and if <code>pd.options.display.max_rows = None</code> then all rows show.</p>
<p>Any idea how I can get a <code>pd.options.display.max_rows</code> of more than 10 to take effect?</p>
| <python><pandas> | 2019-09-09 20:26:07 | HQ |
57,860,966 | Changing String to Integer in Dictionary (Python) | I am trying to convert a list made up of strings in a dictionary to float variables.
Here is the code I was given:
```
data = {'year':[1990, 2000, 2010], 'gdp':['8.95', '12.56', '14.78']}
```
The end result is supposed to look like this:
```
data = {'year':[1990, 2000, 2010], 'gdp':[8.95, 12.56, 14.78]}
```
Thank you in advance for any hints or help! | <python><dictionary><type-conversion> | 2019-09-09 20:44:21 | LQ_EDIT |
57,862,012 | how can I modulo operation for strings issue? | <p>I am trying to use modulo operation with my dummy data <code>msg</code> if msg mutiples by 8 <code>msg%8</code> then give me the output of <code>printf("[-] Error: Size too long");</code> if not then it will be okay , but using directly to <code>msg%8</code>doesnt mean to work how can I fix this? </p>
<p>error output</p>
<p><code>Error C2296 '%': illegal, left operand has type 'char [1000]'</code></p>
<pre><code>int main() {
char buf[8];
char msg[1000];
printf("Enter cookie:\n");
scanf("%s", buf);
printf("Your cookie %s \n", buf);
if (strlen(buf) == 16) {
printf(" [+] Header received: %d bytes \n", strlen(buf));
if (stricmp("0x41414141414141", buf) == 0)
{
strcpy(buf, "hello");
printf("Enter msg:\n");
scanf("%s", msg);
if (strlen(msg) <= 512) {
if (msg % 8) {
printf("[-] Error: Size too long");
}
else {
printf("[-] Good");
}
}
else {
printf(" [-] Error: Invalid \n");
}
}
else {
printf(" [-] Error: Invalid \n");
}
}
else {
printf(" [-] Error: Invalid \n");
}
return 0;
}
</code></pre>
| <c> | 2019-09-09 22:44:02 | LQ_CLOSE |
57,862,489 | Finding variance using c# | I'm trying to Add a static method to calculate the average of a, array of integers, Overload the method in a. to also calculate an array of doubles.
Add a method to calculate the sum of an array of integers or doubles
Add a method to calculate the variance in an array of integers or doubles.
Add a method to calculate the standard deviation of an array of integers or doubles.
I've finished most of the code but ran into a problem when I created the method to calculate the variance.
I've tried different things in here but it always gives me an error, I believe that the Math.Pow is what is messing this up. Is there another way and possibly simpler way to compute the variance with the rest of the code?
class States
{
private static int Sum(int[] a)
{
int sum = 0;
for (int i = 0; i < a.Length; i++)
{
sum += a[i];
}
return sum;
}
private static double Average(int[] a)
{
int sum = Sum(a);
double Avg = (double)sum / a.Length;
return Avg;
}
private static double Var(int[] a)
{
if (a.Length > 1)
{
double Avg = Average(a);
double var = 0.0;
foreach (int A in Average)
{
// Math.Pow to calculate variance?
var += Math.Pow((A - Average)), 2.0)
}
return var;
}
else
{
return 0.0;
}
private static double StdDev(double var)
{
return Math.Sqrt(var);
}
}
}
"Foreach cannot operate on a method group" | <c#><calculator><variance> | 2019-09-10 00:03:54 | LQ_EDIT |
57,863,164 | Why is the scope of object created using new limited? | <p>Object made using <code>new</code> operator does not seem to be available outside the scope! Isn't that the whole point of the <code>new</code> operator?</p>
<p><a href="https://ideone.com/DDvo9y" rel="nofollow noreferrer">https://ideone.com/DDvo9y</a> - Please check this link to see the result. </p>
<pre><code>#include<iostream>
class myClass
{
private:
int val;
public:
myClass () = delete;
myClass (int val):val{val}{}
int get () const
{
return val;
}
};
bool ifEqualMake (int a, int b, myClass * obj)
{
if (a == b) obj = new myClass (a);
else{
std::cout << "Difference exists: " << a - b << '\n';
obj = new myClass (a + b);
}
std::cout << " Object made with value :" << obj->get () << '\n';
return (a == b);
}
int main ()
{
myClass *obj1 = nullptr;
myClass *obj2 = nullptr;
myClass *obj3 = nullptr;
ifEqualMake (3, 3, obj1);
ifEqualMake (4, 3, obj2);
ifEqualMake (4, 4, obj3);
if(obj1) std::cout << "obj 1 made in heap: " << obj1->get () << '\n';
if(obj2) std::cout << "obj 2 made in heap: " << obj2->get()<<'\n';
if(obj3) std::cout << "obj 3 made in heap: " << obj3->get () << '\n';
delete obj1;
delete obj2;
delete obj3;
return 0;
}
</code></pre>
| <c++><new-operator> | 2019-09-10 02:10:29 | LQ_CLOSE |
57,865,068 | now() or date(y-m-d) doesn't work when trying to query using php and sql to a mysql database | I'm trying to check to see if one date (in my database) is larger (later) then the current date. I've looked on other questions for a solution but none of them seem to work.
$sql = "SELECT * FROM customer_details, rental_details WHERE customer_details.customer_ID = rental_details.customer_ID AND rental_details.date_return >= date('y-m-d')";
Ive also tried
$sql = "SELECT * FROM customer_details, rental_details WHERE customer_details.customer_ID = rental_details.customer_ID AND rental_details.date_return >= now()";
Ive tried every combination of parentheses and brackets with these two, nothing seems to work.
Any suggestions?
This is not a duplicate question, I've looked all over stack overflow. | <php><mysql><sql><date><time> | 2019-09-10 06:23:03 | LQ_EDIT |
57,866,246 | How to get starting creating a WordPress plugin? | <p>I would like to start writing a WordPress plugin that will allow the user to play a scratch the card game (like the lottery). I would like to ask what programming language I should learn and how to get started. Is anyone with similar experiences and what are the recommendations you can offer ? Thanks in advance for your responses</p>
| <php><html><wordpress> | 2019-09-10 07:47:32 | LQ_CLOSE |
57,867,914 | Algorithm for merging spatially close paths / line segments | <p>I am looking for (the name of) a geometric algorithm for cartographic generalization of a street map.</p>
<p>In my map data, I have many paths (ordered list of points, connected by line segments) that lay close and almost parallel to one another. How do I <strong>(1)</strong> identify these “adjacent pathsˮ (i.e. how to find paths that are closer than a certain threshold) and <strong>(2)</strong> merge them into one path (i.e. how to compute the centerline between close paths)?</p>
<p>As an example, consider the following graph of roads / lanes of roads created with data from OpenStreetMaps:</p>
<p><a href="https://i.stack.imgur.com/9pkTC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9pkTC.png" alt="Graph of a road network, consisting of three horizontal lines running across the image almost in parallel and one vertical line intersecting them in the middle"></a></p>
<p>As you can see, the two lanes of the road running horizontally are modeled as two separate paths. For detail views this is useful, but for a more zoomed out view I need to merge the two paths (lanes) to display only one line for the road.</p>
<p>What are the established algorithms used in map renderers to achieve this? Obviously, Google Maps, OSM, etc. do this -- how?</p>
| <algorithm><graphics><geometry><gis><cartography> | 2019-09-10 09:32:58 | HQ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.