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 |
|---|---|---|---|---|---|
54,636,551 | I'm trying to get the length of my non list | I have this data I'm saving the player but I have one problem when I want to get the length of the "levels". I want to know how many levels there are with script so I don't need to keep changing an int variable and I'm also automating the process where the level gets added so I need to know how many levels there are.
PlayerData = new SetupData
{
// Level Data
Levels = new Levels
{
Level1 = new Level
{
Name = "First Level",
Progress = 0,
Completed = false
},
Level2 = new Level
{
Name = "Second Level",
Progress = 0,
Completed = false
},
},
// Character Data
Player = new Player
{
SelectedColor = 0,
Berries = 0
}
};
The problem is that this isn't a list or anything so I can't use `.Length` | <c#> | 2019-02-11 18:05:46 | LQ_EDIT |
54,639,192 | Change the favicon of the Sphinx Read The Docs theme? | <p>I'm already using a custom css to override some of the styles of the theme using </p>
<pre><code>def setup(app):
app.add_css_file('custom.css')
</code></pre>
<p>This works fine. What other app. functions are available?
I can't find any documentation.</p>
<p>I'm looking for the function to override the favicon.</p>
| <python-sphinx><read-the-docs> | 2019-02-11 21:08:56 | HQ |
54,640,453 | What is CompositeDefinitionSource in Android Studio | <p>Recently after upgrading Gradle Android Studio automatically added this to my <code>.idea/gradle.xml</code> :</p>
<pre><code> <compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT" />
</compositeConfiguration>
</code></pre>
<p>What is the purpose of this change?</p>
| <android-studio><gradle> | 2019-02-11 23:03:40 | HQ |
54,641,216 | Can scoped_lock lock a shared_mutex in read mode? | <p>C++17 introduced both <code>std::shared_mutex</code> and <code>std::scoped_lock</code>. My problem is now, that it seems, that <code>scoped_lock</code> will lock a shared mutex always in exclusive (writer) mode, when it is passed as an argument, and not in shared (reader) mode. In my app, I need to update an object <code>dst</code> with data from an object <code>src</code>. I want to lock <code>src</code> shared and <code>dst</code> exclusive. Unfortunately, this has the potential for deadlock, if a call to another update method with <code>src</code> and <code>dst</code> switched occurs at the same time. So I would like to use the fancy deadlock avoidance mechanisms of <code>std::scoped_lock</code>.</p>
<p>I could use <code>scoped_lock</code> to lock both <code>src</code> and <code>dst</code> in exclusive mode, but that unnecessarily strict lock has performance backdraws elsewhere. However, it seems, that it is possible to wrap <code>src</code>'s <code>shared_mutex</code> into a <code>std::shared_lock</code> and use that with the <code>scoped_lock</code>: When the <code>scoped_lock</code> during its locking action calls <code>try_lock()</code> on the <code>shared_lock</code>, the later will actually call <code>try_shared_lock()</code> on <code>src</code>'s <code>shared_mutex</code>, and that's what I need.</p>
<p>So my code looks as simple as this:</p>
<pre><code>struct data {
mutable std::shared_mutex mutex;
// actual data follows
};
void update(const data& src, data& dst)
{
std::shared_lock slock(src.mutex, std::defer_lock);
std::scoped_lock lockall(slock, dst.mutex);
// now can safely update dst with src???
}
</code></pre>
<p>Is it safe to use a (shared) lock guard like this inside another (deadlock avoidance) lock guard?</p>
| <c++><deadlock><scoped-lock> | 2019-02-12 00:42:02 | HQ |
54,641,615 | Create DICOM file using java(without using any 3rd party library) | <p>I'm trying to create a sample that creates a new file in DICOM format without using any 3rd party library.
File is supposed to have following details:
1). Patient details(name, DOB, etc)
2). Image pixel data.</p>
<p>I have read a few articles on DICOM format but I still don't understand a lot of things(basically, from where to start and what standards to maintain while creating DICOM file).</p>
<p>Could any one give me an example or point me to a tutorial that shows how to create simple DICOM file using Java?</p>
| <dicom> | 2019-02-12 01:34:10 | LQ_CLOSE |
54,642,061 | query on Python list comprehension | <p>I tried:</p>
<pre><code>a = [0,1, 2, 3, 4, 5]
</code></pre>
<p>this works fine:</p>
<pre><code>>>> for q in a:
... print(q)
...
0
1
2
3
4
</code></pre>
<p>But, if I try to change the (mutable) list objects like so, it doesn't work:</p>
<pre><code>>>> for q in a:
... q = 0
...
>>> a
[0, 1, 2, 3, 4]
</code></pre>
<p>It seems to me that each time through the loop, q refers to a[n], as n ranges from 0 to 4. So, it would seem, setting q = 0 ought to make the list all value zero.</p>
<p>Any suggestions that are quite Pythonic?</p>
| <python-3.x><list-comprehension> | 2019-02-12 02:39:00 | LQ_CLOSE |
54,644,469 | forms of same id in while loop - how to post formdata of user submitted form to php with jquery ajax | I have a while loop wich creates forms like:
<?php
$i = 1;
while($i<10){
?>
<form id="update">
<tr>
<th scope="row"><?php echo $i;?></th>
<td></td>
<td></td>
<td></td>
<td><input type="text" maxlength="5" class ="input-xs valid" name="plus" value=""></td>
<td><input type="submit" name="submit" class="btn btn-info btn-sm" value="Update"></td>
<td><input class="input-sm slip" name="slip" value="" disabled/></td>
<td></td>
</tr>
</form>
<?php $i++; } ?>
I want to post the formdata of user submitted form with jquery ajax. | <php><jquery><ajax> | 2019-02-12 07:00:56 | LQ_EDIT |
54,644,709 | trying to handle webtable in POM using pagefactory but error is thrown | <p><strong>strong text</strong>I was trying to handle webtable in POM using pagefactory but its throwing error </p>
<p>if i try nto paste xpath directly but otherwise its not working</p>
<pre><code> @FindBy (xpath = "//table[@id='userTable']/tbody/tr[")
WebElement before_xpath;
@FindBy (xpath = "]/td[2]")
WebElement after_xpath;
@FindBy (xpath = "//table[@id='userTable']/tbody/tr")
List<WebElement> namelist;
//Intialising PageObjects
public users_page() {
PageFactory.initElements(driver, this);
}
//Actions
public void userlist(String nm, String un, String pw, String cpw, String hub) {
List<WebElement> row =namelist;
int row_count = row.size();
System.out.println("Total no of rows " +row_count);
for(int i=1;i<row_count;i++) {
WebElement actual_xpath = before_xpath +i +actual_xpath;
System.out.println("Total " +actual_xpath);
}
}}
</code></pre>
<p>It is throwing error on WebElement actual_xpath = before_xpath +i +actual_xpath;.</p>
<p>its showing The operator + is undefined for the argument type(s) WebElement, int</p>
<p>so hw i can handle this </p>
| <selenium><pageobjects><page-factory> | 2019-02-12 07:19:48 | LQ_CLOSE |
54,645,454 | Vuetify text color variants | <p>I want to use one of the color variants for text, how can I do this? I have tried:</p>
<p><code><h2 class="red--text lighten-1--text">My Address</h2></code></p>
<p><code><h2 class="red--text lighten-1">My Address</h2></code></p>
<p><code><h2 class="red-lighten-1--text">My Address</h2></code></p>
<p>and many other variations, but I can only seem to get the text to go the base red color, not the variants listed <a href="https://vuetifyjs.com/en/framework/colors#classes" rel="noreferrer">here</a>. Can anyone help?</p>
| <css><vue.js><vuetify.js> | 2019-02-12 08:07:56 | HQ |
54,649,706 | Angualr Material Custom theming | material angular components css is loading at last and overriding my custom theming css. MY custom css should load at end of all the base material css. | <css><angular><angular-material><styling> | 2019-02-12 12:02:12 | LQ_EDIT |
54,650,721 | Can I run Windows containers on Docker Desktop for Mac? | <p>I want to be able to run Windows Docker Containers on my Mac, it seems this was sort of supported using Docker Toolbox
<a href="https://stackoverflow.com/questions/45380972/how-can-i-run-a-docker-windows-container-on-osx">How can I run a docker windows container on osx?</a></p>
<p>But it seems that this is now deprecated and we should be using Docker Desktop now. </p>
<p>Docker Desktop has a better and New Hypervisor called HyperKit instead of Virtual Box <a href="https://docs.docker.com/docker-for-mac/docker-toolbox/" rel="noreferrer">https://docs.docker.com/docker-for-mac/docker-toolbox/</a></p>
<p>Docker toolbox allowed starting Windows Containers using VirtualBox, so not sure if that mean's that this is still possible? </p>
<p>I have found a reference to putting Docker Desktop into "Windows Container Mode" here <a href="https://www.clearpeople.com/insights/blog/2018/june/sitecore-demo-in-a-docker-container" rel="noreferrer">https://www.clearpeople.com/insights/blog/2018/june/sitecore-demo-in-a-docker-container</a></p>
<p>But I cannot find anywhere to enable this, any help or insight would be very much appreciated.</p>
| <macos><docker><docker-desktop> | 2019-02-12 13:02:03 | HQ |
54,650,812 | WARN [middleware:karma]: Invalid file type, defaulting to js. ts | <p>When I run unit testing via karma, I got those warning:</p>
<pre><code>12 02 2019 14:01:05.740:WARN [middleware:karma]: Invalid file type, defaulting to js. ts
12 02 2019 14:01:05.741:WARN [middleware:karma]: Invalid file type, defaulting to js. ts
</code></pre>
<p>I assumed that the type of the <code>karma.conf.js</code> file caused the issue, so I changed it to <code>karma.conf.ts</code>.</p>
<p>However the issue still happened, so it would be great if someone can tell me how to disable this warning.</p>
<p>Below is my karma.conf.ts file</p>
<pre><code>module.exports = function karmaConfig(config) {
config.set({
singleRun: true,
frameworks: [
'jasmine'
],
files: [
'sdk/**/*.spec.ts'
],
preprocessors: {
'sdk/**/*.spec.ts': ['webpack', 'sourcemap'],
'sdk/**/!(*.spec).ts': ['coverage']
},
browsers: [
'PhantomJS'
],
reporters: [
'progress',
'coverage',
'junit'
],
coverageReporter: {
dir: 'coverage/',
reporters: [
{ type: 'text-summary' },
{ type: 'html' },
{
type: 'lcov',
dir: 'reports',
subdir: 'coverage'
}
]
},
junitReporter: {
outputFile: 'reports/junit/TEST-karma.xml',
useBrowserName: false
},
transports: ['polling'],
webpack: require('./webpack.config'),
webpackMiddleware: {
stats: 'errors-only'
},
logLevel: config.LOG_INFO,
});
};
</code></pre>
<p>I use webpack <code>4.16.5</code> and karma <code>4.0.0</code></p>
| <typescript><webpack><karma-jasmine><karma-runner> | 2019-02-12 13:07:17 | HQ |
54,650,965 | Print every N-th Element from an Array JS | <ol>
<li>Print every N-th Element from an Array
Write a JS function that collects every element of an array, on a given step.
The input comes as array of strings. The last element is N - the step.
The collections are every element on the N-th step starting from the first one. If the step is "3", you need to print the 1-st, the 4-th, the 7-th … and so on, until you reach the end of the array. Then, print elements in a row, separated by single space.</li>
</ol>
<p>Example:
Input Output
['5', '20', '31', '4', '20', '2'] 5 31 20</p>
| <javascript><arrays> | 2019-02-12 13:16:55 | LQ_CLOSE |
54,651,141 | Reset coupon code when user leave chekout page | There is a question. There is a website on WordPress + Woocommerce.
There is a checkout page site.com/checkout.
On this page you can enter a promo code and get a discount on the product. Is it possible to do next? When user leave checkout page and go to page for example site.com/shop, site.com/cart - coupon will be reset?
| <php><wordpress><woocommerce> | 2019-02-12 13:25:49 | LQ_EDIT |
54,652,000 | logical operators in C C+ K&R (Polish Reverse Calculator) |
int getop(char s[])
{
int i, c;
while ((s[0] = c = getch()) == ' ' || c == '\t')
;
s[1] = '\0';
i = 0;
if (isalpha(c)) //math function found.
{
while (isalpha(s[++i] = c = getch()))
;
s[i] = '\0';
if (c != 'EOF')
ungetch(c);
return MATHLIB;
}
if ((c != '.'&&c != '-') &&!isdigit(c)) /*operand found*/
return c;
if (c == '-')
{
if (!isdigit(c = getch()))
{
ungetch(c);
return '-';
}
else
{
ungetch(c);
}
}
if (isdigit(c)) /*number found*/
{
{
while (isdigit(s[++i] = c = getch()))
;
}
if (c == '.')
{
while (isdigit(s[++i] = c = getch()))
;
}
s[i] = '\0';
if (c != EOF)
ungetch(c);
return NUMBER;
}
}
This is part of my Reverse Polish Calculator code, which is in working order.
Problem is, I tried to change the line
if ((c != '.'&&c != '-') &&!isdigit(c)) /*operand found*/
to
if ((c != '.'&&c != '-') && (c == '+' || c == '*' || c == '/' || c == '%'))
And even though I thought it was going to work correctly,
It didn't at all.
The switch function in main() won't catch operators at all.
On top of it, every return value was going to default: printf("error");
I don't understand why it didn't work and it bothers me.
Any advice? | <c> | 2019-02-12 14:12:44 | LQ_EDIT |
54,653,343 | VS Code Refresh Integrated Terminal Environment Variables without Restart/Logout | <p>If you add/change some environment variables (e.g. PATH) on windows, even after restarting 'VS Code' it will not be available in VS Code integrated terminals.<br>
But if you open that terminal from windows (Command Prompt/Powershell/...) it will have those new/updated values!! </p>
<p>What should I do to refresh those environment variables? (without restart or log-out)</p>
| <terminal><visual-studio-code><environment-variables><refresh> | 2019-02-12 15:20:29 | HQ |
54,653,529 | Any idea for Next/Previous with json and swift file | <p>In swift, when I display a quote with id = 103, how can I get the next/previous quotes from my json result?</p>
<p>I implement method for swipe left and right in My ViewController :</p>
<pre><code>@objc func handleGesture(gesture: UISwipeGestureRecognizer) -> Void {
if gesture.direction == UISwipeGestureRecognizer.Direction.right {
print("Swipe Right")
}
else if gesture.direction == UISwipeGestureRecognizer.Direction.left {
print("Swipe Left")
}
}
</code></pre>
<p>and my json result is like: </p>
<pre><code>{
"LOVE_METER": [
{
"id": "105",
"cat_id": "57",
"quote": "My quote 1",
"quotes_likes": "0",
"quotes_unlikes": "0",
"cid": "57",
"category_name": "SMS d'amour"
},
{
"id": "104",
"cat_id": "57",
"quote": "My quote 2",
"quotes_likes": "0",
"quotes_unlikes": "0",
"cid": "57",
"category_name": "SMS d'amour"
},
{
"id": "103",
"cat_id": "57",
"quote": "My quote 3",
"quotes_likes": "0",
"quotes_unlikes": "0",
"cid": "57",
"category_name": "SMS d'amour"
}
]
}
</code></pre>
<p>Any idea ?</p>
| <swift> | 2019-02-12 15:29:28 | LQ_CLOSE |
54,654,371 | Better replacement for Comma (,) in filename | <p>I am looking for a more convenient way to name my python scripts.
At the moment they look similar to this:</p>
<p><code>a1_testing_A,B,C.py</code></p>
<p><code>a2_testing_A,B_and_C,X.py</code></p>
<p>I want to rename them, such that the names look prettier while the replacement should cause no trouble with the interpreter (e.g. "blank space" or "/" is inconvenient).
Is there a convention how to do that?
I would be grateful for suggestions.</p>
| <python><filenames><comma><conventions> | 2019-02-12 16:16:03 | LQ_CLOSE |
54,655,756 | HOW ? javascript 3 dijital take random number? | i want to make random just 3digit number but when i run it , its use alphabet and number i want just get random number
generate: function () {
this.newItem.st = Math.random().toString(36).substring(2, 3).toUpperCase() + Math.random().toString(36).substring(2, 4).toUpperCase() | <javascript><web> | 2019-02-12 17:39:23 | LQ_EDIT |
54,656,014 | --recurse ERROR: Insufficient Permission: Request had insufficient authentication scopes | <p>I'm trying to copy a directory from my vm to my local machine's Desktop with the following command:</p>
<pre><code>gcloud compute scp --recurse instance-1:~/directory ~/Desktop/
</code></pre>
<p>I tried reauthenticating with "gcloud auth login" however it still says </p>
<pre><code>ERROR: (gcloud.compute.scp) Could not fetch resource:
- Insufficient Permission: Request had insufficient authentication scopes.
</code></pre>
| <terminal><google-cloud-platform><gcloud> | 2019-02-12 17:57:09 | HQ |
54,657,142 | How should make an unlimited unique username in SQL? | <p>How do I make an infinite number of lines unique? The system I'm using is currently <code>BIGINT(20)</code> but it also has a maximum limit. What approach should be taken? How do I make an unlimited number of rows unique?</p>
| <mysql><sql> | 2019-02-12 19:11:25 | LQ_CLOSE |
54,657,377 | Trying to read the text of an FTP website into a string in pythong | <p>This is the site I can open in Chrome and see text:</p>
<p><a href="ftp://ftp.cmegroup.com/pub/settle/stlags" rel="nofollow noreferrer">ftp://ftp.cmegroup.com/pub/settle/stlags</a></p>
<p>Any idea how to read this into a string in python?</p>
| <python><string><ftp> | 2019-02-12 19:27:41 | LQ_CLOSE |
54,658,508 | Python Converting Two Lists into Dynamic Nested Dict then to JSON, possible? | I have to go through a list of "colors":
`list1 = ["red","green","other"]`
for each one I need to go through a list of possible matches for each one:
`list2 = ["cherries","rasperries","guava","apple","watermelon","grapes","banana"]`
if the criteria of the item of list2 is good, then I'd need to create a dict to then write the output to JSON file.
`for x in list1:`
`print x`
`for y in list2:`
`if y == criteria:`
`myDict = {'list1-item': 'fruit1':'apple'}`
my expected output would be something like:
`data = {'red': {'fruit1': 'cherries', 'fruit2': 'rasperries', 'fruit3': 'guava'},
'green': {'fruit1': 'apple'},
'other': {'fruit1': 'watermelon', 'fruit2': 'grapes', 'fruit3': 'banana'}}`
#writing to JSON
'with open("data_file.json", "w") as write_file:'
` json.dump(data, write_file)`
not really familiar to build a dynamic dictionary as need, any suggestion is appreciated.
| <python><json><list><dictionary> | 2019-02-12 20:51:05 | LQ_EDIT |
54,658,838 | is there anyway i can use directife (#define) define printf functions? | below is just a simple program i'm working on, I need to take all the printf and define it in the directives.
#include <stdio.h>
#define name(parameter) printf("......")
main(){
...
}
how do I do that?
#include <stdio.h>
#define FICA_PERCENTAGE 0.0765
#define HOURS_WORKED(int hours_worked) printf("\nHours Worked: %d\n", hours_worked)
#define HOURLY_RATE(float hourly_rate) printf("Hourly Rate: $%5.2f\n", hourly_rate)
#define GROSS_PAY(float gross_pay) printf("Gross PAy: $%5.2f\n", gross_pay)
#define FICA_DEDUCTION(float fica_deduction) printf("FICA deduction: $%5.2f\n", fica_deduction)
#define NET_PAY(float net_pay) printf("Net Pay: $%5.2f\n", net_pay)
main(){
int hours_worked;
float hourly_rate, gross_pay, net_pay,fica_deduction;
printf("Simple Payroll Program: \n");
printf("-------------------\n");
printf("Enter the number of hrs workrd: ");
scanf("%d", &hoursWorked);
printf("Enter the hourly rte of pay: ");
scanf("%f", &hourly_rate);
gross_pay = hoursWorked * hourly_rate;
fica_deduction = gross_pay * FICA_PERCENTAGE;
net_pay = gross_pay - fica_deduction;
HOURS_WORKED;
HOURLY_RATE;
GROSS_PAY;
FICA_DEDUCTION;
NET_PAY;
/*printf("\nHours Worked: %d\n", hoursWorked);
printf("Hourly Rate: $%5.2f\n", hourly_rate);
printf("Gross PAy: $%5.2f\n", gross_pay);
printf("FICA deduction: $%5.2f\n", fica_deduction);
printf("Net Pay: $%5.2f\n", net_pay);*/
return 0;
}
#include <stdio.h>
#define FICA_PERCENTAGE 0.0765
main(){
int hours_worked;
float hourly_rate, gross_pay, net_pay,fica_deduction;
printf("Simple Payroll Program: \n");
printf("-------------------\n");
printf("Enter the number of hrs workrd: ");
scanf("%d", &hoursWorked);
printf("Enter the hourly rte of pay: ");
scanf("%f", &hourly_rate);
gross_pay = hoursWorked * hourly_rate;
fica_deduction = gross_pay * FICA_PERCENTAGE;
net_pay = gross_pay - fica_deduction;
printf("\nHours Worked: %d\n", hoursWorked);
printf("Hourly Rate: $%5.2f\n", hourly_rate);
printf("Gross PAy: $%5.2f\n", gross_pay);
printf("FICA deduction: $%5.2f\n", fica_deduction);
printf("Net Pay: $%5.2f\n", net_pay);
return 0;
}
| <c><c-preprocessor> | 2019-02-12 21:20:17 | LQ_EDIT |
54,658,881 | How to use funcion inside other function? | I dont know how to make function 'bot_turn' work after function 'player_turn'
Maybe there are some problems with two 'while' functions
<!DOCTYPE html>
<html>
<head>
<meta charset ="utf-8">
<title>Tic Tac Toe</title>
</head>
<body>
<script type="text/javascript">
var asasa=0;
var lal=-1;
var end_game=0;
var asass=0
</script>
<table border='1px' width='500px' height='500px' align="center">
<tr>
<td id='tables1' class="one" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=1; player_turn(); "></td>
<td id='tables2' class="two" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=2; player_turn();"></td>
<td id='tables3' class="three" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=3; player_turn();"></td>
</tr>
<tr style='border-color: red'>
<td id='tables4' class="four" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=4; player_turn(); " ></td>
<td id='tables5' class="five" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=5; player_turn();"></td>
<td id='tables6' class="six" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=6; player_turn();"></td>
</tr>
<tr style='border-color: red'>
<td id='tables7' class="seven" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=7; player_turn();"></td>
<td id='tables8' class="eight" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=8; player_turn();"></td>
<td id='tables9' class="nine" style="font-size: 50px; text-align:center;" onclick="this.style.backgroundColor = '#045d99';asasa=9; player_turn();"></td>
</tr>
<script type="text/javascript">
asasa=0;
function player_turn()
{
if (document.getElementById('tables1').className == 'one' & asasa==1)
{
document.getElementById('tables1').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables2').className == 'two' && asasa==2)
{
document.getElementById('tables2').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables3').className == 'three' && asasa==3)
{
document.getElementById('tables3').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables4').className == 'four' && asasa==4)
{
document.getElementById('tables4').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables5').className == 'five' && asasa==5)
{
document.getElementById('tables5').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables6').className == 'six' && asasa==6)
{
document.getElementById('tables6').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables7').className == 'seven' && asasa==7)
{
document.getElementById('tables7').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables8').className == 'eight' && asasa==8)
{
document.getElementById('tables8').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
else if (document.getElementById('tables9').className == 'nine' && asasa==9)
{
document.getElementById('tables9').className = 'none'
alert("Bot turn")
end_game=end_game+1;
bot_turn()
}
console.log(asasa)
}
var randomik=0;
function bot_turn()
{
while (asass=0)
{
lal=0
while (lal=0)
{
randomik=Math.floor((Math.random() * 9) + 1);
console.log(randomik)
if (randomik==1)
{
if(document.getElementById('tables1').className == 'one')
{
document.getElementById('tables1').className = 'none'
document.getElementById('tables1').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1
end_game+=1
}
}
else if (randomik==2)
{
if(document.getElementById('tables2').className == 'two')
{
document.getElementById('tables2').className = 'none'
document.getElementById('tables2').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==3)
{
if(document.getElementById('tables3').className == 'three')
{
document.getElementById('tables3').className = 'none'
document.getElementById('tables3').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==4)
{
if(document.getElementById('tables4').className == 'four')
{
document.getElementById('tables4').className = 'none'
document.getElementById('tables4').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==5)
{
if(document.getElementById('tables5').className == 'five')
{
document.getElementById('tables5').className = 'none'
document.getElementById('tables5').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==6)
{
if(document.getElementById('tables6').className == 'six')
{
document.getElementById('tables6').className = 'none'
document.getElementById('tables6').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==7)
{
if(document.getElementById('tables7').className == 'seven')
{
document.getElementById('tables7').className = 'none'
document.getElementById('tables7').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==8)
{
if(document.getElementById('tables8').className == 'eight')
{
document.getElementById('tables8').className = 'none'
document.getElementById('tables8').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (randomik==9)
{
if(document.getElementById('tables9').className == 'nine')
{
document.getElementById('tables9').className = 'none'
document.getElementById('tables9').style.backgroundColor = '#FF2400'
alert("Player turn")
lal=1;
end_game+=1
}
}
else if (end_game==9)
{
asass=1
alert('It works!')
}
}
}
}
</script>
</body>
</html>
When i click bot must choose another cell where i hadnt click and paint it in red. When all cells are painted alert "It works!" should appear and random numbers in consol must stop generating.
| <javascript><html> | 2019-02-12 21:24:34 | LQ_EDIT |
54,659,686 | Remove element from list using linq | <p>I have and object of type ct_CompleteOrder and have following classes:</p>
<p><strong>ct_CompleteOrder class</strong></p>
<pre><code>public partial class ct_CompleteOrder {
private ct_CompleteOrderPayments paymentsField;
}
</code></pre>
<p><strong>ct_CompleteOrderPayments class</strong></p>
<pre><code>public partial class ct_CompleteOrderPayments {
private ct_Payment[] paymentField;
public ct_Payment[] Payment {
get {
return this.paymentField;
}
set {
this.paymentField = value;
}
}
}
</code></pre>
<p><strong>ct_Payment class</strong></p>
<pre><code>public partial class ct_Payment {
public string type{get; set;}
}
</code></pre>
<p>I want to remove elements of the <code>ct_Payment</code> array on the basis of type value. I tried to convert it into list first to apply RemoveAll, but its not working. what am I doing wrong?</p>
<pre><code>completeOrder.Payments.Payment.ToList().RemoveAll(x => x.type == "AUTO");
</code></pre>
| <c#><arrays><linq><removeall> | 2019-02-12 22:34:10 | LQ_CLOSE |
54,660,578 | How to remove duplicates automatically | I have two files. I copied File A Column A data into File B Column A but I want to remove Duplicate Values from Column A when I paste into File B (without using VBA would be much better). Thank you
| <excel><duplicates><copying> | 2019-02-13 00:06:13 | LQ_EDIT |
54,660,606 | React w/hooks: prevent re-rendering component with a function as prop | <p>Let's say I have:</p>
<pre><code>const AddItemButton = React.memo(({ onClick }) => {
// Goal is to make sure this gets printed only once
console.error('Button Rendered!');
return <button onClick={onClick}>Add Item</button>;
});
const App = () => {
const [items, setItems] = useState([]);
const addItem = () => {
setItems(items.concat(Math.random()));
}
return (
<div>
<AddItemButton onClick={addItem} />
<ul>
{items.map(item => <li key={item}>{item}</li>)}
</ul>
</div>
);
};
</code></pre>
<p>Any time I add an item, the <code><AddItemButton /></code> gets re-rendered because addItem is a new instance. I tried memoizing addItem:</p>
<pre><code> const addItemMemoized = React.memo(() => addItem, [setItems])
</code></pre>
<p>But this is reusing the setItems from the first render, while </p>
<pre><code> const addItemMemoized = React.memo(() => addItem, [items])
</code></pre>
<p>Doesn't memoize since <code>items</code> reference changes.</p>
<p>I can'd do</p>
<pre><code> const addItem = () => {
items.push(Math.random());
setItems(items);
}
</code></pre>
<p>Since that doesn't change the reference of <code>items</code> and nothing gets updated.</p>
<p>One weird way to do it is:</p>
<pre><code> const [, frobState] = useState();
const addItemMemoized = useMemo(() => () => {
items.push(Math.random());
frobState(Symbol())
}, [items]);
</code></pre>
<p>But I'm wondering if there's a better way that doesn't require extra state references. </p>
| <javascript><reactjs><react-hooks> | 2019-02-13 00:09:43 | HQ |
54,662,169 | creating train/test csv files out of a original csv file for 10 fold cross validation experiment | I have a csv file (main.csv) that has a unique column ID that also pertains to my image names (minus their .jpg extension).
I want to do 10 fold cross-validation and create train and test CSV such that test csv for each fold would only contain 10 percent of the original CSV.
Is there a straighforward path (already done) to this?
Basically, I want my eventual train and test csv files to have the same exact column names but designed such that I could perform 10 fold cross validation with them (aka randomly sampled/shuffled and 10% selected).
I don't mind pandas in Python or R. | <python><r><csv><machine-learning><cross-validation> | 2019-02-13 03:43:45 | LQ_EDIT |
54,663,957 | how to lounch background running android app from push notification? | I'm developing push notification base android app. I need to open (lounch) android app when the application received a push notification. please explain.
i tried following code
<activity
android:name="com.yamuko.driver.PickupRequestCustomDialogActivity"
android:launchMode="singleTask"
android:theme="@style/NoTitleDialog" />
in onMessageReceived() used below code.
Intent home = new Intent();
Bundle extras = new Bundle();
home.putExtras(extras);
home.setAction(Intent.ACTION_MAIN);
home.addCategory(Intent.CATEGORY_LAUNCHER);
home.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_SINGLE_TOP);
ComponentName cn = new ComponentName(getApplicationContext(), PickupRequestCustomDialogActivity.class);
home.setComponent(cn);
getApplication().startActivity(home);
| <android><android-activity><push-notification> | 2019-02-13 06:32:08 | LQ_EDIT |
54,664,505 | Fetch multiple Images from URL | I have a one randomly selected link which have a multiple images so how can i fetch those images in my Android Studio I don't have any URL already, and display those images in RecyclerView.
| <android><android-recyclerview><fetch><android-image> | 2019-02-13 07:13:40 | LQ_EDIT |
54,665,262 | How to fix NumberFormatException for input string "0.40" | <p>i am trying to convert string value to long for further processing but this error occurs everytime </p>
<pre><code>13-Feb-2019 13:15:35.593 SEVERE [http-nio-8084-exec-570] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service()
java.lang.NumberFormatException: For input string: "0.40"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
</code></pre>
| <java><numberformatexception> | 2019-02-13 08:07:13 | LQ_CLOSE |
54,668,000 | type hint for an instance of a non specific dataclass | <p>I have a function that accepts an instance of any <code>dataclass</code>.
what would be an appropriate type hint for it ?</p>
<p>haven't found something official in the python documentation </p>
<hr>
<p>this is what I have been doing, but i don't think it's correct</p>
<pre><code>from typing import Any, NewType
DataClass = NewType('DataClass', Any)
def foo(obj: DataClass):
...
</code></pre>
<p>another idea is to use a <a href="https://www.python.org/dev/peps/pep-0544/#defining-a-protocol" rel="noreferrer"><code>Protocol</code></a> with these class attributes <code>__dataclass_fields__</code>, <code>__dataclass_params__</code>.</p>
| <python><protocols><python-3.7><python-dataclasses> | 2019-02-13 10:32:01 | HQ |
54,668,439 | Order of Programming/Engineering | I am currently working on a new software and I am not sure how to go on.
I already started coding before having a good plan.
My opinion was to start with:
1. Create User Stories
2. Create BMSC & Hsmc
3. Code the required features
4. Test
5. Refactor & solve bugs
Now I want to know where do i put the UML Diagram, before coding or after coding?
| <uml><software-design><requirements> | 2019-02-13 10:51:47 | LQ_EDIT |
54,669,378 | Blueprism- Extract data from a web page into a collection; | i am new to blue prism. I have a scenario where I am giving input (passengers details for travelling) to a travel portal and based on the input its generating a booking reference number,total cost etc. Now I want to read all the outputs into a collection but the problem is data is not tabular (cant use Get Table in read component). Its just the details of travel which are populating into textboxes.Please find attached the screen shot to have more clarity on this.
[enter image description here][1]
How to achieve this? Any leads will be appreciated.
Thanks-
[1]: https://i.stack.imgur.com/m7RpB.jpg | <collections><blueprism><rpa> | 2019-02-13 11:43:55 | LQ_EDIT |
54,669,461 | save items of list with thier index in text file using c# | I have created a list in c#, now I need to save the list in text file with the index for each item in the list? please explain with a simple example. | <c#><c#-2.0> | 2019-02-13 11:47:45 | LQ_EDIT |
54,669,548 | How to select the latest price for product? | <p>Here is my table:</p>
<pre><code>+----+------------+-----------+---------------+
| id | product_id | price | date |
+----+------------+-----------+---------------+
| 1 | 4 | 2000 | 2019-02-10 |
| 2 | 5 | 1600 | 2019-02-11 |
| 3 | 4 | 850 | 2019-02-11 |
| 4 | 5 | 1500 | 2019-02-13 |
+----+------------+-----------+---------------+
</code></pre>
<p>I need to get a list of unique product ids that are the latest (newest, in other word, bigger <code>date</code>) ones. So this is the expected result:</p>
<pre><code>+------------+-----------+---------------+
| product_id | price | date |
+------------+-----------+---------------+
| 4 | 850 | 2019-02-11 |
| 5 | 1500 | 2019-02-13 |
+------------+-----------+---------------+
</code></pre>
<p>Any idea how can I achieve that?</p>
<hr>
<p>Here is my query:</p>
<pre><code>SELECT id, product_id, price, MAX(date)
FROM tbl
GROUP BY product_id
-- ot selects the max `date` with random price like this:
+------------+-----------+---------------+
| product_id | price | date |
+------------+-----------+---------------+
| 4 | 2000 | 2019-02-11 |
| 5 | 1600 | 2019-02-13 |
+------------+-----------+---------------+
-- See? Prices are wrong
</code></pre>
| <mysql><sql> | 2019-02-13 11:51:43 | LQ_CLOSE |
54,669,733 | ASP.NET MVC Call action when a specific change is made in edit | I created a Crud object to track employee holidays, in my HTTP Post EDIT method I'd like to use an email action (which already works) for when a manager edits a request to change the boolean status from `pending` to `approved`.
Here's what I attempted but my c# is not up to scratch just yet.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "RequestID,EmployeeID,StartDate,FinishDate,HoursTaken,Comments,YearCreated,MonthCreated,DayCreated,YearOfHoliday,Approved,SubmittedBy,ApprovedBy")] HolidayRequestForm holidayRequestForm)
{
if (ModelState.IsValid)
{
if (Session["Name"] == null)
{
TempData["msg"] = "Your Session Expired - Please Login";
return RedirectToAction("Login", "Account");
}
string name = Session["Name"].ToString();
var approvedby = db.Employees.Where(s => s.Email.Equals(name)).Select(s => s.Email).FirstOrDefault();
holidayRequestForm.ApprovedBy = approvedby;
db.Entry(holidayRequestForm).State = EntityState.Modified;
db.SaveChanges();
if {
db.HolidayRequestForms.Select(h => h.Approved) == true;
SendMailToManager();
}
return RedirectToAction("Index");
}
ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "FullName", holidayRequestForm.EmployeeID);
return View(holidayRequestForm);
}
How do I get it to send the email (call the SendMailToManager() action) when a manager edit the request's status to true? | <c#><asp.net-mvc> | 2019-02-13 12:01:52 | LQ_EDIT |
54,670,251 | (Excel VBA) - Copy webpage content to a string | I need to access webpages and copy their content (everything) into a string which I will then extract some figures from.
The webpage address changes each time, as I am basically accessing an online simulation tool and I have to specify the sim parameters each time. And the outpit is always a string of about 320 characters. the web page consists ONLY in that text.
Example of web addess / query:
**http://re.jrc.ec.europa.eu/pvgis5/PVcalc.php?lat=45&lon=8&peakpower=1&loss=14&optimalangles=1&outputformat=basic**
Example of webpage content (string to retrieve):
**37 0 1 54.9 72.1 7.21 2 73.1 96.0 12.0 3 114 149 15.5 4 121 160 17.9 5 140 185 11.3 6 142 188 9.31 7 161 212 10.2 8 149 197 10.0 9 123 162 10.3 10 83.0 109 15.5 11 55.8 73.3 13.5 12 55.8 73.2 9.47 Year 1270 1680 58.8 AOI loss: 2.7% Spectral effects: - Temperature and low irradiance loss: 8.0% Combined losses: 24.1%**
***Question to you*** - Is there a method to copy that string without having to open aand close a browser each time? I have to repeat that operation (determine the query parameters, retrieve the relative string, extract the values that I need from the string) a total of **7200 times** when I run my analysis and I'd like it to be as smooth and as fast as possible.
Note: I don't necessary need to save the string text on a document but it would be OK to do so if needed, and then open the file and retrieve my string. But that sounds so inefficient that I#m sure there must be a better way of doing it! | <excel><vba><web-scraping><printing-web-page> | 2019-02-13 12:30:36 | LQ_EDIT |
54,670,622 | Add Elements to an ArrayList within a HashMap | <p>How to add an Element to an ArrayList within a HashMap?</p>
<p>This is a question, that I have asked myself many times and forgot it after solving it. I guess many have the same one so here is the simple answer to it.</p>
<pre><code>// Example
HashMap<String, ArrayList<String>> someElements = new HashMap<String, ArrayList<String>>();
</code></pre>
| <java><hashmap> | 2019-02-13 12:49:29 | LQ_CLOSE |
54,671,556 | how to implement fasthttp framework in golang | I'm new in golang and I want to start learning about the fasthttps server from this link https://github.com/valyala/fasthttp but I dont know that how will I implement a small piece of code in this framework. Can anybody tell me that how i will implement a small piece of code in this? example please.
Code I tried
package main
import "fmt"
type MyHandler struct {
foobar string
}
func main() {
// pass bound struct method to fasthttp
myHandler := &MyHandler{
foobar: "foobar",
}
fasthttp.ListenAndServe(":8080", myHandler.HandleFastHTTP)
// pass plain function to fasthttp
fasthttp.ListenAndServe(":8081", fastHTTPHandler)
}
// request handler in net/http style, i.e. method bound to MyHandler struct.
func (h *MyHandler) HandleFastHTTP(ctx *fasthttp.RequestCtx) {
// notice that we may access MyHandler properties here - see h.foobar.
fmt.Fprintf(ctx, "Hello, world! Requested path is %q. Foobar is %q",
ctx.Path(), h.foobar)
}
// request handler in fasthttp style, i.e. just plain function.
func fastHTTPHandler(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "Hi there! RequestURI is %q", ctx.RequestURI())
}
Can you please tell me that how I will implement this code. | <go> | 2019-02-13 13:37:48 | LQ_EDIT |
54,674,553 | Crashlytics issue when updated from com.crashlytics.sdk.android:crashlytics:2.9.8 to 2.9.9 | <p>During update of my android app, i updated all dependencies. When i tested the release build, i receive the following error:</p>
<p>E/CrashlyticsCore: <b>The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.</b></p>
<p>Crashlytics is working fine for my previous release that is currently available on the play store.</p>
<p>Any help will be appreciated.</p>
| <android><firebase><crashlytics> | 2019-02-13 16:06:23 | HQ |
54,675,587 | @babel/typescript doesn't throw errors while webpack build | <p>I am trying to transpile TypeScript with Babel 7's @babel/typescript preset. It works fine but for some reason, there aren't any error messages from TS in the build console.</p>
<p>I have the next config:</p>
<p>webpack.config.js</p>
<pre><code>const outputPath = require('path').resolve(__dirname, './production');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: [
'./src/index.tsx'
],
output: {
path: outputPath,
filename: '[name].[chunkhash].js',
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'source-map-loader',
enforce: "pre"
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: 'file-loader'
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({template: './src/index.html'})
],
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
devServer: {
contentBase: outputPath
}
};
</code></pre>
<p>.babelrc</p>
<pre><code>{
"presets": [
"@babel/preset-env",
"@babel/typescript",
"@babel/preset-react"
],
"plugins": [
"react-hot-loader/babel",
"@babel/plugin-transform-runtime",
]
}
</code></pre>
<p>tsconfig.json</p>
<pre><code>{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"outDir": "./production/",
"sourceMap": true,
"noImplicitAny": true,
"lib": ["esnext", "dom"]
},
"include": [
"./src/**/*"
]
}
</code></pre>
<p>And output is:</p>
<pre><code>ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/me/projects/react/production
ℹ 「wdm」: Hash: 1186927fe343142edc70
Version: webpack 4.29.3
Time: 1120ms
Built at: 2019-02-13 19:41:10
Asset Size Chunks Chunk Names
index.html 433 bytes [emitted]
main.3bb79f4b9e2925734f50.js 1.64 MiB main [emitted] main
Entrypoint main = main.3bb79f4b9e2925734f50.js
[0] multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.tsx 40 bytes {main} [built]
...
ℹ 「wdm」: Compiled successfully.
</code></pre>
<p>It says that there aren't any errors. But there are TS errors in the code.</p>
<p>If I change babel-loader to ts-loader, I will have:</p>
<pre><code>ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/me/projects/react/production
✖ 「wdm」: Hash: 90ec6ae13f842d672d2d
Version: webpack 4.29.3
Time: 1941ms
Built at: 2019-02-13 19:42:35
Asset Size Chunks Chunk Names
index.html 433 bytes [emitted]
main.90f2073400581ecd9e5b.js 1.59 MiB main [emitted] main
Entrypoint main = main.90f2073400581ecd9e5b.js
...
ERROR in /Users/me/projects/react/src/actions/index.ts
./src/actions/index.ts
[tsl] ERROR in /Users/me/projects/react/src/actions/index.ts(3,28)
TS7006: Parameter 'type' implicitly has an 'any' type.
ERROR in /Users/me/projects/react/src/actions/index.ts
./src/actions/index.ts
[tsl] ERROR in /Users/me/projects/react/src/actions/index.ts(3,34)
TS7019: Rest parameter 'argNames' implicitly has an 'any[]' type.
...
ℹ 「wdm」: Failed to compile.
</code></pre>
<p>So, ts-loader shows the errors.</p>
<p>How can I enable errors throwing for @babel/typescript?</p>
| <javascript><typescript><webpack><compiler-errors><babel> | 2019-02-13 16:57:30 | HQ |
54,675,752 | How can I create an option element using javascript and set it's value | <pre><code>const currencies = [
{
id: 'USD', name: 'US Dollars'
}, {
id: 'UGX', name: 'Ugandan Shillings'
}, {
id: 'KES', name: 'Kenyan Shillings'
}, {
id: 'GHS', name: 'Ghanian Cedi'
}, {
id: 'ZAR', name: 'South African Rand'
}
];
</code></pre>
<p>I have an issue with my code. I want to create an option element using javascript. I have done something like this below. What is my issue?</p>
<p>I want each item in the currencies arrays to populate into populateCurrencies function. And it should also create an option element. And also set it's value to the item id.</p>
<pre><code>const populateCurrencies = () => {
var ans = document.getElementById('USD').value;
}
</code></pre>
| <javascript><arrays><function> | 2019-02-13 17:04:28 | LQ_CLOSE |
54,676,420 | how to make two level select option? | i need make two level select option if selected **bmw** how to show **bmwsubcategory** ?
if select **audi** how to remove **bmwsubcategory** from html and show **audisubcategory** ?
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<select id="category">
<option class="bmwsubcategory" value="bmw">bmw</option>
<option class="audisubcategory" value="audi">audi</option>
<option class="fordsubcategory" value="ford">ford</option>
<option class="fiatsubcategory" value="fiat">fiat</option>
</select>
<select class="bmwsubcategory" name="bmw">
<option value="bmw 1">bmw 1</option>
<option value="bmw 2">bmw 2</option>
<option value="bmw 3">bmw 3</option>
<option value="bmw 4">bmw 4</option>
</select>
<select class="audisubcategory" name="audi">
<option value="audi 1">audi 1</option>
<option value="audi 2">audi 2</option>
<option value="audi 3">audi 3</option>
<option value="audi 4">audi 4</option>
</select>
<select class="fordsubcategory" name="ford">
<option value="ford 1">ford 1</option>
<option value="ford 2">ford 2</option>
<option value="ford 3">ford 3</option>
<option value="ford 4">ford 4</option>
</select>
<select class="fiatsubcategory" name="fiat">
<option value="fiat 1">fiat 1</option>
<option value="fiat 2">fiat 2</option>
<option value="fiat 3">fiat 3</option>
<option value="fiat 4">fiat 4</option>
</select>
<!-- end snippet -->
| <javascript><html> | 2019-02-13 17:47:02 | LQ_EDIT |
54,678,337 | How does one ignore extra arguments passed to a data class? | <p>I'd like to create a <code>config</code> <code>dataclass</code> in order to simplify whitelisting of and access to specific environment variables (typing <code>os.environ['VAR_NAME']</code> is tedious relative to <code>config.VAR_NAME</code>). I therefore need to ignore unused environment variables in my <code>dataclass</code>'s <code>__init__</code> function, but I don't know how to extract the default <code>__init__</code> in order to wrap it with, e.g., a function that also includes <code>*_</code> as one of the arguments.</p>
<pre><code>import os
from dataclasses import dataclass
@dataclass
class Config:
VAR_NAME_1: str
VAR_NAME_2: str
config = Config(**os.environ)
</code></pre>
<p>Running this gives me <code>TypeError: __init__() got an unexpected keyword argument 'SOME_DEFAULT_ENV_VAR'</code>.</p>
| <python><python-3.x><python-dataclasses> | 2019-02-13 19:51:31 | HQ |
54,680,937 | What is the difference between Extends and New in Java? | <p>Say you have a class called superclass.</p>
<p>I can say </p>
<pre><code>Public class MyClass extends superclass
</code></pre>
<p>and i can do</p>
<pre><code>superclass sc = new superclass();
</code></pre>
<p>both methods let me use methods/variables in that class. can someone make the picture a little bit more clear?</p>
| <java> | 2019-02-13 23:19:27 | LQ_CLOSE |
54,681,238 | error: expected ‘while’ before ‘return’, Have equal amounts of closing and opening {}s and cant find the proble | <p>error: expected ‘while’ before ‘return’
return 0</p>
<p>I can't figure why it asks for a "while" before return</p>
<p>Tried nesting the code differently and can't find it work.</p>
<pre><code>int random;
int userinput;
random = rand() % 1000 + 1;
do
{
printf("Can you guess the random number? \n");
scanf("%d", &userinput);
if (random >= userinput)
{
printf("The number you entered is too high! Try again! \n");
}
else if (random <= userinput)
{
printf("The number you entered is too low! Try again! \n");
}
while (random!=userinput)
{
printf("You guessed it! Correct! The number is: %d \n", random);
}
}
return 0;
</code></pre>
| <c> | 2019-02-13 23:52:55 | LQ_CLOSE |
54,681,240 | Deprecated - Methods with the same name as their class will not be constructors in a future version of PHP | <p>In php v 5 these php codes have no problem : </p>
<pre><code><?php
$ERRORS=array("INVALID_ERROR"=>"Invalid/Unknown error",
"ACCESS_DENIED"=>"Access Denied",
"INVALID_INPUT"=>"Invalid Input",
"INCOMPLETE_REQUEST"=>"INCOMPLETE REQUEST"
);
class Error
{ /* This Class is for errors reported from core or interface.
Normally errors should consist of lines of ( keys and messages), formated in a string like "key|msg"
key shows what is error about and msg is the error message for this situation
*/
function Error($err_str)
{
$this->raw_err_str=$err_str;
$this->err_msgs=array();
$this->err_keys=array();
$this->__splitErrorLines();
}
function __splitErrorLines()
{
$err_lines=split("\n",$this->raw_err_str);
foreach($err_lines as $line)
$this->__splitError($line);
}
function __splitError($err_str)
{
$err_sp=split("\|",$err_str,2);
if(sizeof($err_sp)==2)
{
$this->err_msgs[]=$err_sp[1];
$this->err_keys[]=$err_sp[0];
}
else
{
$this->err_msgs[]=$err_str;
$this->err_keys[]="";
}
}
function getErrorKeys()
{/*
Return an array of error keys
*/
return $this->err_keys;
}
function getErrorMsgs()
{/*
Return array of error msgs
useful for set_page_error method of smarty
*/
return $this->err_msgs;
}
function getErrorMsg()
{/*
Return an string of all error messages concatanated
*/
$msgs="";
foreach ($this->err_msgs as $msg)
$msgs.=$msg;
return $msgs;
}
}
function error($error_key)
{/* return complete error message of $error_key */
global $ERRORS;
if (isset($ERRORS[$error_key]))
return new Error($error_key."|".$ERRORS[$error_key]);
else
return new Error($ERRORS["INVALID_ERROR"]);
}
?>
</code></pre>
<p>But after installing php v7.3.2 i got this error : </p>
<blockquote>
<p>Deprecated: Methods with the same name as their class will not be
constructors in a future version of PHP; Error has a deprecated
constructor in /usr/local/IBSng/interface/IBSng/inc/errors.php on line
12</p>
<p>Fatal error: Cannot declare class Error, because the name is already
in use in /usr/local/IBSng/interface/IBSng/inc/errors.php on line 12</p>
</blockquote>
<p>What is that Fatal error mean & how can i fix it?</p>
| <php><class><centos7.6> | 2019-02-13 23:53:07 | LQ_CLOSE |
54,681,833 | ERB Comparison signs ( less than, less than equal to, etc) | I'm wondering how to test if a variable is between two values such as 1 and 10. For example I have the following:
<% bullet_hit = rand(1..10) %>
<% if 1 < bullet_hit < 10 %>
<%= bullet_hit %>
<% end %>
It seems pretty straight, but I think I have the wrong syntax. Any help would be appreciated. Thank you. | <ruby> | 2019-02-14 01:14:09 | LQ_EDIT |
54,682,127 | error of compilation when I open j5 on my computer | when I want to open the p5 file on my computer, it tell me an error. Can you help me to solve it. Thank you
the file that I think there is an error (1)
the error (1)
[1]: https://i.stack.imgur.com/6PsP1.png
[2]: https://i.stack.imgur.com/nJx3u.png | <javascript><p5.js> | 2019-02-14 01:54:13 | LQ_EDIT |
54,683,100 | Now i got the problem "Internet Server Error 500" | There is only 1 page called "index.php" <br>
and it only echo "testing"
<br>
Also there is no error log <br>
Any idea what cause the server 500?
| <php> | 2019-02-14 04:10:09 | LQ_EDIT |
54,683,922 | I want to sort the correlation between the residual of a time series regression and several prospective X independent variables | And, I want the correlations to be ranked by absolute correlation. And, I also want the output show the name of each X variable with its absolute correlation and its actual correlation (showing the sign).
Using the following codes I was able to calculate the correlation between the residuals (object res1) and the X variables (located within the data2 dataframe).
cor(data2, res1, method = c("pearson"))
The above code generated the output below that shows vertically in the console.
[,1]
x1 0.45683210
x2 0.62858863
x3 0.08457911
x4 0.41022052
Next, using the following code I was able to rank those correlations by their absolute value using the sort() function.
abs(cor(data2, res1, method = c("pearson")))
abs1<-abs(cor(data2, res1, method = c("pearson")))
sort(abs1, decreasing = TRUE)
And, I got the following output.
[1] 0.62858863 0.45683210 0.41022052 0.08457911
I want to generate an output that looks like a table or a dataframe. In the first column you would have the labels of the X variable, in the second column you would have their absolute correlation, and in the third column you would have the actual correlation with their sign. And, this vertical tabular list would be ranked in descending order. I think I have all the info I need. I just need the codes to generate the output as specified.
| <r><sorting><correlation><ranking> | 2019-02-14 05:45:54 | LQ_EDIT |
54,684,891 | Client wants following css button | <p>I need help in creating following css style for button, Don't know how to add the different backgrounds with spacing between them.</p>
<p><a href="http://i64.tinypic.com/df9936.jpg" rel="nofollow noreferrer">http://i64.tinypic.com/df9936.jpg</a></p>
| <css><button> | 2019-02-14 07:08:20 | LQ_CLOSE |
54,685,140 | Facebook Audience Network Ads integration Issue | <p>E/FBAudienceNetwork: You are using custom Application class and don't call AudienceNetworkAds.isInAdsProcess(). Multi-process support will be disabled. Please call AudienceNetworkAds.isInAdsProcess() if you want to support multi-process mode.</p>
<pre><code>implementation 'com.facebook.android:audience-network-sdk:5.1.0'
implementation 'com.mopub.mediation:facebookaudiencenetwork:5.1.0.2'
</code></pre>
<p>am using FAN along with Mopub.</p>
<p>How to fix the above issue? Thanks in advance.</p>
| <android><mopub><facebook-audience-network> | 2019-02-14 07:25:44 | HQ |
54,685,237 | conversion from lptstr to wstring | I came up with the same issue,in which I got a LPTSTR portname param as input from a function.I have to convert this into wstring,so that I can fetch the Port paramaters.
below is the code snippet in which am trying to copy lptstr to wstring.
void C_PORT_MONITOR::SetPrinterComPortParam(LPTSTR PortName)
{
#ifdef _UNICODE
std::wstring l_ComPortName;
#else
std::string l_ComPortName;
#endif
DWORD dwSize,le = 0;
dwSize = sizeof(COMMCONFIG);
LPCOMMCONFIG lpCC = (LPCOMMCONFIG) new BYTE[dwSize];
l_ComPortName = PortName;//mPortName;
if(l_ComPortName.length() <= 0 )
return;
bool SetFlag = false;
//Get COMM port params called to get size of config. block
int length = l_ComPortName.length();
int iPos = l_ComPortName.find_first_of(':');
int iChc = length- iPos; //remove the charactrers after :
l_ComPortName = l_ComPortName.substr(0, (length- iChc)); //remove the characters from colon //COM1
//Get COMM port params with defined size
BOOL ret = GetDefaultCommConfig(l_ComPortName.c_str(), lpCC, &dwSize);
_RPT1(_CRT_WARN, "C_PORT_MONITOR::SetPrinterComPortParam length=%x,iPos=%x,iChc=%x,l_ComPortName=%s",length, iPos, iChc, l_ComPortName);
if(!ret)
{
le = GetLastError();
_RPT1(_CRT_WARN ,"C_PORT_MONITOR::SetPrinterComPortParam LastError=%x",le);
}
I need to assign this portname to l_comportname. and I need to create a substring from this l_comportname as COM1 and I have to use this substring in getdafaultcommconfig()
| <c++><string><windows> | 2019-02-14 07:32:08 | LQ_EDIT |
54,685,423 | Android - Use cases of Context in Android Development (Fragment, etc) | In the time I have spent learning Android Development, I have realized that the use of "Context" is a common theme in nearly everything we do.<br>
I recently read the following Article, and all of it's references: [What is it about Context](http://lomza.totem-soft.com/what-is-it-about-context-in-android/)?<br>
<br>
In addition to this being an informative resource regarding Context, I had an additional question, based on something it states..<br>
It says (and I quote): `(6) When in fragment, assign a context to the one from onAttach(Context context) method`<br>
<br>
**QUESTION (1) :** I am currently trying to adjust some Preferences using the `Preferencec-API` from within a `PreferenceFragment`.. In terms of `Context`, how should I go about this?<br>
**NOTE :** I am doing this from within `onPreferenceChangedListener`.<br>
<br>
**QUESTION (2) :** Is there a simple answer, or must I follow the instructions from the Quote I provided from the Link? And if so, how would I go about doing this, as my PreferenceFragment does not have any `onAttach` Method?<br>
<br>
**Many thanks in advance!**
| <android><android-fragments><android-activity><android-fragmentactivity><android-context> | 2019-02-14 07:46:11 | LQ_EDIT |
54,687,250 | How to save java script data from a loop to an array? | <p>How to save javascript data from a loop to an array?</p>
<pre><code>for (i = 0; i < jsonData.Data.Positions.length; i++) {
var h = jsonData.Data.Positions[i].Oid;
}
</code></pre>
| <javascript> | 2019-02-14 09:38:37 | LQ_CLOSE |
54,688,640 | HTML Javascript message input not working | <pre><code>var age1 = 30;
if(age1 >= 13 && age1 <= 19){
message = "You are a teenager";
}else{
message = "You are not a teenager";
}
</code></pre>
<p>This code is pretty self explanatory, but when I run it in html It does not work, I don't know why. It does not give me any of the messages when run in HTML.</p>
| <javascript><html> | 2019-02-14 10:50:31 | LQ_CLOSE |
54,689,361 | Avoiding Android navigation IllegalArgumentException in NavController | <p>I recently switched over to Android Navigation, but have encountered a fair amount of situations (in different parts of the code), where I get:</p>
<pre><code>Fatal Exception: java.lang.IllegalArgumentException
navigation destination com.xxx.yyy:id/action_aFragment_to_bFragment is unknown to this NavController
</code></pre>
<p>In every case, the code are simple calls like:</p>
<pre><code>findNavController(this, R.id.navigation_host_fragment).navigate(R.id.action_aFragment_to_bFragment)
</code></pre>
<p>Usually in response to a button press.</p>
<p>It's unclear why this error is getting thrown. My current suspicion is that the onClickListener is somehow getting called twice on some devices, causing the navigate to be called a second time (causing it to be in the wrong state at the time). The reason for this suspicion is that this most often seems to happen in cases where one might have a "long" running operation before the navigate call. I can't recreate this on my own device, though.</p>
<p>Ideas on how to avoid this issue (or indeed, what the actual root cause of the issue is)?</p>
<p>I don't want to use Global Actions; I'm wary of introducing even more unexpected states to the backstack. And I'd really prefer not to have to try and test for the currentstate every time a navigate call is made.</p>
| <android><android-architecture-navigation> | 2019-02-14 11:29:13 | HQ |
54,690,426 | How to create regular expression with \ on the source | <p>Help on how to create regular expression to extract data in JMeter.</p>
<p>Data to be extracted from:
<code><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ruleset id=\"8DEF7F30-165B-2C44-219E-DB7938283CD4\" locale=\"en\">\n\t<baseQuestions id=\"life\"></code></p>
<p>I need a regular expression that can extract the ruleset id from eg above.</p>
<p>Here are the regular expressions that i tried to use:
<code>*ruleset id=\"(.+?)\"</code>
<code>*ruleset id=[^\\",]+</code>
<code>*"ruleset id"=\"(.+?)\"</code></p>
<p>I tried other variations not I keep getting no match.</p>
| <regex><jmeter> | 2019-02-14 12:28:08 | LQ_CLOSE |
54,690,453 | unable to import from imblearn.over_sampling import SMOTE | I have installed imblearn using
pip install -U imbalanced-learn
#version:
conda version : 4.4.10
conda-build version : 3.4.1
python version : 3.6.4.final.0
I keep getting error related to numpy and scipy like
module 'numpy.random' has no attribute 'mtrand'
module 'numpy.polynomial' has no attribute 'polynomial'
np.__version__
Out[11]: '1.14.0'
scipy.__version__
Out[17]: '1.2.1'
Please let me know how to fix this
| <python><scikit-learn><imblearn> | 2019-02-14 12:30:05 | LQ_EDIT |
54,691,930 | Is there way to update Web form UI when one thread complete task & other is running | I am working on Webforms & using threading. How do i update my UI after completion of one thread process while other is having some long running task.
Basically i am creating UI which will show Audit logs periodically which is running by long running task/Thread.
| <c#><asp.net><multithreading><user-interface><webforms> | 2019-02-14 13:47:15 | LQ_EDIT |
54,692,007 | How to run a cronjob every 50 minutes? | <p>I want to run cron job in following manner</p>
<p>00:00
00:50
01:40
02:30
and so on</p>
<p>how can i setup cron tab so it works like this</p>
| <php><laravel><cron><cron-task> | 2019-02-14 13:51:33 | LQ_CLOSE |
54,694,970 | Index out of bounds after I've already accessed that index less than 10 lines ago | <p>I'm creating a little text dungeon crawler and each floor of the dungeon is a 2d array of rooms. for some reason when you get to the third floor, after creating the array and making sure all rooms are set to null, when I'm setting up the rooms as soon as I get to floor3[1, 0] it throws an index out of bounds.</p>
<p>Having used break points and looking at the array it clearly has a [1,0] as well as everything else between [0,0] and [9,6]. I run a for loop that accesses that index and sets it to null and tried changing the for loop to instead change all the rooms to test rooms and it had no problem with that. I checked probably a dozen times to ensure that there aren't any typos, or that I'm trying to call the wrong floor or anything simple like that. I also wrote just a simple Console.Writeline(floor[1,0]) test line to make sure that I wasn't just missing a typo, I removed that line and it also occurs on anything past that point. Again the identical method works for floors 1 and 2.</p>
<pre><code>floor3 = new RoomClass[9, 6];
//loop through everything and make sure that it's empty
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 6; j++)
{
floor3[i, j] = null;
}
}
//create rooms that actually need to exist.
floor3[0, 0] = new RoomClass("test1.", false, 0, 0);
floor3[0, 1] = new RoomClass("test2.", false, 0, 1);
floor3[0, 2] = new RoomClass("test5.", false, 0, 2);
floor3[0, 3] = new RoomClass("test3.", false, 0, 3);
floor3[0, 4] = new RoomClass("test4.", false, 0, 4);
floor3[0, 5] = new RoomClass("test5.", false, 0, 5);
floor3[0, 6] = new RoomClass("test5.", false, 0, 6);
floor3[1, 0] = new RoomClass("test6.", false, 1, 0);
floor3[1, 3] = new RoomClass("test7.", false, 1, 3);
floor3[1, 6] = new RoomClass("test8.", false, 1, 6);
floor3[2, 0] = new RoomClass("test9.", false, 2, 0);
(etc.)
</code></pre>
<p>This should just go through all the important indexes and create a room for each.</p>
| <c#><indexoutofboundsexception> | 2019-02-14 16:30:43 | LQ_CLOSE |
54,695,919 | Listing employees and their salary as percentage of total salaries using Derived table | I have a table with names, job, salary etc.. what i want to do is to list all names, salary and a third collumn with their salary as a percentage of total salary. like this: https://gyazo.com/179626fb821541405bce72b604cf9475
the table looks like this: https://gyazo.com/95562f6e7bf775aed80954608a2ac5e8
im new to mysql and all help is good help..
thanks | <mysql><sql> | 2019-02-14 17:24:18 | LQ_EDIT |
54,697,030 | Excel 365 vba - (un)protect sheet slows down macro down a lot | Some employees of our company recently switched from office 2007 to office 365. It turns out that the execution time of VBA macros significantly increases in Excel 365. After analyzing the code it became apparent that this increase in time was exclusively caused by "ActiveSheet.(Un)protect"
To give a concrete example: a macro to insert a new line (including some formatting, inserting formulas, etc) increases in execution time from an average of 0.2889 seconds (Excel 2007) to an average of 1.7322 seconds (Excel 365). This difference (i.e. 1.4436 seconds) was caused by an increase in the execution time from (un)protecting the active sheet by 1.5175 seconds (!), which was offset by a slightly faster execution time of the rest of the code -0.0739 seconds.
Does anyone have the slightest idea as to why this is the case? And is there anything that can be done to resolve this without just omitting the protect-functions?
Thank you in advance! | <excel><vba><office365><excel-2007> | 2019-02-14 18:37:27 | LQ_EDIT |
54,697,742 | Greetings, I am devising a project to compare user results to standard results. My algorithm wont run exactly the way I wish it would (scoring system) | The problem with my code is that it simply will not run in the way I wish it would. It will only read from the first "while" & "if" condition. It simply doesn't recognize the other conditions. The age and score will be provided from an external source, therefore this is just an algorithm/scoring system for the tool.
public class algorithm_tester {
int score;
int age;
public static void main(String[] args) {
int score = 0;
int age = 0;
while (age <30) {
if(score <15) {
System.out.println("Your Score Is Slightly Abnormal For Your Age.");
}
else if(score <10) {
System.out.println("Your Results Are Rather Low. Therefore, We Recommend You Seek Medical Advice.");
}
else if(score <8){
System.out.println("Your Results Suggest Severe Cognitive Impairment. You Must Seek Medical Attention Immediately.");
}
else {
System.out.println("Well Done! You Scored Very Well.");
}
while (age <40) {
if (score < 14) {
System.out.println("Your Results Are Slightly Abnormal For Your Age.");
}
else if(score < 10) {
System.out.println("We Recommend You Seek Medical Advice As Your Results Are Quite Low.");
}
else if(score <7) {
System.out.println("Your Score Is Very Low. We Believe You May Have Experienced Majoe Cognitive Impairment. We Recommend You Seek Immediate Medical Attention.");
}
else {
System.out.println("Well Done! You Have Shown No Evidence Cognitive Impairment");
}
while (age < 60) {
if (score < 12) {
System.out.println("Your Results Are Slightly Abnormal For Your Age.");
}
else if(score < 9) {
System.out.println("Your Score is Very Low. We Believe This Is Due To Minor Cognitive impairment. We Recommend You Seek Medical Advice.");
}
else if(score < 6) {
System.out.println("Your Results Have Led Us to Believe You Have Suffered Severe Cognitive Impairment. You Must Seek Medical Attention Immediately.");
}
else {
System.out.println("Congratulations! Your Results Were Excellent. You Have Shown No Evidence Of Cognitive Impairment");
}
while (age < 80) {
if (score < 10) {
System.out.println("Your Results Are Slightly Abnormal For Your Age.");
}
else if(score < 7) {
System.out.println("Your Score is Very Low. We Believe This Is Due To Minor Cognitive impairment. We Recommend You Seek Medical Advice.");
}
else if(score < 5) {
System.out.println("Your Results Have Led Us to Believe You Have Suffered Severe Cognitive Impairment. You Must Seek Medical Attention Immediately.");
}
else {
System.out.println("Congratulations! Your Results Were Excellent. You Have Shown No Evidence Of Cognitive Impairment");
}
while (age > 80) {
if (score < 10) {
System.out.println("Your Results Are Slightly Abnormal For Your Age.");
}
else if(score < 6) {
System.out.println("Your Score is Very Low. We Believe This Is Due To Minor Cognitive impairment. We Recommend You Seek Medical Advice.");
}
else if(score < 4) {
System.out.println("Your Results Have Led Us to Believe You Have Suffered Severe Cognitive Impairment. You Must Seek Medical Attention Immediately.");
}
else {
System.out.println("Congratulations! Your Results Were Excellent. You Have Shown No Evidence Of Cognitive Impairment");
}
}
}
}
}
}
}
}
| <java> | 2019-02-14 19:26:37 | LQ_EDIT |
54,698,339 | for loop to get tapply means by group across many subjects | I'm trying to do some data analysis as follows: I have about 100 subjects, each of whom have a file containing 40,000 lines of numbers. I also have an index file with 40,000 corresponding lines containing group number. I am trying to get the means of each group, for each subject. I can do this easily for one subject with tapply, like this:
```tapply(df$numbers, df$group, mean)```
I can also load in a data frame containing the filenames of each subject's data. What I'd like to do is create a for loop in which I can get the output of the above tapply function for each subject, probably by looping over the filenames and pulling in each one as a new data frame (maybe??). And ultimately I'll want to output this to a .csv with subject names as rows and group names as columns.
Right now I'm very stuck. Can anyone provide some insight?
Thanks!
| <r><tapply> | 2019-02-14 20:11:14 | LQ_EDIT |
54,699,125 | How to use boostrap scrollspy on angular 7 project? | I have transform basic html page with boostrap scrollspy component and my nav doesn't work (no change when page scroll).
I have install boostrap 4 with the command below :
npm install boostrap
There is no change on page scroll or when i clic on menu there is no "active" flag.
Can you help me ? Thanks :)
| <angular><bootstrap-4><scrollspy> | 2019-02-14 21:12:11 | LQ_EDIT |
54,700,276 | Cant Print a list value in python | im trying to organize my server logs a little that are splited by "|"
and now i want to change the positing of the items when i put them in a list and trying to print it out to save it in a new file it give me
print(result[0])
IndexError: list index out of range
it is the same with every position in the list not only 0
with open("logs-DD-MM-YYYY.txt") as f:
for line in f:
result = line.split('|')
print(result[0])
| <python><python-2.7> | 2019-02-14 22:46:06 | LQ_EDIT |
54,701,123 | Image centering with pandoc markdown | <p>I need to create documents periodically for Word-using administrators. How can I centre an image using pandoc markdown? I see mention of div blocks, but I have no idea what they are. </p>
<pre><code>{.center}
</code></pre>
<p>With image code such as that above, and a command line such as:</p>
<pre><code>pandoc -s test.md -o test.docx
</code></pre>
<p>or</p>
<pre><code>pandoc -s test.md -o test.pdf
</code></pre>
<p>I always end up with left-aligned images in my document.</p>
| <markdown><pandoc> | 2019-02-15 00:32:14 | HQ |
54,701,916 | -how to get the contents of a class or id, with a url that leads to the page in question! "sorry for my english :p" | I would like to retrieve the content of a (class), and I would like to recover it just with the url,
kind I give the url and he gives me the content of a class
I hope you understand what I want to say
it's knowing you let me code you,
or redirect me on the same case as me :)
thank you!
(^^ sorry for my english)
http://fr.fetchfile.net/
it's the same principle with this site!
what I am looking for!!!!
we enter url of the page and it recupere automatically the url of the video that seeks for it.
| <javascript><html> | 2019-02-15 02:35:03 | LQ_EDIT |
54,702,910 | Organization proxy self signed certificate not trusted in cent os VM | <p>I am having a VM created out of Cent OS 7.6 ISO. when I try to CURL <a href="https://xxxxxxx" rel="nofollow noreferrer">https://xxxxxxx</a> it shows "(60) CURl Peer certificate issuer has been marked as not trusted by the user. This happens even after I downloaded the certificate and aded it to the store using update-ca-certificate command (ref: <a href="https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html" rel="nofollow noreferrer">https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html</a>). The only doubt I have is that the client system is behind my organization network proxy.
Is there any suggestion to solve the problem?</p>
| <centos> | 2019-02-15 04:59:42 | LQ_CLOSE |
54,704,629 | How to set Product price for india in rupees and out of india in dollar? | <p>I developing ecommerce website. Almost i have done. But i have one problem in show product price in dollar. If user open website in india shows product price in rupees and if website access in out of country shows product price in dollar.</p>
<p>I created product detail page and below provide my code: </p>
<pre><code>public function getProductDetail($pro_code,$error_msg){
$showProDetail='';
$result =$this->connect()->query("SELECT * FROM wm_products WHERE pro_code='$pro_code'");
if($result->num_rows>0){
$row = $result->fetch_assoc();
$cate_id = $row['cate_id'];
$image = json_decode($row['pro_img']);
$showProDetail.='
<div class="page product_detail_wrapper">
<div class="panel-body">
<div class="row">
<div class="col-lg-4 col-mg-4 col-sm-4 col-xs-12">
<figure class="thumbnail">
<img src="../uploads/product_images/' .$image[0].'" alt="">
</figure>
</div>
<div class="col-lg-8 col-mg-8 col-sm-8 col-xs-12">
<div class="responsive-table">
<table class="table table-striped">
<tr>
<td><strong>Product Code</strong></td>
<td>:'.$row["pro_code"].'</td>
</tr>
<tr>
<td><strong>Name</strong></td>
<td>:'.ucfirst(str_replace("_", " ", $row["pro_name"])).'</td>
</tr>
<tr>
<td><strong>Price</strong></td>
<td>: Rs.'.$row["pro_price"].'</td>
</tr>
<tr>
<td><strong>Discount</strong></td>
<td>:'.$row["pro_discount"].'</td>
</tr>
<tr>
<td><strong>Available In</strong></td>
<td>:'.$row["pro_weight"].'</td>
</tr>
<tr>
<td><strong>Quantity</strong></td>
<td>:'.$row["pro_quantity"].'</td>
</tr>
<tr>
<td><strong>Short Description</strong></td>
<td>:'.$row["short_disc"].'</td>
</tr>
</table>
</div>
</div>
</div><br>
</div>
</div>';
}
else{
$showProDetail = '<div class="alert alert-danger">Product Detail Not Found</div>';
}
return $showProDetail;
}
</code></pre>
<p>So, How to set Product price for india in rupees and out of india in dollar?</p>
| <php><currency> | 2019-02-15 07:41:44 | LQ_CLOSE |
54,705,600 | Getting this error **System.NullReferenceException: 'Object reference not set to an instance of an object.'** | <p>I have a page which updates the details of lender in the database but when I click the update button it is throwing this error.</p>
<p>I have put the breakpoints and inspected the code it shows the values when I hover but also it is throwing this error</p>
<p>This is the place where I get the values from the textboxes and when I hover on the <code>enttity.lender_name</code>(same for all the textboxes) it shows the value in textbox correctly </p>
<pre><code>protected void btn_update_Click(object sender, EventArgs e)
{
try
{
enttity.lender_name = lender_name.Text;
enttity.lender_code = lender_code.Text;
enttity.manager_name = manager_name.Text;
enttity.manager_number = manager_number.Text;
enttity.lc_number = lc_number.Text;
enttity.manager_email = manager_email.Text;
enttity.lc_email = lc_email.Text;
enttity.contact_name = contact_name.Text;
enttity.designation = designation.Text;
enttity.branch_name = branch_name.Text;
enttity.branch_add = branch_add.Text;
enttity.branch_add2 = branch_add2.Text;
enttity.branch_city = branch_city.Text;
enttity.branch_state = branch_state.Text;
enttity.branch_zip = branch_zip.Text;
enttity.branch_country = branch_country.Text;
int update = bal.lenderupdate(enttity, Convert.ToInt32(ViewState["lender_id"].ToString()));
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert(' Successfully updated!');window.location.href = 'Lender_registration.aspx'", true);
}
catch (Exception ex)
{
throw ex;
}
}
</code></pre>
<p>The error is thrown in this line <code>int update = bal.lenderupdate(enttity, Convert.ToInt32(ViewState["lender_id"].ToString()));</code> and goes to <code>throw ex</code> saying the error <strong>System.NullReferenceException: 'Object reference not set to an instance of an object.'</strong></p>
<p>This my code where it goes to Stored procedure </p>
<pre><code>public int lenderupdate(lender_entity enttity, int lender_id)
{
try
{
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@lender_id ", lender_id);
cmd.Parameters.AddWithValue("@lender_name ", enttity.lender_name);
cmd.Parameters.AddWithValue("@lender_code", enttity.lender_code);
cmd.Parameters.AddWithValue("@manager_name", enttity.manager_name);
cmd.Parameters.AddWithValue("@manager_number ", enttity.manager_number);
cmd.Parameters.AddWithValue("@lc_number", enttity.lc_number);
cmd.Parameters.AddWithValue("@manager_email", enttity.manager_email);
cmd.Parameters.AddWithValue("@lc_email ", enttity.lc_email);
cmd.Parameters.AddWithValue("@contact_name", enttity.contact_name);
cmd.Parameters.AddWithValue("@designation", enttity.designation);
cmd.Parameters.AddWithValue("@branch_name ", enttity.branch_name);
cmd.Parameters.AddWithValue("@branch_add", enttity.branch_add);
cmd.Parameters.AddWithValue("@branch_add2", enttity.branch_add2);
cmd.Parameters.AddWithValue("@branch_city", enttity.branch_city);
cmd.Parameters.AddWithValue("@branch_state", enttity.branch_state);
cmd.Parameters.AddWithValue("@branch_zip", enttity.branch_zip);
cmd.Parameters.AddWithValue("@branch_country", enttity.branch_country);
int updatelender = dbmngr.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "updatelenders");
return updatelender;
}
catch (Exception ex)
{
throw ex;
}
}
</code></pre>
<p>The values are coming here to but it is throwing the error </p>
<p>data should go to database and update the details of particular lender</p>
| <c#><asp.net><sql-server><visual-studio><stored-procedures> | 2019-02-15 08:54:14 | LQ_CLOSE |
54,706,594 | @types/styled-components Duplicate identifier FormData | <p>If I add @types/styled-components in my project, I will have a bunch of errors in the build output:</p>
<pre><code>ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(36,15):
TS2300: Duplicate identifier 'FormData'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(81,5):
TS2717: Subsequent property declarations must have the same type. Property 'body' must be of type 'BodyInit', but here has type 'string | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Blob | FormData'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(107,14):
TS2300: Duplicate identifier 'RequestInfo'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(126,13):
TS2403: Subsequent variable declarations must have the same type. Variable 'Response' must be of type '{ new (body?: BodyInit, init?: ResponseInit): Response; prototype: Response; error(): Response; redirect(url: string, status?: number): Response; }', but here has type '{ new (body?: string | ArrayBuffer | DataView | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | Blob | FormData, init?: ResponseInit): Response; prototype: Response; error: () => Response; redirect: (url: string, status?: number) => Res...'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(196,5):
TS2717: Subsequent property declarations must have the same type. Property 'abort' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(197,5):
TS2717: Subsequent property declarations must have the same type. Property 'error' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(198,5):
TS2717: Subsequent property declarations must have the same type. Property 'load' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(199,5):
TS2717: Subsequent property declarations must have the same type. Property 'loadend' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(200,5):
TS2717: Subsequent property declarations must have the same type. Property 'loadstart' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(201,5):
TS2717: Subsequent property declarations must have the same type. Property 'progress' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(202,5):
TS2717: Subsequent property declarations must have the same type. Property 'timeout' must be of type 'ProgressEvent', but here has type 'Event'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(206,5):
TS2717: Subsequent property declarations must have the same type. Property 'onabort' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(207,5):
TS2717: Subsequent property declarations must have the same type. Property 'onerror' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(208,5):
TS2717: Subsequent property declarations must have the same type. Property 'onload' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(209,5):
TS2717: Subsequent property declarations must have the same type. Property 'onloadend' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(210,5):
TS2717: Subsequent property declarations must have the same type. Property 'onloadstart' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(211,5):
TS2717: Subsequent property declarations must have the same type. Property 'onprogress' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(212,5):
TS2717: Subsequent property declarations must have the same type. Property 'ontimeout' must be of type '(this: XMLHttpRequest, ev: ProgressEvent) => any', but here has type '(this: XMLHttpRequest, ev: Event) => any'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/globals.d.ts(243,6):
TS2300: Duplicate identifier 'XMLHttpRequestResponseType'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9297,14):
TS2300: Duplicate identifier 'require'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9315,11):
TS2451: Cannot redeclare block-scoped variable 'console'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9323,18):
TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
ERROR in /Users/me/projects/react/node_modules/@types/react-native/index.d.ts(9326,11):
TS2451: Cannot redeclare block-scoped variable 'navigator'.
ERROR in /Users/me/projects/react/node_modules/@types/webpack-env/index.d.ts(203,13):
TS2300: Duplicate identifier 'require'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(5196,11):
TS2300: Duplicate identifier 'FormData'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(5206,13):
TS2300: Duplicate identifier 'FormData'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(16513,11):
TS2320: Interface 'Window' cannot simultaneously extend types 'GlobalFetch' and 'WindowOrWorkerGlobalScope'.
Named property 'fetch' of types 'GlobalFetch' and 'WindowOrWorkerGlobalScope' are not identical.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17406,13):
TS2451: Cannot redeclare block-scoped variable 'navigator'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17510,13):
TS2451: Cannot redeclare block-scoped variable 'console'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17819,6):
TS2300: Duplicate identifier 'RequestInfo'.
ERROR in /Users/me/projects/react/node_modules/typescript/lib/lib.dom.d.ts(17992,6):
TS2300: Duplicate identifier 'XMLHttpRequestResponseType'.
</code></pre>
<p>For some reason it adds @types/react-native, which has some collisions with my react app.</p>
<p>I have the next tsconfig.json:</p>
<pre><code>{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"outDir": "./production/",
"sourceMap": true,
"noImplicitAny": true,
"lib": ["esnext", "dom"],
"resolveJsonModule": true
},
"include": [
"./src/**/*"
]
}
</code></pre>
<p>The problem could be solved with adding exact types in the type property into tsconfig.json:</p>
<pre><code>{
"compilerOptions": {
...
"types": [
"jest",
"jest-diff",
"react",
"react-dom",
"react-intl",
"react-redux",
"react-router-dom",
"webpack-env",
"styled-components"
]
},
...
}
</code></pre>
<p>But this solution doesn't look nice to me. Is there any other fix?</p>
| <javascript><reactjs><typescript><styled-components> | 2019-02-15 09:48:00 | HQ |
54,707,598 | How to customise config.toml on Kubernetes? | <p>I'm have a Gitlab cloud connected to a k8s cluster running on Google (GKE).
The cluster was created via Gitlab cloud.</p>
<p>I want to customise the <code>config.toml</code> because I want to <em>fix</em> the cache on k8s as suggested in <a href="https://gitlab.com/gitlab-org/gitlab-runner/issues/1906" rel="noreferrer">this issue</a>.</p>
<p>I found the <code>config.toml</code> configuration in the <code>runner-gitlab-runner</code> ConfigMap.
I updated the ConfigMap to contain this <code>config.toml</code> setup:</p>
<pre><code> config.toml: |
concurrent = 4
check_interval = 3
log_level = "info"
listen_address = '[::]:9252'
[[runners]]
executor = "kubernetes"
cache_dir = "/tmp/gitlab/cache"
[runners.kubernetes]
memory_limit = "1Gi"
[runners.kubernetes.node_selector]
gitlab = "true"
[[runners.kubernetes.volumes.host_path]]
name = "gitlab-cache"
mount_path = "/tmp/gitlab/cache"
host_path = "/home/core/data/gitlab-runner/data"
</code></pre>
<p>To apply the changes I deleted the <code>runner-gitlab-runner-xxxx-xxx</code> pod so a new one gets created with the updated <code>config.toml</code>.</p>
<p>However, when I look into the new pod, the <code>/home/gitlab-runner/.gitlab-runner/config.toml</code> now contains 2 <code>[[runners]]</code> sections:</p>
<pre><code>listen_address = "[::]:9252"
concurrent = 4
check_interval = 3
log_level = "info"
[session_server]
session_timeout = 1800
[[runners]]
name = ""
url = ""
token = ""
executor = "kubernetes"
cache_dir = "/tmp/gitlab/cache"
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = ""
namespace = ""
namespace_overwrite_allowed = ""
privileged = false
memory_limit = "1Gi"
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.node_selector]
gitlab = "true"
[runners.kubernetes.volumes]
[[runners.kubernetes.volumes.host_path]]
name = "gitlab-cache"
mount_path = "/tmp/gitlab/cache"
host_path = "/home/core/data/gitlab-runner/data"
[[runners]]
name = "runner-gitlab-runner-xxx-xxx"
url = "https://gitlab.com/"
token = "<my-token>"
executor = "kubernetes"
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = "ubuntu:16.04"
namespace = "gitlab-managed-apps"
namespace_overwrite_allowed = ""
privileged = true
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
[runners.kubernetes.volumes]
</code></pre>
<p>The file <code>/scripts/config.toml</code> is the configuration as I created it in the ConfigMap.
So I suspect the <code>/home/gitlab-runner/.gitlab-runner/config.toml</code> is somehow updated when registering the Gitlab-Runner with the Gitlab cloud.</p>
<p>If if changing the <code>config.toml</code> via the ConfigMap does not work, how should I then change the configuration? I cannot find anything about this in Gitlab or Gitlab documentation.</p>
| <kubernetes><gitlab><gitlab-ci><gitlab-ci-runner> | 2019-02-15 10:43:31 | HQ |
54,709,377 | How to perfect forward a member variable | <p>Consider the following code:</p>
<pre class="lang-cpp prettyprint-override"><code>template<typename T> void foo(T&& some_struct)
{
bar(std::forward</* what to put here? */>(some_struct.member));
}
</code></pre>
<p>In the case of forwarding the whole struct I would do <code>std::forward<T>(some_struct)</code>. But how do I get the correct type when forwarding a member?</p>
<p>One idea I had was using <code>decltype(some_struct.member)</code>, but that seems to always yield the base type of that member (as defined in the struct definition).</p>
| <c++><perfect-forwarding> | 2019-02-15 12:26:05 | HQ |
54,709,813 | What is proper name of controller's parameters? | <p>I divided value objects into three types from design point of view. First, Entity is representaton of domain data and map with table of database. Second, DTO (data transfer object) is a simple and compact object and it exist for trans data from service layer to front layer. And there is a question about type three object. Type three objects are parameters of controller. It has also simple data like DTO but it has various entities reference key properties like "departmentIdx in Employee". I want to proper naming on third type object.</p>
<p>VO? It's not only for values, i think. POJO? POJO is too much range concept.</p>
| <java><spring><oop><web><architecture> | 2019-02-15 12:53:58 | LQ_CLOSE |
54,709,906 | Filling json file in a specific html table columns depended on objects value | <p>How to fill a json file in html table where an object value of the file must be filled in a specific column?
i.e: I have the following json file:</p>
<pre><code>[{"id":1,"num":"5","day":1},
{"id":1,"num":"5","day":4},
{"id":2,"num":"6","day":5},
{"id":3,"num":"8","day":4},
{"id":3,"num":"8","day":7},
....
]
</code></pre>
<p>then I want to fill it in html table like that:</p>
<h2>id|day1|day2|day3|day4|day5|day6|day7|</h2>
<h2>1|5|0|0|5|0|0|0|0|</h2>
<h2>2|0|0|0|0|6|0|0|0|</h2>
<h2>3|0|0|0|8|0|0|0|8|</h2>
<p>...</p>
<p>TIA</p>
| <javascript><jquery><json> | 2019-02-15 12:59:33 | LQ_CLOSE |
54,710,230 | How to fix column heigth and width using CSS | i'm developping an e-commerce web site where all the products are displayed in the same page in "cols"
the problem is that i couldn't fix the col width or height using CSS
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<div class="container">
<div class="row">
<!-- BEGIN PRODUCTS -->
<div
class="col-md-3 col-sm-6 col-equal"
*ngFor="let p of (titres | sort: titreSort)"
>
<span class="thumbnail">
<img src="{{ p.URL_couv }}" alt="{{ p.id }}" />
<h4>
<label style="display: block; width: 600px;"
>{{ p.titre }} n° {{ p.numero }}</label
>
</h4>
<p></p>
<hr class="line" />
<div class="row">
<div class="col-md-6 col-sm-6">
<p class="price"></p>
</div>
<div class="col-md-6 col-sm-6"></div>
</div>
</span>
</div>
</div>
</div>
<!-- end snippet -->
this is my code
and this is how the products are showing
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/12k2K.png
and this is my CSS code
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.side-body {
margin-left: 310px;}
.right {
float: right;
border-bottom: 2px solid #4b8e4b;
}
.thumbnail {
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.thumbnail:hover {
opacity: 1;
box-shadow: 0px 0px 10px #41d834;
}
.line {
margin-bottom: 5px;
}
@media (max-width: 768px) {
.col-equal {
margin: auto;
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
}
}
<!-- end snippet -->
Any help please ?
Thank you
| <html><css><bootstrap-4> | 2019-02-15 13:18:30 | LQ_EDIT |
54,711,406 | Sum keys with the same value | I have this object:
obj = {1: 2, 4: 1, 5: 2};
How can I find and multiply only the keys with value 2 on other independent variables ?
I want to compare in this case 1*2 with 5*2.
var1 = 1*2;
var2 = 5*2;
Thank you!
| <javascript><typescript> | 2019-02-15 14:28:25 | LQ_EDIT |
54,711,420 | JavaFX + FXML: Image dissapeared after converting project to Maven | I have a small JavaFX app. Everything looked fine, and was working fine. Suddently, I wanted to convert this project to a Maven project (I wanted to add some external dependencies and use them in the app).
In Eclipse I have right-clicked the project, selected `Configure` and then `Convert to Maven project...`. Everything went fine, until I have build and run the application. The whole app is working perfectly, but there was a logo in the app window, and after converting the project to Maven - the image has dissapeared.
I am using JavaFX with FXML and SceneBuilder.
In the `RootLayout.fxml` file, there is an entry:
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="225.0" layoutY="50.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../../../../../resources/images/nbtc.jpg" />
</image>
</ImageView>
It is still visible in `SceneBuilder` after conversion to Maven, but it has disappeared from the app after running it.
Here is the folder structure:
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/afqJi.png | <java><maven><javafx><fxml> | 2019-02-15 14:28:59 | LQ_EDIT |
54,712,094 | How to prevent building app if component prop types are invalid? | <p>Here is a example for PropTypes:</p>
<pre><code>import PropTypes from 'prop-types';
class Greeting extends React.Component {
render() {
return (
<h1>Hello, {this.props.name}</h1>
);
}
}
Greeting.propTypes = {
name: PropTypes.string
};
</code></pre>
<p>Now I use <code>Greeting</code> component as:</p>
<pre><code><Greetings otherProp="this is a invalid prop" />
</code></pre>
<p>In this case, when I build app for deployment, no error is thrown & app is successfully built. But it give error in runtime & breaks down.</p>
<p>How can I add check to remove this problem & ensure no components are being built using wrong prop types.</p>
| <javascript><reactjs><react-proptypes> | 2019-02-15 15:07:55 | HQ |
54,712,600 | What is the true maximum (and minimum) value of Random.nextGaussian()? | <p>In theory, the bounds for <code>nextGaussian</code> are meant to be positive and negative infinity. But since <code>Random.nextDouble</code>, which is used to calculate the Gaussian random number, doesn't come infinitely close to 0 and 1, there is a practical limit to <code>nextGaussian</code>. And <code>Random.next</code> is also not a perfectly uniform distribution.</p>
<p>It was theorised that the maximum should be about 2.2042*10^17 and related to the 53 bit shift of <code>nextDouble</code> (<a href="https://media.discordapp.net/attachments/508317357228294146/545718295408541716/unknown.png" rel="noreferrer">reference</a>), but that is likely just an upper bound.</p>
<p>The answer probably depends on the distribution of <code>Random.next</code> and the exact implementation of <code>StrictMath.sqrt</code> and <code>StrictMath.log</code>. I couldn't find much information about either.</p>
<p>And yes, I know that the outer values are extremely unlikely, but it can be relevant, for example in the context of RNG manipulation in games.</p>
| <java><random> | 2019-02-15 15:39:57 | HQ |
54,712,960 | Optomise the performance of | I would like to build the following table every day, to store some aggregate data on page performance of a website. However, each days worth of data is over 15 million rows.
What steps can I take to improve performance? I am intending to save them as sharded tables, but I would like to improve further, could I nest the data within each table to improve performance further? What would be the best way to do this?
SELECT
device.devicecategory AS device,
hits_product.productListName AS list_name,
UPPER(hits_product.productSKU) AS SKU,
AVG(hits_product.productListPosition) AS avg_plp_position
FROM `mindful-agency-136314.43786551.ga_sessions_20*` AS t
CROSS JOIN UNNEST(hits) AS hits
CROSS JOIN UNNEST(hits.product) AS hits_product
WHERE parse_date('%y%m%d', _table_suffix) between
DATE_sub(current_date(), interval 1 day) and
DATE_sub(current_date(), interval 1 day)
AND hits_product.productListName != "(not set)"
GROUP BY
device,
list_name,
SKU | <google-analytics><google-bigquery> | 2019-02-15 16:03:13 | LQ_EDIT |
54,713,161 | node how to run concurrent infinite jobs | I have multiple jobs (functions) that process data in my DB.
They should be run indefinitely and concurrently. I was wondering about the
best way to run them. Should I write a bash file that starts ```node somejob.js``` for each job or should I use node workers from a js file, or some other method altogether? | <javascript><node.js><asynchronous><jobs> | 2019-02-15 16:14:58 | LQ_EDIT |
54,713,411 | How to import data from a JSON into a Discord Bot Embed message? | I'm a complete dummy, trying to code a Discord.js bot without any prior coding knowledge. I'm trying to learn as I go. So, the project we are trying to make is a bot that will reply with a discord embed message. It's discord for an online game, where there are multiple different characters. Each of them have unique stats, skills and type. So the idea is to fill a JSON with all the information on all units, then have people use .unitname and have the bot reply with an embed will all information about that unit. This is how it should look like: https://i.imgur.com/Uc4F3En.png (sorry, I can't post images).
First of all, adding dozens of different commands for every single unit doesn't seem right, so I'm having the bot check every single message for a potential unit request. This does sounds pretty unoptimized for me, but will it slow down the bot in practice? And how would I code it to recognize something as .OneOfDozensOfPossibleUnits? Maybe I could have a separate list with all unit names, and have it trigger at .AnyOfThose, but is that the optimal way to do it?
Let's say the bot recognizes .Lucius as a unit request. He will have to look into the JSON file with dozens of units and gather data from Lucius specifically. How do I do that? Then I would have data saved, like stats, for example. Those would have to go in the places I called "variable" (check the code), but what's the syntax for that? I would also like to add some extra "if"s (for example, if unit type = "defense", make the color blue). This one I can probably search and find the syntax for, but I'd be really glad if you could include it.
Sorry, this is such a "do the work for me, please" post, but it can't be helped, haha. I would usually take my time and learn everything bit by bit, but since this is a community project, I'm going blind into a lot of areas. Please let me know if you have any other tips or if you found potential flaws in the program. Thank you in advance!
```
client.on('message', message => {
if (message.content === '.' + "unit") {
const embed = new Discord.RichEmbed()
.setAuthor("Author", "https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120")
.setColor(0xFF0000)
.addField("<:stats:545991150486421514> Stats", "⧫ ATK: " + "variable" + "\r\n ⧫ HP: " + "variable" + "\r\n ⧫ DEF: " + "variable", true)
.addField("\u200B", "⧫ CRIT RATE: " + "variable" + "\r\n ⧫ CRIT DMG: " + "variable" + "\r\n ⧫ AGI: " + "variable", true)
.addField("<:skills:545991578355761152> Skills", "Skill descriptions")
.setImage("https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120", 2, 2)
.setThumbnail("https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120")
.setFooter("Footer", "https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120");
message.channel.send(embed);
```
| <javascript><json><bots><discord.js> | 2019-02-15 16:29:53 | LQ_EDIT |
54,714,968 | Function on a variable declaration | <p>I'm reading the C Programming Language (chapter 5), and I'm confused by this example:</p>
<pre><code>int n, array[SIZE], getint(int *);
</code></pre>
<p>Why is this function call in here like that? Is this just some tricky example and invalid code?</p>
| <c> | 2019-02-15 18:17:02 | HQ |
54,715,024 | How to display integers in android studio using for loop | How can i display integers inside this loop? When i run this code it only display 1 value.
public View.OnClickListener buttonClick = new View.OnClickListener() {
@Override
public void onClick(View v) {
int inputFirst = Integer.parseInt(etTxt1.getText().toString());
int inputSec = Integer.parseInt(etTxt2.getText().toString());
for (int i = inputFirst; i <= inputSec; i++){
tView.setText(i); ;
}
}
}; | <android> | 2019-02-15 18:20:48 | LQ_EDIT |
54,715,554 | Dart: Should I prefer to iterate over Map.entries or Map.values? | <p>Every time I need to iterate over the values of a <code>Map</code> in Dart, I contemplate the cost that this loop will incur, in terms of the complexity and the amount of garbage produced. There are two ways to iterate over the values of a <code>Map</code>: <code>Map.values</code>, and <code>Map.entries</code>. For example:</p>
<pre class="lang-dart prettyprint-override"><code>Map<String, Person> people;
int olderThan(int age) {
int result = 0;
for(Person p in people.values)
if(p.age > age) result++;
return result;
}
int olderThan2(int age) {
int result = 0;
for(MapEntry<String, Person> me in people.entries)
if(me.value.age > age) result++;
return result;
}
// Which one is faster: olderThan or olderThan2?
</code></pre>
<p>If <code>Map</code> stores its values internally as <code>MapEntry</code> objects, it's possible that <code>entries</code> would be just as efficient or even more efficient than <code>values</code>. The implementation details of <code>Map</code> are buried deep inside Dart libraries, so I wonder if anybody has this knowledge and can shed the light on this subject. </p>
<p>I understand that <code>Map.entries</code> gives you access to the key, but I am talking about cases where I don't need to use the key of the entry. I also understand that there are different implementations of <code>Map</code>. I am mostly interested in the default implementation, <code>LinkedHashMap</code>, but if it would be nice to know if there's a difference between the different <code>Map</code> implementations in this aspect. </p>
| <dart> | 2019-02-15 18:58:40 | HQ |
54,718,866 | Azure Pipeline Nuget Package Versioning Scheme, How to Get "1.0.$(Rev:r)" | <p>I'm setting up an Azure Pipelines build that needs to package a C# .NET class library into a NuGet package.</p>
<p>In <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/artifacts/nuget?view=azure-devops&tabs=yaml#package-versioning" rel="noreferrer">this documentation</a>, it lists a couple different ways to automatically generate SemVer strings. In particular, I want to implement this one:</p>
<blockquote>
<p><code>$(Major).$(Minor).$(rev:.r)</code>, where <code>Major</code> and <code>Minor</code> are two variables
defined in the build pipeline. This format will automatically
increment the build number and the package version with a new patch
number. It will keep the major and minor versions constant, until you
change them manually in the build pipeline.</p>
</blockquote>
<p>But that's all they say about it, no example is provided. A link to learn more takes you to <a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/nuget?view=azure-devops" rel="noreferrer">this documentation</a>, where it says this:</p>
<blockquote>
<p>For <code>byBuildNumber</code>, the version will be set to the build number, ensure
that your build number is a proper SemVer e.g. <code>1.0.$(Rev:r)</code>. If you
select byBuildNumber, the task will extract a dotted version, <code>1.2.3.4</code>
and use only that, dropping any label. To use the build number as is,
you should use byEnvVar as described above, and set the environment
variable to <code>BUILD_BUILDNUMBER</code>.</p>
</blockquote>
<p>Again, no example is provided. It looks like I want to use <code>versioningScheme: byBuildNumber</code>, but I'm not quite sure how to set the build number, I think it pulls it from the <code>BUILD_BUILDNUMBER</code> environment variable, but I can't find a way to set environment variables, only script variables. Furthermore, am I suppose to just set that to <code>1.0.$(Rev:r)</code>, or to <code>$(Major).$(Minor).$(rev:.r)</code>? I'm afraid that would just interpret it literally.</p>
<p>Googling for the literal string "versioningScheme: byBuildNumber" returns a single result... Does anyone have a working <code>azure-pipelines.yml</code> with this versioning scheme?</p>
| <continuous-integration><azure-devops><nuget><azure-pipelines><semantic-versioning> | 2019-02-16 01:00:12 | HQ |
54,719,260 | Curved header with pure CSS | <p>Trying to nail this curved header with pure CSS but using border radius isn't keeping the left & right border edges as sharp as they are in the image. Any help would be appreciated.<a href="https://i.stack.imgur.com/Bj4ge.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bj4ge.png" alt="Curved header"></a></p>
| <css> | 2019-02-16 02:21:28 | LQ_CLOSE |
54,719,548 | Tail Call Optimization implementation in Javascript Engines | <p>As of February 2019 in Chrome Version <code>71.0.3578.98</code> on Mac
, the following program throws <code>Uncaught RangeError: Maximum call stack size exceeded error.</code> at a count of <code>16516</code>.</p>
<pre><code>const a = x => {
console.log(x)
a(x + 1)
}
a(1)
</code></pre>
<p>I've done quite a bit of Googling, but wasn't able to find any articles discussing Chrome or other browser support for Tail Call Optimization (TCO) or any future plans to implement it. </p>
<p>My two questions are:</p>
<ol>
<li>Is TCO currently supported in Chrome or any other browser or Javascript Engine</li>
<li>Are there plans to implement TCO in the near future in any Javascript Engine</li>
</ol>
<p>The posts that I've found are mostly old (2016 or earlier) or simply confusing. e.g. <a href="https://www.chromestatus.com/feature/5516876633341952" rel="noreferrer">https://www.chromestatus.com/feature/5516876633341952</a></p>
| <javascript><firefox><chromium><v8> | 2019-02-16 03:12:40 | HQ |
54,719,915 | Can I make a float number in a C program always round up | <p>Can I make a float number in a C program always round up</p>
| <c> | 2019-02-16 04:33:53 | LQ_CLOSE |
54,720,069 | How to add a class with new styles css to v-dialog, vuetify? | <p>Good day. I am working with vuetify, using the following v-dialog in a component:</p>
<pre><code><template>
<div>
<!--Indicador-->
<v-dialog class="vdialognew" v-model="mostrarIndicator" persistent>
<v-content>
<v-container fluid fill-height>
<v-layout align-center justify-center>
<cube-shadow class="spinnerRotate"></cube-shadow>
</v-layout>
</v-container>
</v-content>
</v-dialog>
<!-------------->
</div>
</template>
<style scoped>
.vdialognew {
box-shadow: none !important;
max-width: 610px !important;
}
</style>
</code></pre>
<p>As you will see in v-dialog I have added the vdialognew class, to apply those new styles, but when loading the content by checking in the browser console, I see that the vdialognew class does not apply to it, only. Similarly, if I use the style property inside the v-dialog tag, it does not work for me. How can I make such a change?</p>
<p>I am doing this modification to eliminate the box that is seen behind the green square:</p>
<p><a href="https://i.stack.imgur.com/WpV6n.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WpV6n.png" alt="enter image description here"></a></p>
<p>Thank you very much in advance. Blessings</p>
| <vuetify.js> | 2019-02-16 05:05:57 | HQ |
54,720,347 | c++ memory managment problem, std::vector nevere relase memory out of scope | <p>i am very confuse about this simple code.
why this code can release memory that allocated.</p>
<pre><code>double *a;
for(int i = 0 ; i < 1000000 ; i++)
{
if(1){
a = new double ;
}
if(1){
delete a;
}
}
</code></pre>
<p>but this code can not remove all memory that allocated.</p>
<pre><code>std::vector<double *>rubberList ;
for(int i = 0 ; i < 1000000 ; i++)
{
rubberList.push_back(new double);
//delete rubberList[i];
}
for(unsigned long j = 0 ; j < 1000000 ; j++)
{
delete rubberList.at(j);
}
</code></pre>
<p>and when delete items in allocator block correctly remove memory.</p>
<pre><code>for(int i = 0 ; i < 1000000 ; i++)
{
rubberList.push_back(new double);
delete rubberList[i];
}
</code></pre>
<p>tnx</p>
| <c++><stdvector> | 2019-02-16 05:56:52 | LQ_CLOSE |
54,720,619 | How to program HTML to create consistent columns for text? | <p>I’m trying to make it so that the pages of my book can fit into 2 specific column sizes for all the text such that I can click through the pages. Is there any way I can automate it so it detects where exactly in the page it needs to stop and move onto the next? </p>
| <html> | 2019-02-16 06:49:16 | LQ_CLOSE |
54,722,054 | Margin defined in XML file to be included has no impact | I am trying to re-use the XML defined for a button in a calculator app but the margin value defined within the Button's XML has no effect after it is included in a layout file.
Button's XML:
<?xml version="1.0" encoding="utf-8"?>
<Button
xmlns:android="http://schemas.android.com/apk/res/android"
android:text="@string/standard_sqrt"
android:gravity="center"
android:textStyle="italic"
android:textSize="25dp"
android:padding="16dp"
android:background="@drawable/dark_button_selector"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="5dp"/>
Button seems to be handling margin pretty well on its own:
[![Button Layout][1]][1]
Now, I am simply including it in a TablowRow like this:
<TableRow
android:layout_weight="2"
android:gravity="center">
<include layout="@layout/button_component" />
<include layout="@layout/button_component" />
<include layout="@layout/button_component" />
<include layout="@layout/button_component" />
</TableRow>
No matter what value I assign the margin/height/width of the Button, they act the same when included in the table row (i.e without any spaces between them).
[![Included buttons][2]][2]
[1]: https://i.stack.imgur.com/P0FRP.png
[2]: https://i.stack.imgur.com/cnZNR.png | <android> | 2019-02-16 10:21:23 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.