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 |
|---|---|---|---|---|---|
56,926,373 | From List to Jagged Array | <p>I am trying to convert a <code>List<T></code> to a <code>Jagged Array T [][]</code>. But each array inside the Jagged Array is repeating the first N Elements of the List. I know that my code is doing exactly that, but how can I iterate over my list in a different way so I dont go through the same N elements?</p>
<p>Please ignore the <code>DataTree<T></code> type, its just a reference data structure topology to create the Jagged Array.</p>
<pre><code> public static T[][] ToJaggedArrray<T>(this List<T> data, DataTree<T> dataTree)
{
// Get total elements on each row
//dataTree.DataCount = total elements in data structure
int totalElementsPerArray = dataTree.DataCount / dataTree.BranchCount;
// dataTree.BranchCount = number of elemets/rows
int numElements = dataTree.BranchCount;
T[][] outPut = new T[numElements][];
for (int i = 0; i < outPut.Length; i++)
{
T[] temp = new T[totalElementsPerArray];
for (int j = 0; j < temp.Length; j++)
{
temp[j] = data[j];
}
outPut[i] = temp;
}
return outPut;
}
/* Output:
54
19
83
80
28
48
46
16
52
38
41
10
Element(0): 54 19 83 80
Element(1): 54 19 83 80
Element(2): 54 19 83 80
*/
/* Expected Output:
54
19
83
80
28
48
46
16
52
38
41
10
Element(0): 54 19 83 80
Element(1): 28 48 46 16
Element(2): 52 38 41 10
*/
</code></pre>
| <c#><list><jagged-arrays> | 2019-07-07 21:50:43 | LQ_CLOSE |
56,927,036 | how to include my twitter timeline in a html page? | How can use the twitter API's to get my timeline and display it in a html page? I want to query the API's using JavaScript.
The questions I found on stackoverflow are old and the answer don't seem to work any more.
Any help would be appreciated. | <html><twitter> | 2019-07-08 00:12:26 | LQ_EDIT |
56,927,106 | How to fix invalid literal for int() with base 10: '' | new to python. Using python3.7 and tkinter to make a GUI, where I grab the input from 2 text boxes, and use a math formula then export it out.
I've looked through other forms and tried what they suggested and could not find how to fix it. I've tried global inside and outside of the function, setting the variable before the function.
```python
def retrieve_input():
global InputValue
global InputValue2
global Delay
InputValue=tasks.get()
InputValue2=proxies.get()
print(InputValue)
print(InputValue2)
Delay=3500/int(InputValue)*int(InputValue2)
print(Delay)
retrieve_input()
Label (window, width=12, text=Delay,bg="white",fg="Pink", font="none 22 bold") .grid(row=5, column=0,sticky=W)
```
File ", line 29, in retrieve_input
Delay=3500/int(InputValue)*int(InputValue2)
ValueError: invalid literal for int() with base 10: ''
Thank you :) | <python><python-3.x><tkinter> | 2019-07-08 00:28:06 | LQ_EDIT |
56,928,652 | I want to hide a image button when session is destroyed or user logs out in my code <div class=right icons> | I want to hide the image button while user logs out or there is no session created. ( Right icons class ) this image <img class="upload" src="assets/images/icons/upload.png"> button
<div class="rightIcons">
<a href="upload.php">
<img class="upload" src="assets/images/icons/upload.png">
</a>
<?php echo ButtonProvider::createUserProfileNavigationButton($con, $userLoggedInObj->getUsername()); ?>
</div>
</div>
<div id="sideNavContainer" style="display:none;">
<?php
$navigationProvider = new NavigationMenuProvider($con, $userLoggedInObj);
echo $navigationProvider->create();
?>
</div>
<div id="mainSectionContainer">
<div id="mainContentContainer"> | <javascript><php> | 2019-07-08 05:01:04 | LQ_EDIT |
56,929,577 | Image processing- how to check which Star is closer and which Star is farther in a space image | <p>Let's say we pick an image of space. Let's assume there is big star at 40 light years away and a smaller star 20 light years away. But when we look at the image both would look same size. How can we identify which is bigger and which is smaller by size and how far is it from us.</p>
<p>I want to do image processing on these images.</p>
<p>Keywords: Astronomy, space telescope, stars machine learning, opencv, python.</p>
| <python><opencv><astronomy> | 2019-07-08 06:42:55 | LQ_CLOSE |
56,930,171 | How can we open my website only chrome browser? Shoul not open in firefox,uc browser etc | I want that my website only open in chrome browser.
It should not open any other browser like uc browser ,firefox etc. | <javascript><jquery><html><css><browser> | 2019-07-08 07:27:17 | LQ_EDIT |
56,930,925 | i want to join column with specific match case | i have two tables TableA and TableB the TableA having column called Code Like 'A','AB','B','BB' in TableB i have column called pnrcode like 'A001','AB001','B001','BC001' both table has no relationship i want to join this two table based on TableA code with TableB pnrcode with matching the characters based on TableA | <mysql><sql> | 2019-07-08 08:20:01 | LQ_EDIT |
56,930,999 | Fetch strings of date from a given arrays of date | I want to extract dates from a a arrays of dates which i was fetching from the database .
[{"event_start_date":"2019-03-12"},{"event_start_date":"2019-07-05"},{"event_start_date":"2019-07-05"},{"event_start_date":"2019-08-01"}]
i want to fetch those controller datas to .blade.php file in ["2019-03-12,2019-03-12,2019-03-12,2019-03-12".split(",")] this format | <javascript><php><json><laravel-5><laravel-5.8> | 2019-07-08 08:25:22 | LQ_EDIT |
56,932,990 | How to deal with very long arrays | <p>I have a <code>longArray</code> which contains other long <code>arrays</code> at the beginning of my code(think of it as a database). I'm afraid if it slows down the speed of my code. </p>
<p>If I still want both <strong>execution speed</strong> and the <code>longArray</code>, What do you recommend?</p>
<p>I thought if I could put my array into a function and access its data only when I need the array data it would be a solution, but it seems there is no way to do that ...</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function foo (){
var longArray = [1, 2, 3, 4, 5];
}
console.log(a)</code></pre>
</div>
</div>
</p>
| <javascript> | 2019-07-08 10:26:32 | LQ_CLOSE |
56,933,523 | Apache Airflow : airflow initdb throws ModuleNotFoundError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package error | <p>On Ubuntu 18.04 with python 3.6.8, trying to install airflow. When I ran airflow initdb command, below error is thrown</p>
<pre><code>Traceback (most recent call last):
File "/home/uEnAFpip/.virtualenvs/airflow/bin/airflow", line 21, in <module>
from airflow import configuration
File "/home/uEnAFpip/.virtualenvs/airflow/lib/python3.6/site-packages/airflow/__init__.py", line 40, in <module>
from flask_admin import BaseView
File "/home/uEnAFpip/.virtualenvs/airflow/lib/python3.6/site-packages/flask_admin/__init__.py", line 6, in <module>
from .base import expose, expose_plugview, Admin, BaseView, AdminIndexView # noqa: F401
File "/home/uEnAFpip/.virtualenvs/airflow/lib/python3.6/site-packages/flask_admin/base.py", line 6, in <module>
from flask import Blueprint, current_app, render_template, abort, g, url_for
File "/home/uEnAFpip/.virtualenvs/airflow/lib/python3.6/site-packages/flask/__init__.py", line 20, in <module>
from .app import Flask
File "/home/uEnAFpip/.virtualenvs/airflow/lib/python3.6/site-packages/flask/app.py", line 69, in <module>
from .wrappers import Request
File "/home/uEnAFpip/.virtualenvs/airflow/lib/python3.6/site-packages/flask/wrappers.py", line 14, in <module>
from werkzeug.wrappers.json import JSONMixin as _JSONMixin
ModuleNotFoundError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package
</code></pre>
<p>tried pip3 install --upgrade Flask</p>
| <airflow> | 2019-07-08 11:03:02 | HQ |
56,934,567 | can we extract only year in the string "04.07.2019 16:56:21" without using for loop? | <p>I am trying to extract the year from a date and time string something like "04.07.2019 16:56:21". Can I extract only year without using for loop in batch script?</p>
| <batch-file> | 2019-07-08 12:05:34 | LQ_CLOSE |
56,934,710 | Find string inside string using regular expressions | <p>So I'm trying to find a efficient way of extract a string inside a string, I believe regular expressions would probably be the best approach for this, however I'm not familiar with regular expressions nor with C# & How I would go about constructing that.</p>
<p>I'm currently using a for loop that searches the string for a sequence, then extracts the next 3 entries after that sequence, however it isn't accurate due to entries varying in size etc.</p>
<p>-Example of String</p>
<pre><code> heythereiamexample: 12instackoverflow
</code></pre>
<p>String can vary though in terms of chars between target string</p>
<p>-Example of target string</p>
<pre><code>example: 12
</code></pre>
<p>Now I don't necessarily mind on what I extract, whether it be the digits relative to the string, or the string entirely ( digits included ), but one factor is that the string must end with [0-9]+</p>
<p>So expected output would obviously be,</p>
<pre><code>example: 12
</code></pre>
| <c#><regex> | 2019-07-08 12:14:10 | LQ_CLOSE |
56,934,826 | Distinguish between iPad and mac on iPad with iPadOs | <p>In iOS 13 apple changed the user-agent that iPad uses.</p>
<p>Instead of (for example)</p>
<blockquote>
<p>Mozilla/5.0(<strong>iPad</strong>; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10</p>
</blockquote>
<p>it become (for example)</p>
<blockquote>
<p>Mozilla/5.0 (<strong>Macintosh</strong>; Intel Mac OS X 10_15) AppleWebKit/605.1.15
(KHTML, like Gecko) Version/13.0 Safari/605.1.15</p>
</blockquote>
<p>My question is how can we distinguish between iPad and mac now?</p>
| <ios><ipad><user-agent><ios13><ipados> | 2019-07-08 12:20:38 | HQ |
56,934,848 | PostMessage, how to send CTRL BUTTON? | <p>I'm using C#.</p>
<p>I have process file and I can send via PostMessage for example button 'W'.</p>
<p>I have idea how to make shortcut -> I want to spam each milisecond button "CTRL" (works for button "S" cuz I checked it) and then send "W" button.</p>
<p>But my problem is I don't know how to send 'CTRL" via PostMessage</p>
<p>Any suggestions?</p>
| <c#> | 2019-07-08 12:21:36 | LQ_CLOSE |
56,935,698 | AttributeError: 'NoneType' object has no attribute 'loader' | <p>having an issue today when I started up my laptop (Ubuntu 18.4) and trying to use pip to install packages, I'm met with this error:</p>
<pre><code>Error processing line 3 of /home/cjones/.local/lib/python3.6/site-packages/googleapis_common_protos-1.5.8-py3.6-nspkg.pth:
Traceback (most recent call last):
File "/usr/lib/python3.6/site.py", line 174, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 568, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
Remainder of file ignored
</code></pre>
<p>I don't think I changed anything since last successful boot but it seems as though something is missing... can anyone help?</p>
| <python><ubuntu><pip> | 2019-07-08 13:12:21 | HQ |
56,936,336 | How to transform NTLM credentials to Kerberos token in Node.js | <p>I want to build a server using Node.js, which acts as some kind of proxy. The clients that connect to my server use NTLMv2 for authentication (there is no chance to change this), but the upstream server my server shall connect to requires a Kerberos token.</p>
<p>So, my question is pretty simple: How do I, using Node.js, transform the information provided by NTLMv2 into a Kerberos token? On npm, so far I have found modules for NTLMv2 authentication, but I somehow would probably need to talk to Windows to translate NTLMv2 data of a user into a token for this user.</p>
<p>Any hints on this, how to approach this problem?</p>
| <node.js><kerberos><ntlm><ntlm-authentication><ntlmv2> | 2019-07-08 13:47:19 | HQ |
56,937,914 | How to properly terminate strings in C programming? | <p>I'm using scanf to scan 5 product names and store them in a string. However, when i print them, the last one is always printed as ♣. Where am i going wrong ?</p>
<p>I am trying to take in the id, name and prices of 5 products and print them using structures. However the last product name is always printed as ♣. I realised that this may be due to improper terminating of the string, and tried the solutions provided to such questions.
I saw another similar question on strings and tried to terminate the string properly by doing, char name[50]={'0'}; in my code. This part is within the structure part of the code.</p>
<pre><code>struct product
{
int id;
char name[50];
int price;
};
void main()
{
struct product p [5];
int i,a;
for(i=1;i<=5;i++)
{
printf("Enter the id no., name and price of the product %d\n",i);
scanf("%d%s%d",&p[i].id,&p[i].name,&p[i].price);
}
printf("The id no., name and price of the product %d are\n",i);
for(i=1;i<=5;i++)
{
printf("\t%d\t%s/0\t%d\n",p[i].id,p[i].name,p[i].price);
}
}
</code></pre>
<p>The final output, that is p[5].name ,should've been what i had entered, but is, however, ♣.
And if i try to terminate the code by entering: char name[50]={'\0'};
it puts up an error message over the '=' saying that it expected a ';'.</p>
| <c> | 2019-07-08 15:13:25 | LQ_CLOSE |
56,938,436 | First Flutter App error: cannot resolve symbol "Properties" | <p>I followed the steps in the Flutter document and tried to build my first Flutter app in Intellij IDEA. And when I try to run it,there was an error about my JAVA_HOME variable. And an error about cannot resolve symbol "Properties" in the build.gradle file. I really don't know what to do.</p>
<p>This is my error information displayed in the Console window.</p>
<pre><code>Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Finished with error: ProcessException: Process
"F:\untitled\android\gradlew.bat" exited abnormally:
ERROR: JAVA_HOME is set to an invalid directory: F:\Google download\jdk-
10.0.1_windows-x64_bin.exe
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Command: F:\untitled\android\gradlew.bat -v
</code></pre>
<p>Actually there is nothing wrong with my JAVA_HOME variable, I set it to the proper directory: C:\Program Files (x86)\Java\jdk1.8.0_131.</p>
<p>And I run the command it shows above "F:\untitled\android\gradlew.bat -v", it seemed to update the gradle version, but the error didn't resolved.</p>
<p>And this is the code in build.gradle file.</p>
<pre><code>def localProperties = new Properties()
//there will be a highlight on Properties indicates that 'cannot resolve symbol "Properties" '
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
//the same as the Properties on GradleException
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.untitled"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
</code></pre>
| <intellij-idea><flutter> | 2019-07-08 15:44:47 | HQ |
56,938,870 | array conversion in javascript | <p>I am new to JavaScript. </p>
<p>I have the following 1-d arrays:</p>
<pre><code> m=[1,2,3,4]
n=[5,6,7,8]
</code></pre>
<p>I want to convert the following in JavaScript:</p>
<pre><code> x=[[1,5], [2,6], [3,7], [4,8]]
</code></pre>
<p>How can I do this?</p>
<p>Thanks for your help in advance.</p>
<p>I am new to java-script</p>
| <javascript><arrays> | 2019-07-08 16:14:23 | LQ_CLOSE |
56,943,139 | casting a vector's size() as int does not work | <p>I am learning C++ on the fly and am having problems with vectors so I am writing some programs that use vectors to familiarize myself with them.</p>
<p>I was following the advice from this post regarding printing out the value of a vector's size() call:</p>
<p><a href="https://stackoverflow.com/questions/31196443/how-can-i-get-the-size-of-an-stdvector-as-an-int">How can I get the size of an std::vector as an int?</a></p>
<p>My code is a simple C++ code:</p>
<pre><code>#include <vector>
int main(int argc, char ** argv) {
/* create an int vector of size 10, initialized to 0 */
std::vector<int> int_list[10];
int int_list_size;
int_list_size = static_cast<int>(int_list.size()); // <-- compilation error here
} // End main()
</code></pre>
<p>I'm on Ubuntu 16.04 and I get this error:</p>
<pre><code>"error: request for member 'size' in 'int_list', which is of non-class type 'std::vector<int> [10]'
</code></pre>
<p>Since the size of the vector int_list is 10, shouldn't size() return 10, which I can then cast to an int?</p>
| <c++><vector> | 2019-07-08 22:15:00 | LQ_CLOSE |
56,944,093 | Resolve axios to a variable instead of doing everything in the callback | <p>So I am 99% sure this cannot be done, but humor me for a moment. Consider the two functions:</p>
<pre><code>function doAjaxCall(fieldTocheckAgainst, currentField, value) {
axios.get(
window.location.origin +
'/api/clinic/'+window.id+'/patient/'+window.secondId+'/field-validation',
{
params: {
field_to_check_against: fieldTocheckAgainst,
current_field: currentField,
value: moment(value).format('YYYY-MM-DD')
}
}
).then((result) => {
return result.data
});
}
async function resolveAjaxCall(fieldTocheckAgainst, currentField, value) {
const result = await doAjaxCall(fieldTocheckAgainst, currentField, value)
console.log(result);
}
</code></pre>
<p>I am attempting to resolve the axios ajax call into a variable based on what I saw <a href="https://stackoverflow.com/a/43371957/1270259">here</a> and it doesn't work. I get <code>undefined</code>.</p>
<p>I understand when it comes to callbacks, everything has to be done in the callback, but is there no way, with async and await to resolve the promise to a variable as I am attempting to do, to then use said variable else where?</p>
<p><strong>Or am I just going to be stuck with callbacks?</strong> </p>
| <javascript><promise><callback><async-await><axios> | 2019-07-09 00:49:42 | LQ_CLOSE |
56,945,715 | How to group an object in Javascript? | <p>I have two arrays:</p>
<pre><code>let props = ['a', 'b', 'c', 'd', 'e'];
let values = ['a', 'f', 'k', 'd', 'l'];
</code></pre>
<p>I need to get an object like:</p>
<pre><code>{
"a": [
{
"b": "f",
"c": "k"
}
],
"d": [
{
"e": "l"
}
]
}
</code></pre>
<p>How can i do that in Javascript? Thanks</p>
| <javascript><node.js> | 2019-07-09 05:11:58 | LQ_CLOSE |
56,946,129 | In java main method String replace vith int | what was the result when public static void main(String args[])
string replace vith int means public static void main(int args[]) | <java> | 2019-07-09 05:57:04 | LQ_EDIT |
56,947,046 | Flutter for loop to generate list of widgets | <p>I have code like this but I want it to iterate over an integer array to display a dynamic amount of children:</p>
<pre><code>return Container(
child: Column(
children: <Widget>[
Center(
child: Text(text[0].toString(),
textAlign: TextAlign.center),
),
Center(
child: Text(text[1].toString(),
textAlign: TextAlign.center),
),
],
),
)
</code></pre>
<p>Where the <code>text</code> variable is a list of integers converter to string here. I tried adding a function to iterate through the array and display the 'children' but was getting a type error. Not sure how to do it since I'm new to Dart and Flutter.</p>
| <flutter><dart> | 2019-07-09 07:07:08 | HQ |
56,949,164 | fail in creating a dictionary | I am trying to create a dictionnary in a function but I don't know for which reason I got this:
MONdic = {"mama"}
print MONdic
what I get as a result is :
> set(['mama'])
any help ? | <python><python-2.7> | 2019-07-09 09:14:08 | LQ_EDIT |
56,950,041 | Karate UI Automation support | <p>wanted to explore on Karate UI Automation (selenium) support.
found out that a jar is available for it click [<a href="https://search.maven.org/search?q=a:karate-core]" rel="nofollow noreferrer">https://search.maven.org/search?q=a:karate-core]</a> </p>
<p>any blogs which can help to start with it like:
browser configuration
Initiating the webdriver/karate driver?</p>
<p>karate UI automation documentation provided few code snippets but no clue on how to start, please guide.</p>
<p>Added karate jar available (<a href="https://search.maven.org/search?q=a:karate-core" rel="nofollow noreferrer">https://search.maven.org/search?q=a:karate-core</a>) but when i try driver.location("<a href="http://sampledotcom" rel="nofollow noreferrer">http://sampledotcom</a>") writing this code on feature file, the gherkin is not identifying these lines</p>
| <user-interface><selenium-webdriver><automation><karate> | 2019-07-09 09:58:49 | LQ_CLOSE |
56,954,042 | What is the difference between Any and Unit in scala? | What is the difference between `Any` and `Unit` in Scala ?
I know both are datatypes, but what is the difference ? | <scala> | 2019-07-09 13:44:41 | LQ_EDIT |
56,957,310 | Iterate over objects of the array | <p>I've the below array of objects.
How do I iterate over it to change <code>inventory</code> and <code>unit_price</code> if product <code>name</code> is found, and create new product if the <code>name</code> is no found.
for example, if in <code>my_product</code> the name is <code>stool</code> as shown, this record to be added to the array, but if the <code>name</code> is, let's say <code>table</code> then the <code>inventory</code> and <code>unit_price</code> of product <code>table</code> are required to be adjusted.</p>
<pre><code>let products = [
{
name: "chair",
inventory: 5,
unit_price: 45.99
},
{
name: "table",
inventory: 10,
unit_price: 123.75
},
{
name: "sofa",
inventory: 2,
unit_price: 399.50
}
];
let my_product = {name: "stool", inventory: 1, unit_price: 300}
</code></pre>
| <javascript> | 2019-07-09 16:52:34 | LQ_CLOSE |
56,958,144 | Where should I save created files? | <p>I need to save users created pdf files somewhere. I wanted to save files to ClassPathResource (but I read that It is not a good idea), because I need one thing... Application must work on every computer... so I cannot save it directly on my disc...
Any recommendation, where I could save pdf files to make it work as I need?</p>
| <java><spring><spring-boot> | 2019-07-09 17:50:54 | LQ_CLOSE |
56,959,864 | Javascript open link in new tab not same tab | <p>I have some code to make a table row clickable which works as it should.</p>
<p>The only problem is it opens the URL in the same tab. Is there a way I can change this to open the URL in a new tab?</p>
<pre><code><tr class='clickable-row' data-href='http://www.google.com'>
<script>
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
window.location = $(this).data("href"));
});
});
</script>
</code></pre>
| <javascript><html> | 2019-07-09 20:08:06 | LQ_CLOSE |
56,963,163 | how to sort partition in apache spark | Hi i have a used the dataframe which contains the query
df : Dataframe =spark.sql(s"show Partitions $yourtablename")
now the number of partition changes everyday as it runs everyday
the main concern is i need to fetch the latest partition.
supoose i get the partition for a random table for a particular day
like
year=2019/month=1/day=1
year=2019/month=1/day=10
year=2019/month=1/day=2
year=2019/month=1/day=21
year=2019/month=1/day=22
year=2019/month=1/day=23
year=2019/month=1/day=24
year=2019/month=1/day=25
year=2019/month=1/day=26
year=2019/month=2/day=27
year=2019/month=2/day=3
Now of you can see have as the functionality that it sorts the partition after day=1 comes day=10 so this creates a problem as need to fetch the latest partition.
I have managed to get the partition by using
val df =dff.orderby(col("partition").desc.limit(1)
but this gives me the tail -1 partition and not the latest partition .
How can i get the latest partition from the tables overcoming hives's limitation of arranging partition.
so suppose in the above example
i need to pickup
year=2019/month=2/day=27
and not year=2019/month=2/day=3
which is the last partition in the table | <dataframe><apache-spark-sql><rdd><natural-sort> | 2019-07-10 03:48:38 | LQ_EDIT |
56,963,738 | my code keeps on giving me segfauls when I try to break it up into three smaller functions | I've tried passing the values by reference. the program reads a single line every time the function get_next_line is called and returns 1 if a line is found, 0 if a line is not found and -1 for other errors such as failed memory allocation. the code leaks but for now my main problem is breaking up the get_next_line function.
========================================================================
#include "get_next_line.h"
char *ft_strnew(size_t size)
{
char *str;
str = (char *)malloc(size + 1);
if (!str)
return (NULL);
str[strlen(str) + 1] = '\0';
return (str);
}
void *ft_memset(void *start, int init, size_t size)
{
unsigned char *ptr;
ptr = (unsigned char*)start;
while (size > 0)
{
*ptr++ = (unsigned char)init;
size--;
}
return (start);
}
void ft_bzero(void *s, size_t size)
{
ft_memset(s, '\0', size);
}
char *ft_strjoin(char const *s1, char const *s2)
{
char *new;
size_t len;
if (!s1 || !s2)
return (NULL);
len = strlen((char *)s1) + strlen((char *)s2);
new = (char *)malloc(len + 1);
if (!new)
return (NULL);
while (*s1 != '\0')
*new++ = *s1++;
while (*s2 != '\0')
*new++ = *s2++;
*new = '\0';
return (new - len);
}
char *ft_strdup(const char *str)
{
char *strdup;
int i;
strdup = (char *)malloc(strlen(str) + 1);
if (strdup == NULL)
return (NULL);
i = 0;
while (str[i] != '\0')
{
strdup[i] = str[i];
i++;
}
strdup[i] = '\0';
return (strdup);
}
static char *read_line(int f, int fd, char *buff, char *temp)
{
int i;
i = 0;
while (f > 0)
{
if (buff[i] == '\n'){
break;
}
else if (i == BUFF_SIZE)
{
f = read(fd, buff, BUFF_SIZE);
if (f == 0)
{
if (BUFF_SIZE == 1)
return (temp);
return ((char *)LINE_NOT_FOUND);
}
temp = ft_strjoin(temp, buff);
i = -1;
}
i++;
}
return (temp);
}
int get_next_line(const int fd, char **line)
{
static t_var var;
char buff[BUFF_SIZE + 1];
char *new;
int i;
int f = 0;
int s = 0;
int w = 0;
i = 0;
if (fd < 0 || line == NULL)
return (INVALID);
ft_bzero(buff, BUFF_SIZE + 1);
if (var.j > 0)
{
new = (char *)malloc(sizeof(char) * (var.j + 1));
if (!new)
return (INVALID);
s = strlen(var.temp) - var.j;
f = s;
w = var.j;
while (var.temp[s] != '\0')
{
new[i] = var.temp[s];
if (var.temp[s] == '\n')
{
if(!(*line = (char *)malloc(sizeof(char) * (i + 1))))
return (INVALID);
*line = strncpy(*line, new, i);
var.j--;
return (LINE_FOUND);
}
s++;
var.j--;
i++;
}
s = f;
var.temp = ft_strdup(new);
}//first read after this if statement
if (w == 0)
var.temp = ft_strnew(BUFF_SIZE);
f = read(fd, buff, BUFF_SIZE);
if (f == 0)
return (LINE_NOT_FOUND);
var.temp = ft_strjoin(var.temp, buff);
var.temp = read_line(f, fd, buff, var.temp);//function call
if (var.temp == (char *)LINE_NOT_FOUND)
return (0);
s = 0;
if (var.temp[s])
{
while (var.temp[s] != '\n')
s++;
}
s++;
if(var.j == 0)
*line = (char *)malloc(sizeof(char) * (s + 1));
*line = strncat(*line, var.temp, s - 1);
var.j = strlen(var.temp) - s;
return (LINE_FOUND);
}
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd;
char *line;
int x = 1;
if (argc > 1)
{
fd = open(argv[1], O_RDONLY);
while (x == 1)
{
x = get_next_line(fd, &line);
if (x > 0)
printf("%s\n", line);
}
close(fd);
}
return (0); | <c> | 2019-07-10 05:09:00 | LQ_EDIT |
56,965,157 | I need sql query for below table | I've two integer columns and need to display consecutive one's
ID NUM
1 1
2 1
3 1
4 2
5 1
6 2
7 2
Expected O/P:
id num
1 1
2 1
3 1 | <sql><oracle> | 2019-07-10 07:06:49 | LQ_EDIT |
56,966,019 | Have to discard numeric decimal(25.0987)values with some string and keep those values who are decimal(25) | In some source table suppose a column there
Column A
25.00
19.890
16
5.980
100
Write sql to show output
Column A
25
Decimal values so discarded
16
Decimal values so discarded
100
Nothing coming in my mind | <sql><oracle> | 2019-07-10 07:59:10 | LQ_EDIT |
56,967,478 | How do I remove an image a certain amount of time after its been created in Javascript? | <p>I'm trying to make an image disappear after like 2 seconds but I don't know how to do it.</p>
<p>I've looked online but haven't really found anything useful.</p>
<pre><code>function rockImage() {
var img = document.createElement("img");
img.src = "rock.png";
var src = document.getElementById("compChoiceImage");
img.setAttribute("width", "100");
src.appendChild(img);
}
</code></pre>
<p>That's the function to create the image I want to add the timer thing into the function.</p>
| <javascript> | 2019-07-10 09:21:22 | LQ_CLOSE |
56,968,229 | Can anuone explain the below code How it works? | I have a custom class that has overridden hashcode() and equals() method
class Employee1{
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Employee1(int id) {
super();
this.id = id;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + id;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee1 other = (Employee1) obj;
if (id != other.id)
return false;
return true;
}
}
and in main class I am using a Map having Object as Key
Map<Integer,Employee1> g = new HashMap<>();
Employee1 e = new Employee1(1);
Employee1 e1 = new Employee1(2);
g.put(1, e);
g.put(2, e1);
Employee1 e4 = g.get(1);
e4.setId(3);
for(Map.Entry<Integer,Employee1> e3:g.entrySet()) {
System.out.println(e3.getKey()+" "+e3.getValue().getId());
}
my question is how come the key of the map is changed even though I have overridden hashcode and equals methods,key should be same but I am able to get and set the id and its reflecting in the map
The o/p for above code is
1 3
2 2 | <java><object><hashmap> | 2019-07-10 09:59:06 | LQ_EDIT |
56,969,415 | Data Table with select inputs and print option button | I have a data table with select inputs and a print button, while printing I am getting all the select option tag text how to fix that | <javascript><jquery><datatables> | 2019-07-10 11:08:17 | LQ_EDIT |
56,969,945 | Is there an alternative for --rebaseRootRelativeCssUrls option in Angular CLI 8? | <p>I had a lot of issues because my application is hosted inside a subfolder and for that reason the relative <code>/assets/</code> path, which is referenced inside <code>.scss</code> files, doesn't work.
The solution was to enable the <code>--rebaseRootRelativeCssUrls</code> option to get the expected behaviour. With that option, the build process has adjusted my <code>/assets/</code> paths by injecting the "--base-href" value and now the referenced images and fonts are loading correctly.</p>
<p>However, I see in the documentation that the option is deprecated and it will be removed in the next major release.</p>
<p><a href="https://angular.io/cli/build" rel="noreferrer">https://angular.io/cli/build</a> (search for <code>--rebaseRootRelativeCssUrls</code>)</p>
<p>So my question is, what is the alternative, is there any other way to get the same result?</p>
| <angular><angular-cli> | 2019-07-10 11:39:26 | HQ |
56,970,495 | Build React components library with Webpack 4 | <p>I'm currently building a library of React components and bundling it with Webpack 4.</p>
<p>Everything works just fine from building the library's bundle to publishing it on an npm registry.</p>
<p>But then, I'm not able to import any of its components in an other React application and get this error message at runtime:</p>
<blockquote>
<p>Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.</p>
</blockquote>
<p>And here is the related code:</p>
<p>A dumb component from my components library:
<code>button/index.js</code></p>
<pre><code>import React from "react";
const Button = () => <button>Foobar</button>;
export { Button };
</code></pre>
<p>The main entry point of my library <code>index.js</code>:</p>
<pre><code>import { Button } from "./src/components/Button";
export { Button };
</code></pre>
<p>My Webpack config <code>webpack.config.js</code>:</p>
<pre><code>const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
entry: "./index.js",
plugins: [new CleanWebpackPlugin()],
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
},
output: {
filename: "index.js",
path: path.resolve(__dirname, "dist"),
libraryTarget: "commonjs",
library: ""
}
};
</code></pre>
<p>And finally, the import of this component in an other application:</p>
<pre><code>import { Button } from "my-design-system";
</code></pre>
<p>I guess I'm missing something in my Webpack config or one of the property may be wrong, but after reading multiple posts and tutorials, I can't figure which one.</p>
| <javascript><reactjs><webpack> | 2019-07-10 12:14:54 | HQ |
56,971,043 | Calculate averages for each country, from a data frame | <p>I'm working on a dataframe called 'df'. Two of the columns in 'df' are 'country' and 'dissent'. I need to calculate the average dissent per country. What is the most effective way to iterate through the data frame and calculate the averages by country? </p>
<p>I tried for loops but it does not work and also I don't think it is the most effective way.</p>
| <r> | 2019-07-10 12:47:05 | LQ_CLOSE |
56,972,739 | How can i change this code for multiplication? | i have this code and i am using for addition of inputs. How can i change this code for multiplication?
function sumIt() {
var total = 0, val;
$('.inst_amount').each(function() {
val = $(this).val();
val = isNaN(val) || $.trim(val) === "" ? 0 : parseFloat(val);
total += val;
});
$('#total_price').html(Math.round(total));
$('#total_amount').val(Math.round(total));
}
$(function() {
$("#add").on("click", function() {
$("#container input").last()
.before($("<input />").prop("class","inst_amount").val(0))
.before("<br/>");
sumIt();
});
$(document).on('input', '.inst_amount', sumIt);
sumIt() // run when loading
}); | <javascript> | 2019-07-10 14:18:19 | LQ_EDIT |
56,973,959 | SwiftUI: How to implement a custom init with @Binding variables | <p>I'm working on a money input screen and need to implement a custom <code>init</code> to set a state variable based on the initialized amount.</p>
<p>I thought this would work, but I'm getting a compiler error of:</p>
<p><code>Cannot assign value of type 'Binding<Double>' to type 'Double'</code></p>
<pre><code>struct AmountView : View {
@Binding var amount: Double
@State var includeDecimal = false
init(amount: Binding<Double>) {
self.amount = amount
self.includeDecimal = round(amount)-amount > 0
}
...
}
</code></pre>
| <swift><swiftui> | 2019-07-10 15:23:37 | HQ |
56,974,216 | Did rewriting Roslyn in C# make it slower? | <p>I read this article: <a href="https://medium.com/microsoft-open-source-stories/how-microsoft-rewrote-its-c-compiler-in-c-and-made-it-open-source-4ebed5646f98" rel="nofollow noreferrer">https://medium.com/microsoft-open-source-stories/how-microsoft-rewrote-its-c-compiler-in-c-and-made-it-open-source-4ebed5646f98</a></p>
<p>Since C# has a built in garbage collector, is Roslyn slower than the previous compiler which was written in C++? Did they perform any benchmarks?</p>
| <c#><.net><roslyn> | 2019-07-10 15:39:26 | LQ_CLOSE |
56,975,509 | C# functiion by passing parameters | Calculate a c# function by passing parameters
My function is something like this:
Result<double> Evaluate(string var, Result<double> height, Result<double> perm)
Var can be anything user wants to enter. For example, if the user enters FC then the calculation would be like height * perm and return the var.
If user enters SC the calculation is height/ perm and result is stored in var and returns the result | <c#><.net> | 2019-07-10 17:06:10 | LQ_EDIT |
56,975,660 | Check if a value exists in an object | <p>I'm trying do some validations based of an object with key-value pairs like below</p>
<p><code>var map = {'1': ['a','b','c'], '2': ['d','e'], '3': 'f'}</code></p>
<p>and I want to check if my desired value is in a particular key segment
<code>if('a' in map[1])</code></p>
<p>is there a way where we can check it like above?</p>
| <javascript> | 2019-07-10 17:16:47 | LQ_CLOSE |
56,975,943 | Email Markup It does not show the button in the subject line on gsuite, in Gmail is working | I did Email Markup tests in Gmail with positive results, but in gsuite gmail (company) the same script does not show the button in the subject line.
I do not know if it is related, but before setting up Dkim registration in Gsuite, we recieve external emails with Email Markup, will any additional permission, or additional code, be needed?
I used the example code of the following link:
https://developers.google.com/gmail/markup/apps-script-tutorial | <gmail><gsuite><google-schemas> | 2019-07-10 17:38:07 | LQ_EDIT |
56,977,143 | can i use GET method instead of POST method in SpringMVC? | <p>In SpringMVC if suppose I can use POST method instead of the GET method and it works. Then what is the purpose of these methods and how can we differentiate these methods.</p>
| <java><spring-mvc> | 2019-07-10 19:05:29 | LQ_CLOSE |
56,977,372 | How to validate Date of Birth in javascript with input[type="Date"]? | <p>I know there are a few questions out there on this topic, but they all are either unclear or, they are using <code>input[type="text"]</code> in them.</p>
<p>In my HTML form I have an input of type date. So now I want to make sure that the date of birth is valid(Date is not in the future!). How do I do this?</p>
| <javascript><jquery><html> | 2019-07-10 19:23:22 | LQ_CLOSE |
56,977,980 | RPS Game While and if loops not able to get working | I don't know why but i keep getting the code ending straight after the input part
I have tried using elif but i get invalid syntax
import getpass
answer1 = getpass.getpass(prompt = "Hello Player 1, Please pick either ROCK (1) SCISSORS (2) OR PAPER (3) \n")
answer2 = input(("Hello Player 2, Please pick either ROCK (1) SCISSORS (2) OR PAPER (3) \n"))
Forever = 0
while Forever < 1:
if answer1 == 1 and answer2 == 1:
print('DRAW PLAY AGAIN !')
Forever = Forever + 1
if answer1 == 2 and answer2 == 2:
print('DRAW PLAY AGAIN !')
Forever = Forever + 1
if answer1 == 3 and answer2 == 3:
print('DRAW PLAY AGAIN !')
Forever = Forever + 1
if answer1 == 1 and answer2 == 2:
print('Player 1 wins !')
Forever = Forever + 1
if answer1 == 3 and answer2 == 1:
print('Player 1 wins !')
Forever = Forever + 1
if answer1 == 2 and answer2 == 3:
print('Player 1 wins !')
Forever = Forever + 1
if answer1 == 2 and answer2 == 1:
print('Player 2 wins !')
Forever = Forever + 1
if answer1 == 1 and answer2 == 3:
print('Player 2 wins !')
Forever = Forever + 1
if answer1 == 3 and answer2 == 2:
print('Player 2 wins !')
Forever = Forever + 1
The code never ends as well. | <python><python-3.x> | 2019-07-10 20:13:34 | LQ_EDIT |
56,978,590 | Node.js - What does “socket hang up” mean in simple words? | <p>I would like to know what socket hang up means in very simple words. </p>
| <javascript><node.js> | 2019-07-10 21:02:16 | LQ_CLOSE |
56,979,915 | When I compress a tar gz file using paths, folders get included | <p>When I compress a tar gz file using paths, folders get included. However, I want to just compress the file only. This is what I tried:</p>
<pre><code>$ tar -czf ../coolfile.tar.gz newfol/coolfile
</code></pre>
<p>When I uncompress this tar.gz, I get the <code>coolfile</code> file in newfol folder. I would like compress <code>coolfile</code> only. </p>
<p>Uncompress tar gz command:</p>
<pre><code>$ tar -xvf coolfile.tar.gz`
</code></pre>
| <linux><shell><terminal><redhat><tar> | 2019-07-10 23:43:32 | LQ_CLOSE |
56,980,966 | Load data from the database to mat-table when click Next page | <p>I am using angular 7 with spring boot, and i am use mat-table, i don't want load for example all the data from database in one load, i want to load data just when click on next page in mat-table.
and This image for my mat-table.</p>
<p><a href="https://i.stack.imgur.com/OSKLW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OSKLW.png" alt="mat-table image"></a></p>
<p>how i can do that in angular 7 and spring boot together, if anybody have solution please give me it, thanks.</p>
| <spring-boot><spring-data-jpa><angular-material><spring-data><angular7> | 2019-07-11 02:45:23 | LQ_CLOSE |
56,981,114 | implement executeusingpath() in c | I have one question which is as follows can someone explain me
Consider environment variables used in Unix-based operating systems. A frequently seen environment variable is named PATH, and is used by command interpreters, or shells, to identify the names of directories to be searched to find executable programs.
For example, a typical value of PATH may be: "/Users/chris/bin:/usr/local/bin:/usr/bin:/bin:."
which provides a colon-separated list of directories to search for a required program.
Write a C99 function, named executeUsingPATH(), which accepts the name of a program to execute and a NULL-pointer terminated vector of arguments to be passed to that program.
The requested program may be specified using just its name, or with either an absolute or a relative pathname.
int executeUsingPATH(char *programName, char *arguments[]); Function executeUsingPATH() should attempt to execute programName from each
directory provided via PATH, in order.
If programName is found and may be executed (passing to it the indicated program arguments), the function should wait for its execution to terminate, and then return the exit status of the terminated process. If the function cannot find and execute programName then it should simply return the integer -1.
Your function should not simply call the similar library function named execvp().
I have no idea about it | <c><string><vector> | 2019-07-11 03:08:19 | LQ_EDIT |
56,981,552 | Java while loop not breaking after break; statment | import java.util.Scanner;
public class LoopsEndingRemembering {
public static void main(String[] args) {
// program in this project exercises 36.1-36.5
// actually this is just one program that is split in many parts
Scanner reader = new Scanner(System.in);
System.out.println("Type numbers: ");
int input = Integer.parseInt(reader.nextLine());
while(true){
if(input == -1){
break;
}
}
System.out.println("Thank you and see you later!");
}
}
//The user should be able to put in multiple numbers until -1 is reached. Once its reached it should break the loop and print the last line.
| <java><loops><while-loop> | 2019-07-11 04:15:33 | LQ_EDIT |
56,981,752 | Python .append not working when found within a for, if else | <p>Working on a list creator to generate assignments for a sound crew. Creating 4 lists and adding people to the various lists based on the training they have recieved and the jobs they are capable of doing. I have one base list with all of the people included. The .append works for that list, but for all lists with conditions the names are not appending.</p>
<p>I tried changing my for from for str in addto to other things but nothing has worked so far.</p>
<pre><code>my_list = []
stage_list = []
mic_list = []
all_list = []
def addto_list():
addto = input()
for str in addto:
input("Can he do stage?(y/n): ")
if input == "y":
stage_list.append(addto)
else:
break
for str in addto:
input("Can he do mic?(y/n): ")
if input == "y":
mic_list.append(addto)
else:
break
for str in addto:
input("Can he do sound?(y/n): ")
if input == "y":
all_list.append(addto)
else:
break
my_list.append(addto)
</code></pre>
<p>The results I want are when I answer y for any of the conditional statements then the name append to the list. But when I do that the list still appears blank. For example I run the code</p>
<pre><code>addto_list()
Input: Jack
Can he do stage: y
can he do mic: y
can he do sound: y
print(my_list)
return: Jack
print(mic_list)
return: [] blank when it should say Jack
</code></pre>
| <python><string><list><input><append> | 2019-07-11 04:44:41 | LQ_CLOSE |
56,982,292 | Should I block certain charecters from my EditTexts for security reasons? | I've been programming for about 6 months now, but also did a bit if code about 10 years ago.
I remember back then I had to block some characters from text fields for security purposes, so people won't type in some code that would cause harm.
Is it still relevant in 2019? Should I be worried about anything of that sort?
I am using Cloud Firestore as my server.
** My app would allow all languages, so I can't limit what characters ARE allowed as there are way too many. | <android><security><android-edittext><google-cloud-firestore> | 2019-07-11 05:42:50 | LQ_EDIT |
56,982,330 | Getting an error - 'java: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown' | <p>import java.util.<em>;
import java.io.</em>;</p>
<p>public class Main {
public static void main(String args[]){</p>
<pre><code> int total = 0;
File file = new File("expenditure.txt");
Scanner fileScanner = new Scanner(file);
while (fileScanner.hasNextLine()) {
total += fileScanner.nextInt();
}
fileScanner.close();
System.out.println("The total expenditure is " + total);
}
</code></pre>
<p>}</p>
| <java><file> | 2019-07-11 05:46:08 | LQ_CLOSE |
56,983,904 | What is the best way for URL clustering in Map-reduce job java | I have a huge data set of URLs from various domains. I have to process them via mapreduce so that the URLs with similar pattern are grouped together. For example
http://www.agricorner.com/price/onion-prices/
http://www.agricorner.com/price/potato-prices/
http://www.agricorner.com/price/ladyfinder-prices/
http://www.agricorner.com/tag/story/story-1.html
http://www.agricorner.com/tag/story/story-11.html
http://www.agricorner.com/tag/story/story-41.html
https://agrihunt.com/author/ramzan/page/3/
https://agrihunt.com/author/shahban/page/5/
https://agrihunt.com/author/Sufer/page/3/
I want to group these URLs based on their pattern i.e., if URLs has similar pattern ( in reducer phase of Map-reduce). The expected output may be like
group1, http://www.agricorner.com/price/onion-prices/, http://www.agricorner.com/price/potato-prices/, http://www.agricorner.com/price/ladyfinder-prices/
group2, http://www.agricorner.com/tag/story/story-1.html, http://www.agricorner.com/tag/story/story-11.html, http://www.agricorner.com/tag/story/story-41.html
group3, https://agrihunt.com/author/ramzan/page/3/, https://agrihunt.com/author/shahban/page/5/, https://agrihunt.com/author/Sufer/page/3/
It it possible ? Is there any better approach that the supposed one? | <java><algorithm><mapreduce><grouping> | 2019-07-11 07:36:06 | LQ_EDIT |
56,984,488 | Counting Duplicate Row in Itab | ABAP Friends,
I need to count the number of duplicate row in ITAB base on one field.
I have tried create work area and counting the duplicate data but the problem its counting all duplicate data. my purpose is to count duplicate data by the same date.
DATA: gv_line TYPE i.
gv_line = 0.
LOOP AT i_sect_proe.
IF wa_sect_proe IS INITIAL.
wa_sect_proe = i_sect_proe.
CONTINUE.
ENDIF.
IF wa_sect_proe-/smr/wondat EQ i_final_f-/smr/wondat.
gv_line = gv_line + 1.
ENDIF.
i_sect_proe-/smr/line = gv_line.
ENDLOOP.
The code i've tried displaying number off all duplicate data. | <abap> | 2019-07-11 08:09:48 | LQ_EDIT |
56,985,435 | A PhP program to select album names from album mysql table, Did not understand usage of IF at preparing the statement? why should use IF at all? | $sql = "SELECT album_name FROM albums WHERE artist_id=?";
if($stmt = $link->prepare($sql)) // Doubt: why should you use if statement, can't we just write it without if statement?
{
$stmt->bind_param('i', $_POST['artist']);
$stmt->execute();
$stmt->bind_result($album);
while($stmt->fetch()) {
printf("Album: %s<br />", $album);
}
$stmt->close();
}
// Close the connection
$link->close(); | <php><mysqli> | 2019-07-11 09:02:02 | LQ_EDIT |
56,988,717 | How to target a component in svelte with css? | <p>How would I do something like this:</p>
<pre><code><style>
Nested {
color: blue;
}
</style>
<Nested />
</code></pre>
<p>i.e. How do I apply a style to a component from its parent?</p>
| <javascript><svelte><svelte-component> | 2019-07-11 12:01:16 | HQ |
56,989,797 | Should we be using two GraphQL tiers? | <p>I work on a project that uses a single GraphQL schema to expose data from REST APIs to various clients. The schema design is "owned" by the front-end teams, and is shaped to represent the universe as they see it. This neatly decouples the UI from the API tier, and is working fairly well.
Some (poorly designed but essential) APIs are relatively complex, and require domain knowledge (aka business logic) to compose the data into a form that maps to the UI schema, but that business logic is changing, as legacy APIs are pulled apart and rewritten - the problem therefore is twofold:</p>
<ol>
<li>We have unwanted business logic in the resolvers that populate GraphQL query responses</li>
<li>When an API team produce a new version of their service, and wants it to be called, the UI team are not necessarily ready to update their resolvers to call it</li>
</ol>
<p>I am considering introducing a second GraphQL instance that acts as the domain model, which will be owned by the API teams, and abstracts the details of how to call each API, and compose raw data to be consumed by the UI schema. It does introduce a small performance overhead, but on the plus side, decouples the Schema from the API implementation detail.</p>
<p>In researching this approach I have not found examples of this being attempted elsewhere so wondered if I'd missed any, or if this represents an anti-pattern that should be avoided? </p>
| <architecture><graphql> | 2019-07-11 12:58:13 | HQ |
56,990,649 | How to delete a pull request? | <p>I am getting a deployment error and I want to delete an unmerged pull request. I have to make changes to the pulled code and create a new PR.</p>
| <git><github> | 2019-07-11 13:42:24 | LQ_CLOSE |
56,990,893 | 500 Internal Server Error when I do a Include | <p>I'm trying to do an include in php, but when I execute the form submit Internal Server Error appears. If I delete the include this error does not appears. </p>
<p>I've tryed to change permissions and the owner of the forlders and files to www-data: but it doesn't work. </p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>
registro.
</title>
<meta charset="utf-8">
<script src="jquery.js"></script>
</head>
<body>
<form action="#" method="post">
<label for="user">Nombre de usuario:</label><input name="usuario" id="user" type="text"><br>
<label for="pass1">Contraseña:</label><input name="pass1" id="pass1" type="text"><br>
<label for="pass2">Repita Contraseña</label> <input name="pass2" id="pass2" type="text"><br>
<input type="submit" value="enviar">
</form>
<?php
if($_POST){
$user=$_POST['usuario'];
$pass1=$_POST['pass1'];
$pass2=$_POST['pass2'];
echo $pass1;
if(is_null($user)|| is_null($pass1)||is_null($pass2)){
echo 'Error, alguno de los datos no es válido';
}else{
if($pass1==$pass2){
include 'conexion.php';
$mysqli -> query("INSERT INTO USERS VALUES ('2','2')");
echo 'Realizado correctamente, Redirigiendo a pagina principal...';
header ("refresh :2,url=login.php");
}else{
echo 'Error, las contraseñas no coinciden';
}
}
}
?>
</body>
</html>
</code></pre>
<p>this is the mensage:
Internal Server Error</p>
<p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p>
<p>Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.</p>
<p>More information about this error may be available in the server error log.
Apache/2.4.25 (Debian) Server at localhost Port 80</p>
| <php><mysql><apache> | 2019-07-11 13:55:19 | LQ_CLOSE |
56,992,618 | how to include structures as header file | <p>I am trying to create a header file for my structure, but after I created the structure and included it in the main program it gives me error messages.</p>
<p>this is my header file</p>
<pre><code>#pragma once
#ifndef MYSTRUCT_H_INCLUDED
#define MYSTRUCT_H_INCLUDED
struct book{
int bknum;
string bname;
string author;
};
#endif // MYSTRUCT_H_INCLUDED
</code></pre>
| <c++><header><structure> | 2019-07-11 15:25:32 | LQ_CLOSE |
56,993,697 | How to fix this error in visual stodio 2017 | Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.
Cannot find wrapper assembly for type library "ADODB". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit.
The referenced component 'adodb1' could not be found. | <c#><visual-studio><visual-studio-2017> | 2019-07-11 16:32:31 | LQ_EDIT |
56,994,427 | Create a diffrent table in html | I want to create a table with less rows but with large columns where every 4th column right boundary is 2times thick of other boundary.
Example:
```
| | | | || | | | || | | | || | | | ||
| | | | || | | | || | | | || | | | ||
| | | | || | | | || | | | || | | | ||
```
consider "||" as double width of "|" | <javascript><html><css> | 2019-07-11 17:23:01 | LQ_EDIT |
56,995,330 | How to print all the instance in a class one by one? | This is the code. Error is in the last line. How to print all the instance in a class one by one?
error is : Traceback (most recent call last):
File "ex1.py", line 23, in <module>
print(n.age)
AttributeError: 'str' object has no attribute 'age'
class Person:
def __init__(self,fname,lname,age,gender):
self.fname = fname
self.lname = lname
self.age = age
self.gender = gender
class Children(Person):
def __init__(self,fname,lname,age,gender,friends):
super().__init__(fname,lname,age,gender)
self.friends = friends
a100 = Children("a1","a10",17,"male","a2 , a3 , a4 , a5")
a200 = Children("a2","a20",17,"male","a5, a1, a4, a3 ")
a300 = Children("a3", "a30" , 17 , "male", "a2, a1")
a400 = Children("a4","a40",17,"female", "a1, a2")
a500 = Children("a5","a50",16, "male","a2, a1")
x = ["a100","a300","a500","a200","a400"]
for n in x:
print(n.age)
| <python><python-3.x> | 2019-07-11 18:28:55 | LQ_EDIT |
56,995,824 | Best way to abstract wrapping C error handling with exceptions | <p>It is not uncommon for a useful C library to not provide C++ bindings. It's easy to call C from C++, but among other issues, a C++ project probably wants exceptions, rather than numerical error return values.</p>
<p>Is there any particular convention or trick for converting to exceptions without including an <code>if</code> and <code>throw</code> with each function call?</p>
<p>I wrote this solution for wrapping gphoto2 calls. Having to wrap the templated function in a macro is awkward (but the function name is kind of important for error messages; the logic here is similar to <code>perror</code>). </p>
<p>Is there a better technique, or any open source project that does this particularly well?</p>
<pre class="lang-cpp prettyprint-override"><code>#include <gphoto2/gphoto2.h>
#include <string>
class Gphoto2Error : public std::exception {
private:
std::string message;
public:
Gphoto2Error(std::string func, int err) {
message = func + ": " + std::string(gp_result_as_string(err));
}
const char *what() const throw() {
return message.c_str();
}
};
template <typename F, typename... Args>
void _gpCall(const char *name, F f, Args... args) {
int ret = f(args...);
if (ret != GP_OK) {
throw Gphoto2Error(name, ret);
}
}
#define gpCall(f, ...) ((_gpCall(#f, ((f)), __VA_ARGS__)))
int main() {
GPContext *ctx = gp_context_new();
Camera *camera;
gpCall(gp_camera_new, &camera);
gpCall(gp_camera_init, camera, ctx);
}
</code></pre>
| <c++><exception> | 2019-07-11 19:05:33 | HQ |
56,996,713 | Best way to setup a webhook for dialogflow? | I'm using the inline code editor with dialogflow. But i want to use an external webhook I just wasn't sure the best way to do this. I've got some experience with firebase and firebase functions - so if I wanted to create a firebase project i'd just run firebase init, etc. Can the url for the webhook be the firebase functions url?
In addition there are is the action on google github page https://github.com/actions-on-google/actions-on-google-nodejs where there are examples of writing conversational code for dialogflow using a dialogflow instance but the syntax for this is different to the syntax used in fulfilment. Just wondering the differences between writing code for actions on google versus dialogflow. | <dialogflow> | 2019-07-11 20:17:17 | LQ_EDIT |
56,997,725 | Make Equal-Width SwiftUI Views in List Rows | <p>I have a <code>List</code> that displays days in the current month. Each row in the <code>List</code> contains the abbreviated day, a <code>Divider</code>, and the day number within a <code>VStack</code>. The <code>VStack</code> is then embedded in an <code>HStack</code> so that I can have more text to the right of the day and number.</p>
<pre class="lang-swift prettyprint-override"><code>struct DayListItem : View {
// MARK: - Properties
let date: Date
private let weekdayFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "EEE"
return formatter
}()
private let dayNumberFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "d"
return formatter
}()
var body: some View {
HStack {
VStack(alignment: .center) {
Text(weekdayFormatter.string(from: date))
.font(.caption)
.foregroundColor(.secondary)
Text(dayNumberFormatter.string(from: date))
.font(.body)
.foregroundColor(.red)
}
Divider()
}
}
}
</code></pre>
<p>Instances of <code>DayListItem</code> are used in <code>ContentView</code>:</p>
<pre class="lang-swift prettyprint-override"><code>struct ContentView : View {
// MARK: - Properties
private let dataProvider = CalendricalDataProvider()
private var navigationBarTitle: String {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM YYY"
return formatter.string(from: Date())
}
private var currentMonth: Month {
dataProvider.currentMonth
}
private var months: [Month] {
return dataProvider.monthsInRelativeYear
}
var body: some View {
NavigationView {
List(currentMonth.days.identified(by: \.self)) { date in
DayListItem(date: date)
}
.navigationBarTitle(Text(navigationBarTitle))
.listStyle(.grouped)
}
}
}
</code></pre>
<p>The result of the code is below:</p>
<p><a href="https://i.stack.imgur.com/5notv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5notv.png" alt="Screenshot of app running in Xcode Simulator"></a></p>
<p>It may not be obvious, but the dividers are not lined up because the width of the text can vary from row to row. What I would like to achieve is to have the views that contains the day information be the same width so that they are visually aligned.</p>
<p>I have tried using a <code>GeometryReader</code> and the <code>frame()</code> modifiers to set the minimum width, ideal width, and maximum width, but I need to ensure that the text can shrink and grow with Dynamic Type settings; I chose not to use a width that is a percentage of the parent because I was uncertain how to be sure that localized text would always fit within the allowed width.</p>
<p>How can I modify my views so that each view in the row is the same width, regardless of the width of text?</p>
<p>Regarding Dynamic Type, I will create a different layout to be used when that setting is changed.</p>
| <swiftui> | 2019-07-11 21:50:18 | HQ |
57,000,597 | VBA to create Table with working days and the date for every month depending on the year | I would like to make a VBA to do to do the following:
*fill two columns in a table : first column for Days and second column for
Dates and it has only to be with working days(Mon-Fri) for the whole Month
*This is depending on two inputs in two cells (Year, Month)
*When and cell contains Fri as a day and starts again from Mon then the Frame between the two cells has to be Bold.
Would you please help me write the code? | <excel><vba> | 2019-07-12 05:19:40 | LQ_EDIT |
57,000,994 | GHC: Are there consistent rules for memoization for calls with fixed values? | <p>In my quest to understand and harness GHC automatic memoization, I've hit a wall: when pure functions are called with fixed values like <code>fib 42</code>, they are sometimes fast and sometimes slow when called again. It varies if they're called plainly like <code>fib 42</code> or implicitly through some math, e.g. <code>(\x -> fib (x - 1)) 43</code>. The cases have no seeming rhyme or reason, so I'll present them with the intention of asking what the logic is behind the behavior.</p>
<p>Consider a slow Fibonacci implementation, which makes it obvious when the memoization is working:</p>
<pre><code>slow_fib :: Int -> Integer
slow_fib n = if n < 2 then 1 else (slow_fib (n - 1)) + (slow_fib (n - 2))
</code></pre>
<p>I tested three basic questions to see if GHC (version 8.2.2) will memoize calls with fixed args:</p>
<ol>
<li>Can <code>slow_fib</code> access previous top-level calls to <code>slow_fib</code>?</li>
<li>Are previous results memoized for later non-trivial (e.g. math) top-level expressions?</li>
<li>Are previous results memoized for later identical top-level expressions?</li>
</ol>
<p>The answers seem to be:</p>
<ol>
<li>No</li>
<li>No</li>
<li>Yes [??]</li>
</ol>
<p>The fact that the last case works is very confusing to me: if I can reprint the result for example, then I should expect to be able to add them. Here's the code that shows this:</p>
<pre><code>main = do
-- 1. all three of these are slow, even though `slow_fib 37` is
-- just the sum of the other two results. Definitely no memoization.
putStrLn $ show $ slow_fib 35
putStrLn $ show $ slow_fib 36
putStrLn $ show $ slow_fib 37
-- 2. also slow, definitely no memoization as well.
putStrLn $ show $ (slow_fib 35) + (slow_fib 36) + (slow_fib 37)
putStrLn $ show $ (slow_fib 35) + 1
-- 3. all three of these are instant. Huh?
putStrLn $ show $ slow_fib 35
putStrLn $ show $ slow_fib 36
putStrLn $ show $ slow_fib 37
</code></pre>
<hr>
<p>Yet stranger, doing math on the results worked when it's embedded in a recursive function: this fibonacci variant that starts at Fib(40):</p>
<pre><code>let fib_plus_40 n = if n <= 0
then slow_fib 40
else (fib_plus_40 (n - 1)) + (fib_plus_40 (n - 2))
</code></pre>
<p>Shown by the following:</p>
<pre><code>main = do
-- slow as expected
putStrLn $ show $ fib_plus_40 0
-- instant. Why?!
putStrLn $ show $ fib_plus_40 1
</code></pre>
<p>I can't find any reasoning for this in any explanations for GHC memoization, which typically incriminate explicit variables (e.g. <a href="https://stackoverflow.com/questions/11466284/how-is-this-fibonacci-function-memoized">here</a>, <a href="https://stackoverflow.com/questions/34644761/haskell-memoization">here</a>, <a href="https://stackoverflow.com/questions/38167078/does-this-haskell-function-memoize">and here</a>). This is why I expected <code>fib_plus_40</code> to fail to memoize.</p>
| <haskell><ghc><memoization> | 2019-07-12 06:02:32 | HQ |
57,001,408 | why OrderByDescending not working in linq? | I have a query that returns weekending in datetime format, i want to sort it by descending but seems that order by not working..
see the [image][1]
```
var WeekEnd = db.mqTimeReportingTimeLogs.OrderByDescending(e=>e.tlWeekEnding).Select(c => c.tlWeekEnding).Distinct().ToList();
```
i also tried:
```
WeekEnd=WeekEnd.OrderByDescending(x=>x.tlWeekEnding).ToList();
```
but here x.tlWeekEnding does not appears
[1]: https://i.stack.imgur.com/q43iy.png | <c#><asp.net-mvc><linq> | 2019-07-12 06:37:26 | LQ_EDIT |
57,002,121 | How to merge two branches(master and demo branch) code in Git | <p>I've 2 branches,like master and demo.
I want to merge demo code in to master so please help me to solve this issue.
Branches
1 Master
2 demo</p>
| <android><git> | 2019-07-12 07:27:45 | LQ_CLOSE |
57,002,631 | Beginner Please Help: How to pass variables in this code? | //Inventory Items classs
import java.util.Scanner;
public class InventoryItems {
public int sackrice = 4;
public int animalfeed = 12;
public int trayeggs = 15;
public int bottlemilk = 9;
ItemSupplier supple = new ItemSupplier();
public void inventoryItem() {
System.out.println("\nAvailable items:\n");
sackrice = sackrice + supple.getRice();
System.out.println("Sack of rice: " + sackrice);
if(sackrice < 10)
System.out.println("Sack of rice low, please restock");
System.out.println();
System.out.println("Animal feed: " + animalfeed);
if(animalfeed < 10)
System.out.println("Animal feed low, please restock");
System.out.println();
System.out.println("Tray of eggs: " + trayeggs);
if(trayeggs < 15)
System.out.println("Tray of eggs low, please restock");
System.out.println();
System.out.println("Bottle of milk: " + bottlemilk);
if(bottlemilk < 15)
System.out.println("Bottle of milk low, please restock");
System.out.println();
press();
}
public static void press(){
Scanner input = new Scanner(System.in);
System.out.println("Press Enter to continue...");
String enter = input.nextLine();
}
}
//Item Supplier class
import java.util.Scanner;
public class ItemSupplier {
public int z;
Scanner scan = new Scanner(System.in);
public void ricesupplier() {
System.out.println("How many sacks of rice would you like to
order?");
z = scan.nextInt();
}
public int getRice() {
return z;
}
public void feedsupplier() {
}
public void eggsupplier() {
}
public void milksupplier() {
}
}
The "z" I get from getRice() is 0. It only takes the declared but initialized z. How do I get the "z" that was inputed in ricesupplier() method? Specfically, here: System.out.println("How many sacks of rice would you like to order?");
z = scan.nextInt(); I'm really just a beginner please help me. | <java> | 2019-07-12 07:59:49 | LQ_EDIT |
57,004,982 | sorting a json array by one field during iteration using JS | I have an array as follows
var array = {"week1":[{"id":1,"name":"x","mark":"20"},{"id":2,"name":"y","mark":"30"}],"week2":[{"id":1,"name":"x","mark":"40"},{"id":2,"name":"y","mark":"60"},{"id":3,"name":"z","mark":"10"}]}
I want to sort the array by mark field. How can I achieve this? | <javascript><arrays><sorting> | 2019-07-12 10:19:00 | LQ_EDIT |
57,006,470 | I want to generate all possible list from given range of list which will target given input sum | Input:target sum
output: count of all possible pairs of given sum from : **list[1,2,3]**
Example:
Input
4
Output
7
Explanation
1, 1, 1, 1
1, 2, 1
1, 1, 2
1, 3
2, 1, 1
2, 2
3, 1
Note: for these given pairs for explanation of output these all must be taken from only and only.....**[1,2,3]** for any input... | <python><python-3.x><list> | 2019-07-12 11:53:38 | LQ_EDIT |
57,006,663 | Could not get GOOGLE_APP_ID in Google Services file from build environment | <p>For setting up firebase i am using two config 1.GoogleService-Info-test.plist, 2.GoogleService-Info-prdn.plist for UAT and Production. For installing crashlytics using firebase i have followed firebase documentation <a href="https://firebase.google.com/docs/crashlytics/get-started?authuser=1#ios" rel="noreferrer">https://firebase.google.com/docs/crashlytics/get-started?authuser=1#ios</a>. But when i try to run, it throws error in build phase while running script.</p>
<p>I tried without changing config file name and it worked.</p>
<p>Error msg at build phase while running fabric run script "Could not get GOOGLE_APP_ID in Google Services file from build environment".</p>
<p>Can anyone suggest better solution to achieve my requirement.</p>
| <ios><swift><firebase><crashlytics> | 2019-07-12 12:05:35 | HQ |
57,007,245 | Wrapping a HTML tag that currently is in a string? | <p>I have HTML as a string, something like:</p>
<pre><code><p>some text</p><p>some more text</p><table><th>....</table>
</code></pre>
<p>I wish to wrap table in a div tag - table could be anywhere.</p>
<p>I've thought about using <code>replace</code> but I would have to replace both the opening table tag and the closing table tag.</p>
<p>Is there a way to just wrap the table element?</p>
<p>Vanilla JS only.</p>
| <javascript> | 2019-07-12 12:42:58 | LQ_CLOSE |
57,008,652 | GoLang size of compressed JSON madness | I'll try to clear up my question.
myJSON is a simple JSON string.
`len(myJSON)` = 78
e is `json.Marshal(myJSON)`
From what I understand, e is now a `[]byte`
Then I gzip e like this:
var buf bytes.Buffer
gz := gzip.NewWriter(&buf)
gz.Write(e)
gz.Close()
And `buf.Len()` = 96
So... why is my compressed buffer bigger than the original non-compressed string? | <json><go><gzip> | 2019-07-12 14:07:18 | LQ_EDIT |
57,008,746 | I got an error in a code which is related to NumPy Array please help me with the code | I am working with NumPy Array but I got error
I am running that code with Pycharm and getting error IndexError: invalid index to scalar variable.
''' python
import numpy as np
arr = np.array([1,2,5,8,3])
l1 = arr.argsort()[-3][::-1]
print(l1)
''' | <python><numpy> | 2019-07-12 14:12:15 | LQ_EDIT |
57,012,884 | Is it possible to do a function that detects the final part of an input to differentiate it from others? | I want to make a piece of code that detects the final part of an input to define what command to execute.
I am asking this like that because I have no clue of what to even start from. I've not tried anything, and I would like to know if its even possible before I start. My piece of code is what I know would work, but I want to make a lot of them, so I was wondering if you could possibly make it shorter than just adding the if's by hand, as if with a function.
```python
command = input()
if command == "add role_1"
role = 1
``` | <python> | 2019-07-12 19:15:41 | LQ_EDIT |
57,013,480 | library not found for -lRCTGeolocation | <p>Have installed react-native-firebase & and i'am using my project.xcworkspace for getting build on iOS with Xcode that was fine when I installed only auth & core packages. When i installed messaging package I get the error "library not found for -lRCTGeolocation" anyway. Some could help me?</p>
<p>react-native: 0.60.3
react-native-firebase: 5.5.4</p>
<p>Thansk in advance.</p>
<p>I delete the messaging reference from pod file I delete pods folder & podfile.lock file re installed pods, clean the build but didn't
solved.</p>
| <ios><xcode><react-native><react-native-firebase><pod> | 2019-07-12 20:08:40 | HQ |
57,013,503 | How can I write an if statement with multiple conditions using && and ||? | <p>I am making a tic tac toe board game and I need the user to enter any position between 1 to 9 then type in X or O. Some conditions I need include is that I want to restrict the user to enter any number greater than 9 and do not enter any character either than 'X' or 'O'. The problem I encounter is that it doesn't follow the conditional statement. Any help would be appreciated.</p>
<pre><code>void CreateBoard(int m, int n, char board[][n])
{
int i, j, position;
char one;
char two;
char temp;
char xORo;
int count = 0;
int end;
do {
printf("Enter the number of the cell you want to insert X or O or enter -1 to exit: \n");
scanf("%d", &position);
printf("Type X or O: \n");
scanf(" %c", &xORo);
if(position < 0){
break;
}
if((position > 9) && xORo != ('X') && ('O'))
{
continue;
}
else if((position > 0 || position < 9) && xORo == ('X') && ('O'))
{
switch(position)
{
case 1: temp = xORo;
xORo = board[0][0];
board[0][0] = temp;
break;
case 2: temp = xORo;
xORo = board[0][1];
board[0][1] = temp;
break;
case 3: temp = xORo;
xORo = board[0][2];
board[0][2] = temp;
break;
case 4: temp = xORo;
xORo = board[1][0];
board[1][0] = temp;
break;
case 5: temp = xORo;
xORo = board[1][1];
board[1][1] = temp;
break;
case 6: temp = xORo;
xORo = board[1][2];
board[1][2] = temp;
break;
case 7: temp = xORo;
xORo = board[2][0];
board[2][0] = temp;
break;
case 8: temp = xORo;
xORo = board[2][1];
board[2][1] = temp;
break;
case 9: temp = xORo;
xORo = board[2][2];
board[2][2] = temp;
break;
}
PrintBoard(3, 3, board);
}
}while(position != -1);
}
</code></pre>
| <c><if-statement><conditional-statements> | 2019-07-12 20:11:09 | LQ_CLOSE |
57,014,132 | Javascript change .css with variable from text box | Seems real simple but im missing something...
lets say I want this code below but I dont want the "12px" to be static.. i want to use the variable fontInput . How would I rewrite this?
```
var fontInput = document.getElementById("changesize").value;
$('.schedule-show').css({"font-size":"12px"});
``` | <javascript><jquery><css> | 2019-07-12 21:17:55 | LQ_EDIT |
57,015,003 | Log all queries in the official Postgres docker image | <p>I have a docker container based on Postgres's official docker image. I want to see the incoming queries when I look at the logs of the docker container using <code>docker logs -f</code>. This is my Dockerfile:</p>
<pre><code>FROM postgres:11.1-alpine
COPY mock_data.sql /docker-entrypoint-initdb.d/mock_data.sql
ENV PGDATA=/data
</code></pre>
<p>and this is the part of my docker-compose.yml file related to this service:</p>
<pre><code>version: '3'
services:
mock_data:
image: mock_data
container_name: mock_data
ports:
- 5434:5432/tcp
</code></pre>
<p>What is the eaasiest way to include the incoming queries in docker logs?</p>
| <postgresql><docker> | 2019-07-12 23:26:58 | HQ |
57,016,035 | C# Filling an array with classobjects | <p>I have a very basic questions and I feel like something fundamental is missing because none of my searches seems to answer my question.</p>
<p>What i want to achieve is to create a class lets say Dog with a couple of variablemembers, public int age, public string name, public string breed etc and make a classobject of said class which I would name MyDog and ask the user to give MyDog some values.</p>
<p>Lets say have a class with an array lets call it dogcage and i want to fill it with these class objects myDog from the user. </p>
<p>I thought it would be something like this, pardon my formating I only have a phone available.(code removed since the page didnt accept the formating)</p>
<pre><code>Dogcage[]mydogcage = {New mydog(5, "MrDog", "German shepherd")}
</code></pre>
<p>I think im way off on my array where is would need some guidance.
I also dont quite grasp how to name an array after something in a different class. I would usually just read more but I have read so much and feel a bit blocked on my logic where i cant reason properly any more. </p>
| <c#><arrays> | 2019-07-13 04:04:52 | LQ_CLOSE |
57,017,220 | Removing additional spaces in a table td | I have some spaces around each and every td in the question palette. hereby i have attached the screenshot.[Problem is displayed][1]
[1]: https://i.stack.imgur.com/VkvYh.jpg | <css> | 2019-07-13 07:52:09 | LQ_EDIT |
57,017,935 | (react-window) How to pass props to {Row} in <FixedSizeList>{Row}</FixedSizeList> | <p>I am using library called <a href="https://github.com/bvaughn/react-window" rel="noreferrer">react-window</a></p>
<p>When I pass props to its row like this:</p>
<pre><code>{Row({...props, {otherProps}})}
</code></pre>
<p>it gave me an error something like:</p>
<blockquote>
<p>React.createElement: type is invalid -- expected a string (for
built-in components) or a class/function (for composite components)
but got: ...</p>
</blockquote>
<p>How is the correct way to do that?</p>
| <reactjs><react-props><react-window> | 2019-07-13 09:37:47 | HQ |
57,020,667 | How to call main function from another header files's cpp file | i want to call main function form another header file's cpp file. where main included a header file.
lets call main.cpp has a header file. can i call main.cpp's main form header file's cpp .
This is main.cpp
``` #include "another.h"
int main()
{
cout<<"Main";
}
```
this is another.h
```class another
{
public:
void another_func(void);
};
```
this is another_func.cpp separate file
```void another::another_func(void)
{
//how do i call main()
}
``` | <c++><header-files><main> | 2019-07-13 15:52:16 | LQ_EDIT |
57,021,171 | Concatenate two vectors while preserving order in R | <p>This is hard to explain, so I'll try and then leave a simple example. When I concatenate the vectors, I would like the first element of each vector next to each other, then the second elements next to each other, etc. See example below. </p>
<pre><code>x <- c("a","b","c")
y <- c(1,2,3)
c(x,y)
[1] "a" "b" "c" "1" "2" "3"
</code></pre>
<p>However, I would like the following: </p>
<pre><code>[1] "a" "1" "b" "2" "c" "3"
</code></pre>
<p>I'm sure there is an answer on here already, but I'm having trouble putting in the right search. Any help appreciated!</p>
| <r><concatenation> | 2019-07-13 16:58:58 | LQ_CLOSE |
57,021,531 | Change total value of a stacked progress bar | I want to change stacked progress bar maximum value,By default it will
take 100
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar"
style="width:20%">
Abc
</div>
<div class="progress-bar progress-bar-warning" role="progressbar"
style="width:30%">
dfgdf
</div>
</div>
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/P9eYm.png
In this image i want to give maximum value 60 but it will take 100. | <twitter-bootstrap> | 2019-07-13 17:47:50 | LQ_EDIT |
57,021,722 | SwiftUI Optional TextField | <p>Can SwiftUI Text Fields work with optional Bindings? Currently this code:</p>
<pre><code>struct SOTestView : View {
@State var test: String? = "Test"
var body: some View {
TextField($test)
}
}
</code></pre>
<p>produces the following error:</p>
<blockquote>
<p>Cannot convert value of type 'Binding< String?>' to expected argument type 'Binding< String>'</p>
</blockquote>
<p>Is there any way around this? Using Optionals in data models is a very common pattern - in fact it's the default in Core Data so it seems strange that SwiftUI wouldn't support them</p>
| <swiftui> | 2019-07-13 18:17:20 | HQ |
57,021,983 | Why does the program run the lines after line 13 | I want to make a program that gets a number input and finds the closest perfect square to determine the square length. Thus, the closest perfect square has to be less than the input. For example, if the input is 8, the largest side length of the square is 2.
import java.util.Scanner;
public class J1 {
public static void main(String[] args) {
int a;
int a1;
Scanner number = new Scanner(System.in);
System.out.println("Number: ");
a = number.nextInt();
int n = (int) Math.sqrt(a1);
for (int a1=a; a1<a; a1--) {
if (Math.floor(a1)==0)
System.out.println("The largest square has side length" + a1);
}
}
} | <java><for-loop><perfect-square> | 2019-07-13 18:53:57 | LQ_EDIT |
57,023,018 | Python List comprehension execution order | <pre><code>matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
squared = [[x**2 for x in row] for row in matrix]
print(squared)
</code></pre>
<p>In the preceding data structure and list comprehension, what is the order of execution? </p>
<p>Visually it appears to process from right to left. Considering the nested list first has to be access before each of its individual items can be squared.</p>
| <python><list-comprehension> | 2019-07-13 21:36:29 | LQ_CLOSE |
57,023,251 | Adding to an Array in C/C++ with no size | <p>The following code compiles and outputs <code>6</code>:</p>
<pre><code>#include <stdio.h>
int main(){
int a[]={};
a[0] = 5;
a[1] = 6;
printf("%d\n", a[1]);
return 0;
}
</code></pre>
<p>Is this correct or am I getting into undefined behaviour and this code woks by luck? Can I add to an array with no size?</p>
| <c++><c> | 2019-07-13 22:25:13 | LQ_CLOSE |
57,023,772 | Why is my operater "<" undefined for the argument type(s) boolean, int | <p>If the input is between a certain value I want the formula to be different than when the input falls between another range. However, when I write my if statement, I am getting an error that states "The operator < is undefined for the argument type(s) boolean, int".</p>
<p>import java.util.Scanner;</p>
<p>public class jOne {</p>
<pre><code>public static void main(String[] args) {
System.out.println("Enter daytime minutes:");
Scanner a = new Scanner(System.in);
String daytime = a.nextLine();
double daytime1 = Integer.parseInt(daytime);
System.out.println("Enter evening minutes:");
Scanner b = new Scanner(System.in);
String evening = b.nextLine();
Integer.parseInt(evening);
double evening1 = Integer.parseInt(evening);
System.out.println("Enter weekend minutes:");
Scanner c = new Scanner(System.in);
String weekend = c.nextLine();
Integer.parseInt(weekend);
double weekend1 = Integer.parseInt(weekend);
if (0 < daytime1 < 100) {
double PlanA = (((daytime1 - 100)) + (evening1 * 0.15)+(weekend1 * 0.20));
double PlanB = (((daytime1 - 250)) + (evening1 * 0.35)+(weekend1 * 0.25));
}
else if (100 < daytime1 < 250) {
double PlanA = (((daytime1 - 100)*0.25) + (evening1 * 0.15)+(weekend1 * 0.20));
double PlanB = (((daytime1 - 250)) + (evening1 * 0.35)+(weekend1 * 0.25));
}
else if (daytime1 > 250) {
double PlanA = (((daytime1 - 100)*0.25) + (evening1 * 0.15)+(weekend1 * 0.20));
double PlanB = (((daytime1 - 250)*0.45) + (evening1 * 0.35)+(weekend1 * 0.25));
}
</code></pre>
| <java><integer><boolean><arguments><operators> | 2019-07-14 00:39:27 | LQ_CLOSE |
57,023,899 | How to get the status bar height in iOS 13? | <p>In iOS 13 <code>UIApplication.shared.statusBarFrame.height</code> warns</p>
<blockquote>
<p>'statusBarFrame' was deprecated in iOS 13.0: Use the statusBarManager
property of the window scene instead.</p>
</blockquote>
<p>How do you get the status bar height without using a deprecated API in iOS 13?</p>
| <ios><ios13> | 2019-07-14 01:16:12 | HQ |
57,025,199 | How to import a project from GitLab to intellij? | I know how to clone a project from `Github` to `intellij`, but i need to clone a project from `Gitlab`.
The problem is, intellij does not have a Gitlab option?
As far as i can see, it only supports `Git`, `Mercurial` and `Subversion`.
[![enter image description here][1]][1]
You can find the version of intelij in the below image:
[![enter image description here][2]][2]
How can i import a `GitLab` project into the `Intelij`?
[1]: https://i.stack.imgur.com/tSkKU.png
[2]: https://i.stack.imgur.com/1l8U4.png | <intellij-idea><gitlab> | 2019-07-14 06:50:25 | LQ_EDIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.