Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
59,900,533 | How can I draw lines with html, css and js | <p>I'm working on a Personal web project I need to draw lines from 2 inputs to a third one.</p>
<p>How can I draw the lines (D in picture) using HTML, CSS and Js ?</p>
<p><a href="https://i.stack.imgur.com/IC4eH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IC4eH.png" alt="enter image description here"></a></p>
<p><strong>EDIT:</strong> Ths inputs can be inside div blocks.</p>
| <javascript><html><css><draw> | 2020-01-24 16:39:46 | LQ_CLOSE |
59,900,538 | Shared component library best practices | <p>I am creating a shareable React component library. </p>
<p>The library contains many components but the end user may only need to use a few of them. </p>
<p>When you bundle code with Webpack (or Parcel or Rollup) it creates one single file with <em>all the code</em>. </p>
<p>For performance reasons I do not want to all that code to be downloaded by the browser unless it is actually used.
Am I right in thinking that I should not bundle the components? Should the bundling be left to the consumer of the components?
Do I leave anything else to the consumer of the components? Do I just transpile the JSX and that's it?</p>
<p>If the same repo contains lots of different components, what should be in main.js?</p>
| <reactjs><npm><webpack><es6-modules><rollup> | 2020-01-24 16:40:06 | HQ |
59,900,637 | Error "TestEngine with ID 'junit-vintage' failed to discover tests" with Spring Boot 2.2 | <p>I have a simple app using Spring Boot and Junit 5:</p>
<ul>
<li><p>When using Spring Boot 2.1 (e.g, 2.1.8 or 2.1.12), my unit tests run
smoothly</p></li>
<li><p>When using Spring Boot 2.2 (e.g., 2.2.2.RELEASE or 2.3.2.RELEASE) my unit tests fail with error message </p></li>
</ul>
<pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projets\workspace\XXX\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:656)
</code></pre>
<p>I am using Maven 3.6.1, JDK 1.8, JUnit 5.6.0 and JUnit platform 1.6.0. I exclude the dependency on <code>junit:junit</code> from <code>spring-boot-starter-test</code>, so that I have no JUnit 4 artifacts left in the dependency tree. Note that both Spring Boot 2.2 and 2.3 use <code>maven-surefire-plugin</code> 2.22.2, so my problem does not originate from any regression of the <code>maven-surefire-plugin</code>.</p>
<p>Should I stick to Spring Boot <strong>2.1</strong> in order to have my unit test working?</p>
<p>Thanks in advance for your help.</p>
| <spring-boot><junit5> | 2020-01-24 16:47:41 | HQ |
59,901,898 | How to check .Net framework installed on Windows | <p>How to check .Net framework installed on Windows using power shell or any programmatically? I have been checking the registry key value in path <strong>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP</strong> and referring to below link <a href="https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed</a>.</p>
<p>Recently figured out way to get .Net framework version installed using PowerShell.</p>
| <.net> | 2020-01-24 18:31:11 | LQ_CLOSE |
59,902,516 | adding a tag when a button is clicked | <p>I need a script when the selected text is surrounded by tags after clicking on the button. For example, there was the text</p>
<blockquote>
<p>This is my text, I love read</p>
</blockquote>
<p>I selected "my text" and then clicked on the button, and this text becomes surrounded by tags, for example</p>
<blockquote>
<p>This is < myTag >my text< /myTag >, I love read</p>
</blockquote>
<p>The principle of operation is the same as that of text editors, when you can change fonts and style of the text, but I need to surround the text with my tag. How can I do it?</p>
| <javascript><css> | 2020-01-24 19:23:32 | LQ_CLOSE |
59,902,752 | Unlimited ArrayList in Java | <p>I need to make trivial array of strings in Java but I can not find a simple way to do it. I try to use <code>List<String> myList = new ArrayList<>();</code> but implementation says this is limited to 10 items. The question is simple how to make array of strings without limit which is able to add new items and iterate in for cycle around it. </p>
| <java><list> | 2020-01-24 19:41:05 | LQ_CLOSE |
59,903,635 | Angular 8 and Observable that waits for another observable | <p>I need the data of observable1, but I need it only when observable2 is set to <code>true</code>. It is set to <code>true</code> AFTER the data of observable1 changes. How can I chain the two observables so that I will get the data of observable1 every time it changes, but that these results will wait for the change of observable2 before they are being used? </p>
| <angular><rxjs><observable> | 2020-01-24 21:01:04 | LQ_CLOSE |
59,904,445 | PHP : preg_replace_callback() not working if occurrence starts with a number | I'm using **preg_replace_callback()** with a regex to pick up some heading content and create an ID based on the content but it seems that it's not working if the occurrence begins with a number and I don't understand where I'm wrong. Here is the code I'm using :
function betterId($match){
$escape = str_split(strip_tags($match[2]), 20);
$id = strlen($escape[0]) >=5 ? function_to_makeItClear($escape[0]) : str_shuffle('AnyWordsHere');
return '<h'.$match[1].' id="'.$id.'">'.$match[2].'</h'.$match[1].'>';
}
return preg_replace_callback('#<h([1-6]).*?>(.*?)<\/h[1-6]>#si', 'betterId', $texte);
Here is the text I want to transform
<p>Paragraph one is okay </p>
<h2>This will work without problem</h2>
<p>Paragraph two is okay </p>
<h2>This heading too</h2>
<p>Paragraph one is okay </p>
<h2>This item list will work too</h2>
<p>Paragraph two is okay </p>
<h3>1. <a href="https://www.example1.com/">This wont work</a></h3>
<p>Paragraph one is okay </p>
<h3>2. <a href="https://www.example2.com/">Not working</a></h3>
<p>Paragraph two is okay </p>
<h3>3. Neither this one</h3>
<h3>But this works again</h3>
I would like to have something like this :
<p>Paragraph one is okay </p>
<h2 id="this-will-work">This will work without problem</h2>
<p>Paragraph two is okay </p>
<h2 id="this-heading-too">This heading too</h2>
<p>Paragraph one is okay </p>
<h2 id="this-item-list">This item list will work too</h2>
<p>Paragraph two is okay </p>
<h3 id="this-wont-work">1. <a href="https://www.example1.com/">This wont work</a></h3>
<p>Paragraph one is okay </p>
<h3 id="not-working">2. <a href="https://www.example2.com/">Not working</a></h3>
<p>Paragraph two is okay </p>
<h3 id="neither-this-one">3. Neither this one</h3>
<h3 id="but-this-works">But this works again</h3>
Any help will be greatly appreciated | <php><html> | 2020-01-24 22:23:45 | LQ_EDIT |
59,904,576 | My assembly "quiz Multiply" code is not working at all? | this is my assembly code . it not working at all..
I tried to write it in another way but it gives me other mistakes
I use emu8086..... in first page there will be 3 pages (1,2,3) and you have to choose which
page.
1- study 2-exam 3-exit
1-study: will learn Multiplication table from 0-9
2-exam: questions about mult from 0-9
3-exit from the quiz
and after finish quiz there will be mark.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
multi-segment executable file template.
data segment
firstpage db "welcome to learn math ",10,13,"create by:saad ",10,13,"1.study",10,13,"2.exam",10,13,"3.exit" ,10,13,"$"
q1 db "2*1=$"
q2 db "2*2=$"
q3 db "2*3=$"
q4 db "2*4=$"
q5 db "2*5=$"
std1 db "2*1=1 $"
std2 db "2*2=4 $"
std3 db "2*3=6 $"
std4 db "2*4=8 $"
std5 db "2*5=10 $"
nl db ,10,13,"$"
mark0 db "your mark us:0 $"
mark1 db "your mark us:20 $"
mark2 db "your mark us:40 $"
mark3 db "your mark us:60 $"
mark4 db "your mark us:80 $"
mark5 db "your mark us:100 $"
count db 0
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
mov ax, data
mov dx, ax
lea dx, firstpage
mov ah, 9
int 21h
mov ah,7
int 21h
cmp al,3
je t1
t1: mov ax,3
int 21h
lea dx,std1
int 21h
mov ah,7
int 21h
lea dx ,nl
mov ah,9
int 21h
lea dx,std2
int 21h
mov ah,7
int 21h
lea dx ,nl
mov ah,9
int 21h
lea dx,std3
int 21h
mov ah,7
int 21h
lea dx ,nl
mov ah,9
int 21h
lea dx,std4
int 21h
mov ah,7
int 21h
lea dx ,nl
mov ah,9
int 21h
lea dx,std5
int 21h
mov ah,7
int 21h
lea dx ,nl
mov ah,9
int 21h
mov ah,7
int 21h
lea dx ,q1
mov ah,9
int 21h
lea dx ,nl
mov ah ,9
int 21h
lea dx ,q2
mov ah,9
int 21h
lea dx ,nl
mov ah ,9
int 21h
lea dx ,q3
mov ah,9
int 21h
lea dx ,nl
mov ah ,9
int 21h
lea dx ,q4
mov ah,9
int 21h
lea dx ,nl
mov ah ,9
int 21h
lea dx ,q5
mov ah,9
int 21h
lea dx ,nl
mov ah ,9
int 21h
mov ah,1
int 21h
cmp count,0
je mark0
cmp count,1
je mark1
cmp count, 2
je mark2
cmp count,3
je mark3
cmp count,4
je mark4
cmp count,5
je mark5
mark0:lea dx,mark0
mov ah,9
int 21h
jmp soof
mark1:lea dx,mark1
mov ah,9
int 21h
jmp soof
mark2:lea dx,mark2
mov ah,9
int 21h
jmp soof
mark3:lea dx,mark3
mov ah,9
int 21h
jmp soof
mark4:lea dx,mark4
mov ah,9
int 21h
jmp soof
mark5:lea dx,mark5
mov ah,9
int 21h
jmp soof
mov ax, 4c00h
int 21h
ends
end start
<!-- end snippet -->
| <assembly><dos><x86-16><emu8086> | 2020-01-24 22:38:25 | LQ_EDIT |
59,905,201 | How can I solve this problem without using lists? | <p>Problem: You're a swimmer, and you want to compare all of your race times to find the fastest one. Write a program that continuously takes race times as doubles from standard input, until the input is "no more races," at which point it should print out the time of your fastest race.</p>
<p>The answer I found on another thread was using lists like:</p>
<pre><code>list1 = []
race_time = input("Enter a race time or type no more races to quit: ")
while race_time != "no more races":
list1.append(float(race_time))
race_time = input("Enter a race time or type no more races to quit ")
print(min(list1))
</code></pre>
<p>The problem is from if-else, and loops chapter and lists aren't introduced to us yet. How would I store the race times and compare them?</p>
| <python> | 2020-01-25 00:12:05 | LQ_CLOSE |
59,907,578 | Using Dart (webdev) to write a js library / expose a dart api to js. IN THE BROWSER | <p>Please give a simple but complete example showing how to write a library in dart that can be used from javascript in the browser without using requirejs. </p>
<p>The library should contain a function, a class and a global variable. </p>
<p>A reference to sass-dart is not a solution to that problem because it is for use with nodejs and requirejs.</p>
| <dart><dart-js-interop> | 2020-01-25 08:26:01 | LQ_CLOSE |
59,908,100 | How to show increment of counter in my ui in flutter? | <p>I have declared a variable called ticketCounter that is getting stored in SharedPrefs. This variable is getting incremented and decremented as needed. However I wanted to display this counter on my appBar and want its value to update. Although the value is getting stored in the variable it isn't showing up. </p>
<pre><code> int tickets;
void fetchTickets() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
tickets = prefs.getInt('ticketRW') ?? 0;
}
void initState() {
portraitModeOnly();
fetchTickets();
super.initState();
}
Widget build(BuildContext context) {
return Material(
child: Scaffold(
appBar: AppBar(
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 14, right: 14),
child: Text(
tickets.toString(),//isn't getting updated
style: TextStyle(
fontSize: 22,
fontFamily: "Netflix",
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
),
),
),
}
</code></pre>
| <user-interface><flutter><dart> | 2020-01-25 09:43:54 | LQ_CLOSE |
59,908,682 | java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference | <p>Everything working fine i got this error at the end please give solution. I have tried each and every solution, I don't know what to do.. please give the exact solution trying from past 2 days but i can't solve the problem..</p>
<p>Thanks in advance</p>
<pre><code>public double calculatedDistance(DataSnapshot dataSnapshot ) {
HashMap<String, Object> values = (HashMap<String, Object>) dataSnapshot.getValue();
double lati = Double.parseDouble(values.get("latitude").toString());
double longi = Double.parseDouble(values.get("longitude").toString());
double xSquare = Math.pow(lat-lati, 2);
double ySquare = Math.pow(lng-longi, 2);
double distance = Math.sqrt(xSquare + ySquare);
//double dist = distance;
textViewdistance.setText(String.valueOf(""+distance+""+"km"));
return distance;
}
</code></pre>
<pre><code>Error in Logcat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ambulance, PID: 17399
java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
at com.example.ambulance.MapsActivity.calculatedDistance(MapsActivity.java:451)
at com.example.ambulance.MapsActivity$2$1.onChildAdded(MapsActivity.java:178)
at com.google.firebase.database.core.ChildEventRegistration.fireEvent(com.google.firebase:firebase-database@@19.2.0:79)
at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@19.2.0:63)
at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@19.2.0:55)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
</code></pre>
| <java><android><firebase-realtime-database><maps><double> | 2020-01-25 11:13:36 | LQ_CLOSE |
59,908,685 | which version of java supported by eclipse helios? | im new to eclipse and java.whenever i run the java program in eclipse there is a major.minor 52 exception.i want to know which version of java is supported by eclipse helios. My computer is windows 7 32 bit os. so i cant download any other version of eclipse. plzz help me with a favourable answer
| <java><eclipse><testing><selenium-webdriver><helios> | 2020-01-25 11:14:31 | LQ_EDIT |
59,909,606 | Java - NullPointerExceptioneven when variable has been set in constructor | <p>I have made this code, but it seems that it throws a NullPointerException even when it has been set.
This is the code (I am aware my code is not future proof or optimised at all. Please do not comment about it). I have tried passing the reference to the method Main, but that doesn't seem to work.</p>
<p>MainTest.java</p>
<pre><code>public class MainTest {
public static void main(String[] args) {
for (int i = 0; i < 500; i++) {
Main main = new Main();
main.run();
}
}
}
</code></pre>
<p>Main.java</p>
<pre><code>public class Main {
Chicken[] chickenList = new Chicken[8388607];
int counter = 0;
public void run() {
for (int i = 0; i < 4; i++) {
chickenList[counter++] = new Chicken(Chicken.ADULT, this);
}
for (int i = 0; i <= 7200; i++) {
for (Chicken chicken : chickenList) {
if (chicken != null) {
if (chicken.getAdultOrBaby() == Chicken.ADULT) {
chicken.layEgg();
} else {
chicken.hasGrown();
}
} else {
break;
}
}
}
System.out.println(amountOfChickens());
}
public void newChicken() {
chickenList[counter++] = new Chicken(Chicken.CHILD, this);
}
public int amountOfChickens() {
int amount = 0;
for (Chicken chicken : chickenList) {
if (chicken != null) {
amount++;
} else {
return amount;
}
}
return amount;
}
}
</code></pre>
<p>Chicken.java</p>
<pre><code>import java.util.Random;
public class Chicken {
Random random = new Random();
private int timeAlive;
private int timeSinceLastEgg;
private int adultOrBaby;
private int randomTimer;
public static final int ADULT = 0;
public static final int CHILD = 1;
public static Main caller;
public Chicken(int adultBaby, Main callers) {
caller = callers;
timeAlive = 0;
timeSinceLastEgg = 0;
adultOrBaby = adultBaby;
if (adultOrBaby == ADULT) {
randomTimer = newRandomTimer();
}
}
public int getAdultOrBaby() {
return adultOrBaby;
}
public void hasGrown() {
if (++timeAlive == 1200) {
adultOrBaby = ADULT;
}
}
private int newRandomTimer() {
return random.nextInt(300);
}
public void layEgg() {
timeAlive++;
if ((++timeSinceLastEgg) == (300 + randomTimer)) {
new Egg(caller);
timeSinceLastEgg = 0;
randomTimer = newRandomTimer();
}
}
}
</code></pre>
<p>Egg.java</p>
<pre><code>import java.util.Random;
public class Egg {
Main caller;
Random random = new Random();
private static final int WILL_HATCH = 2;
private final int WILL_4 = 3;
public Egg(Main callers) {
if (random.nextInt(8) == WILL_HATCH) {
if (random.nextInt(32) == WILL_4) {
spawn4();
} else {
spawn();
}
}
caller = callers;
}
private void spawn4() {
for (int i = 0; i < 4; i++) {
caller.newChicken();
}
}
private void spawn() {
caller.newChicken();
}
}
</code></pre>
<p>And this is the output:</p>
<pre><code>Exception in thread "main" java.lang.NullPointerException
at Egg.spawn(Egg.java:27)
at Egg.<init>(Egg.java:14)
at Chicken.layEgg(Chicken.java:40)
at Main.run(Main.java:13)
at MainTest.main(MainTest.java:5)
</code></pre>
| <java><class><methods> | 2020-01-25 13:19:51 | LQ_CLOSE |
59,912,085 | Hash of a complex structure | <p>I'd like to know a relatively simple way to generate the hash of a complex C structure (which form a graph, in my case). By "simple" I mean, if possible, without having to go through all the nodes it forms. My goal would be, afterwards, to check if two structures are identical thanks to their hash, but also to sort them in an orderly way.</p>
<p>There are functions and algorithms for numbers or strings for instance, but I don't know a good way to do it for a structure. What would you recommend? </p>
| <c><hash> | 2020-01-25 18:13:24 | LQ_CLOSE |
59,912,529 | ESP32 CAM - EEPROM / sdcard / non erasable memory - beginier problem | {overwiew}
I am working on my first project with ESP32, I have ESP32 CAM model and I am creating an automatic roller blinds. I got most of the project working - I have web server that controls continous servo and all mechanics. I want to be able to adjust the time for going up-down without reprograming the microcontroller. The goal is to have an automatic roller blinds with alarm clock function.
{problem}
I need a way to reliable save/read data to store variables state, even without power. How to achive it with ESP32 CAM?
{additional info}
On arduino board that would be EEPROM, and I found some tutorials that claim that EEPROM can be used on ESP32. However, when I tried using EEPROM, it looks like the values are overwritten while bootloading. So I guess ESP32 CAM needs different approach. Correct me if I am wrong, please. | <arduino><microcontroller><esp32><eeprom> | 2020-01-25 19:06:26 | LQ_EDIT |
59,913,082 | How to send an Image which is in uri file by email in c# | <p>I want to send a picture via email through the code in c#, but I get the picture I need to send as a URI.
I saw that to send I need the location of the image but I only have the image as URI.</p>
<p>Is it possible?</p>
| <c#><image><email><uri> | 2020-01-25 20:22:15 | LQ_CLOSE |
59,913,250 | mkdir immediatly after rmdir gives me access denied | <p>I have a folder (let's call it <code>F</code>). </p>
<p>I wrote a batch file that does</p>
<pre><code>rmdir F /S /Q
mkdir F
</code></pre>
<p>When I call the mkdir <code>F</code>, it gives me access denied, probably because the system may be still deleting <code>F</code>. How can I do to deal with this problem?</p>
| <batch-file><mkdir><rmdir> | 2020-01-25 20:45:51 | LQ_CLOSE |
59,913,470 | Getting different results when dereferencing a pointer to an integer | <pre><code>#include<stdlib.h>
#include<iostream>
using namespace std;
void fun(int* a){
int b=*a++;
cout<<b<<endl;
}
void fun1(int *a){
int b=*a+1;
cout<<b<<endl;
}
int main(){
int n=5;
fun(&n);//output remains 5
fun1(&n);//output incremented by 1
}
</code></pre>
<p>In the function fun the value of n does not get incremented when done as shown in the above code, on the other hand in function fun1 the value of n gets incremented by 1.What is the problem with the first approach to increment n?</p>
| <c++><function><pointers><dereference> | 2020-01-25 21:16:28 | LQ_CLOSE |
59,913,580 | What does (1UL << 22) mean in MySQL Source Code Documentation | <p>I am updating an existing library in Java I have to connect to MySQL 8 but the source code documentation has a #DEFINE I don't understand. I'm looking specifically at the client capability flags at <a href="https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html</a>. </p>
<p>Some of the capability flags show the decimal value so I can convert them to unix for easier bitmasking but there's some flags like <code>CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS</code> which has the value of <code>(1UL << 22)</code>.
I have no idea what <code>(1UL << 22)</code> means to be able convert that to something I can use in java. </p>
| <java><mysql><mysql-8.0> | 2020-01-25 21:31:03 | LQ_CLOSE |
59,913,765 | Convert factor to number with this command correct | <p>Im trying to convert the following factor to number in RStudio, can I use this commands?</p>
<p><code>NewFactor <- factor(c(31, 764, 9.6, 513, 125.344, 3131.657, 9853));as.numeric(NewFactor)</code></p>
| <r><type-conversion> | 2020-01-25 21:57:32 | LQ_CLOSE |
59,914,412 | Skipping lines in a txt file and returning them | <p>I need some help completing this problem. I have no idea how to tackle this at all and I need to finish it.</p>
<p>"Q: Sometimes, when processing a file, some number of header, comment, or documentation lines at the beginning of a file must be omitted from the processing and skipped over before processing the remaining lines in the file. Consider the addition of parameter, skiplines with a default value of 0 for the previous problem:</p>
<p>lineLengths(filepath, skiplines=0)
The function should skip the specified number of lines and then, for the remainder of the lines, compute a list of (line number, line length) tuples, one per processed lines. The line number advances, even for the skipped lines. Line lengths should exclude any leading or trailing whitespace (spaces, tabs, trailing newline). So for the tennyson.txt file:</p>
<p>Twilight and evening bell,<br>
And after that the dark! </p>
<p>And may there be no sadness of farewell,<br>
When I embark;<br>
the result of lineLengths("tennyson.txt", skiplines=2) is the list of tuples: [(3, 0), (4, 40), (5, 14)] since lines 1 and 2 are skipped, and line 3 is an empty line, consisting of just a newline."</p>
| <python> | 2020-01-25 23:51:20 | LQ_CLOSE |
59,916,267 | java.util.ConcurrentModificationException in activity onCreate | <p>In a recent release where I added MoPub via Admob ad mediation I am seeing a bunch of ConcurrentModificationException in crash logs. It all seems to be native code and I am on the latest version of all ad related and google/android related libraries. Anyone run in to this before?</p>
<pre><code>java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3121)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3264)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1955)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7078)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:964)
Caused by: java.util.ConcurrentModificationException:
at androidx.c.g.put (SimpleArrayMap.java:482)
at com.google.android.gms.measurement.internal.hs.a
at com.google.android.gms.measurement.internal.hi.onActivityCreated
at android.app.Application.dispatchActivityCreated (Application.java:245)
at android.app.Activity.onCreate (Activity.java:1108)
at androidx.core.app.e.onCreate (ComponentActivity.java:81)
at androidx.activity.b.onCreate (ComponentActivity.java:149)
at androidx.fragment.app.c.onCreate (FragmentActivity.java:313)
at androidx.appcompat.app.e.onCreate (AppCompatActivity.java:106)
at com.teamtol.livedota.BaseActivity.onCreate (BaseActivity.java:21)
at com.teamtol.livedota.RecentGameActivity.onCreate (RecentGameActivity.java:70)
at android.app.Activity.performCreate (Activity.java:7327)
at android.app.Activity.performCreate (Activity.java:7318)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1275)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3101)
</code></pre>
<p>This is what the code looks like up to line 21 of BaseActivity:</p>
<pre><code>protected void onCreate(Bundle savedInstanceState) {
supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
super.onCreate(savedInstanceState);
</code></pre>
<p>This is what the code looks like up to line 70 of RecentGameActivity</p>
<pre><code>public class RecentGameActivity extends BaseActivity implements AdapterView.OnItemSelectedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
</code></pre>
| <java><android><admob><mopub> | 2020-01-26 07:04:09 | HQ |
59,917,340 | Can't cast interface{} to []map[string]interface{} directly | <p>I have method which accepts <code>map[string]interface{}</code> parameters (it comes from parsed YAML file):</p>
<pre class="lang-golang prettyprint-override"><code>func load(params map[string]interface{}) error {
}
</code></pre>
<p>This method is trying to extract one element from <code>params</code> and cast it to <code>map[string]interface{}</code>:</p>
<pre class="lang-golang prettyprint-override"><code>if tmp, has := params["badges"]; has {
if badges, ok := tmp.([]map[string]interface{}); ok {
// ...
} else {
return fmt.Errorf("expected []map[string] but was: %T", tmp)
}
}
</code></pre>
<p>When I run this method with correct <code>params</code> (with element <code>badges</code> of type <code>[]map[string]string</code>) it fails with error:</p>
<blockquote>
<p>expected []map[string] but was: []interface {}</p>
</blockquote>
<p>But if I go through all items manually and cast them one by one, it will be OK:</p>
<pre class="lang-golang prettyprint-override"><code>lst := tmp.([]interface{})
ifaces := make([]map[interface{}]interface{}, len(lst), len(lst))
for pos, item := range lst {
ifaces[pos] = item.(map[interface{}]interface{})
}
badges := make([]map[string]interface{}, len(lst), len(lst))
for pos, mp := range ifaces {
badges[pos] = make(map[string]interface{})
for k, v := range mp {
badges[pos][k.(string)] = v
}
}
</code></pre>
<p>But the second solution looks overcomplicated for just casting one type to another. Is it possible to cast <code>interface{}</code> to list of maps simpler?</p>
| <go><casting> | 2020-01-26 10:12:35 | LQ_CLOSE |
59,918,015 | JS parse string always as string and no number evaluation | <p>Example:</p>
<pre><code>var garbage = JSON.parse('12345E666');
</code></pre>
<p>=> infinity
while </p>
<pre><code>var garbage = JSON.parse('1234E300');
</code></pre>
<p>=> 1.234e+303</p>
<p>As you can see, this is rather rotten and definitely not what I want. </p>
<p>The task at hand is to receive a string ... and it should remain as such.
I have looked at JSON.stringify already, but this is also not what I want:</p>
<p>=> "\"1234E300\"".
Additional clean-up is required and it is always a mess to do this afterwards. </p>
<p>JSON.parse accepts an additional parameter, but from what I have seen, this is also not elegant.</p>
<pre><code>var garbage1 = JSON.parse('1234E300', function(key, value){return value;});
var garbage2 = JSON.parse('1234E300', function(key, value){return value;});
</code></pre>
<p>Well ... see for yourself. It is rotten. </p>
<p>How do I prevent JS to be smart and interpret something out of a string that it should not do? </p>
<p>Input (String) => Output (Value) ... and no messing around with the data that should not be there.</p>
| <javascript> | 2020-01-26 11:48:45 | LQ_CLOSE |
59,919,528 | Decode the string with the number of letter repeation | <p>I have a string "<strong>3A4B2GEF</strong>", need to decode it to "<strong>AAABBBBGGEF</strong>". If there is no number before letter, <strong>it means that repeat = 1</strong>. But in the output the maximum letters of string is 30, example "29A3B" output is:</p>
<pre><code>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
BB
</code></pre>
| <python><python-3.x> | 2020-01-26 14:59:21 | LQ_CLOSE |
59,919,587 | How to add spaces between two words using html? | <p>Suppose I have word Abhishek Mane
I want to make this as follows
Abhishek_____________________________ Mane. Underscore(_) indicates spaces that i want</p>
| <html> | 2020-01-26 15:05:34 | LQ_CLOSE |
59,920,912 | Border not showing in CSS even after labeling them !important | <p>Here is the code for this particular <code>div</code>:</p>
<pre><code>.generated_text {
display: inline-block;
width: 50px;
font-family:'Gudea' !important;
text-align: left;
color:#000 !important;
background:#fff !important;
border: 30px !important;
border-color: #4b4b4b !important;
position: absolute;
top: 54%;
left: 38.5%;
margin: -150px 0 0 -150px;
width:560px;
height:170px;
}
</code></pre>
<p>Here is the result:
<a href="https://i.stack.imgur.com/qNVen.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qNVen.png" alt="enter image description here"></a></p>
<p>Note, I'm very new when it comes to web dev. Any help would be much appreciated and let me know if i'm missing anything in this post. </p>
| <html><css> | 2020-01-26 17:31:13 | LQ_CLOSE |
59,922,794 | JavaScript charAt problem that I can’t seem to answer correctly | <p>Write a function called charAt which accepts a string and an index (number) and returns the character at that index.</p>
<p>The function should return an empty string if the number is greater than the length of the string.</p>
<p>Do not use the built in charAt method - the tests will fail if you do!</p>
| <javascript> | 2020-01-26 21:14:01 | LQ_CLOSE |
59,923,035 | How to align button and ul elements horizontally | <p>I want to achieve following layout:</p>
<p>[my button][hello1][hello2]</p>
<p>This is html:</p>
<pre><code><div id='container'>
<button id='my-button'>my button</button>
<ul id='my-ul'>
<li>hello1</li>
<li>hello2</li>
</ul>
</div>
</code></pre>
<p>How to define css?</p>
| <css> | 2020-01-26 21:46:36 | LQ_CLOSE |
59,923,243 | Composer warning "Package zendframework/zend-code is abandoned" | <p>I get a warning from composer:</p>
<p>Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.
Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.</p>
<p>However, I can't see any reference to zend in my composer.json (see below). Should I be worrying about it? Can I simply install laminas/laminas-code, etc to make it go away?</p>
<p>Any info welcome.</p>
<p>Thanks</p>
<p>Martyn</p>
<pre><code>{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"easycorp/easyadmin-bundle": "^2.0",
"edwin-luijten/oauth2-strava": "^1.3",
"egulias/email-validator": "^2.1",
"knpuniversity/oauth2-client-bundle": "^1.32",
"martynwheeler/oauth2-komoot": "dev-master",
"sensio/framework-extra-bundle": "^5.2",
"symfony/apache-pack": "^1.0",
"symfony/asset": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/expression-language": "4.4.*",
"symfony/filesystem": "4.4.*",
"symfony/flex": "^1.1",
"symfony/form": "4.4.*",
"symfony/framework-bundle": "4.4.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/process": "4.4.*",
"symfony/security-bundle": "4.4.*",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/translation": "4.4.*",
"symfony/twig-bundle": "4.4.*",
"symfony/validator": "4.4.*",
"symfony/web-link": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*",
"symfony/web-server-bundle": "4.4.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
}
}
}
</code></pre>
| <symfony> | 2020-01-26 22:14:57 | HQ |
59,923,613 | Difference of Product and Sum of Digits | <p>The task is to find the difference in the products of the digits and sum of digits. For example, an input of <code>4 5 6</code> would give <code>105</code>. The issue I'm having is dealing with previous iterations. I know it has something to do with the indexes of the list but I'm having difficulty figuring it out. Here's my code:</p>
<pre><code># find the difference between the product of all digits and sum of all digits
nums = input()
nums = list(nums.split())
def findProduct():
for i in range(len(nums)):
int(nums[i]) *= int(nums[i+1])
findProduct()
</code></pre>
| <python><python-3.x> | 2020-01-26 23:14:07 | LQ_CLOSE |
59,923,964 | Replace items in a list by for in statement ( Python) | <p>I am a new Python user and I am wondering how to replace every integer in a list with str variables? </p>
<p>I used the for-in statement, but it is not working. Please let me know how I can make the code work? Thank you so much! </p>
<p><a href="https://i.stack.imgur.com/3m7PX.png" rel="nofollow noreferrer">my code (what is wrong here?</a></p>
| <python> | 2020-01-27 00:16:09 | LQ_CLOSE |
59,926,495 | Can any body help me to create this image in android by using shape | <p><a href="https://i.stack.imgur.com/BWBz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BWBz8.png" alt="enter image description here"></a></p>
<p>Please suggest me which is the best way to create this image by just create png or jpeg or by using shape. I want an only bg image not "20% Off" written. I can do it by just using the circle. But I am not able to create the background image.</p>
| <android><android-studio><android-layout> | 2020-01-27 07:10:27 | LQ_CLOSE |
59,926,620 | What is the being called here: return _() | <p>I have come across this code in MoreLinq, in file <code>Batch.cs</code> (<a href="https://github.com/morelinq/MoreLINQ/blob/master/MoreLinq/Batch.cs#L96" rel="noreferrer">link</a>):</p>
<pre><code>return _(); IEnumerable<TResult> _()
</code></pre>
<p>I read up on discards, but nevertheless I cannot make sense of the above code. When I hover above the first <code>_</code> it says: "Variables captured: resultSelector, collection".</p>
<ul>
<li>What do the two <code>_()</code> represent?</li>
<li>Since we are doing a <code>return _();</code>, how can the subsequent code <code>IEnumerable<TResult> _()</code> still be executed?</li>
</ul>
| <c#> | 2020-01-27 07:21:11 | HQ |
59,927,859 | How to .js file $ajax code defined '$ not defined error''? | <pre><code>var deneme = document.createElement("SCRIPT");
deneme.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js";
var nodeajax = document.createTextNode("function deneme() {console.log('dawdawdawd');$.ajax({ type: \"POST\", url: \"http://localhost:54371/checkbox.aspx/Check\", data: '{sayfa: 10 }', contentType: \"application/json; charset=utf-8\", dataType: \"json\", success: function (response) { console.log(response.d); alert('sdf'); }, failure: function (response) { console.log(response); } });}"););
deneme.appendChild(nodeajax);
document.body.appendChild(deneme);
</code></pre>
<p>How do I define ajax without using script tag in the .js file?</p>
<p>' $ is not defined.' I get an error.</p>
| <javascript><jquery><ajax> | 2020-01-27 09:03:51 | LQ_CLOSE |
59,929,469 | creating a foriegn key contstraint on non primary or unique key | how to use foreign key constraint on non primary key for example ihave two tables account and transactions i want to check the acname in transactions is one of the acname in account
table account (acno,acname,bal,type)
table transactions (tid,acno,acname,bal,credit/debit,datetime)
here transactions .acname should be equal to account.acname.... | <sql><postgresql><foreign-keys> | 2020-01-27 10:39:49 | LQ_EDIT |
59,929,999 | Do I cast the result of new? | In the answers to the question https://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc was covered that I do not need and should not cast the returned `void` pointer of `malloc()`.
But how is it about the `new` operator in C++?
_____________________________
Is there an explicit reason to do:
````
int *p_rt = new int;
````
instead of
````
int *p_rt = (*int) new int;
````
Or can I do the cast?
| <c++><casting><new-operator><heap-memory> | 2020-01-27 11:12:59 | LQ_EDIT |
59,932,106 | MySQL Join with several CASE WHEN | <p>I need some help with MySQL where I want to JOIN with a CASE WHEN. I am getting 3 columns from statement below. </p>
<p>I would like to add from table Customer.name so I get a 4th column with Customer Name.
Table CustomerCategory has foreign key and ID from Customer.CustomerID<br>
Also every customer has an id but not necessary a CustomerCode, null exists.
Tried many versions of join but...</p>
<pre><code>SELECT
(CASE WHEN CustomerCategory.CustomerCode = "CUST01" THEN "Distributor" ELSE " " END ) AS Distributor,
(CASE when when CustomerCategory.CustomerCode = "CUST02" THEN "Retail" ELSE " " END ) AS Retail,
(CASE WHEN CustomerCategory.CustomerCode = "CUST03" THEN "Enduser" ELSE " " END ) AS Enduser
from CustomerCategory
</code></pre>
| <mysql> | 2020-01-27 13:26:37 | LQ_CLOSE |
59,939,275 | Count from long to wide format | <p>Having a long format like this:</p>
<pre><code>df <- data.frame(id = c(1,1,1,2,2), text = c("stock","arrange","stock","arrange","arrange"))
</code></pre>
<p>How is it possible to receive the wide format of making the variables in text column new columns which have as values the number the exist?
Example of expected output:</p>
<pre><code>data.frame(id = c(1,2) stock = c(2,0), arrange = c(1,2))
</code></pre>
| <r> | 2020-01-27 21:38:16 | LQ_CLOSE |
59,940,084 | Create/append nested dictionary inside a dictionary in Python? | <p>How to append a dictionary?<br>
I tried <code>maindict[a] = m</code> and <code>maindict[a][x] = n</code>. It didnt work, I get <code>TypeError: list indices must be integers or slices, not str</code></p>
<pre><code>maindict =
{ 'a' : '',
'b' : '',
...
}
m =
{ 'x' : '',
'y' : ''}
n =
{ 'l' : '',
'm' : ''}
</code></pre>
<p>tobe</p>
<pre><code>maindict = { 'a' : { 'x' : { 'l' : '',
'm' : ''}, 'y' : ''},
'b' : '', ... }
</code></pre>
| <python><python-3.x> | 2020-01-27 22:57:10 | LQ_CLOSE |
59,943,354 | Grouping dataframe based on similar column values | <pre><code>OFFENSE_ID RULE_ID STATUS
100 1 open
101 2 closed
102 2 open
103 1 open
104 2 closed
105 2 open
</code></pre>
<p>Here's how I want it - </p>
<pre><code>RULE_ID OPEN CLOSED
1 2 0
2 2 2
</code></pre>
<p>Thank you in advance for any help!</p>
| <python><dataframe> | 2020-01-28 06:40:28 | LQ_CLOSE |
59,946,042 | how to use VBA to copy paste in a determinate cell, changing the variable every week (not in the code) | I receive a weekly table and I've to update various columns in the whole document.
Every week has a target number from 1 to 52.
I tried to make the VBA copy paste in the next free column, but I realized that It can lead you to an error if you don't update it in the proper way.
So I was thinking, do you know a vba code that allows me to decide in the Excel sheet, where the Macro has to copy?
Like I choose the right weekly number in the excel sheet and then run the macro to make it copy in the rightful column in every designated sheet.
Thanks! | <excel><vba> | 2020-01-28 09:50:40 | LQ_EDIT |
59,946,532 | How to convert numbers like 902.1 or 902 to 900 in php | <p>Anyone knows how i can convert How to convert numbers like 902.1 or 902 to 900 in php..i have tried both ceil and floor like below but still same issue</p>
<pre><code>$amount = 902.1
$amount2 = floor($amount);
return $amount2;
returns 902
</code></pre>
<p>but i want to return either 900 or 910..something like this</p>
| <php> | 2020-01-28 10:19:10 | LQ_CLOSE |
59,946,764 | Combobox items does not display title in C# WPF MVVM | <p>I have main view model which contains:</p>
<pre><code>public class MainViewModel: INotifyPropertyChanged
{
public MainViewModel() { Categories = LoadCategories(); }
public ObservableCollection<CategoryViewModel> Categories {get;}
public FileData Data {get; set;}
}
public class FileData: INotifyPropertyChanged
{
public string Title {get {...} set {...}}
public CategoryViewModel Category {get {...} set{...}}
}
</code></pre>
<p>and</p>
<pre><code>public class CategoryViewModel
{
public string Title {get;set;}
public EMyEnum Value {get;set;}
}
</code></pre>
<p>and xaml:</p>
<pre><code><ComboBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Stretch" FontSize="16"
SelectedItem="{Binding Data.Category, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Categories}"
DisplayMemberPath="{Binding Title}"/>
</code></pre>
<p>Seems that dropdown list does not show <code>Title</code> value. In debug, the <code>Title</code> is populated and is not empty.</p>
<p>If I remove <code>DisplayMemberPath</code> then in list will display full namespace to <code>CategoryViewModel</code> class.</p>
<p>What can do here ? Where's my mistake ?</p>
| <c#><wpf><mvvm> | 2020-01-28 10:31:54 | LQ_CLOSE |
59,948,085 | How the Substitution of the 3rd to the last occurrence using SED command works? | <p>Let's consider the 'file.txt',
<a href="https://i.stack.imgur.com/qt4sr.png" rel="nofollow noreferrer">click for the file contents</a></p>
<p>I want to substitute the 3rd to the last occurrence of "p".</p>
<pre><code>sed -E 's/(.*)p((.*p){2})/\1@\2/' file.txt
</code></pre>
<p>Here, "p" is substituted by "@".
I want to know how it works.
Can anyone explain me ? </p>
| <unix><sed> | 2020-01-28 11:47:04 | LQ_CLOSE |
59,948,685 | python3 i wonder if u guys can solve? | Guys i code on this website :https://repl.it/ | i really need help with python,in tkinter stuff this is my code:
from tkinter import *
import tkinter as tk
root = tk.Tk()
root.geometry('400x400')
___________________________________________________
so guys the error is :
Traceback (most recent call last):
File "main.py", line 4, in <module>
root = tk.Tk()
File "/usr/local/lib/python3.7/tkinter/__init__.py", line 202
3, in __init__
self.tk = _tkinter.create(screenName, baseName, className,
interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment
variable
i wonder if u guys can pls help me...thx! :D | <python><python-3.x><tkinter> | 2020-01-28 12:21:34 | LQ_EDIT |
59,949,022 | Declare a C++ function that has C calling convention but internal linkage | <p>I'm trying to interface with a C library, which expects me to provide a pointer to a callback function.</p>
<p>As I understand it, according to the standard the callback must have C <em>language linkage</em>, due to possibly different calling convention. I can accomplish this by declaring my callback function as <code>extern "C"</code>. However this has an undesirable side effect: exposing the function's unqualified and unmangled name to other translation units.</p>
<p>Is it possible to declare a function such that its name has <em>internal linkage</em> (not visible to other translation units), but which can be called from C via a pointer (has appropriate calling convention) using only standard C++?</p>
<p>If it's impossible to make it have <em>internal linkage</em>, is it at least possible to make it keep its C++ name mangling?</p>
<p>I tried:</p>
<ul>
<li>Declaring it as <code>static extern "C" void f();</code> which caused a compilation error to the effect that <code>static</code> and <code>extern "C"</code> cannot be used together.</li>
<li>Declaring it within an anonymous namespace as <code>namespace { extern "C" void f(); }</code> which turned out to have the same effect as regular namespace, exposing the unmangled unqualified name.</li>
</ul>
| <c++><c><extern><linkage><cross-language> | 2020-01-28 12:42:13 | HQ |
59,949,285 | Array sum that I got from a for loop returns NaN (Javascript) | <p>That function below returns <strong>NaN</strong> instead of expected <strong>4</strong>. I bet there's some obvious mistake, but I'm not seeing it.</p>
<pre><code>function myFunction(arr) {
let arrSum = 0
for (let i=0; i<=arr.length; i++) {arrSum += arr[i];}
return arrSum;
}
const myArr = [2,2];
console.log(myFunction(myArr));
</code></pre>
| <javascript><arrays><return><nan> | 2020-01-28 12:56:13 | LQ_CLOSE |
59,950,954 | How do I work with the alphavantage API to fetch the currency exchange data using either JSON or php? | https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=JPY&apikey=demo
DATA AS FOLLOWS:-
Realtime Currency Exchange Rate
1. From_Currency Code "USD"
2. From_Currency Name "United States Dollar"
3. To_Currency Code "JPY"
4. To_Currency Name "Japanese Yen"
5. Exchange Rate "108.99000000"
6. Last Refreshed "2020-01-28 14:27:02"
7. Time Zone "UTC"
8. Bid Price "108.99000000"
9. Ask Price "108.99000000" | <javascript><php><html><json><ajax> | 2020-01-28 14:29:28 | LQ_EDIT |
59,950,988 | Why does the compiler parse this as a function pointer and not a recursive call? | <p>In this following code <code>foo()</code> is parsed in two different places and calls two different functions (marked by the <code>********</code>).</p>
<pre><code>#include <cstdio>
typedef int (*func)(void);
int bar()
{
printf("bar\n");
return 4; // guaranteed to be random
}
int foo()
{
printf("foo\n");
static int i = 0;
if(i)
return i;
++i;
i = foo(); // recursive call ********
printf("%d\n", i);
func foo = bar;
i = foo(); // calls bar. Why? ********
printf("%d\n", i);
return i;
}
int main()
{
return foo();
}
</code></pre>
<p>In all the compilers I was able to try (<a href="https://godbolt.org/#z:OYLghAFBqd5QCxAYwPYBMCmBRdBLAF1QCcAaPECAM1QDsCBlZAQwBtMQBGAFlICsupVs1qhkAUgBMAISnTSAZ0ztkBPHUqZa6AMKpWAVwC2tEJNJb0AGTy1MAOWMAjTMTMBOUgAdUCwuto9QxNBHz81Ohs7RyMXN05FZUxVAIYCZmICIONTcyUVCNo0jIIoh2dXD0V0zOyQhIUa0tty2MrOAEpFVANiZA4AcikAZltkQywAanFhnWRG/FQZ7HEABgBBNfWCAE8vTCwqSdsCSYgAKioDWmQOiAA3VDx0DpnZDa2TyacMiFePgDs73Wk1Bky8xBOVAgUkkP2I4gArDpaLDXsNgWDJsRMARerRJtw3pMAPQkybAAwZEQETAHSZEb6YbEidCoIxbcQAgAinI2XxoqD%2BnKBWyxEKhMMkkkFSJRaLeYrBjWYamQx3ox2mw25k1Wio2WLw0Lw/xBWLBOLxxAJeAN5tBcjkdoxStBeG1usFwoxpPJOOQvT892ZLFYrDd4Mh9GhsKkiPQctR0tIx3RmLBVxuk0Fnu%2BGXtRrz3vTfsmYdYCnzCMNYIlMalknjieRyfMacLltx%2BOO9q5vI%2B/M1RmYtmFgIzoKtPZLfZ5Ay6rBAA0RA1IpgGqzXqGXOidMkmCh6fWZI04a4Iy63HS6AGszIihMvuGuN1vSDuBmuFCBVqRL5uC6kHAsBIGgRheHg7BkBQEDgZB0EgMA7jmFQUG0sQP4QE4V5rk4tgZDsy7nqQ4FGFoBAAPK0KwRGAaQWAjqI7C4QxeABmoIY/vRmAAB7JAYtLEWuJzKKxrB4E4xCEXoWDCf%2BkJGMJXQ0PQTBsBwPD8IIwiiCg%2B7yBJTg/pAXSoF4hTcQAtAA6mwrCTFZ%2BzoDSeDIN%2BSQpBoECWHUpgJJYZQxHEoS%2BP4dB%2BaF4QBEFFTxIkBSpE0kUNJ5hTFJksVtPFKq1PoOSCLlzTRHFXBdEevT9GVT4rq%2BrGfrxAAcABsVnNdwFLIOq7gAHSSGcuCECQ0ySMMCSTHoEFQa4I1jR0E0GReuE3qQ96SI%2BS4DC%2B671cu36/v%2By3ATAiAgHxAlEDBlAZMACgAAoiMoDAIKgADuG4kfBUGqgED12Kwz1vW%2Ba5fYhyHmKDriUYJgPvax53IOsxC3XtFj8cgaT4Bua6qYwYaabwAgJLpYgGUIkkmX8H4WQE3HfseVUNAQWN/U9L1wwM56Lsuq47fRDUtW1HXAF1ky9f12Do4Jw0QINl2zZ0C0yHIS2ASta0bc%2BdX86jP5/gB17HfAEBgeyCGuOQlCQ244wiMAAD6BDENct6kGhrAYVhOH0fhtCEfJZEUdRtGsYxdssfR%2BAcXgXHw1LQmcyJ9BifRRnScQOyyYMJFO3gSmJypdB4xpXCE2YQh2/pysyOTxnwGZNN0NZdnho5zmue5CXJIUmjaClFjaFlIUJGE4WBPl9TeGFhRD%2B0XdeUUyUT/58/pU0s85UvwQr0VG/VRVJ7VZtvPAx%2By5Na17XliTZxOy782y/g8tnqmk3m8Qs2SPNe7V9IqvXneB8NVtqn0/PtfWy1uYDEkNrd8YDDpqy6CGTCAQQDcCAA%3D%3D%3D" rel="nofollow noreferrer">gcc, clang</a>, MSVC, and a couple others), the output is:</p>
<blockquote>
<p>foo<br>
foo<br>
1<br>
bar<br>
4 </p>
</blockquote>
<p>Why does the compiler choose to call <code>bar</code> via the function pointer and mask a recursive call? Is this behavior defined? If so, can I please have a reference?</p>
| <c++><language-lawyer> | 2020-01-28 14:30:54 | LQ_CLOSE |
59,951,280 | Why is android still using Java 8? | <p>Just wondering why Android is very behind the latest versions of Java which the latest release is Java 11.</p>
<p>I understand we have Kotlin now which comes with some great features. But just wondering will Google ever update to the latest version if not, why?</p>
<p>Many thanks in advance </p>
| <java><android> | 2020-01-28 14:46:24 | LQ_CLOSE |
59,952,704 | C++20 Concepts : Which template specialization gets chosen when the template argument qualifies for multiple concepts? | <p>Given :</p>
<pre><code>#include <concepts>
#include <iostream>
template<class T>
struct wrapper;
template<std::signed_integral T>
struct wrapper<T>
{
wrapper() = default;
void print()
{
std::cout << "signed_integral" << std::endl;
}
};
template<std::integral T>
struct wrapper<T>
{
wrapper() = default;
void print()
{
std::cout << "integral" << std::endl;
}
};
int main()
{
wrapper<int> w;
w.print(); // Output : signed_integral
return 0;
}
</code></pre>
<p>From code above, <code>int</code> qualifies to both <code>std::integral</code> and <code>std::signed_integral</code> concept.</p>
<p>Surprisingly this compiles and prints "signed_integral" on both GCC and MSVC compilers. I was expecting it to fail with an error along the lines of "template specialization already been defined".</p>
<p>Okay, that's legal, fair enough, but why was <code>std::signed_integral</code> chosen instead of <code>std::integral</code>? Is there any rules defined in the standard with what template specialization gets chosen when multiple concepts qualify for the template argument?</p>
| <c++><language-lawyer><c++20><c++-concepts> | 2020-01-28 16:06:05 | HQ |
59,953,382 | How can I extend the length of an array by 1 in C#? | <p>I want an array capacity to increase as I add items in order to add as many items to it as possible. Is there a way to do this in C#?</p>
| <c#><arrays> | 2020-01-28 16:46:31 | LQ_CLOSE |
59,953,428 | How to code in python a system $dF/dt=A$ with $F$ and $A$ matrices? | I'd like to code in python a coupled system of differential equations like :
$dF_{ij}/dt=A_{ij}$ where $A_{ij}$ is a function of the matrix $F$.
Meaning a system of 1st order differential equations.
For the same system but with vectors : $dF_{i}/dt=A_{i}$ I'm using scipy.integrate.odeint.
But it doesn't work for matrices.
Could you help please ?
PS: how is it possible to write the math in latex on stackoverflow ? | <python><matrix><scipy><system><differential-equations> | 2020-01-28 16:48:52 | LQ_EDIT |
59,956,033 | Difference of sys.path | <p>The following two python runs don't print the same output. Does anybody know why there is a difference? Thanks.</p>
<pre><code>$ pwd
/tmp
$ cat main.py
import sys
print("\n".join(sys.path))
$ python3 -c 'import sys; print("\n".join(sys.path))' | head -n 1
$ python3 ./main.py | head -n 1
/private/tmp
</code></pre>
| <python> | 2020-01-28 19:50:34 | LQ_CLOSE |
59,956,374 | Is void() a valid C++ expression? | <p>Apparently, this ternary expression with <code>void()</code> as one argument compiles:</p>
<pre class="lang-cpp prettyprint-override"><code>void foo() {}
//...
a == b ? foo() : void();
</code></pre>
<p>Is <code>void()</code> a valid expression by the standard, or is it just a compiler thing? If it's valid, then what kind of expression is it?</p>
| <c++><expression><void> | 2020-01-28 20:17:48 | HQ |
59,958,536 | How to click button with Selemium without "id=" or "name=" | Trying to have selenium click a button on a webpage. Cannot find the element to make it click.
```
<button type="submit" class="xButton xCTA xSubmit">
<span>Enter</span>
</button>
```
| <javascript><selenium><selenium-webdriver> | 2020-01-28 23:19:42 | LQ_EDIT |
59,959,815 | How to output whole information when using group_by and summarize | <p>My data has continent, country and dif(number).I am now trying to find the maximum of dif by each continent, and following is my code. How can I get the countries name at the same time?</p>
<pre><code>dt_dif %>%
group_by(continent)%>%
summarize(max_dif = max(dif))
</code></pre>
| <r> | 2020-01-29 02:39:18 | LQ_CLOSE |
59,961,772 | Can anyone help to draw rectangle in wxwidgets because i have written a code but it doesn't work it only displays a window frame | #include "wx/wx.h"
class MyFrame : public wxFrame{
public:
MyFrame();
~MyFrame();
private:
//DECLARE_EVENT_TABLE()
};
class MyWindow : public wxWindow{
public:
void OnPaint(wxPaintEvent& event);
private:
DECLARE_EVENT_TABLE()
};
class MyApp : public wxApp
{
public:
MyApp();
~MyApp();
virtual bool OnInit();
void DrawSimpleShapes(wxDC& dc);
private:
MyFrame* m_frame = NULL;
//MyWindow* w = NULL;
};
MyFrame::MyFrame() : wxFrame(nullptr,wxID_ANY,"Rectangle",wxPoint(30,30),wxSize(800,600))
{
}
bool MyApp :: OnInit()
{
m_frame = new MyFrame();
m_frame->Show();
//w = new MyWindow();
//w->Show();
return true;
}
wxIMPLEMENT_APP(MyApp);
wxBEGIN_EVENT_TABLE(MyWindow,wxWindow)
EVT_PAINT(MyWindow::OnPaint)
wxEND_EVENT_TABLE()
MyFrame::~MyFrame()
{
}
MyApp::MyApp()
{
}
MyApp::~MyApp()
{
}
void MyWindow :: OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxRED_BRUSH);
wxSize sz = GetClientSize();
wxCoord w = 100, h = 50;
int x = wxMax(0,(sz.x-w)/2);
int y = wxMax(0,(sz.y - h)/2);
wxRect recToDraw(x,y,w,h);
dc.DrawRectangle(recToDraw);
}
1. List item
how to draw a rectangle
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
some guide to learn wxwidgets
what's the problem with my code
please explain the problem
when i run this code it does not print any rectangle instead it just print window only
that's why i am unable to print rectangle
I am new to wxwidgets library so it is difficult for me to find any error
i cannot do any error handling in the wxwidgets so please help to resolve this problem
| <c++><wxwidgets> | 2020-01-29 06:48:28 | LQ_EDIT |
59,962,577 | Is it possible to send SMS over Wifi in Android App? | I'm working on an Android application in Android Studio and wanted to add a feature that allowed a text (SMS) message to be sent from the application to a mobile phone number.
I found one way to do this by using the SMS Manager API, but it seems like this only works if the application is run on a cell phone with a SIM Card/Data plan. I'd like the user to be able to send a text over WiFi in case they're running the application on a tablet with only WiFi or another device that only has access to a WiFi connection. The application would only send messages to a mobile number, and doesn't need to worry about receiving texts back from said mobile number.
My initial research proves that it is not possible to send SMS messages over WiFi. My question is, is this actually the case? Or does anyone know of a way to do this over a WiFi connection? Even if I don't use SMS, I'd like some other way to get a message from the device to a mobile phone number. I just figured that SMS would be the most straight forward.
Thanks for your time! | <android><sms><android-wifi><smsmanager> | 2020-01-29 07:49:39 | LQ_EDIT |
59,966,387 | Strongly typing props of vue components using composition api and typescript typing system | <p>I am using vue composition api with typescript.</p>
<p>How can I strongly type the component props using typescript typing system?</p>
| <typescript><vue.js><strong-typing><vue-composition-api> | 2020-01-29 11:43:51 | HQ |
59,967,898 | How would I modify this to put it into a function? | <pre><code>question_prompts = [
"What color are Apples?\n(a) Red/Green\n(b) Purple\n(c) Orange\n\n",
"What color are Bananas?\n(a) Blue\n(b) Yellow\n(c) Green\n\n",
"What color are Strawberries?\n(a) Red\n(b) Blue\n(c) Green\n\n" ]
def main_questions():
</code></pre>
<p>These are a set of three questions, and they have three answers which I didn't post. I'm trying to figure out how I would put this in the function called main_questions():
I am a beginner, I've looked at multiple articles but can't seem to understand them. Help please?</p>
| <python><python-3.x> | 2020-01-29 13:13:19 | LQ_CLOSE |
59,969,636 | No list returned by random.shuffle() | <p>I wrote some code in two different ways which I thought were exacly equivalent but I got two very differnt answers:</p>
<p>This first way worked exactly as expected:</p>
<pre><code>test_listA = list(range(0, 5))
random.shuffle(test_listA)
print(test_listA)
</code></pre>
<p>It printed out:</p>
<pre><code>[2, 1, 0, 3, 4]
</code></pre>
<p>But when I reorganised it like so:</p>
<pre><code>test_listB = random.shuffle(list(range(0, 5)))
print(test_listB)
</code></pre>
<p>It prints out:</p>
<pre><code>None
</code></pre>
<p>Why the difference?</p>
| <python> | 2020-01-29 14:47:42 | LQ_CLOSE |
59,970,843 | C# | Best way to read file into byte array in selected encoding? | Now i use something like that:
Encoding.UTF8.GetBytes(File.ReadAllText(filename))
Any suggestions how to do that better?
And what encoding uses `File.ReadAllBytes(filename)` method?
P.S. I need utf-8 byte arrays to store files in db | <c#><.net> | 2020-01-29 15:54:16 | LQ_EDIT |
59,972,432 | Why compilation error is giving in this java code? | <p>I was trying to compile the code and it shows a compilation error. Can anyone help me out to understand what is wrong in the code? I guess there should be a default constructor inside Mammal class but why?</p>
<pre><code>class Mammal {
public Mammal(int age) {
System.out.print("Mammal");
}
}
public class Platypus extends Mammal {
public Platypus() {
System.out.print("Platypus");
}
public static void main(String[] args) {
new Mammal(7); //Compilation Error
}
}
</code></pre>
| <java> | 2020-01-29 17:21:54 | LQ_CLOSE |
59,972,626 | Parse Space Delimited Files With Spaces In Fields | <p>I have a CSV file that uses a space as the delimiter. But some of the fields contain a space and those fields are wrapped with double quotes. Any field with a null/empty value is represented as "-". Fields that are not null/empty and do not contain spaces are not wrapped in double quotes. Here's an example of one row in the CSV file.</p>
<pre><code>foobar "foo bar" "-" "-" "-" fizzbuzz "fizz buzz" fizz buzz
</code></pre>
<p>Also there are no headers for the CSV file. I was going to use a simple solution such as this one <a href="https://stackoverflow.com/a/20769342/3299397">https://stackoverflow.com/a/20769342/3299397</a> but using <code>strings.Split(csvInput, " ")</code> wouldn't handle the spaces inside the fields. I've also looked into this library <a href="https://github.com/gocarina/gocsv" rel="nofollow noreferrer">https://github.com/gocarina/gocsv</a> but I'm curious if there's a solution that doesn't use a third-party library.</p>
| <csv><go><delimiter> | 2020-01-29 17:34:10 | LQ_CLOSE |
59,974,044 | need help for fix code in html for oage format | hello i need my page to look like this
[this what im trying to do][1]
but thats what i got [enter image description here][2]
thats the whole page i hope i can get a help with it i have a problem with layout and color of navigation
and the picture up is at the top left
i tried to work at it and took hours and i cant reach any result with it
[1]: https://i.stack.imgur.com/I8pt1.jpg
[2]: https://i.stack.imgur.com/7r0HH.jpg
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Digital Cloud</title>
<style type="text/css">
#container{
width: 800px;
height: 700px;
background-color: white;
margin-left: auto;
margin-right: auto;
position: fixed;
top: 20%;
left: 30%;
}
#logo{
margin-top:15px;
width: 200px;
height: 200px;
}
#ending{
float: right;
text-align: center;
margin: 120px;
}
#navigation{
background-color: #3c99dc;
float:left;
margin-left: 5px;
margin-bottom: 15px;
font-size: 20px;
width: 190px;
height: 50px;
text-align: center;
}
#content{
text-align: center;
}
#text{
float: left;
margin-bottom: 10px;
}
img{
width: 260px;
height: 150px;
float: left;
}
#texting{
width: 258px;
height: 200px;
float: left;
margin-left: 6px;
margin-bottom: 7px;
margin-left: 3px;
}
#description{
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>
<div id="logo">
<h1><img src="images/logo.jpeg" alt="logo" /></h1>
</div>
<div id="container">
<div id="navigation">
<div id="nav01">
<nav> <a href="#"> Business </a></nav>
</div>
</div>
<div id="navigation">
<div id="nav01">
<nav> <a href="#"> Pricing </a></nav>
</div>
</div>
<div id="navigation">
<div id="nav01">
<nav> <a href="#"> Community </a> </nav>
</div>
</div>
<div id="navigation">
<div id="nav01">
<nav> <a href="#"> Help </a> </nav>
</div>
</div>
<div id="content">
<h1>Droplets</h1>
<p>We rent out easy-to-deploy and resizable cloud servers.</p>
<h2>Deploy in 55 seconds</h2>
</div>
<div id="textimg">
<div id="texting">
<h3>1. Select an image or app</h3>
<p><img src="images/image.jpeg" alt="Representative picture of server's image" /></p>
<div id="description">
<p>Choose from our library of distros and apps, or create a Droplet from a snapshot.</p>
</div>
</div>
<div id="texting">
<h3>2. Choose a size</h3>
<p><img src="images/size.jpeg" alt="Representative picture of server's size" /></p>
<div id="description">
<p>Select a Droplet size based on the resources you need. You can resize at any time from the control panel.</p>
</div></div>
<div id="texting">
<h3>3. Select a region</h3>
<p><img src="images/region.jpeg" alt="Representative picture of server's region" /></p>
<div id="description">
<p>Deploy your Droplet to any of our datacenter locations around the world.</p>
</div>
</div>
</div>
<div id="ending">
<em>48,087,734 DROPLETS LAUNCHED</em>
<em>© COPYRIGHT 2017 DIGITAL CLOUD INC.</em>
</div>
</body>
</html>
<!-- end snippet -->
| <html><css><layout><alignment><centering> | 2020-01-29 19:13:36 | LQ_EDIT |
59,976,940 | How to make document.querySelector accept div id as parameter? | <p>I have this function:</p>
<pre><code>document.querySelector(".myDivClass");
</code></pre>
<p>Which accepts a div css class as parameter. How to make it accept a div id as parameter instead?</p>
| <javascript><css><reactjs> | 2020-01-29 23:10:51 | LQ_CLOSE |
59,977,174 | I was trying to write a program and it seems totally fine but i cannot find the reason why it doesn't work, any help would be thankful | <p>I have created a program which acts as a quiz. It is nowhere near done but I am working on it.</p>
<p>The code is below:</p>
<pre><code>#include <stdio.h>
#include <string.h>
#include <iostream>
int optionOne(int choice, int plonkPoints);
int optionTwo(int choice, int plonkPoints);
int optionThree(int choice, int plonkPoints);
int optionFour(int choice, int plonkPoints);
int optionFive(int choice, int plonkPoints);
int optionOnev2(int choice, int plonkPoints);
int plonkPoints = 0;
void main()
{
char fName[30];
char sName[30];
char rightFname[30] = "Thomas";
char rightSname[30] = "Sloane";
char rightFname2[30] = "Ryan";
char rightSname2[30] = "Gleeson";
int result;
printf("This is the Plonker test, it will determine where you are on the scale of Plonkerhood. \nGood luck and don't mess up you twat.\nTo answer yes type 1, to answer no type 0 \n");
printf("\nFirst what is your first name?: ");
scanf_s("%s", fName, sizeof fName);
printf("What is your surname?: ");
scanf_s("%s", sName, sizeof sName);
int res1 = strcmp(fName, rightFname);
int res2 = strcmp(sName, rightSname);
int res3 = strcmp(fName, rightFname2);
int res4 = strcmp(sName, rightSname2);
if (res1 == 0 && res2 == 0)
plonkPoints = 528;
if (res3 == 0 && res4 == 0)
plonkPoints = 528;
int choice;
printf("\nQuestion 1: Are you a plonker?: ");
scanf_s("%d", &choice);
if (choice == 0)
plonkPoints = plonkPoints + 1;
if (choice == 1)
plonkPoints = plonkPoints + 0;
printf("points: %d\n", plonkPoints);
while (choice != 0 && choice != 1)
{
printf("That's not a valid answer!\n");
printf("\nQuestion 1: Are you a plonker: ");
scanf_s("%d", &choice);
if (choice == 0)
plonkPoints = plonkPoints + 1;
if (choice == 1)
plonkPoints = plonkPoints + 0;
}
printf("\nQuestion 2: What does ORTCEMF stand for?\n");
printf("1. Only Retards Take Canned Eggs Mother Fucker\n");
printf("2.\n");
printf("3.\n");
printf("4.\n");
printf("5.\n");
printf("Enter your answer: ");
scanf_s("%d", &choice);
optionOnev2(choice, plonkPoints);
printf("points = %d", plonkPoints);
}
int optionOne(int choice, int plonkPoints)
{
switch (choice)
{
case 1: plonkPoints = plonkPoints + 5;
break;
case 2: plonkPoints = plonkPoints + 1;
break;
case 3: plonkPoints = plonkPoints + 4;
break;
case 4: plonkPoints = plonkPoints + 2;
break;
case 5: plonkPoints = plonkPoints + 3;
break;
}
return plonkPoints;
printf("Plonkpints : %d", plonkPoints);
}
int optionTwo(int choice, int plonkPoints)
{
switch (choice)
{
case 1: plonkPoints = plonkPoints + 1;
break;
case 2: plonkPoints = plonkPoints + 5;
break;
case 3: plonkPoints = plonkPoints + 2;
break;
case 4: plonkPoints = plonkPoints + 4;
break;
case 5: plonkPoints = plonkPoints + 3;
break;
}
return plonkPoints;
}
int optionThree(int choice, int plonkPoints)
{
switch (choice)
{
case 1: plonkPoints = plonkPoints + 2;
break;
case 2: plonkPoints = plonkPoints + 4;
break;
case 3: plonkPoints = plonkPoints + 5;
break;
case 4: plonkPoints = plonkPoints + 1;
break;
case 5: plonkPoints = plonkPoints + 3;
break;
}
return plonkPoints;
}
int optionFour(int choice, int plonkPoints)
{
switch (choice)
{
case 1: plonkPoints = plonkPoints + 3;
break;
case 2: plonkPoints = plonkPoints + 4;
break;
case 3: plonkPoints = plonkPoints + 2;
break;
case 4: plonkPoints = plonkPoints + 5;
break;
case 5: plonkPoints = plonkPoints + 1;
break;
}
return plonkPoints;
}
int optionFive(int choice, int plonkPoints)
{
switch (choice)
{
case 1: plonkPoints = plonkPoints + 4;
break;
case 2: plonkPoints = plonkPoints + 1;
break;
case 3: plonkPoints = plonkPoints + 2;
break;
case 4: plonkPoints = plonkPoints + 3;
break;
case 5: plonkPoints = plonkPoints + 5;
break;
}
return plonkPoints;
}
</code></pre>
<p>I have created five functions. These functions will be used for questions that have 5 options and each option gives you a different amount of points. For example question 2 of the quiz gives 5 points for option one because it is the correct option. I have defined each function and declared them before the main function which seems to be working well. For each of the functions I want the variable choice (the option number which the user chooses) to be the input into the function. It will then work and give the variable "plonkPoints" as the output. In this case when I choose the first option of question two I should then have an extra five points. I even put in a printf to check. For some reason no points are added to the variable "plonkPoints".</p>
<p>I originally had the variable "plonkPoints" as a local variable but then made it a global variable but that did not seem to help.</p>
<p>Any help would be greatly appreciated. Thank you all.</p>
| <c><function> | 2020-01-29 23:40:52 | LQ_CLOSE |
59,977,227 | Put real time (non static) on qt (c++) | <p>i want put the real time on qt, but non static</p>
<p>I have this code:</p>
<pre><code>QDateTime dateTime = dateTime.currentDateTime();
QString dateTimeString = dateTime.toString("yyyy-MM-dd hh-mm-ss");
ui->data->setText(dateTimeString);
</code></pre>
<p>but it shows only a static dateTime and i want the real dateTime (change every second)</p>
| <c++><qt> | 2020-01-29 23:46:30 | LQ_CLOSE |
59,977,887 | How to try Android development as an older programmer in 2020? | <p>Given a person who has been programming for embedded industrial systems for a few decades now. </p>
<p><strong>How can I make it easy for an older programmer to try mobile development (Android)?</strong></p>
<p>I’m asking because the amount of information on Android development is so overwhelming, and so much of it has been obsolete, I don’t even know where to begin. Would that person start with Eclipse or Android Studio? Plain Java or Kotlin? </p>
<p><strong>In other words</strong>, what is the quickest way to get an Android IDE set up to print “hello world” on a real device in 2020?</p>
| <android><android-studio><mobile><ide> | 2020-01-30 01:22:17 | LQ_CLOSE |
59,979,633 | Index position in Python | <p>Can someone please explain why in the second variable we select index [1]? Wouldn't the index position be the same as the first variable since I am trying to compare the first letter of the word. Please help and thank you in advance. </p>
<pre><code>def animal_crakers(text):
string = text.split()
return string[0][0] == string[1][0]
</code></pre>
| <python> | 2020-01-30 05:30:02 | LQ_CLOSE |
59,979,741 | Which is best pdf viewer in android? | <p>Which is best pdf viewer in android? Jio magzine which pdf viewer used?</p>
| <android> | 2020-01-30 05:41:57 | LQ_CLOSE |
59,979,799 | How to fetch data and show in Tgrid in delphi | <p>I'm working on an application where i want to fetch data from database and show it in <code>Tgrid.</code> Since it doesn't have a <code>DataSource</code> Property, i can't figure out a way how to add item in Tgrid.</p>
| <delphi> | 2020-01-30 05:49:36 | LQ_CLOSE |
59,980,081 | html+input type text with regex not taking underscore(_) and special characters | <p>am working for an html input type text which i dont want to take underscore and special characters.
I dont want to have an change function which will do the same..if there is a regex which wont take mainly underscore and special characters will be awesome.</p>
<p>Any fiddle will be highly helpful</p>
| <html><regex> | 2020-01-30 06:15:43 | LQ_CLOSE |
59,982,070 | How can I select unique row based on value matched in other column | I have searched a lot but can not get my head around this.
I need to filter the results based on comparing values in 2 rows.
Data)
[Data I want to filter][1]
Results I want to end up with
[Desired results][2]
Is this possible in MySQL?
If there is a way to do this in PHP after the query I'm happy with that too.
Thanks for any help.
[1]: https://i.stack.imgur.com/bEKfz.png [2]: https://i.stack.imgur.com/35CMY.png | <mysql> | 2020-01-30 08:48:52 | LQ_EDIT |
59,982,393 | Java 8 Stream | Add a value of the stream to another List/Collection without using foreach or any terminal Operation | <p>So far i tried to add values from a stream to a list with peek() but later I found out that peek() is only used "to support debugging, where you want to see the elements as they flow past a certain point in a pipeline".</p>
<p>Now my question is whats the coding-convention here ?</p>
<p>Do I map it in a second stream or can I map it one String like my Code with Peek() ?</p>
<pre><code> final int range = 9;
List <String> help = new ArrayList<String>();
//random numbers to fill help
for(int i = 5;i< range;i++)
{
help.add(String.valueOf(i+(i*2)+(i*(i+2))) );
}
List<Test> others = new LinkedList<>();
List<Test> tests = help.stream().map(s-> new Test(s,(int) Integer.valueOf("10")))
.peek(t->System.out.println(t.getText()))
.peek(t-> others.add(t)).collect(Collectors.toList());
</code></pre>
<p>The class Test looks like this:</p>
<pre><code>public class Test
{
String text;
int id;
public Test(String text, int id) {
this.text = text;
this.id = id;
}
public String getText() {
return text;
}
public int getId() {
return id;
}
}
</code></pre>
| <java><java-stream> | 2020-01-30 09:08:41 | LQ_CLOSE |
59,982,443 | unable to write the output to a text file | from urllib import request
from redditscore.tokenizer import CrazyTokenizer
tokenizer = CrazyTokenizer()
url = "http://www.site.uottawa.ca/~diana/csi5386/A1_2020/microblog2011.txt"
for line in request.urlopen(url):
tokens = tokenizer.tokenize(line.decode('utf-8'))
#print(tokens)
with open('your_file.txt', 'a') as f:
print(tokens)
for item in tokens:
f.write("%s\n" % item)
In the above code my output is in variable tokens in the form of list.
Output sample: ['\ufeffsave', 'bbc', 'world', 'service', 'from', 'savage', 'cuts'] ['a', 'lot', 'of', 'people', 'always', 'make', 'fun', 'about', 'the', 'end', 'of', 'the', 'world', 'but', 'the', 'question', 'is', '"are', 'u', 'ready', 'for', 'it'] ['rethink', 'group', 'positive', 'in', 'outlook', 'technology', 'staffing', 'specialist', 'the', 'rethink', 'group', 'expects', 'revenues', 'to', 'be']
Now i'm trying to print this output into a text file.
How can i do that? please help.. | <python> | 2020-01-30 09:11:32 | LQ_EDIT |
59,983,736 | How do I make my window 10 PC an SMTP server? | I want to configure my window system as mail server,please let me if any body know how to configure windows 10 as mail server, I have ec2 window instance. | <technical-indicator> | 2020-01-30 10:20:47 | LQ_EDIT |
59,985,128 | Pseudocode Python Concepts | <p>I know that pseudocode by its very nature is based more on natural language syntax and principles than anything else, but it is supposed to represent coding concepts. I am still a beginner , so I don't understand all of the concepts.</p>
<pre><code> int string (char s[1..m], char t[1..n])
// d is a table with m+1 rows and n+1 columns
declare int d[0..m, 0..n]
</code></pre>
<p>I understand this except for the last line. Could somebody explain to this to me in python ? </p>
| <python><pseudocode> | 2020-01-30 11:34:37 | LQ_CLOSE |
59,987,153 | why we cannot perform this operation in vector | When we passing vector in function why we cant do it like an array for example.
#include<bits/stdc++.h>
using namespace std;
void func(vector<int> vect)
{
vect.push_back(30);
}
int main()
{
vector<int> vect;
vect.push_back(10);
vect.push_back(20);
func(vect);
for (int i=0; i<vect.size(); i++)
cout << vect[i] << " ";
return 0;
}
In this example, it works fine.
But if I do it like this why it doesn't work like array.
#include<bits/stdc++.h>
using namespace std;
void func(vector<int> *vect)
{
vect.push_back(30);
}
int main()
{
vector<int> vect;
vect.push_back(10);
vect.push_back(20);
func(&vect[0]);
for (int i=0; i<vect.size(); i++)
cout << vect[i] << " ";
return 0;
}
Just like array why this is not possible. | <c++><pointers><vector> | 2020-01-30 13:28:17 | LQ_EDIT |
59,987,614 | sapnco BAPI invoked in CUA for child systems | Hi I am currently developing an C# application with sapnco 3 connector.
I am wondering if I could invoke BAPI into CUA and this BAPI would pass details to child system.
This field is available through Test Function Module (field "RFC target sys"), but it is unavailable directly in standard BAPIs when accessed from sapnco.
[![RFC target sys:][1]][1]
[1]: https://i.stack.imgur.com/OMgTz.png
In ABAP devs can use
call function 'BAPI_USER_CHANGE' destination '<TARGET_SYS>'
Can I use something similar in sapnco library?
IRfcFunction rfcs = rfcDest.Repository.CreateFunction("BAPI_USER_CHANGE");
Does anybody know how this could be achieved?
Main intent is to reset user passwords to initial ones through App(BAPI) --> CUA --> ChildSystem
Without direct access into child systems. | <c#><sap><saprfc><bapi><function-module> | 2020-01-30 13:54:13 | LQ_EDIT |
59,987,658 | React js destructuring assignment | I have the following function.
```
returnStateElement = (...elements) => {
const copy = Object.assign({}, this.state);
return elements.reduce((obj, key) => ({ ...obj, [key]: copy[key] }), {});
};
```
Work:
```
f = () => {
const dataSender = this.returnStateElement('email', 'password');
let { email, password } = dataSender;
console.log(dataSender,email,password);
}
```
No work:
```
f2 = () => {
const { email, password } = dataSender = this.returnStateElement('email', 'password');
console.log(dataSender,email,password);
}
```
There is a way to make a more compact type of assignment like f2 (), but that works. | <javascript><reactjs><variable-assignment><assignment-operator><destructuring> | 2020-01-30 13:56:43 | LQ_EDIT |
59,989,362 | awk to match pattern in html and use regex | <p>Using <code>awk</code> to parse an <code>html</code> and it does execute but prints the entire line not just the percentage as in the desired. My thinking is that the pattern <code>reads passed filters:</code> is matched, then the <code>regex</code> is used to use the <code></td><td class='col2'>78.760142 M</code> and print the field after. There are aditional lines above and below, but the are different then the pattern. Thank you :).</p>
<p>file</p>
<pre><code>...
...
<tr><td class='col1'>reads passed filters:</td><td class='col2'>78.760142 M (95.514721%)</td></tr>
...
...
</code></pre>
<p>awk</p>
<pre><code>awk -F'reads passed filters:[^a-z][0-9][::space::][a-z][::space::]*' '/reads passed filters:/ {sub("[^a-z][0-9][::space::][a-z][::space::].*", "", $1); print $1}' file
</code></pre>
<p>current</p>
<pre><code><tr><td class='col1'>reads passed filters:</td><td class='col2'>78.760142 M (95.514721%)</td></tr>
</code></pre>
<p>desired</p>
<pre><code>95.514721%
</code></pre>
| <regex><awk> | 2020-01-30 15:29:33 | LQ_CLOSE |
59,989,651 | Python find max in list of lists and elements with undefined number of values | I have a big list of list. I am trying to find max and min in it. Previous questions on this consists lists with strings and this question is differen.t
big_list = [[1,2,3],4,[5,6,0,5,7,8],0,[2,1,4,5],[9,1,-2]]
My code:
max = max(list(map(max,boxs_list)))
Present output:
TypeError: 'numpy.float64' object is not iterable
| <python><pandas><list><numpy><nested-lists> | 2020-01-30 15:45:52 | LQ_EDIT |
59,990,837 | Safely deleting unused coded: What are all the ways a macro can be called? (Excel-VBA) | I want to remove some code I believe is unused in a specific Excel VBA Project. I think I've checked all the places that macros can be hiding, but I want to be absolutely sure the workbook won't try to a call certain sub after I delete it. Is my checklist complete?
1. The code itself, called by other subroutines
2. Assigned to a shape on a worksheet
3. In a worksheet cell as a user defined function
4. Called by the XML of a custom ribbon
| <excel><vba> | 2020-01-30 16:54:25 | LQ_EDIT |
59,991,809 | Select range of data between two string vlaues | <p>I want select the data in between two string values AAA and DDD. There are data out of range of AAA and DDD that I do not want. Any ideas. Thanks.</p>
<p><a href="https://i.stack.imgur.com/bOf7U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bOf7U.png" alt="enter image description here"></a></p>
| <tsql> | 2020-01-30 17:53:56 | LQ_CLOSE |
59,992,775 | What is the best way to create an Observable which directly emits after creation? | <p>I am asking myself what would be the most proper and semantically correct way to create an observable which emits directly after creation?</p>
<p>Of course I can always do something like this <code>of(unkown)</code>, <code>of(undefined)</code>, <code>of(null)</code>, <code>of(true)</code> and so on, but what would be the "correct" way to do this, is there any reference? </p>
| <angular><typescript><rxjs><observable> | 2020-01-30 18:59:11 | LQ_CLOSE |
59,995,278 | form that saves information entered into a data.txt file php none of them works | <p>i'am looking for form that has index.html and process.php
In index you enter Your Name:
Your age: (but you dont enter it gives you option from 10 to 50) and you click submit
and that information saves in data.txt file on /var/www/html not on client side.
I've tried hundred of them none of them works</p>
<p>Also please don't link other forms i've tried hundred of them on stack, on google, look they are all outdated?
I'am using Ubuntu 18.04 lts server, with apache2 installed and php, PHP 7.0.33-0+deb9u6 (cli) (built: Oct 24 2019 18:50:20) ( NTS )
Server version: Apache/2.4.25 (Debian)
Server built: 2019-10-13T15:43:54</p>
| <php><html><forms> | 2020-01-30 22:11:24 | LQ_CLOSE |
59,996,193 | 'which' command outputs nothing in Ubuntu | <p>I want to figure out path of the executable command, but <code>which</code> says nothing. Why ? So and when it's usual case for <code>which</code>to return nothing about command's path. path is hidden/inaccessible for some types of executables or ...</p>
<pre><code>which sdk
</code></pre>
<p>sdk - it's <a href="https://sdkman.io/" rel="nofollow noreferrer">SDKMAN</a></p>
| <linux><bash><shell><ubuntu> | 2020-01-30 23:51:35 | LQ_CLOSE |
59,997,831 | Python: Turn Nested List to Dictionary | <p>I am trying to turn a nested list like this:
(Example list)</p>
<pre><code>[['A','1','2','3'], ['B','4','5','6'],...]
</code></pre>
<p>To a dictionary that looks like this</p>
<pre><code>{'A':'1','2','3','B': '4','5','6'}
</code></pre>
<p>Can someone please help me?</p>
| <python><list><dictionary><nested> | 2020-01-31 04:24:23 | LQ_CLOSE |
59,998,302 | convert vba macro to google sheets | i need a way to translate a vba excel macro to google sheets, the code below transfers a list of data to an invoice and then saves it as a pdf i searched online for a translator but didn't find it if some one knows one or if some one can translate this one.
thank you in advance
Private Sub CommandButton1_Click()
'define value
Dim customer As String
Dim invoicenumber As Long
Dim invoicedate As Long
Dim path As String
Dim myfilename As String
Dim rate As Long
Dim r As Long
'define our last row
lastrow = Sheets("Dispatch1").Range("O" & Rows.Count).End(xlUp).Row
' start at row 5
r = 5
For r = 5 To 10
If Cells(r, 1).Value = "done" Then GoTo nextrow
invoicedate = Sheets("Dispatch1").Cells(r, 5).Value
rate = Sheets("Dispatch1").Cells(r, 15).Value
invoicenumber = Sheets("Dispatch1").Cells(r, 17).Value
Amount = Sheets("Dispatch1").Cells(r, 19).Value
Application.DisplayAlerts = False
Sheets("invoiceblank").Select
' map the variables to invoice worksheet data
ActiveSheet.Range("F4").Value = invoicedate
ActiveSheet.Range("G4").Value = invoicenumber
ActiveSheet.Range("F18").Value = rate
path = "C:\Users\Dell\Desktop\feb"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
fileName:="C:\Users\Dell\Desktop\aa new trucking\feb\" & _
ActiveSheet.Range("G4 ").Value & _
Worksheets("Customers").Range("A1").Value & _
ActiveSheet.Range("A16").Value & ".pdf", _
OpenAfterPublish:=False
'our label next row. Labels have a colon after their name
nextrow:
Next r
End Sub | <javascript><excel><vba><google-apps-script><google-sheets> | 2020-01-31 05:20:47 | LQ_EDIT |
59,998,317 | Download fb videos, I have attached two images, just need download after on click | I have attached two image:
--------------------------
first is: my link where fb video link
second is: after click video opening & play
**Actually I want to download this video from the url when user click on the link then video will be download but currently its opening video & play....
but I don't want this, I want to download this video when click on link or click on button then facebook video will start downloading! Thanks in advanced. You can suggest me please**
[My FB Video Link image][1]
[After Click the link its open like this image, but I don't want this][2]
[1]: https://i.stack.imgur.com/RK17r.png
[2]: https://i.stack.imgur.com/cwgH6.png
| <javascript><php><video> | 2020-01-31 05:22:14 | LQ_EDIT |
59,998,851 | Abnormal behavior of python's set function | <p>I was working on a problem which required the use of python's set function to be applied onto strings.
This is what I observed which is baffling me.
Please do tell me a reason as to why it occurs if anyone does know.</p>
<pre><code>>>> set('123456789')
{'2', '6', '7', '5', '9', '1', '8', '4', '3'}
>>> set('123456789')
{'2', '6', '5', '7', '9', '1', '8', '4', '3'}
>>> set('132457689')
{'2', '6', '5', '7', '9', '1', '8', '4', '3'}
>>> set('122333444455555666666777777788888888999999999')
{'2', '6', '5', '7', '9', '1', '8', '4', '3'}
>>> >>> set('1223334444555556666667777777888888889999999991324354657869874645231232435465768986753514324354657698587647536425312635746587873562413237485769546372641495565364319483726415523648759648573462')
{'2', '6', '5', '7', '9', '1', '8', '4', '3'}
</code></pre>
<p>Despite the number of times or the order in which the elements(1-9) in the string are passed, they seem to get arranged in this strange pattern after execution.</p>
<p>So I thought to generalize this and see. Here is what I observed when I applied it on a-z and 0-9 all combined</p>
<pre><code>>>> set('1234567890qwertyuiopasdfghjklzxcvbnm')
{'r', 'p', '9', '8', 'l', 'c', 't', 's', '5', 'g', '0', '4', 'q', 'b', 'a', 'i', 'x', 'w', 'o', 'z', 'n', 'm', '2', '6', 'u', 'j', '7', 'd', '1', 'e', 'v', 'k', '3', 'f', 'y', 'h'}
>>> set('1234567890qwertyuiopasdfghjklzxcvbnm'[::-1])
{'r', 'p', '9', '8', 'c', 'l', 't', 's', '5', 'g', '0', 'q', '4', 'b', 'a', 'i', 'x', 'w', 'o', 'z', 'n', 'm', '2', '6', 'j', 'u', '7', 'd', '1', 'e', 'v', 'k', '3', 'f', 'y', 'h'}
</code></pre>
<p>The order comes out to be different.
'c' & 'l' are flipped.
'4' & 'q' are flipped.
'j' & 'u' are flipped.</p>
<p>But something even crazier is this</p>
<pre><code>>>> set('1234567890qwertyuiopasdfghjklzxcvbnm') == set('1234567890qwertyuiopasdfghjklzxcvbnm'[::-1])
True
</code></pre>
<p>Any information about why this behavior occurs is much appreciated. Thank you.</p>
| <python><python-3.x><set> | 2020-01-31 06:21:42 | LQ_CLOSE |
59,998,926 | Can we have a 2 different textStyle inside styles.xml? | <p>I wanted to my title to have italic and bold at the same time. How can i achieve this on styles.xml? or is it possible to achieve this within styles.xml only?</p>
| <android><xml> | 2020-01-31 06:28:15 | LQ_CLOSE |
59,999,021 | How to extract text from a pdf file | <p>What is the best way to extract text from a pdf file.....
I have tried some
PyPDF2 -----> it only returns an empty string for all pages
tabula -----> it returns a weird table of NaN
the pdf I am trying to scrap is
<a href="http://imdagrimet.gov.in/sites/default/files/daas_bulletin/Vaishali_46.pdf" rel="nofollow noreferrer">http://imdagrimet.gov.in/sites/default/files/daas_bulletin/Vaishali_46.pdf</a></p>
| <python><pdf> | 2020-01-31 06:35:39 | LQ_CLOSE |
59,999,152 | SQL : Conversion failed when converting date and/or time from character string | I am working with data stored in SQL and I am having troubles inserting NULLS into a DATETIME Column.
Ideas? | <sql-server><datetime><null> | 2020-01-31 06:47:56 | LQ_EDIT |
59,999,863 | SyntaxError in python while using commas | <p><strong>Hi.I am new to python.I caught a syntax error while executing this code:</strong></p>
<pre><code>a="input("Enter a no.")"
print(type(a))
</code></pre>
<p><strong>But if I execute:</strong></p>
<pre><code>a='input("Enter a no.")'
print(type(a))
</code></pre>
<p><strong>Or:</strong></p>
<pre><code>a="input('Enter a no.')"
print(type(a))
</code></pre>
<p><strong>Then no error occurs can someone explain me this.
Thanks in advance.</strong></p>
| <python><python-3.x> | 2020-01-31 07:49:52 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.