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,026,112 | i want to add 10% service tax and 13 % vat but i am unabble to do so please anybody help me. Beside this i have to print the bill for 5 users | You are required to create an MVP (Minimal Viable Product) to take customer orders for a local ethnic food restaurant in Kathmandu. The restaurant offers 10 different types of food dishes, taken from the local ethnic food culture. The restaurant operates with limited dishes and limited staff. You are required to create a prototype of order taking system to ease the working process within the restaurant. Your program should have the following functionalities:
• The program should display the menu at the start (with 10 dishes)
• Each customer will make an order based on the menu shown. For each order, the system should calculate the total bill.
• For each bill, after adding the sum total of the prices of the dishes, the sum total would be subject to 10% service Tax and 13% VAT.
• For every new instance where a customer (new or repeating) makes an order, a new bill is generated.
• Altering a confirmed order would not be a necessary feature for the MVP phase of the system.
• Your MVP should be able to manage order and billing of 5 customers at once.
• The menu prices and the dishes in them could be initially hardwired into your MVP for test purposes (in a file or an array)
public class Array { //class name
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int choice;
double total = 0;
double tax = 0.10;
//Array for storing prices
double[] Price = new double[10];
Price[0] = 120;
Price[1] = 80;
Price[2] = 40;
Price[3] = 100;
Price[4] = 50;
Price[5] = 60;
Price[6] = 90;
Price[7] = 45;
Price[8] = 70;
Price[9] = 60;
//Menu item array
String[] FoodItem = new String[10];
FoodItem[0] = "Momo";
FoodItem[1] = "Chawmin";
FoodItem[2] = "Sausages";
FoodItem[3] = "Pizza";
FoodItem[4] = "Burger";
FoodItem[5] = "Buff Sekuwa";
FoodItem[6] = "Chicken Sekuwa";
FoodItem[7] = "Alu Paratha";
FoodItem[8] = "Chicken Chilly";
FoodItem[9] = "Fry Rice";
//Welcome user and gather their menu selection
System.out.println("Welcome to PurpleHaze ! Please enjoy!");
// System.out.printf("The average pricing for our drinks is: %.2f \n", + cafeAvg( cafePrice));
System.out.println("Please enter a menu selection:\n" +
"0. Momo -- 120\n" +
"1. Chawmin -- 80\n" +
"2. Sausages -- 40\n" +
"3. Pizza -- 100\n" +
"4. Burger -- 50\n" +
"5. Buff Sekuwa -- 60\n" +
"6. Chicken Sekuwa -- 90\n" +
"7. Alu Paratha -- 45\n" +
"8. Chicken Chilly -- 70\n" +
"9. Fry Rice -- 60");
choice = input.nextInt();
//Add up the total
total = Price[choice] + tax;
System.out.println("Your total is: " + total + tax);
}
}
// i want to add 13% VAT and 10% charge.
//Also the should be able to manage order and billing of 5 customers at once. | <java><arrays><variable-assignment> | 2019-07-14 09:24:07 | LQ_EDIT |
57,026,463 | Protocol type cannot conform to protocol because only concrete types can conform to protocols | <p>Within the app, we have two types of Stickers, String and Bitmap. Each sticker pack could contain both types. This is how I declare the models:</p>
<pre><code>// Mark: - Models
protocol Sticker: Codable {
}
public struct StickerString: Sticker, Codable, Equatable {
let fontName: String
let character: String
}
public struct StickerBitmap: Sticker, Codable, Equatable {
let imageName: String
}
</code></pre>
<p>After the user chooses some stickers and used them, we want to save the stickers into <code>UserDefaults</code> so we can show him the "Recently Used" Sticker tab. I'm trying to Decode the saved <code>[Sticker]</code> array:</p>
<pre><code>let recentStickers = try? JSONDecoder().decode([Sticker].self, from: data)
</code></pre>
<p>But I get the following compile error:</p>
<pre><code>Protocol type 'Sticker' cannot conform to 'Decodable' because only concrete types can conform to protocols
</code></pre>
<p>I can't understand why as I declared <code>Sticker</code> as <code>Codable</code> which also implement <code>Decodable</code>. Any help would be highly appreciated! </p>
| <ios><swift><protocols><codable><decodable> | 2019-07-14 10:17:15 | HQ |
57,027,059 | How to fix "Issue: Violation of Families Policy Requirements" | <p>I've tried to publish an app on Play store but it's rejected and I've received an email titled: "Issue: Violation of Families Policy Requirements"</p>
<p>And it also followed by: "Apps that contain elements that appeal to children must comply with all Families Policy Requirements. We found the following issue(s) with your app:</p>
<p>Eligibility Issue
<>
In order to review your app for “Designed for Families” eligibility, we will need you to provide a test login account. Please provide login credentials to the support team before you submit any updated version for another review (select “Test Login Needed” and include the test login account and password details in the open box field)."</p>
<p>I sent the test login account and password as requested, and I'm sure that my app doesn't violate Families Policy Requirements that includes these items:</p>
<p><a href="https://play.google.com/about/families/children-and-families/families-policy/" rel="noreferrer">https://play.google.com/about/families/children-and-families/families-policy/</a></p>
<p>I've received the same email several time without any further detailed information about this issue.</p>
<p>How can I contact Play_store to Know more about my Problem?</p>
| <android><google-play><android-permissions> | 2019-07-14 11:36:09 | HQ |
57,027,283 | While loop isn't looping | <p>I have a while loop which I would like to keep prompting a user to enter a number until the user types "exit". Unfortunately when the user enters anything, they aren't prompted to enter another number, and the procedure doesn't end. I'm using Pycharm as my IDE. Here is my code:</p>
<pre><code>a = []
num = ""
newa = []
def makelist():
num = input("Type a number! Or if you want to exit, type 'exit' ")
while num != "exit":
if int(num):
a.append(num)
num
def firstandlast():
newa.append(a[0]) and newa.append([len(a)])
print("Here are the first and last numbers you typed:")
print(newa)
makelist()
firstandlast()
</code></pre>
| <python><python-3.x> | 2019-07-14 12:11:56 | LQ_CLOSE |
57,027,472 | Given an n-element unsorted array 𝐴 of 𝑛 integers and an integer x, rearranges the elements in 𝐴 | (a) Given an n-element unsorted array 𝐴 of 𝑛 integers and an integer x, rearranges the elements in 𝐴 such that all elements less than or equal to x come before any elements larger than x. ( Note: Don't have to include integer x in the new array )
(b) What is the running time complexity of your algorithm? Explain your answer. | <java><c++><algorithm><pseudocode> | 2019-07-14 12:33:13 | LQ_EDIT |
57,027,796 | Calling function with different arguments produces the same output. (C) | <p>I'm trying to make a program to generate 2 random numbers and print them to the screen. This is achieved by calling the Numbers function twice and assigning the value to num1 and num2 then calling PrintMsg twice also with those variables but instead the function prints the first value twice. </p>
<p>In the debugger num1 and num2 are being set to 2 different numbers and the mode variable is being successfully passed through to the PrintMsg function.</p>
<pre><code>// C program to generate random numbers
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include<time.h>
int Numbers() {
bool valid = false;
int randNum;
srand(time(0));
while(valid != true) {
randNum = rand() % 100;
if (randNum > 0 && randNum <= 6) {
valid = true;
}
}
return(randNum);
}
void PrintMsg(int x, int mode) {
if (mode == 1) {
switch(x) {
case 1:
printf(" %d ", x);
break;
case 2:
printf(" %d ", x);
break;
case 3:
printf(" %d ", x);
break;
case 4:
printf(" %d ", x);
break;
case 5:
printf(" %d ", x);
break;
case 6:
printf(" %d ", x);
break;
}
}
else if (mode == 2){
switch(x) {
case 1:
printf(" %d ", x);
break;
case 2:
printf(" %d ", x);
break;
case 3:
printf(" %d ", x);
break;
case 4:
printf(" %d ", x);
break;
case 5:
printf(" %d ", x);
break;
case 6:
printf(" %d ", x);
break;
return;
}
}
int main(void)
{
int num1;
int num2;
num1 = Numbers();
PrintMsg(num1, 1);
num2 = Numbers();
PrintMsg(num2, 2);
return 0;
}
</code></pre>
<p>Thanks.</p>
| <c><random> | 2019-07-14 13:19:56 | LQ_CLOSE |
57,027,826 | adding firebase to flutter project and getting FAILURE: Build failed with an exception error | <p>for [this flutter library][1] as <code>barcode scanner</code> i should to adding <code>firebase</code> to project, but after doing that i get this error and i cant fix that yet</p>
<blockquote>
<p>Launching lib\main.dart on WAS LX1A in debug mode... Initializing
gradle... Resolving dependencies...
* Error running Gradle: ProcessException: Process "E:\Projects\Flutter\barcode_scanner\android\gradlew.bat" exited
abnormally:</p>
<p>FAILURE: Build failed with an exception.</p>
<ul>
<li><p>Where: Build file 'E:\Projects\Flutter\barcode_scanner\android\app\build.gradle' line:
14</p></li>
<li><p>What went wrong: A problem occurred evaluating project ':app'.</p>
<blockquote>
<p>ASCII</p>
</blockquote></li>
<li><p>Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.</p></li>
<li><p>Get more help at <a href="https://help.gradle.org" rel="noreferrer">https://help.gradle.org</a></p></li>
</ul>
<p>BUILD FAILED in 6s Command:
E:\Projects\Flutter\barcode_scanner\android\gradlew.bat app:properties</p>
<p>Finished with error: Please review your Gradle project setup in the
android/ folder.</p>
</blockquote>
<p>line 14 is:</p>
<pre><code>apply plugin: 'com.android.application'
</code></pre>
<p>I'm not sure whats problem and this is my implementation about that</p>
<p><code>pabspec.yaml</code> content:</p>
<pre><code>version: 1.0.0+1
environment:
sdk: '>=2.0.0-dev.28.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.4.0
...
...
</code></pre>
<p><code>android/build.gradle</code> content:</p>
<pre><code>buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</code></pre>
<p><code>android/app/build.gradle</code> content:</p>
<pre><code>def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "barcodescanner.pishguy.barcode_scanner"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:17.0.1'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha01'
}
apply plugin: 'com.google.gms.google-services'
</code></pre>
<p>running <code>flutter</code> command:</p>
<pre><code>E:\Projects\Flutter\barcode_scanner>flutter pub get
Running "flutter pub get" in barcode_scanner... 2.7s
[1]: https://github.com/facundomedica/fast_qr_reader_view
</code></pre>
| <flutter> | 2019-07-14 13:24:51 | HQ |
57,028,617 | What 3d simulation software does deepmind use? | <p>I am looking for the name of simulation software used by Deepmind in <a href="https://www.youtube.com/watch?v=gn4nRCC9TwQ" rel="nofollow noreferrer">this video</a>? and what alternative softwares are available?</p>
| <deep-learning> | 2019-07-14 15:09:40 | LQ_CLOSE |
57,028,965 | Click to show & Click to call php, javascript | i need to create function on php so when user click on Button, will show phone Number After mobile number shown , must be clickable so we can call via mobile
i have tried to implement some codes but it didn't work
<div class="category-list-title">
<h5><a href="javascript:void(0)" class="number" data-last="<?php echo get_post_meta($pid, '_carspot_poster_contact', true ); ?>"><span><?php echo esc_html__('Click to View', 'carspot' ); ?></span></a></h5>
</div> | <javascript><html> | 2019-07-14 15:56:39 | LQ_EDIT |
57,032,701 | Can anyone explain me the working of this C code? | <p>I don't know how this code is working? </p>
<pre><code>#include<stdio.h>
int main()
{
char *s = "PRO coder";
int n = 7;
printf("%.*s", n, s);
return 0;
}
</code></pre>
<p>The result I am getting is "PRO cod"</p>
| <c> | 2019-07-15 02:41:17 | LQ_CLOSE |
57,033,169 | Forced Update of first two letter or mark as null if empty | Forced update of first letters if present else mark it as null when empty | <sql><postgresql> | 2019-07-15 04:10:28 | LQ_EDIT |
57,034,212 | how to erase several characters in a cell? | <p>I would like to erase characters "(B)" in the code column, so then I could do "summarise" the 'stock_needed'. My data looks like this.</p>
<pre><code> code stock_need
(B)1234 200
(B)5678 240
1234 700
5678 200
0123 200
</code></pre>
<p>to be like this.</p>
<pre><code>code stock_need
1234 200
5678 240
1234 700
5678 200
0123 200
</code></pre>
<p>How could these "(B)" erased? Thanx in advance</p>
| <r><erase> | 2019-07-15 06:25:25 | LQ_CLOSE |
57,035,746 | How to scale text to fit parent view with SwiftUI? | <p>I'd like to create a text view inside a circle view. The font size should be automatically set to fit the size of the circle. How can this be done in SwiftUI? I tried scaledToFill and scaledToFit modifiers, but they have no effect on the Text view:</p>
<pre><code>struct ContentView : View {
var body: some View {
ZStack {
Circle().strokeBorder(Color.red, lineWidth: 30)
Text("Text").scaledToFill()
}
}
}
</code></pre>
| <swift><swiftui> | 2019-07-15 08:15:24 | HQ |
57,035,796 | How to compare two lists of tuple elements | I am a beginner of python, so maybe there will be some incorrect words in my question, and please correct me without hesitation.<br/>
Here is what I have got.<br/>
`List_1 = [(1.1,2,3),(1.1,2,3,4),(3,4,5),5,6,7]`<br/>
`List_2 = [(1.1,2,3),(1.1,2,3,4),(3,4.4,5),5,6,7]`
I expect the output:<br/>
`Error = (3,4.4,5)`<br/>
Does anyone know how to do it? Thank you in advance. | <python><list><tuples> | 2019-07-15 08:19:08 | LQ_EDIT |
57,036,671 | Urgent: run visual studio project in vs code | How can I run a vs project in vs code?
when I type `dotnet run` in the terminal I get:
> Couldn't find a project to run. Ensure a project exists | <c#><.net><visual-studio-code> | 2019-07-15 09:18:17 | LQ_EDIT |
57,037,335 | Need help fixing "property value expected" in CSS (Beginner/amateur) | <p>So I'm trying to set up some animated text in my project, but I keep getting an error in vscode saying "property value expected css(css-propertyvalueexpected) [59, 1]" in ".main-title" which I think is leading the code not to work cause it's not showing anything like what I'm trying to do when I open the page in browser, it shows it like the css code is non existent</p>
<p>I haven't tried to fix it, I posted the full code below cause I'm not sure what's causing it and I'm a beginner</p>
<pre class="lang-html prettyprint-override"><code><main role="main" class="main-content" id="main-content">
<div class="titleCont">
<h1 class="main-title" id="main-title">
"Here, in the forest,<br><span style="padding-left:100px">dark and deep,</span><br><span style="padding-right:110px">I offer you,</span><br><span style="padding-left:-20px">eternal sleep."</span>
</h1>
</div>
<canvas id="noise" class="noise"></canvas>
<div class="vignette"></div>
</main>
</code></pre>
<pre class="lang-css prettyprint-override"><code>.main-content {
overflow:hidden;
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex-flow: column;
height: 100vh;
background: linear-gradient(to right, rgba(36,31,31,1) 0%, rgba(36,31,31,1) 32%, rgba(74,71,70,1) 100%);
color: #fff;
text-align: center;
}
.vignette{
position:absolute;
width:100%; height:100%;
box-shadow:inset 0px 0px 150px 20px black;
mix-blend-mode: multiply;
-webkit-animation: vignette-anim 3s infinite; /* Safari 4+ */
-moz-animation: vignette-anim 3s infinite; /* Fx 5+ */
-o-animation: vignette-anim 3s infinite; /* Opera 12+ */
animation: vignette-anim 3s infinite; /* IE 10+, Fx 29+ */
}
.noise {
z-index: 100;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: .15;
}
.line{
position:absolute;
height:100%; width:1px;
opacity:0.1;
background-color:#000;
}
.titleCont{position:relative;}
.main-title {
padding: .3em 1em .25em;
font-weight: 400;
font-size: 40px;
color: white;
font-family: 'Bellefair', serif;
position:relative;
line-height:1.3;
white-spacing:
}
.overTitle{
position:absolute;
top:0;
left:0;
}
.dot{
width:3px;
height:2px;
background-color:white;
position:absolute;
opacity:0.3;
}
@-webkit-keyframes vignette-anim {
0% , 100%{ opacity: 1; }
50% { opacity: 0.7; }
}
@-moz-keyframes vignette-anim {
0% , 100%{ opacity: 1; }
50% { opacity: 0.7; }
}
@-o-keyframes vignette-anim {
0% , 100%{ opacity: 1; }
50% { opacity: 0.7; }
}
@keyframes vignette-anim {
0% , 100%{ opacity: 1; }
50% { opacity: 0.7; }
}
</code></pre>
<p>I copy pasted the code from here "<a href="https://codepen.io/mimikos/pen/QMjjzy" rel="nofollow noreferrer">https://codepen.io/mimikos/pen/QMjjzy</a>" expected it to look the same.</p>
<p>Thanks in advance</p>
| <html><css> | 2019-07-15 09:56:51 | LQ_CLOSE |
57,038,788 | Flatten Javascript / Typescript object array | I have an array of object like below
let list = [
{
'items': [
'item 1',
'item 2'
]
},
{
'items': [
'item 3'
]
}
]
and I want flatten array from this array like below
['item 1','item 2','item 3']
which javascript / typescript function (chaining) I should use so I will get expected output.
I have tried with map function `list.map(i => i.items)` but I got array in array like below
[["item 1","item 2"],["item 3"]]
**NOTE** : I am looking for any existing function / function chaining if available to get expected output. I am not expecting result by any loop.
| <javascript><arrays><typescript> | 2019-07-15 11:30:38 | LQ_EDIT |
57,041,465 | Use existing DbContext of a Webapplication in ConsoleApp | <p>I've finished programming my asp.net Core Webapplication.
Additionaly I would like to add a console app to my solution which should handle some cronjobs.</p>
<p>Unfortunately I got absolutely stuck on how to use my DbContext-Class from the Webapplication in the console app.
I've added the reference and can now access the namespaces.</p>
<p>But how do I access my DbContext in the console app an be able to reuse it in additional classes?</p>
<p>Thanks to all for your hints.
Patrick</p>
| <c#><dependency-injection><dbcontext> | 2019-07-15 14:05:06 | LQ_CLOSE |
57,041,954 | Can I use onbeforeunload only when the site is being redirected to a particular website | <p>I want to use the onbeforeunload only when the site is being redirected to a particular page. How can I do that?</p>
| <javascript><jquery> | 2019-07-15 14:31:04 | LQ_CLOSE |
57,042,393 | how can I make a bookmark that installs jquery? | <p>how can I make a bookmark that installs jquery?</p>
<p>so that when I am in the developer console, I can call jquery functions from whatever websites i'm on?</p>
| <jquery><browser><bookmarks> | 2019-07-15 14:56:55 | LQ_CLOSE |
57,043,805 | Returning true and a value from class function | <p>In my project i return <code>True</code> from a function within my class, when looking over the code i need to return <code>True</code> plus a <strong><em>URL value</em></strong> but i am coming in to issues, i would instanciate the class like:</p>
<pre><code>if Engine(driver).mode_login_and_post(driver, "http://" + xml_site_name.get_text() + "/wp-login.php", s_user, s_pass, xml_content_title.get_text(), body_with_html, SLEEP, captcha, verify=False) == True:
run more code once true is returned ...
looking to get the returned value of a url here is possible ...
</code></pre>
<p><code>Engine</code> is the class i have instantiated, the way it is now this works fine, i'm getting back <code>True</code> so i continue with the code execution, is there a way to get back <code>True</code> plus another value (in this case a URL) to use in the rest of the code execution? i cannot think of away to do this, any help would be appreciated.</p>
| <python> | 2019-07-15 16:26:51 | LQ_CLOSE |
57,043,940 | What is the purpose of the "new" keyword in Java, PHP, etc.? | <p>In many languages, we use <code>new</code> to instantiate a new instance of a class. For example, in Java:</p>
<pre class="lang-java prettyprint-override"><code>class MyClass {
int number = 1;
MyClass(int n) {
self.number = n;
}
}
</code></pre>
<pre class="lang-java prettyprint-override"><code>MyClass obj1 = new MyClass(5);
</code></pre>
<p>However, as I've been using Python more and more, I've come to wonder why the <code>new</code> keyword is even necessary. In Python, we can simply do:</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
def __init__(self, n):
self.n = n
</code></pre>
<pre class="lang-py prettyprint-override"><code>obj1 = MyClass(5)
</code></pre>
<p>So, what's the purpose of the keyword? Is there some syntactic ambiguity that we resolve by using the keyword?</p>
| <java><php><python><syntax> | 2019-07-15 16:38:31 | LQ_CLOSE |
57,044,232 | How to access elements using Javascript with no id | I'm trying to access an element that has no id and has a shared classname, using Javascript.How can I successfully do that?
I tried using document.getElementsbyClassName property but since the classname is shared by other elements, this is not working.
<a class="sharedClass anotherClass" href="www.mybooks.com" data-m="{"CN":"uniquename"}"> Proceed </a>
//I want to be able to click Proceed element from the above code. Please note that uniquename is unique to this element. I'm thinking we can use that somehow here but am not really sure. | <javascript> | 2019-07-15 16:59:58 | LQ_EDIT |
57,044,867 | İf-elif-else statement in Bash | <p>I trying to control that my file exist or not in directory using if-elif-else statement in for loop. But in if and elif command line gives me this error: No command</p>
<p>Below is an example of the codes:</p>
<pre><code>#! /bin/bash
controlfile="String"
firstfile="String"
lastfile="String"
nsolve=false
for i in $(ls $file1| grep /*.png)
do
firstfile=${i:0:21} #satır 10
if ["$firstfile"!="$file2"]; then #ERROR LINE
#something doing...
nsolve=false
for j in $(ls $file2| grep /*.jpeg)
do
if [${j:0:31}==${controlfile:0:31}]; then #.if already jpeg file exist like png
nsolve=true
continue
else
nsolve=false
fi
done
elif [$nsolve==true] #ERROR LINE
then
#something doing...
continue
fi
lastfile=${i:0:21}
done
printf "%s\n" "Successfully"
</code></pre>
| <bash><shell><if-statement> | 2019-07-15 17:51:58 | LQ_CLOSE |
57,046,248 | Is not saving an object instance in Java considered bad practice or totally not? | <p>ex.</p>
<pre><code>new SportsCar().drive();
</code></pre>
<p>vs.</p>
<pre><code>SportsCar sc = new SportsCar();
sc.drive();
</code></pre>
<p>assuming that you have no reason at the moment why you would need to use the instance of SportsCar again? </p>
| <java> | 2019-07-15 19:43:57 | LQ_CLOSE |
57,046,473 | Why does this recursive code print "1 2 3 4 5"? | <p>I am new to Recursion in Java and came across this code in a textbook. After running the code it prints "1 2 3 4 5" and am wondering why it doesn't print "5 4 3 2 1"?</p>
<pre><code>public class Test {
public static void main(String[] args) {
xMethod(5);
}
public static void xMethod(int n) {
if (n > 0) {
xMethod(n - 1);
System.out.print(n + " ");
}
}
}
</code></pre>
| <java><recursion> | 2019-07-15 20:04:04 | LQ_CLOSE |
57,046,855 | What is the meaning of the symbol % between two variables in python? | <p>What is the meaning of the symbol '%' such as in this sentence:</p>
<p><code>assert (timesteps % pool_size == 0)</code></p>
| <python> | 2019-07-15 20:36:30 | LQ_CLOSE |
57,047,793 | How to decrease the speed of the below program? | I am trying to solve the below question.
You are given an array of n numbers and q queries. For each query you have to print the floor of the expected value(mean) of the subarray from L to R.
First line contains two integers N and Q denoting number of array elements and number of queries.
Next line contains N space seperated integers denoting array elements.
Next Q lines contain two integers L and R(indices of the array).
print a single integer denoting the answer.
I have replaced print with stdout.write() and input with stdin.readline
````
from sys import stdin, stdout
x,y=map(int,stdin.readline().split())
array=[int(x) for x in stdin.readline().split()]
result=[]
sum=0
for i in range(y):
l,r=map(int,stdin.readline().split())
for i in range(l-1,r):
sum = sum + array[i]
result.append(sum//(r-l+1))
sum=0
for i in result:
stdout.write(str(i)+"\n")
````
The time taken by my program is about 8 secs to solve that challenge whereas the required limit is 1.5secs. | <arrays><python-3.x> | 2019-07-15 22:13:34 | LQ_EDIT |
57,048,021 | how to to change value every looop | How to loop and change everytime value
example run for loop 7 times for inserting day names to database
for ($t = 0 ; $t < 7 $t++){
$defaultValues = "INSERT INTO workingDays (bussinessID, day, workingHours) VALUES (?,?,?)";
$pdo->prepare($defaultValues)->execute([$bussinessID, $dayNames, $hours]);
}
So it inserts to database like this:
Default values:
>BussinessID: 1, Day: Monday, workingHours: 8
>BussinessID: 1, Day: Tuesday, workingHours: 8
>BussinessID: 1, Day: Wednesday, workingHours: 8
>BussinessID: 1, Day: Thursday, workingHours: 8
>BussinessID: 1, Day: Friday, workingHours: 8
>BussinessID: 1, Day: Saturday, workingHours: 8
>BussinessID: 1, Day: Sunday, workingHours: 8 | <php> | 2019-07-15 22:47:04 | LQ_EDIT |
57,048,097 | Is there any cheat sheet for opencv-python? | <p>I've been working on face tracking turret with OpenCV_Python version 4.1.0, but I don't know a lot of commands and functions. So I tried to look up Google or other documentation to see if there's any cheat sheet for OpenCV_Python that has all the possible functions and brief explanations about them. </p>
<p>I only found a cheat sheet for OpenCV_C++ version 2.7.0, but couldn't find any cheat sheet for OpenCV_Python. </p>
<p>I saw the official OpenCV 3.0.0 documentation for Python as well, but that only shows few functions for general things you can do. </p>
<p>Is there any source or document(or book) that I can learn all the possible functions of OpenCV_Python?</p>
| <python><opencv> | 2019-07-15 23:00:05 | LQ_CLOSE |
57,049,709 | What you recommend for Election Notification? | I am looking for recommendation to show Electron Notifications. Electron provides Notification API but did not find that helpful. Is there any way to show some Toast notification in Electron main window itself rather showing Windows/System Notification ? | <electron> | 2019-07-16 03:44:41 | LQ_EDIT |
57,050,007 | How to substring from character to end of string? C# | Old: https://stackoverflow.com/questions/ask
New: /questions/ask
I want to get the string from the third "/" character onwards. | <c#><substring> | 2019-07-16 04:21:44 | LQ_EDIT |
57,050,249 | Check the User Whether Exist in Azure AD from WPF application | <p>I have a WPF application and its authentication is AzureAD. If any new user comes then first we will add that user in Azure AD and after that we will add the same user to our WPF application. While adding that user to WPF we need to verify that user is present in Azure</p>
<p>Steps
1. Network Admin creating a user in Azure AD
2. Our project Admin add that user to our client in Azure
3. Project Admin login to our WPF application using azure authentication and adding this user
4. At that time we need to recheck the new user is present in azureAD.</p>
<p>It means project admin login to WPF application using Azure authentication [His userid, ticket, clientid etc are available] and he trying to check a user present it Azure AD [New users name is available, but password will not know by this Admin]. </p>
<p>Please help me to write a c# code for solving this problem.</p>
| <c#><azure-active-directory> | 2019-07-16 04:53:07 | LQ_CLOSE |
57,053,880 | CORS issue on angular in ionic 3 and glassfish with javaEE6 on server side | <p>I have an issue with ionic3 framework when I run "ionic serve" and I make a request to a localhost server. The error I receive is:</p>
<pre><code>Access to XMLHttpRequest at 'http://localhost:8080/myrestapi/myendpoint' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
</code></pre>
<p>I have searched around and I have added the Access-Control-Allow both in my server and in angular. From the angular point of view I have the following:</p>
<pre><code>@Injectable()
export class Gateway {
private getBasicHttpOptions(): any {
let headers: HttpHeaders = new HttpHeaders();
headers = headers.append('Access-Control-Allow-Origin', '*');
headers = headers.append('Content-Type', 'application/json');
let httpOptions: any = {headers: headers};
return httpOptions;
}
public getData(myparam: string): Observable<any> {
let httpOptions: any = this.getBasicHttpOptions();
let body: any = {
'param': myparam
};
return this.http.post("http://localhost:8080/myrestapi/myendpoint", body, httpOptions);
}
}
</code></pre>
<p>And then on the server side I have the following (javeEE6, SDK 7, glassfish 3.1.2):</p>
<pre><code>@Path("/myrestapi")
@Stateless
public class Authentication {
@POST
@Path("/myendpoint")
@Consumes("application/json")
@Produces(MediaType.APPLICATION_JSON)
public Response myEndPoint(@HeaderParam("Content-Type") String contentType, String body){
return Response.status(200)
.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Credentials", "true")
.header("Access-Control-Allow-Headers", "origin, content-type, accept, authorization")
.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD")
.header("Access-Control-Max-Age", "1209600")
.type(MediaType.APPLICATION_JSON)
.entity("{ke1:'val1'}").type(MediaType.APPLICATION_JSON).build();
}
}
</code></pre>
<p>Whenever I call this.gateway.getData('aparam'); because I have in the debug mode my local server I cannot receive any request (from Postman it works fine). So it seems that it's from the client side that it doesnt send any request. </p>
<p>From Chrome from the network tools I have the following:</p>
<p><a href="https://i.stack.imgur.com/1597I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1597I.png" alt="enter image description here"></a></p>
<p>Any ideas?</p>
| <angular><ionic3><java-7><java-ee-6><glassfish-3> | 2019-07-16 09:13:39 | LQ_CLOSE |
57,054,166 | How to subtract ten minutes from a time picked from time picker? | <p>I have a time picker in which the user picks the time and I am sending a notification to user ten minutes before or after the time user picked.Suppose if the user picks time as 11:00 AM then I want the notification to trigger at 10:55 AM. I am unable to subtract and add ten minutes to the time. As I am new to this Please help..I have spent a lot of time on it still not able to solve this. Any help is appreciated</p>
| <ios><swift><datetimepicker> | 2019-07-16 09:30:39 | LQ_CLOSE |
57,054,326 | How to evaluate user policy via API for a given set of users | <p>I want to evaluate user policies for a particular user or list of users, is there any API available to perform the same in OIM 11gR2PS3?</p>
| <java><api><oim> | 2019-07-16 09:39:50 | LQ_CLOSE |
57,055,363 | "%+%" function returning NULL | <p>I am trying to use %+% to concatenate. I am trying the following:</p>
<pre><code>>nrow(myData)
1200
> a = "ORG_" %+% 1:nrow(myData)
</code></pre>
<p>I expect the results to be like:</p>
<pre><code>ORG_1
ORG_2
ORG_3
.
.
.
ORG_1200
</code></pre>
<p>But, I am getting:</p>
<pre><code>> a
NULL
</code></pre>
<p>Please help.</p>
| <r><dplyr> | 2019-07-16 10:38:13 | LQ_CLOSE |
57,055,405 | Custom date format in javascript form date format yyyy-mm-dd | <p>I have the date <code>2013-03-10</code> how can i get <code>March 10,2013</code>. I tried a lot with Date function in javascript but can't get correct format as given above.Help should be appreciated.</p>
| <javascript><date><date-format> | 2019-07-16 10:40:46 | LQ_CLOSE |
57,056,094 | Calling Stored Procedures using LINQ | I have SP written on SQL Server:
- the input is `XML`
- It has a different OUTPUT
`ALTER PROCEDURE [dbo].[uspMyProcedure](
@XML XML,
@FamilySent INT = 0 OUTPUT ,
@FamilyImported INT = 0 OUTPUT)`
- The status is returned via `RETURN` and `SELECT` is also called
`SELECT Result FROM @tblResult
RETURN 0 --ALL OK
END`
How to set about calling this procedure in C#, Net. Core, EntityFrameworkCore using LINQ?
*The question about SP was already asked, but I can not find the answer for this situation* | <c#><sql-server><linq><stored-procedures> | 2019-07-16 11:20:25 | LQ_EDIT |
57,057,221 | SQL Not Executing | The first SQL is executing but the second one doesn't seem to work.
When i change the query to the first one it works just fine but when I put it like that it doesn't seem to work for some reason.
I've just started learning MySQL i'm really struggling with this one and understanding the language.
//Classic One that checks if the hwid is there
public void checkHWID(string HWID)
{
string line;
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Users WHERE HWID = @HWID", con))
{
cmd.Parameters.AddWithValue("@HWID", HWID);
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
line = reader[1].ToString();
Console.Write(line);
con.Close();
}
else
{
updateHWID(HWID);
}
}
}
}
}
//This one doesn't seem to update the hwid but when i change the query to the first one it works just fine
public void updateHWID(String HWID)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("INSERT INTO USERS(hwid) VALUES(@HWID)", connection))
{
command.Parameters.AddWithValue("@HWID", HWID);
connection.Close();
}
}
} | <c#><sql><sql-insert> | 2019-07-16 12:24:03 | LQ_EDIT |
57,057,366 | How to reduce footer size in wordpress | <p>is there a way to decrease the footer height? I have been playing with the style.css, but did not make it. I would need the footer height as small as possible. Can anyone help?
My client is asking he want full width slider in home page without scroll bar and he is asking footer is also visible in home page like sticky footer without scroll. I tried but its not working. please save me out from this.</p>
<p>website is in wordpress</p>
<p>This is my website url: <a href="http://f9interiors.com/" rel="nofollow noreferrer">http://f9interiors.com/</a></p>
<p>Thanks for your suggestions.</p>
| <html><css><wordpress> | 2019-07-16 12:31:45 | LQ_CLOSE |
57,057,857 | net core api controller unit testing using xunit and moq | <p>i have some api controller methods that i would like to add some unit tests to. I am using xunit and moq and writing in c# using asp net core.</p>
<p>example of one method is:</p>
<pre><code>public async Task<ActionResult<List<StatusDTO>>> Get()
{
return await _statusservice.GetStatusesAsync();
}
</code></pre>
<p>at this point in time my controller method is simply returning the dto that the service layer method is returning. In future it might change to return a specific viewmodel.</p>
<p>i have read <a href="https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/testing?view=aspnetcore-2.2" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/testing?view=aspnetcore-2.2</a> to get some guidance on testing controllers.</p>
<p>My question is : for example above would the unit test just consist of
- checking that the return type is <code>ActionResult<StatusDTO></code> and/or (using moq) verifying the service method has been called. </p>
<p>Should i set up my service method to return a mock <code>StatusDTO</code> and do some assertions against that. I don't see benefit of that in this situation, as that would be testing the service method wouldn't it and i would cover that in the service method tests.</p>
<p>Sorry if this seems quite basic - my knowledge and experience in writing unit tests is very limited.
Thanks for any help.</p>
| <unit-testing><asp.net-core><xunit> | 2019-07-16 13:00:05 | LQ_CLOSE |
57,057,957 | Convert Set<> to List<String> | Need help in Converting Set<> to List<String> in Flutter
Set<_Filter> _selectedFilters = Set<_Filter>();
final List<_Filter> _filters = [
_Filter('Bee Cattle'),
_Filter('Crops'),
_Filter('Machinery'),
_Filter('Fish'),
_Filter('Sheep'),
_Filter('Cattle Breeds'),
_Filter('Wells'),
_Filter('Farm'),
];
I need to convert this Set to list<string> hence i can get a String List | <flutter><dart> | 2019-07-16 13:05:41 | LQ_EDIT |
57,058,704 | How to open another activity with a pre-written EditText | I have an activity which consists of an EditText. The problem is I want to open this activity with a pre-written EditText.
Here is the example:
[Example of a pre-written EditText][1]
[1]: https://i.stack.imgur.com/uVQP0.png
I want when I open this activity from the MainActivity, the text of EditText will always be set to "Tùng". | <android> | 2019-07-16 13:44:11 | LQ_EDIT |
57,059,477 | How to develop an application that recognize a type of image | i must develop a program in python that recognize the flowchart image files.Result must be 'yes this is a flowchart' or 'no this is not a flowchart'.I have watched a video series that classify dog and cat images, there are two categories as dataset dogs and cats.But i have only one category 'flowcharts'.How can i seperate flowchart images from all other things? | <python><image-processing><machine-learning><deep-learning><image-recognition> | 2019-07-16 14:21:16 | LQ_EDIT |
57,059,792 | How to disabled another input text when a input text has changed value | I'm a new guy in javascript/jquery, I have three inputs text like above. I don't know how to disable inputs #newPass and #confirmPass when #oldPass has changed value. Please help me or give me some advises.
P/s: This is the first time I raise a question on stackoverflow. Sorry if I make someone feels uncomfortable about my question.
| <javascript><jquery> | 2019-07-16 14:36:57 | LQ_EDIT |
57,062,738 | I want to do String validation | <p>We need to consider the below string as use cases , First I want to split
by "," then by "@"</p>
<p>After Splitting by @ if all the domain are same(either all gmail or all yahoo) its valid
else invalid.</p>
<p>Help me with split part.</p>
<pre><code>String input1 = example@gmail.com , example1@gmail.com;
String input2 = example@yahoo.com , example1@gmail.com;
String input 1 == valid.
String input 2 == Invalid.
</code></pre>
| <javascript> | 2019-07-16 17:37:41 | LQ_CLOSE |
57,062,760 | Python replace value in text file Problem | I have a settings file which is test.py. in this file i have to replace some values like ORDER_PAIRS = 10 to --> ORDER_PAIRS = new value
and overwrite to the test.py file again how can i do that?
thanks..
FileName = "test.py"
# Open file and replace line
with open(FileName) as f:
updatedString = f.read().replace("ORDER_PAIRS = 10", "ORDER_PAIRS = " + str(6))
# Write updated string to file
with open(FileName, "w") as f:
f.write(updatedString) | <python><file> | 2019-07-16 17:38:55 | LQ_EDIT |
57,063,213 | Serving same PDF through multiple URLs without duplicating it? | <p>I have a pdf called <code>dummy.pdf</code> that I want to serve whenever someone visits different path names like <code>acme.pdf</code> or <code>apple.pdf</code>.</p>
<p>Since the path names are known in advance, is there a way to serve the PDF via different names (with a rails route perhaps) without duplicating the original pdf?</p>
| <ruby-on-rails><ruby-on-rails-5> | 2019-07-16 18:12:50 | LQ_CLOSE |
57,063,740 | please help me to access all this characters json by react.js | please help me how to access this all characters
----------------
data: [
{
"url": "https://www.anapioficeandfire.com/api/characters/823",
"name": "Petyr Baelish",
"culture": "Valemen",
"born": "In 268 AC, at the Fingers",
"died": "",
"titles": [
"Master of coin (formerly)",
"Lord Paramount of the Trident",
"Lord of Harrenhal",
"Lord Protector of the Vale"
],
"aliases": [
"Littlefinger"
],
"father": "",
"mother": "",
"spouse": "https://www.anapioficeandfire.com/api/characters/688",
"allegiances": [
"https://www.anapioficeandfire.com/api/houses/10",
"https://www.anapioficeandfire.com/api/houses/11"
],
"books": [
"https://www.anapioficeandfire.com/api/books/1",
],
"povBooks": [],
"tvSeries": [
"Season 1",
"Season 2",
"Season 3",
"Season 4",
"Season 5"
],
"playedBy": [
"Aidan Gillen"
]
}
]
render() {
var { data } = this.state;
return (
<div>
<h1>Sample data block</h1>
{this.state.data.map(function(item, i) {
return <h3 key={'data-'+ i}>{data.title}</h3>
})}
</div>
);
} | <javascript><arrays><json><object><nested> | 2019-07-16 18:52:05 | LQ_EDIT |
57,064,860 | How I can impute a specific row with mean in pandas? | I am trying to impute mean to a specific column in my data frame, the names of the columns are in a list.
for col in ValIndex: #ValIndex has the columns name
dataSet[col] = dataSet[col].fillna(dataSet[col].mean())
I get this error when I run my code:
can only concatenate str (not "int") to str | <python><pandas><mean> | 2019-07-16 20:18:43 | LQ_EDIT |
57,065,016 | how do i write code to get text from amountField and convert to a double | I have created a bank account class and a bank account GUI with with amountField to show the amount i wish to withdraw and deposit.
using public void actionPerformed(ActionEvent e) function how can i write code to get text from amountField and convert to a double.
i want to input account details and be able to withdraw and deposit whilst storing values within a string
write event handler for deposit button
write event handler for withdraw button
public class BankAccountGUI extends JFrame implements ActionListener
{
private Label amountLabel = new Label("Amount");
private JTextField amountField = new JTextField(5);
private JButton depositButton = new JButton("DEPOSIT");
private JButton withdrawButton = new JButton("WITHDRAW");
private Label balanceLabel = new Label("Starting Balance = 0" );
private JPanel topPanel = new JPanel();
private JPanel bottomPanel = new JPanel();
private JPanel middlePanel = new JPanel();
BankAccount myAccount = new BankAccount("James","12345");
// declare a new BankAccount object (myAccount) with account number and name of your choice here
public BankAccountGUI()
{
setTitle("BankAccount GUI");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(340, 145);
setLocation(300,300);
depositButton.addActionListener(this);
withdrawButton.addActionListener(this);
topPanel.add(amountLabel);
topPanel.add(amountField);
bottomPanel.add(balanceLabel);
middlePanel.add(depositButton);
middlePanel.add(withdrawButton);
add (BorderLayout.NORTH, topPanel);
add(BorderLayout.SOUTH, bottomPanel);
add(BorderLayout.CENTER, middlePanel);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
}
} | <java><string><swing><double><jtextfield> | 2019-07-16 20:32:44 | LQ_EDIT |
57,065,913 | getting unknow type error, something like segmentation fault(code dumped) | I am new to data structure and i am trying to implement link list data structure,i am getting segmentation fault(core dumped), during run time.I am using linux terminal to compile and run the program. I have written a insert_element() function to insert function at the beginning and a recursive function print() to print the list.Plz..help me.Thanks in advance.
struct node{
int data;
struct node* link;
};
struct node* insert_element(struct node* A,int ino)
{
struct node *temp=(struct node*)malloc(sizeof(struct node));
temp->data=ino;
temp->link=NULL;
if(A=NULL)
{
A=temp;
}
else
{
struct node* temp1=A;
while(temp1->link!=NULL)
{
temp1=temp1->link;
}
temp1->link=temp;
}
return A;
}
void print(struct node* ptr)
{
if(ptr==NULL)
return;
printf("%d",ptr->data);
print(ptr->link);
}
int main()
{
struct node* head=NULL;
head=insert_element(head,5);
head=insert_element(head,5);
head=insert_element(head,6);
head=insert_element(head,3);
head=insert_element(head,5);
print(head);
return 0;
}
| <c> | 2019-07-16 21:51:30 | LQ_EDIT |
57,066,412 | Item is shifted way too much to the left, no clue how to change the position? | Thank you for helping me, so for some odd reason all my column 1 items are moved to the left of my screen, and so I cannot see it unless I add a String with a bunch of spaces, eg. "----- This works" whereas '4' this would not work.
In the table below I added an example if I add a bunch of spaces with a string and then with a normal number
1) I have tried googling for a solution but for some reason,
I cannot find any likewise situations
2) I have tried to mess around with the layout but it only makes everything scrambled.
I added a Picture of the code https://i.imgur.com/sRbgClT.png | <java><swing><jtable> | 2019-07-16 22:49:47 | LQ_EDIT |
57,068,373 | Send attachment from Android Device to another automatically - Android studio | I have Android Studio code that creates a new wav file every 30 seconds, I need to send these wav files to another device ( As some sort of notification) as they are made.
I can't use the traditional andorid studio default/built-in app for this as I need to send the email automatically without user input. I found a way to send the email automatically in background, from the source below, but I cannot get it to send the wav file attachment:
http://www.wisdomitsol.com/blog/android/sending-email-in-android-without-using-the-default-built-in-application
Any advice about the best way to achieve this would be greatly appreciated. | <android><push-notification><attachment><email-attachments> | 2019-07-17 04:06:03 | LQ_EDIT |
57,068,891 | Where to place code for audio playback in a SwiftUI app | <p>Where is the best place to put code for audio playback in a SwiftUI based app, i.e. not having UIViewController classes? The sound I want to play is initiated by a view, so I'm thinking of putting it into the corresponding view model class. But as a model class is about data, I think there should be a better option. What's the best architecture?</p>
| <swift><audio><avfoundation><avaudioplayer><swiftui> | 2019-07-17 05:11:51 | LQ_CLOSE |
57,070,052 | create-react-app Typescript 3.5, Path Alias | <p>I am trying to setup Path alias in my project by adding these values to tsconfig.json:</p>
<pre><code> "compilerOptions": {
"baseUrl": "src",
"paths": {
"@store/*": ["store/*"]
},
</code></pre>
<p>And if I create an import, neither IntelliJ or VSCode bother me:</p>
<pre><code>import { AppState } from '@store/index';
</code></pre>
<p>But when I compile the application I get this warning:</p>
<pre><code>The following changes are being made to your tsconfig.json file:
- compilerOptions.paths must not be set (aliased imports are not supported)
</code></pre>
<p>And it bombs saying it cannot find the reference:</p>
<pre><code>TypeScript error in C:/xyz.tsx(2,26):
Cannot find module '/store'. TS2307
</code></pre>
<p>Is there any workaround or it is not supported by <code>create-react-app --typescript</code>?</p>
| <typescript><create-react-app> | 2019-07-17 06:49:53 | HQ |
57,070,718 | updating value in JSON /Rest-api (Powershell) | I want to update values in my JSON/Rest-api, but I can't PATCH the new values in rest-api. I saved the new values in csv-file and I converted this file to JSON to patch the new values in Rest-api
$Authorization = "Bearer API-KEY"
$Accept = "application/json"
$Content = "application/json"
$Uri = "URL"
$getTapes = Invoke-RestMethod -Method PATCH -ContentType $content -Uri $Uri -Headers @{'Authorization' = $Authorization}
import-csv "C:\123\test.txt" | ConvertTo-Json | Set-Content -Path $getTapes
| <json><powershell><updates><patch> | 2019-07-17 07:33:34 | LQ_EDIT |
57,071,027 | Flask admin remember form value | <p>In my application, I have Users and Posts as models. Each post has a foreign key to a username. When I create a ModelView on top of my Posts model I can create posts as specific users in the admin interface
as seen in the screenshot below</p>
<p><a href="https://i.stack.imgur.com/DdBkJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DdBkJ.png" alt="enter image description here"></a></p>
<p>After I have added a post and click "Save and Add Another", the "User" reverts back to "user1". How can I make the form remember the previous value "user2"? </p>
<p>My reserach has led me to believe it can be done by modifying on_model_change and on_form_prefill, and saving the previous value in the flask session, but it seems to be overengineering such a simple task. There must be a simpler way.</p>
<p>My code can be seen below</p>
<pre class="lang-py prettyprint-override"><code>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import flask_admin
from flask_admin.contrib import sqla
app = Flask(__name__)
db = SQLAlchemy()
admin = flask_admin.Admin(name='Test')
class Users(db.Model):
"""
Contains users of the database
"""
user_id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), index=True, unique=True, nullable=False)
def __str__(self):
return self.username
class Posts(db.Model):
"""
Contains users of the database
"""
post_id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(11), db.ForeignKey(Users.username), nullable=False)
post = db.Column(db.String(256))
user = db.relation(Users, backref='user')
def build_sample_db():
db.drop_all()
db.create_all()
data = {'user1': 'post1', 'user1': 'post2', 'user2': 'post1'}
for user, post in data.items():
u = Users(username=user)
p = Posts(username=user, post=post)
db.session.add(u)
db.session.add(p)
db.session.commit()
class MyModelView(sqla.ModelView):
pass
if __name__ == '__main__':
app.config['SECRET_KEY'] = '123456790'
app.config['DATABASE_FILE'] = 'sample_db.sqlite'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database'
app.config['SQLALCHEMY_ECHO'] = True
db.init_app(app)
admin.init_app(app)
admin.add_view(MyModelView(Posts, db.session))
with app.app_context():
build_sample_db()
# Start app
app.run(debug=True)
</code></pre>
| <python><flask><flask-admin> | 2019-07-17 07:53:00 | HQ |
57,072,076 | Using if and elif in list comprehension in python3 | Please I'm trying to use list comprehension to Write a program that prints the numbers from 1-100. But for multiples of 3, print 'fizz', for multiples of 5, print 'buzz', for multiples of 3 & 5, print 'fizzbuzz'"
I also used for loops
`for num in range(1, 101):`
`if num %3 == 0 and num%5 == 0:`
print('fizzbuzz')
elif num%3 == 0:
print('fizz')
elif num%5 ==0:
print('buzz')
else:
print(num) | <python><python-3.x><list-comprehension> | 2019-07-17 08:54:38 | LQ_EDIT |
57,073,009 | How to convert a textView text into a char variable? (Java) | So I'm trying to convert a textView text that will be entered by the user into a char variable, but i can't seem to make it work. Also, did'nt manage find anything useful so decided to just ask in here.
Thanks in adavance! | <java><android><textview><char> | 2019-07-17 09:45:50 | LQ_EDIT |
57,074,300 | What is the recommended way to break long if statement? (W504 line break after binary operator) | <p>What is currently the recommended way to break long line of if statement with "and" and "or" operators? </p>
<p><strong>1st option</strong> </p>
<p>With the style below <a href="https://www.python.org/dev/peps/pep-0008/#maximum-line-length" rel="noreferrer">(which is from PEP8)</a> with flake8 I'm getting warnings: W504 line break after binary operator:</p>
<pre><code>if (this_is_one_thing and
that_is_another_thing):
do_something()
</code></pre>
<p><strong>2nd option</strong> </p>
<pre><code>if (this_is_one_thing
and that_is_another_thing):
do_something()
</code></pre>
<p>Now I'm getting the warning W503 line break before binary operator.
The second seems to be in line with <a href="https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator" rel="noreferrer">this recommendation from PEP8</a></p>
<p>I tried to find answer but I'm still unsure. I think maybe using 2nd option and disabling W503 warning will be a way to deal with this problem?</p>
| <django><python-3.x><pep8><flake8> | 2019-07-17 10:58:22 | HQ |
57,075,531 | Why is there one `Atomic*` type for many primitive type instead of a generic `Atomic<T>`? | <p>Looking at <a href="https://doc.rust-lang.org/stable/std/sync/atomic/index.html" rel="noreferrer">the <code>std::sync::atomic</code> module</a>, one can see a bunch of different <code>Atomic*</code> types, like <code>AtomicU32</code>, <code>AtomicI16</code> and more. Why is that?</p>
<p>Rust has generics and – as I see it – it would be possible to add a generic <code>Atomic<T></code> where <code>T</code> is bounded by some trait defined in the module (in Java-ish naming: <code>Atomicable</code>). That trait would be implemented by the types that could be handled in an atomic fashion and users could just use <code>Atomic<u32></code> instead of <code>AtomicU32</code>.</p>
<p><strong>Why isn't there a generic <code>Atomic<T></code>? Why have a bunch of different types instead?</strong></p>
| <rust><atomic> | 2019-07-17 12:11:45 | HQ |
57,075,685 | IndexOutOfRangeException on for loop with enough content on list | I currently have a project that takes every x number of seconds (using Timer and a 10000 milliseconds Interval) the events happening on Windows and filters them under certain conditions.
Each time the Timer does Tick, date and hour corresponding to 10 seconds before (due to the Interval) the moment events are checked, and the next method is executed:
// Method that returns wanted events from an EventLogEntryCollection
private List<EventLogEntry> lastEvents(EventLogEntryCollection eventsList, DateTime minimumMoment)
{
// Wanted events list
// 4624: Login
// 4634: Logout
long[] events = new long[] { 4624, 4634 };
// Table to return with valid events
List<EventLogEntry> filteredEventsList = new List<EventLogEntry>();
// Checking if there are events to filter
if (eventsList.Count > 0)
{
// There are events to filter
// Going across all events to filter
for (int i = 0; i < eventsList.Count; i++)
{
// Getting the current event
EventLogEntry event = listaEventos[i]; // Line with exception
// Checking if the current event happened in the last 10 seconds (due to the Interval)
if (event.TimeGenerated >= minimumMoment)
{
// The event is valid time wise
// Checking if the event's ID is contained in the required ID's list
if (events.Contains(event.InstanceId))
{
// The event has a valid ID
// Adding the event to the list
filteredEventsList.Add(event);
}
}
}
}
// Returning obtained list
return filteredEventsList;
}
That event obtains a list of all events (obtained by using EventLog.Entries) and the date and time an event has to have to get added to the filtered events list (so an event had to be generated 10 seconds ago to be 'accepted').
But, during eventsList iterating, an OutOfRangeException is generated being i on the first test around 28000 and on the second test 43, and the Count property around 31000 in both tests.
¿Is anyone able to tell me why this happens?
Here is a screenshot of the exception data (it is in Spanish, sorry):
[IndexOutOfRange exception data][1]
[1]: https://i.stack.imgur.com/KDVLI.png | <c#><event-log><indexoutofrangeexception> | 2019-07-17 12:18:51 | LQ_EDIT |
57,075,846 | How to disable a link using CSS? | <p>I have the following link in a <code>wordpress</code> page.</p>
<p>This class is a link. Is it possible to disable the link using only <code>CSS</code>?</p>
<pre><code><a class="select-slot__serviceStaffOrLocationButton___5GUjl"><i class="material-icons select-slot__serviceStaffOrLocationIcon___3WFzp">timelapse</i><span class="select-slot__serviceName___14MHL">Employee Assistance Line</span></a>
</code></pre>
| <html><css><wordpress> | 2019-07-17 12:27:06 | LQ_CLOSE |
57,078,329 | c# intialize static variable from different class | I am doing this
public static class IDs{
public static string someID{ get; set; }
static IDs(){
log.info(someID);
//use someID here
}
}
pulic class otherClass{
public otherMethod(string sym){
IDs.someID = sym;
}
}
public class anotherClass{
//access instance of otherClass in wrp and call otherMethod()
wrp.otherMethod("someStringSymbol")
}
I dont have any build errors but `log.info(someID);` is printing `null` . I am expecting it to be `someStringSymbol`
| <c#> | 2019-07-17 14:32:01 | LQ_EDIT |
57,079,483 | sql datetime. how to set the month | <pre><code>DECLARE @DateMin AS datetime = '2019-01-05 00:00:00';
DECLARE @PrmMois AS tinyint = 4;
</code></pre>
<p>How do I replace the month by 04 ?</p>
| <sql><sql-server> | 2019-07-17 15:30:25 | LQ_CLOSE |
57,080,167 | checking room availability for hotel booking system | hello i'm trying to check available rooms in booking system so i have two tables : table of rooms called chambre (`id`,`name`) and table reservation_client(`id`,`start`,`end`,`id_chambre`) the start and end are the check in and checkout dates.
my query is :
```
$sql = "SELECT * FROM chambre WHERE id NOT IN (SELECT id_chambre FROM reservation_client WHERE end < '2019-07-20' AND start > '2019-07-19 ')";
```
but its not give me any result . | <mysql> | 2019-07-17 16:07:48 | LQ_EDIT |
57,080,923 | please help me out to understanding this array sorting (bubble sort) | how did it working when both the loop is starting from 0 and comparison between both indexes have the same value
public class BubbleSort {
public static void main(String[] args)
{
int arr[]={5,1,2,1,1,4,4,4,4,4,3};
for(int i=0;i<arr.length;i++)//i=0
{
for(int j=0;j<arr.length;j++)//j=0
{
if(arr[i]>arr[j])//i=5>j=5
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(int k=0;k<arr.length;k++)` `
System.out.println(arr[k]);
}
} | <java><loops><for-loop> | 2019-07-17 17:00:45 | LQ_EDIT |
57,081,532 | "how to create this type of shape with text inside it?" | "i'm creating this type of shape with text inside it. but not, anyone can help me?"
https://i.stack.imgur.com/KQfwm.png | <html><css> | 2019-07-17 17:41:36 | LQ_EDIT |
57,081,763 | LiveData observing in Fragment | <p>As of 2019, I'm trying to follow a best practice on where to start observing <code>LiveData</code> in Fragments and if I should pass <code>this</code> or <code>viewLifecycleOwner</code> as a parameter to the <code>observe()</code> method.</p>
<ul>
<li><p>According to this <a href="https://developer.android.com/topic/libraries/architecture/livedata" rel="noreferrer">Google official documentation</a>, I should observe in <code>onActivityCreated()</code> passing <code>this</code> (the fragment) as parameter.</p></li>
<li><p>According to this <a href="https://github.com/googlesamples/android-architecture-components/blob/master/GithubBrowserSample/app/src/main/java/com/android/example/github/ui/user/UserFragment.kt" rel="noreferrer">Google sample</a>, I should observe in <code>onViewCreated()</code> passing <code>viewLifecycleOwner</code> as parameter.</p></li>
<li><p>According to this <a href="https://youtu.be/pErTyQpA390?t=459" rel="noreferrer">I/O video</a>, I shouldn't use <code>this</code> but instead <code>viewLifecycleOwner</code>, but doesn't specify where should I start observing.</p></li>
<li><p>According to this pitfalls <a href="https://medium.com/@BladeCoder/architecture-components-pitfalls-part-1-9300dd969808" rel="noreferrer">post</a>, I should observe in <code>onActivityCreated()</code> and use <code>viewLifecycleOwner</code>.</p></li>
</ul>
<p>So, where should I start observing? And should I either use <code>this</code> or <code>viewLifecycleOwner</code>?</p>
| <android><android-fragments><android-architecture-components><android-livedata> | 2019-07-17 17:59:37 | HQ |
57,084,807 | converting string array to int array for sql statement c# | In my model i have:
public List<uint> Ids {get; set;}
I am executing sql in my get call and the format for the Ids are not in proper format for the sql statment to successfully execute.
db.tableName.FromSql("SELECT * FROM tableName where( id in ({0}) && itemId = {1}), x.Ids, x.ItemId);
currently my x.ids looks like this: [0]: 100 [1]: 101
i want for my x.ids to look like 100, 101 so that in my where clause they will look like...`id in (100, 101)`..
I have tried: `var temp = string.Join(', ', x.Ids); //result: "100, 101"` but this is a string array and i want int array for the sql to work.
x is being passed in my method.
Is there a simple way to make this conversion or do i have to loop through the string array and convert and push into int array?
| <c#><sql><arrays><entity-framework-core> | 2019-07-17 22:32:58 | LQ_EDIT |
57,087,274 | Minimum no of bracket reversals | Given an expression with only ‘}’ and ‘{‘. The expression may not be balanced. Find minimum number of bracket reversals to make the expression balanced
…. python
``
a=['}{}{}{}}}{{{{{}{}{}}{{}{}{}}{{}}{{']
for elem in a:
sol=0
stack=[]
#stack.append(elem[i])
i=0
while i<len(elem)-1:
if elem[i]=='{' and elem[i+1]=='{':
stack.append(elem[i])
stack.append(elem[i+1])
sol+=1
elif elem[i]=='}' and elem[i+1]=='{':
if len(stack)!=0:
if stack[-1]=='{':
stack.pop()
stack.append(elem[i+1])
else:
stack.append(elem[i])
stack.append(elem[i+1])
sol+=1
else:
stack.append(elem[i])
`` stack.append(elem[i+1])
sol+=2
elif elem[i]=='}' and elem[i+1]=='}':
if len(stack)!=0:
if stack[-1]=='{' and stack[-2]=='{':
stack.pop()
stack.pop()
sol-=1
elif stack[-1]=='{' and stack[-2]=='}':
stack.pop()
stack.append(elem[i+1])
else:
stack.append(elem[i])
stack.append(elem[i+1])
sol+=1
else:
stack.append(elem[i])
stack.append(elem[i+1])
sol+=1
i+=2
print(sol)
….
expected 5
output 6 | <python><stack><brackets> | 2019-07-18 04:45:48 | LQ_EDIT |
57,087,283 | How to check if a data is present in sql table column where the data re inserted in inverted commas | I have added some data valus as 'a','b','c' (same as this) in sql table column
how can i check if a or b or c is present in this table value or not
s | <c#><sql-server> | 2019-07-18 04:47:06 | LQ_EDIT |
57,088,154 | Mysql database Insert duplicate foriegn key problem | #1062 - Duplicate entry '8' for key 'user_id'
A Mysql database Insert duplicate foriegn key problem
anyone to solve this problem | <mysql> | 2019-07-18 06:18:12 | LQ_EDIT |
57,089,401 | How to get spotify access token -Spotify Web API Node | I reffered the link https://www.npmjs.com/package/spotify-web-api-node
**code sample**
var SpotifyWebApi = require('spotify-web-api-node');
// credentials are optional
var spotifyApi = new SpotifyWebApi({
clientId: 'fcecfc72172e4cd267473117a17cbd4d',
clientSecret: 'a6338157c9bb5ac9c71924cb2940e1a7',
redirectUri: 'http://www.example.com/callback'
});
In this how can i get the access token..?
Please help me | <node.js><api><npm><authorization><spotify> | 2019-07-18 07:39:32 | LQ_EDIT |
57,091,039 | Here is a link . How is the random string f6909.... Generated? | <p>I got an email for verification . <a href="http://xyz.pythonanywhere.com/record/upload/f690928d034d27ebb943b3f9bc9e3ae9/12" rel="nofollow noreferrer">http://xyz.pythonanywhere.com/record/upload/f690928d034d27ebb943b3f9bc9e3ae9/12</a>. How is the string f6909..... Generated and is there a way to find out the pattern ? Is there any function which is generating the random string for different email addresses ? </p>
| <python><django><email-verification> | 2019-07-18 09:14:18 | LQ_CLOSE |
57,091,101 | Make a data frame of two columns based on values less than a threshold value in column 2 in r | <p>I want to make a data frame that only has entries below a certain defined threshold that is compared with column b, such that entry "OP2775iib SAV OP2958i_b POR" is excluded.</p>
<p>I tried this code:</p>
<pre><code>less_than_threshold <- data.frame(which(data[data$b < threshold]))
</code></pre>
<p>but it returns and error that I cant quite grasp:</p>
<p>Error in <code>[.data.frame</code>(pairwise_ind_Mdists, pairwise_ind_Mdists$Mdist < :
undefined columns selected</p>
<p>This is a sample of the data I'm working with:</p>
<pre><code>data <- data.frame(a = c("OP2775iia MOU OP2775iib SAV","OP2775iia MOU OP2958i_a COM","OP2775iib SAV OP2958i_a COM","OP2775iia MOU OP2958i_b POR","OP2775iib SAV OP2958i_b POR"),
b = c(4.9022276,3.8867063,3.0126033,5.0261763,6.3745697))
threshold <- 6.3745697
</code></pre>
<p>I want a data frame that has all the entries from the original dataset except for the last entry "OP2775iib SAV OP2958i_b POR"</p>
| <r><dataframe><max><threshold> | 2019-07-18 09:17:48 | LQ_CLOSE |
57,091,138 | Javascript: function to convert an array object and its rewriting | When choosing a currency to convert all the price products according to what they choose and then defend the change in the page
I want when I select a coin to convert the sum of all the products in the chunk and then to show the sum of each product
The function must be written in javascript vanilla without jquery
This is the list of objects
let productsList = [
{
imageURL: "https://s12emagst.akamaized.net/products/8096/8095064/images/res_689070343515d1e2bcd294526b17f3c8_200x200_gnvo.jpg",
discount: "-15%",
name: "Monitor LFD PHILIPS 4k",
brand: "philips",
colors: "black",
stoc: "out stoc",
review: "",
type: "monitor",
price: 70000
},
{
imageURL: "https://s12emagst.akamaized.net/products/22044/22043004/images/res_b6ecd7bc761b9d80fcefe28923b1b756_200x200_59vo.jpg",
discount: "",
name: "Monitor LED Dell Curbat 4k",
brand: "dell",
colors: "black",
stoc: "on stoc",
review: "",
type: "monitor",
price: 49000
}];
This is the function that creates the cards
function createCard(product) {
let card = document.createElement('div');
card.className = 'card';
let box_d = document.createElement('div');
box_d.className = 'box-d';
box_d.innerHTML = product.discount;
if (product.discount !== "") {
card.appendChild(box_d);
}
let box_h = document.createElement('div');
box_h.className = 'box-h';
box_h.innerHTML = '<i class="fas fa-2x fa-heart" onclick="heartSlide()"></i>';
card.appendChild(box_h);
let image = document.createElement('img');
image.className = 'card-img';
image.src = product.imageURL;
card.appendChild(image);
let review = document.createElement('div');
review.className = 'p-info';
review.innerHTML = 'Review: <span class="star"><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i><i class="fas fa-star"></i></span>';
card.appendChild(review);
let name = document.createElement('div');
name.className = 'p-info';
name.innerHTML = product.name;
card.appendChild(name);
let stoc = document.createElement('div');
stoc.className = 'p-info';
stoc.innerHTML = `Stoc: ${product.stoc}`;
card.appendChild(stoc);
let price = document.createElement('div');
price.className = 'p-info';
price.innerHTML = `Price: ${product.price} RON`;
card.appendChild(price);
let button = document.createElement('button');
button.className = 'add-btn';
button.innerHTML = 'Add to cart <i class="fas fa-shopping-cart an"></i>';
card.appendChild(button);
return card;
} | <javascript> | 2019-07-18 09:20:13 | LQ_EDIT |
57,091,176 | What is meant by event i n azure event hub | <p>I would like to know what is meant by an event in azure event hub.
I thought it's like getting some content(string) from source and process it by other services is one event.
if so, what is maximum content(string) I can send at one event</p>
| <azure><azure-eventhub><azure-stream-analytics><azure-eventgrid><azure-eventhub-capture> | 2019-07-18 09:22:03 | LQ_CLOSE |
57,094,602 | which technologies are used by Faceapp? | <p>I am eagerly want to know how many types of technologies are used in "faceapp" application.which is working with selfies of users.it provides change gender,change age of user through its selfies and give result as per user filter..then how they do it ??
Help and give spark to my curiosity</p>
| <android><google-play> | 2019-07-18 12:35:38 | LQ_CLOSE |
57,094,967 | I am new in flutter i want pass data like user details name,address,moible number,email to another screen can you tell me how to do this | <p>i want to pass some data from one screen to another scrren</p>
<ol>
<li>first nanme</li>
<li>lastname</li>
<li>email</li>
<li>address</li>
</ol>
| <flutter> | 2019-07-18 12:54:54 | LQ_CLOSE |
57,097,777 | refactor SELECT WHERE AND OR EXISTS | SELECT *
FROM a
WHERE
a.field=@fieldValue
AND
(
YEAR(a.myDate)=@y
OR EXISTS
(
SELECT *
FROM b
WHERE b.Id=a.Id
)
OR EXISTS
(
SELECT *
FROM c
WHERE c.Id=a.Id
)
...
)
How can this be rewritten in a simpler way ? | <sql><sql-server> | 2019-07-18 15:15:39 | LQ_EDIT |
57,104,044 | I want to test if a list of URLs is valid | <p>I have Googled for a solution to read through a bunch of URLs, in a text file, and test if each one is valid. Anything, simple or complex, is fine. Simpler is probably better. Maybe getting a 200 response is the way to go. As I said, I tested some scripts that I found online, and non worked. Sometimes people want to see what has been tried already, but I don't think there is any sense in posting what does NOT work. </p>
<p>As a bonus, I'm wondering if there is a way to loop through all bookmarks in a browser, like Firefox specifically, and test if all URLs are valid or not. I'm not sure that's doable, but it would be a nice-to-have!!</p>
<p>TIA everyone.</p>
| <python><python-3.x><web><url> | 2019-07-19 00:14:33 | LQ_CLOSE |
57,104,260 | Reverse engineering - Is this a cheap 3D distance function? | <p>I am reverse engineering a game from 1999 and I came across a function which looks to be checking if the player is within range of a 3d point for the triggering of audio sources. The decompiler mangles the code pretty bad but I think I understand it.</p>
<pre><code>// Position Y delta
v1 = * (float * )(this + 16) - LocalPlayerZoneEntry - > y;
// Position X delta
v2 = * (float * )(this + 20) - LocalPlayerZoneEntry - > x;
// Absolute value
if (v1 < 0.0)
v1 = -v1;
// Absolute value
if (v2 < 0.0)
v2 = -v2;
// What is going on here?
if (v1 <= v2)
v1 = v1 * 0.5;
else
v2 = v2 * 0.5;
// Z position delta
v3 = * (float * )(this + 24) - LocalPlayerZoneEntry - > z;
// Absolute value
if (v3 < 0.0)
v3 = -v3;
result = v3 + v2 + v1;
// Radius
if (result > * (float * )(this + 28))
return 0.0;
return result;
</code></pre>
<p>Interestingly enough, when in game, it seemed like the triggering was pretty inconsistent and would sometimes be quite a bit off depending on from which side I approached the trigger.</p>
<p>Does anyone have any idea if this was a common algorithm used back in the day?</p>
<p>Note: The types were all added by me so they may be incorrect. I assume that this is a function of type bool.</p>
| <c++><algorithm><math><reverse-engineering> | 2019-07-19 00:53:39 | HQ |
57,105,317 | How to get the data I want according to the rules | <p>I have a configuration table like the below, and some users with different attributes. I need to get a configuration data based on user attributes.</p>
<p>I don't know how to implement it, no idea.</p>
<p><a href="https://i.stack.imgur.com/vFKP3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vFKP3.png" alt="configuration data from db table"></a></p>
<p>Initial code: </p>
<pre><code>void Main()
{
var configList = new List<ConfigEntity>() {
new ConfigEntity { ConfigCode="37", GoodCode="A", UserType="personal", Country="US", State="NewYork", City="Buffalo", Price=37 },
new ConfigEntity { ConfigCode="36", GoodCode="A", UserType="personal", Country="US", State="NewYork", City="Albany", Price=36 },
new ConfigEntity { ConfigCode="35", GoodCode="A", UserType="personal", Country="US", State="NewYork", City="", Price=35 },
new ConfigEntity { ConfigCode="34", GoodCode="A", UserType="personal", Country="US", State="", City="", Price=34 },
new ConfigEntity { ConfigCode="40", GoodCode="A", UserType="personal", Country="China", State="Guangdong", City="Guangzhou", Price=40 },
new ConfigEntity { ConfigCode="39", GoodCode="A", UserType="personal", Country="China", State="Guangdong", City="", Price=39 },
new ConfigEntity { ConfigCode="38", GoodCode="A", UserType="personal", Country="China", State="", City="", Price=38 },
new ConfigEntity { ConfigCode="33", GoodCode="A", UserType="personal", Country="", State="", City="", Price=33 },
new ConfigEntity { ConfigCode="45", GoodCode="A", UserType="organization", Country="US", State="NewYork", City="Buffalo", Price=45 },
new ConfigEntity { ConfigCode="44", GoodCode="A", UserType="organization", Country="US", State="NewYork", City="Albany", Price=44 },
new ConfigEntity { ConfigCode="43", GoodCode="A", UserType="organization", Country="US", State="NewYork", City="", Price=43 },
new ConfigEntity { ConfigCode="42", GoodCode="A", UserType="organization", Country="US", State="", City="", Price=42 },
new ConfigEntity { ConfigCode="48", GoodCode="A", UserType="organization", Country="China", State="Guangdong", City="Guangzhou", Price=48 },
new ConfigEntity { ConfigCode="47", GoodCode="A", UserType="organization", Country="China", State="Guangdong", City="", Price=47 },
new ConfigEntity { ConfigCode="46", GoodCode="A", UserType="organization", Country="China", State="", City="", Price=46 },
new ConfigEntity { ConfigCode="41", GoodCode="A", UserType="organization", Country="", State="", City="", Price=41 },
new ConfigEntity { ConfigCode="29", GoodCode="A", UserType="", Country="US", State="NewYork", City="Buffalo", Price=29 },
new ConfigEntity { ConfigCode="28", GoodCode="A", UserType="", Country="US", State="NewYork", City="Albany", Price=28 },
new ConfigEntity { ConfigCode="27", GoodCode="A", UserType="", Country="US", State="NewYork", City="", Price=27 },
new ConfigEntity { ConfigCode="26", GoodCode="A", UserType="", Country="US", State="", City="", Price=26 },
new ConfigEntity { ConfigCode="32", GoodCode="A", UserType="", Country="China", State="Guangdong", City="Guangzhou", Price=32 },
new ConfigEntity { ConfigCode="31", GoodCode="A", UserType="", Country="China", State="Guangdong", City="", Price=31 },
new ConfigEntity { ConfigCode="30", GoodCode="A", UserType="", Country="China", State="", City="", Price=30 },
new ConfigEntity { ConfigCode="25", GoodCode="A", UserType="", Country="", State="", City="", Price=25 },
new ConfigEntity { ConfigCode="13", GoodCode="", UserType="personal", Country="US", State="NewYork", City="Buffalo", Price=13 },
new ConfigEntity { ConfigCode="12", GoodCode="", UserType="personal", Country="US", State="NewYork", City="Albany", Price=12 },
new ConfigEntity { ConfigCode="11", GoodCode="", UserType="personal", Country="US", State="NewYork", City="", Price=11 },
new ConfigEntity { ConfigCode="10", GoodCode="", UserType="personal", Country="US", State="", City="", Price=10 },
new ConfigEntity { ConfigCode="16", GoodCode="", UserType="personal", Country="China", State="Guangdong", City="Guangzhou", Price=16 },
new ConfigEntity { ConfigCode="15", GoodCode="", UserType="personal", Country="China", State="Guangdong", City="", Price=15 },
new ConfigEntity { ConfigCode="14", GoodCode="", UserType="personal", Country="China", State="", City="", Price=14 },
new ConfigEntity { ConfigCode="9", GoodCode="", UserType="personal", Country="", State="", City="", Price=9 },
new ConfigEntity { ConfigCode="21", GoodCode="", UserType="organization", Country="US", State="NewYork", City="Buffalo", Price=21 },
new ConfigEntity { ConfigCode="20", GoodCode="", UserType="organization", Country="US", State="NewYork", City="Albany", Price=20 },
new ConfigEntity { ConfigCode="19", GoodCode="", UserType="organization", Country="US", State="NewYork", City="", Price=19 },
new ConfigEntity { ConfigCode="18", GoodCode="", UserType="organization", Country="US", State="", City="", Price=18 },
new ConfigEntity { ConfigCode="24", GoodCode="", UserType="organization", Country="China", State="Guangdong", City="Guangzhou", Price=24 },
new ConfigEntity { ConfigCode="23", GoodCode="", UserType="organization", Country="China", State="Guangdong", City="", Price=23 },
new ConfigEntity { ConfigCode="22", GoodCode="", UserType="organization", Country="China", State="", City="", Price=22 },
new ConfigEntity { ConfigCode="17", GoodCode="", UserType="organization", Country="", State="", City="", Price=17 },
new ConfigEntity { ConfigCode="5", GoodCode="", UserType="", Country="US", State="NewYork", City="Buffalo", Price=5 },
new ConfigEntity { ConfigCode="4", GoodCode="", UserType="", Country="US", State="NewYork", City="Albany", Price=4 },
new ConfigEntity { ConfigCode="3", GoodCode="", UserType="", Country="US", State="NewYork", City="", Price=3 },
new ConfigEntity { ConfigCode="2", GoodCode="", UserType="", Country="US", State="", City="", Price=2 },
new ConfigEntity { ConfigCode="8", GoodCode="", UserType="", Country="China", State="Guangdong", City="Guangzhou", Price=8 },
new ConfigEntity { ConfigCode="7", GoodCode="", UserType="", Country="China", State="Guangdong", City="", Price=7 },
new ConfigEntity { ConfigCode="6", GoodCode="", UserType="", Country="China", State="", City="", Price=6 },
new ConfigEntity { ConfigCode="1", GoodCode="", UserType="", Country="", State="", City="", Price=1 }
};
configList.Dump();
}
public class ConfigEntity
{
public string ConfigCode { get; set; }
public string GoodCode { get; set; }
public string UserType { get; set; }
public string Country { get; set; }
public string State { get; set; }
public string City { get; set; }
public decimal Price { get; set; }
}
</code></pre>
<p>if GoodCode="A" and user (UserType="personal", Country="US", State="NewYork", City="Albany"), I expect get a data of ConfigCode="36";</p>
<p>if GoodCode="A" and user (UserType="personal", Country="China", State="Guangdong", City=""), I expect get a data of ConfigCode="39";</p>
<p>if GoodCode="A" and user (UserType="personal", Country="", State="", City=""), I expect get a data of ConfigCode="33";</p>
<p>if GoodCode="" and user (UserType="personal", Country="", State="", City=""), I expect get a data of ConfigCode="9";</p>
<p>if GoodCode="B" and user (UserType="", Country="", State="", City=""), I expect get a data of ConfigCode="1";</p>
| <c#><algorithm> | 2019-07-19 03:56:38 | LQ_CLOSE |
57,105,485 | writing with python into a csv file with multiple lines in one cell | <p>im using writer.writerow(groupOfUsers) where groupOfUsers is a list of users
ex: ['joe','john','jane']
i want all 3 names printed with a new line into one cell but with the current command it writes the 3 names into 3 different new rows</p>
<p>i want it to look like
joe
john
jane</p>
<p>and not</p>
<p>joe</p>
<hr>
<p>john</p>
<hr>
<p>jane</p>
| <python><selenium> | 2019-07-19 04:20:34 | LQ_CLOSE |
57,107,425 | how can I split the image into 3 parts in the image processing project | [filename pathname]=uigetfile('*.png','Pick the image file');
file=strcat(pathname,filename);
I=imread(file);
figure,imshow(I);
title('Input Image');
im1=I;
su=median(im1);
median=ceil(su);
disp('mean Value');
disp(median)
[row, col]=size(I);
%mr = median(row/2); % median of rows
mc = median(col/3); % median of columns
right = I(1:mr , (mc+1):col);
figure,imshow(right)
% Back_to_original = [top_left,top_right ; bot_left,bot_right];
i expect to split the image into three parts but it is splitted into top right and left and creating mirror image | <matlab><image-processing> | 2019-07-19 07:20:49 | LQ_EDIT |
57,107,563 | An explicit conversion exists (are you missing a cast?) shenoywebapi D:\shenoystudio\shenoywebapi\Controllers\RateController.cs 69 Active | Hello guys can anyone try to solve this my error i got stuck here, it shows the ..(Cannot implicitly convert type 'shenoy webapi.Models.PatIndex' to 'System.Collections.Generic.IEnumerable<shenoywebapi.Models.PartIndex>'. An explicit conversion exists (are you missing a cast?) shenoywebapi D:\shenoystudio\shenoywebapi\Controllers\RateController.cs 69 Active)
```[Route("api/Rate/getproductrate")]
public IEnumerable<Rate> GetProductRate()
{
var list = new List<Rate>();
var dsRate = SqlHelper.ExecuteDataset(AppDatabaseConnection, CommandType.StoredProcedure, 0, "GetProductRates");
if (dsRate.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in dsRate.Tables[0].Rows)
{
list.Add(new Rate
{
Id = Convert.ToInt64(row[0]),
SerialNumber = row[1].ToString(),
ProductName = row[2].ToString(),
Unit = row[3].ToString(),
PartIndex = new PartIndex { Series = row[4].ToString() },
});
}
}
return list;
}
```
this is my model
```namespace shenoywebapi.Models
{
public class Rate
{
public long Id { get; set; }
public DateTime wefDate { get; set; }
public string SerialNumber { get; set; }
public string ProductName { get; set; }
public string Unit { get; set; }
public long Rates { get; set; }
public IEnumerable<PartIndex> PartIndex { get; set; }
}
}
```
Severity Code Description Project File Line Suppression State
Error CS0266 Cannot implicitly convert type 'shenoywebapi.Models.PartIndex' to 'System.Collections.Generic.IEnumerable<shenoywebapi.Models.PartIndex>'. An explicit conversion exists (are you missing a cast?) shenoywebapi D:\shenoystudio\shenoywebapi\Controllers\RateController.cs 69 Active | <c#><asp.net-mvc> | 2019-07-19 07:28:54 | LQ_EDIT |
57,108,132 | Cell color in excel | <p>I have a table in excel with data. I want that as soon as any data in any cell is updated the cell gets colored. As there is no condition (other than that the cell is updated) I am not able to do it using conditional formatting. This could be done through VBA. </p>
| <excel><vba> | 2019-07-19 08:06:10 | LQ_CLOSE |
57,109,283 | Combine 2 arrays, updating values | <p>In my reducer I am pulling down results from my API, I would like to combine this array with the persisted data from storage if it exists, the only fields that need to be overwritten in the data are <code>bookMarked</code>, <code>totalScore</code>, and <code>completed</code>. How can I compare arrays and overwrite the required properties if they are different?</p>
<p>What is the best way to do this?</p>
<pre><code>let arrayFromAPI= [
{
bookMarked: false,
completed: false,
totalScore: 50,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 1
},
{
bookMarked: false,
completed: false,
totalScore: 50,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 2
}
];
let arrayFromPersist = [
{
bookMarked: true,
completed: false,
totalScore: 50,
completed: true,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 1
},
{
bookMarked: true,
completed: false,
totalScore: 50,
completed: true,
current: 0,
description:
"<p>Lorem ipsum culpa qui officia deserunt mollit anim id est laborum.</p>",
icon: "male-urinary-catheterisation",
id: 2
}
];
</code></pre>
| <javascript> | 2019-07-19 09:16:24 | LQ_CLOSE |
57,110,516 | I want to send pictures and messages to users phone numbers without making them install the app. I am using firebase for storage ( swift iOS) | <p>currently twilio.com offers a service where you can send messages and pictures through a phone number, I want to know is there any API or service that I can use to send my stored user data to their cell phone without making them install the app, I am not trying to Create a separate admin feature. </p>
<p>I don't want to create an admin feature,I want to see if I can send data to user phone-number without making them install the app.</p>
| <ios><swift><firebase><message> | 2019-07-19 10:30:37 | LQ_CLOSE |
57,110,552 | integer function with no return value | <p>I'm trying to execute the below code, since the function has no return value but it was defined with integer return type. how it was running without any error.</p>
<pre><code>#include <stdio.h>
int fn(int a, int b){
int temp = b;
a = 2*temp;
b = a;
}
int main()
{
int x,y,printval;
scanf("%d%d",&x,&y);
printval = fn(x,y);
printf("%d", printval);
return 0;
}
</code></pre>
<p>i Expect the output be error but it was resulting in 40(input:10,20)</p>
| <c++><c><c++11> | 2019-07-19 10:32:59 | LQ_CLOSE |
57,110,557 | React testing library: The given element does not have a value setter when fireEvent change on input form | <p>I want to change the value of <a href="https://material-ui.com/components/text-fields/" rel="noreferrer">material UI</a> <code>TextField</code> in react testing library.
I already set up the data-testid. Then using <code>getByTestId</code> i picked up the input element.</p>
<pre><code>// the component
<TextField
data-testid="input-email"
variant="outlined"
margin="normal"
required
fullWidth
id="email"
label="Email Address"
name="email"
value={email}
onChange={e => setEmail(e.target.value)}
autoComplete="email"
autoFocus
/>
// the test
//...
let userInput = getByTestId('input-email')
fireEvent.change(userInput, { target: { value: 'correct@mail.com' } })
</code></pre>
<p>but this doesn't work as it's returning error: <code>The given element does not have a value setter</code>. Isn't the element uses <code>e.target.value</code> on it's <code>onChange</code> attribute? What am I do wrong?</p>
| <javascript><react-testing-library> | 2019-07-19 10:33:12 | HQ |
57,113,287 | Display a visual at a certain position in the browser with javascript/jquery | is it possible for me to display some sort of visual at a certain position in the browser(firefox)? Let's say I have these offsets {left: 336, top: 378} which I am calculating dynamically, and I want to display a small line of some sort (either an `<hr>` or an image, depending on what is possible). Is this even possible? Any help is greatly appreciated. Ideally I don't want to intefere with the markup at all, I'd rather have some sort of overlay. | <javascript><jquery> | 2019-07-19 13:14:21 | LQ_EDIT |
57,113,826 | How to create an app like youtube for dowload and show video | <p>YouTube after the download file, just show it in the youtube app
. Where the file is stored and how it can be created application that open my videos and files in my application</p>
| <android> | 2019-07-19 13:45:36 | LQ_CLOSE |
57,113,876 | i need assistance in fixing this bug in node | i'm new to node and i keep getting this error everytime i try to access a file from the command line.
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'C:\Users\USER\Desktop\ngs\1-getting-started1-
executing-scripts1-hello-world.js'
at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) | <node.js> | 2019-07-19 13:48:08 | LQ_EDIT |
57,114,055 | Which is best way to clean the innerHTML when working with dinamic content? | What i want i know is what's the best way to clean the innerHTML of an element that is going to be changing over and over, i made a small function that would clean the containers but i do not think that's quite efficient enough, i mean, it does work but only with the containers which it's told to so maybe is better to just make every element to rewrite it's own innerHTML?
(Not sure if duplicate) | <javascript><jquery><html> | 2019-07-19 13:58:20 | LQ_EDIT |
57,114,332 | why does this code give me error, when written between div tag | <pre><code>movies.map((movie)=>(
if(movie.name=='Harry Potter'){
setCount(count=5)
}
<Movie name={movie.name} price={movie.price} key={movie.id}/>
))
</code></pre>
<p>it is written in between div tag in react, what is the error of this code</p>
| <javascript><reactjs><jsx> | 2019-07-19 14:14:03 | LQ_CLOSE |
57,114,903 | Stock price prediction with neuralnet package in R | I have build an neural network with the neuralnet package in R to predict stock prices. My model and code works well, but I am getting an accuracy around 97-99%, which makes me a bit skeptical if an overfitting of the model exists.
This is my Dataset I am using (which is already scaled)
[Dataset Scaled][1]
And this is my original Dataset (not scaled), which I need to calc the accuaracy.
[Dataset not scalled][2]
And this is my code to build and test the model:
normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x)))
}
nn_df <- as.data.frame(lapply(nn_df, normalize))
nn_df_train = as.data.frame(nn_df[1:1965,]) #1965
nn_df_test = as.data.frame(nn_df[1966:2808,]) #843
# NN for Sentiment GI
nn_model <- neuralnet(GSPC.Close ~ GSPC.Open +GSPC.Low + GSPC.High + SentimentGI, data = nn_df_train, hidden=5, linear.output=TRUE, threshold=0.01)
plot(nn_model)
nn_model$result.matrix
nn_pred <- compute(nn_model, nn_df_test)
nn_pred$net.result
results <- data.frame(actual = nn_df_test$GSPC.Close, prediction = nn_pred$net.result)
results
#calc accuracy
predicted = results$prediction * abs(diff(range(nn_org$GSPC.Close))) + min(nn_org$GSPC.Close)
actual = results$actual * abs(diff(range(nn_org$GSPC.Close))) + min(nn_org$GSPC.Close)
comparison = data.frame(predicted,actual)
#deviation=((actual-predicted)/actual)
deviation= abs((actual-predicted)/actual)
comparison=data.frame(predicted,actual,deviation)
accuracy=1-abs(mean(deviation))
accuracy
[1]: https://gofile.io/?c=KUzbLW
[2]: https://gofile.io/?c=zenlWe | <r><machine-learning><neural-network><recurrent-neural-network> | 2019-07-19 14:49:07 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.