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
36,493,344
C++ PRESS ENTER TO CONTINUE
Evening, I am looking for a way to get the program to continue on instead of exiting out after asking to press enter to continue. [1] I cannot use the list command because im calling function "seatingChart" in another function and having the list command sends me back into the menu. Any suggestions? void seatingChart() { for(row = 0; SEATROWS > row; ++row) // Placeholder for '#' for (seat = 0; SEATS > seat; ++seat) // Placeholder for '#' theater[row][seat] = '#'; // Applying '#' to the chart cout << "\n\t\tSeats"; cout << "\n 123456789012345678901234567890" << endl; //seat header for (int row = 0; SEATROWS > row; ++row) { // Initializing 15 rows cout << "\nRow " << setw(2) << row+1 << "\t"; for (int seat = 0; SEATS > seat; ++seat){ // Initializing 30 seats cout << theater [row][seat];} //display seating chart } cout << "\n\n\n\tLegend:\t* = Sold"; cout << "\n\t\t# = Available"; cout << "\n\n\nPress the Enter key to continue."; cin.ignore(); cin.get(); } [1]: http://i.stack.imgur.com/VpAzm.png
<c++><c++11>
2016-04-08 06:52:22
LQ_EDIT
36,496,372
Conversion of Java to C# code
<p>All,</p> <p>I am currently trying to convert some lines of code from Java to C# using Visual Studio 2013. However the lines below is causing me some issues:</p> <pre><code>final double testdata[][] = {{patientTemperatureDouble, heartRateDouble, coughInteger, skinInteger}}; result[i] = BayesClassifier.CalculateProbability{testdata[k],category[i]}; </code></pre> <p>Any clarification as to converting the array to a suitable c# format would be greatly appreciated, I have attempted using readonly and sealed but I've had no luck.</p> <p>Thanks</p>
<java><c#><arrays><final>
2016-04-08 09:41:09
LQ_CLOSE
36,497,331
I need to ask again. this time with more details
This is a Firebird database. First Table Contacts Company_ID - job_title Second Table Client_id - Co_name In contacts, I want to the job_title field to contain the co_name. client_id and company_id are the same. Co_name correspond to company_id as well as client_id. this: UPDATE Contacts SET Contacts.Job_title = Clients.co_name where company_id in (select client_id from clients JOIN Contacts c ON Client_id=company_id where record_status='A') gives me an error as cannot find (clients.co_name) this other option: UPDATE Contacts JOIN Clients ON Clients.Client_id = Contacts.Client_id SET Contacts.Job_title = Clients.Client_name gives me an error on JOIN Any other ideas please? Thank you all
<firebird>
2016-04-08 10:29:04
LQ_EDIT
36,497,498
How to get JsonData from string variable in jquery?
{"features":[{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[43.9075888632345,39.5410827982141],[43.9072923576627,39.5407692922427],[43.9070921336948,39.5405093525187],[43.906856401821,39.5402965882992],[43.9066291860298,39.5401742759428],[43.9064319803254,39.5401484540191],[43.9065181219529,39.5402838501285],[43.9066942609979,39.5405172920263],[43.9066503905753,39.5406621287682],[43.9065838779526,39.5408287916261],[43.9067755329389,39.5409986936949],[43.9071501248081,39.5411817901501],[43.9074409065243,39.5413833897095],[43.9076678059399,39.5415032206895],[43.9078429924457,39.5416138288897],[43.9078678260103,39.5415108105989],[43.9078313663027,39.5413314258037],[43.9075888632345,39.5410827982141]]]]},"properties":{"ParselNo":"1","SayfaNo":"10","Alan":"6.511,21","Mevkii":"Köy arkası","Nitelik":"Tarla","CiltNo":"1","Ada":"106","Il":"Ağrı","Ilce":"Doğubeyazıt","Pafta":"I51-c-2","Mahalle":"Alıntepe"}}],"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"EPSG:4326"}}} Hi Guys, i need get json type from this string variable. i need get "coordinates" title value by json type in jquery.
<jquery><json>
2016-04-08 10:37:10
LQ_EDIT
36,497,517
The shortest way to choose array with less elements
I have 2 array, which should be the shortest code to return array with less element ? If (count($a)<count(b)) return $a; else return $b;
<php>
2016-04-08 10:38:10
LQ_EDIT
36,497,520
Code work when debugging, but when it running the code crashed
<p>This code need to save friends in some array of array(pointer to pointer) and by the length of the names do realloc (build exactly dynamic place for the strings of each of them) and than prints the string and the length and free everything. So the code work when i debugging but when I running it with CTR+f5 it's crashed after the fgets of the first string. also all the free loops and the free function doesn't work me here, but if remove it the debugging still work and the CTR+f5 still don't work. help someone?</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #define LENGTH 20 int main(void) { int i = 0, j = 0,friends=0; char str[LENGTH]; printf("Hello bro,how U doin'?\nTell me how many friends do you have?\n"); scanf("%d",&amp;friends); char** friendBook = (char**)malloc(sizeof(char)*friends); if (friendBook) { getchar(); for (i = 0; i &lt; friends; i++) { *(friendBook+ i) = malloc(LENGTH*sizeof(char)); } for (i = 0; i &lt; friends; i++) { printf("Enter friend number: %d\n", i + 1); fgets(str, LENGTH, stdin); str[strcspn(str, "\n")] = 0; *(friendBook + i) = (char*)realloc(*(friendBook+i),(sizeof(char)*strlen(str))); // dynamic memory for every string(name) if (*(friendBook + i)) { strcpy(*(friendBook+i),str); } } for (i = 0; i &lt; friends; i++) { printf("Friend: %s\tLength of friend name %d\n", *(friendBook + i), strlen(*(friendBook + i))); } } for (i = 0; i &lt;friends; i++) { free(*(friendBook+i)); } free(friendBook); system("PAUSE"); return 0; } </code></pre>
<c><dynamic><char><realloc>
2016-04-08 10:38:12
LQ_CLOSE
36,497,536
how to save html code in sql server database for correct display
My website is just like Stackoverflow and under developement. I am using plain textarea to take text input as I do not have any WMD editor like Stackoverflow's. When I take html code as input and store it in database table in a text or nvarchar(max) column, it is stored successfully. But when I call that data for display, it displays the corresponding html page instead of that html code on screen. I am not able to resolve it. For better understanding I'm putting here input page and output page images of my website. First is [This is image of input page][1] [1]: http://i.stack.imgur.com/n1b9O.png and second is [This is the image of output page][2] [2]: http://i.stack.imgur.com/wrHCV.png What is going wrong here ?
<java><html><sql><sql-server>
2016-04-08 10:39:02
LQ_EDIT
36,499,277
Why should initialize list in Java
<p>If I use the below code</p> <pre><code>List&lt;String&gt; listOfStrings=new ArrayList&lt;&gt;(); listOfStrings.add("first string"); </code></pre> <p>or the following code</p> <pre><code>List&lt;String&gt; listOfStrings; listOfStrings.add("first string"); </code></pre> <p>to create a Java list, both the codes get compiled successfully and give same output on iterating the list. So what is the relevance of initializing the list</p>
<java><list>
2016-04-08 12:13:27
LQ_CLOSE
36,499,810
Sublime Text 3 with Sass Support
<p>Since Bootstrap changed from less to sass... I have to use sass now. I somehow can't find an easy solution for having auto-completion and auto-compiling on save for Sublime Text 3.</p> <p>Does anyone know a Plugin or something which gives me these features?</p> <p>I want to be able to specify where the compiled css should go, where my custom-sass files are and where bootstrap is located. :)</p> <p>Thanks</p>
<twitter-bootstrap><sass><sublimetext3>
2016-04-08 12:40:39
LQ_CLOSE
36,501,123
Boolean which changes its value
<p>In my code boolean value isIndefinite unexpectedly changes it's value to "true" after if (flag = true) {isIndefinite = true;} even though flag wasn't true. Can anybody tell me what kind of trivial mistake I made? :(</p> <pre><code>#include &lt;iostream&gt; using namespace std; int rows = 3; int columns = 4; double primaryTab[3][4] = { {3, 3, 1, 12}, {2, 5, 7, 33}, {1, 2, 1, 8} }; bool flag = true; double multi; int main() { bool isIndefinite = false; for(int i = 0; i &lt; rows; i++) { for(int j = 0; j &lt; rows; j++) { if(i != j &amp;&amp; primaryTab[i][0] != 0) { multi = primaryTab[i][0] / primaryTab[j][0]; for(int k = 0; k &lt; columns; k++) { if((primaryTab[j][k] * multi) != primaryTab[i][k]) { flag = false; } } if (flag = true) {isIndefinite = true;} } } } if(isIndefinite == true) {cout&lt;&lt;"Indefinite"&lt;&lt;endl;} } </code></pre>
<c++>
2016-04-08 13:40:44
LQ_CLOSE
36,502,910
Per Regular Expression to find $0.00
Need to count the number of "$0.00" in a string. I'm using: my $zeroDollarCount = ("\Q$menu\E" =~ tr/\$0\.00//); but it doesn't work. Thanks
<regex><perl>
2016-04-08 14:59:16
LQ_EDIT
36,503,768
How to pass a PHP string as JS function parameter?
<p>I have this PHP code who send an URL as argument to a JS function :</p> <pre><code>&lt;?php $url="www.google.com"; echo '&lt;input type="submit" name="btnfone" onclick="window.open('.$url.')" class="btn-style2" value="Viewmap"/&gt;'; ?&gt; </code></pre> <p>When I test it, nothing append. But if I change the URL with an integer</p> <pre><code>$url=1234; </code></pre> <p>Then the argument is interpreted.</p> <p>What's the solution ?</p>
<javascript><php><html>
2016-04-08 15:39:45
LQ_CLOSE
36,504,066
How to make a button stop counting below 0? Java
Hi guys im stuck with this code if anyone could help me out it would be awesome private static String labelPrefix = "Number of boats added: "; private int numClicks = 0; JLabel addb = new JLabel(labelPrefix + "0 "); JButton del = new JButton("Delete Boat!"); panel.add(addb); addb.setText(labelPrefix + --numClicks); del.setVisible(true); when delete button is pressed it counts down from labelPrefix.. but i need it to stop at 0 and not go to negative side..any ideas how i could do it without changing alot?
<java><windows><swing>
2016-04-08 15:53:07
LQ_EDIT
36,505,007
T-SQL Rouding, First Truncates to LENGTH + 2
In using the T-SQL ROUND function I noticed what seems like weird behavior. It looks like the ROUND function only looks at the first digit to the right of the digit to be rounded. If I round -6.146 to one decimal I get -6.1. I would have thought it would start at the right and round each digit as it works its way to the left, like this: -6.146 -> -6.15 -> -6.2 I’ve observed the same behavior with Excel’s round function too. The query below illustrates what I am describing. I may simply use the nested ROUND functions as shown below but I’m curious if there’s a better way and which approach is considered mathematically correct. DECLARE @Num AS FLOAT SET @Num = -6.1463 SELECT @Num [OriginalVal], ROUND(@Num, 1, 0) [SingleRound], ROUND(ROUND(ROUND(@Num, 3, 0), 2, 0), 1, 0) [NestedRound] Results OriginalVal | SingleRound | NestedRound -6.1463 | -6.1 | -6.2
<sql-server><tsql>
2016-04-08 16:44:13
LQ_EDIT
36,505,032
Python: Quotient unequal to a variable with the same value
<p>Am working on a small math-checker using Python and everything works well except of divisions. Problem: The quotient with two decimals (2/3 = 0.67), float, is equal to an input (0.67). But the if-statement I use to compare a user's input with the result says it isn't equal. </p> <p>Assumption: the problem is related to float. </p> <p>My code:</p> <pre><code>result = float(value0 / value1) result = round(result,2) value3 = input("Number 1") value3 = float(value3) if result != value3: print "Wrong!" print result elif result == value: print "Right!" </code></pre> <p>Of course I could create a function with a different approach, but I am curious to understand why it doesn't work.</p> <p>If there's a similar thread, please post the link and close this one. Thanks for any help.</p>
<python>
2016-04-08 16:45:40
LQ_CLOSE
36,505,393
Trying to understand function prototypes
<p>I'm going through K&amp;R and I'm on the functions chapter, and I have a quick question:</p> <p>Do I always have to declare functions as prototypes? What decides what kind of arguments will be in the prototype? Can it just be two variables in the function definition?</p> <p>Thanks!</p>
<c>
2016-04-08 17:06:22
LQ_CLOSE
36,506,398
I have to create a table with 96 columns . is it efficient or not ? but 96 columns must be in the table
<p>I have a table with 96 columns . the problem is i get confused for create this table with a large amount of columns.</p>
<mysql>
2016-04-08 18:05:34
LQ_CLOSE
36,507,244
How to write Facebook App that continuously update profile picture
<p>I want to know if its possible to create Facebook app that continuously update users profile picture. I can't see anything in the docs. Do you know if this is possible and if so any docs on implementing it?</p> <p>Thanks in advance.</p>
<facebook><documentation><facebook-apps>
2016-04-08 18:57:11
LQ_CLOSE
36,509,681
Conver Sql query to ruby
i need to query in ruby on rails select p.name from shoppe_products p join shoppe_product_categorizations ca on (p.id = ca.product_id) join shoppe_product_categories c on (c.id = ca.product_category_id) where c.id = 2 I use Ruby version 2.1.5, Rails version 4 and PG 9.4 Thanks very much for your assistance.
<ruby><ruby-on-rails-4><rails-activerecord>
2016-04-08 21:31:53
LQ_EDIT
36,510,064
Hash function for sorting 100 or more integar numbers
<p>I searched the problem but not satisfied, so that I want to ask a question. If I want to sort suppose 100 numbers using hash table what hash function may help me.I sorted 10 numbers(by bucketsort) through the table, of whats length was 10. Without increasing the table length how could I still imply bucket sort there.X%10 will not help me any more?. So how could I still sort my numbers.</p>
<c>
2016-04-08 22:03:44
LQ_CLOSE
36,511,455
Priority List with Heap Sort (Java)
<p>I would like know if exists a Java native implementation for a Priority List using Heap Sort approach. If not, is there any recommended alternative?</p>
<java><heap><heapsort>
2016-04-09 00:43:36
LQ_CLOSE
36,511,530
Is there any way to reference other elements with Ruby's #map and #select?
I have an array of numbers, with I'd like to compare with its neighbours: a = [1, 2, 3, 90, 4, 5, 6 ..., 10] I'd like to remove any "too much different" items (ex.: 90). Is there a "map / select with index", by which I could reference previous/next items ? a.select { |i| i.too_much_different? i.prev, i.next }
<arrays><ruby>
2016-04-09 00:57:31
LQ_EDIT
36,513,180
to get data from array in php
i have to echo the value from array . In an array we have two feilds . Need to fetch specific feilds. My code is this $fields = array( 'name' => $name, 'age' => $age, ); Need to get the name only in result.I have done this . But showing Array. foreach ($fields as $key => $value) { echo $value; }
<php><arrays>
2016-04-09 05:38:39
LQ_EDIT
36,513,284
Is there an API for voice recognition of a person used for authentication
<p>I am very new to API's and searches alot but doesn't find any thing related, I want an API for voice recognition in which the frequency of voice for a user is stored and then used as a bio-metric authentication for that user. for example a user is to register giving his voice as an input, it will be processed using an API and stores the frequency or pitch of the user to somewhere then the same user when tries to login he/she has to provide his voice, it will be match with the one given at the time of registration, if it matches user will be authenticated. Please help me out</p>
<java><php><android><voice-recognition>
2016-04-09 05:56:45
LQ_CLOSE
36,513,304
mysql process 10M records table
recently I am using mySQL to process some tables with over 40M records. The detail scenario is as follows: Given two tables with same structure containing over 40M price info Table 1 product_id price date 101 5.7 2016/1/1 102 11.6 2016/1/1 104 8 2016/1/1 … … … Table 2 product_id price date 101 5.9 2016/1/2 103 20.3 2016/1/2 104 8 2016/1/2 … … … my goal is to find out how many product_id exist on both days, and I use the below query to search: SELECT count(*) FROM t1 a,t2 b where a.product_id=b.product_id ; SELECT count(*) FROM t1 a,t2 b on a.product_id=b.product_id ; It takes over half an hour to get the result, is there any way to improve the performance?
<mysql><database><performance>
2016-04-09 05:59:39
LQ_EDIT
36,513,381
create file form text file in java
I write this code to output text file but it doesn't produce any file after running it. String text1="hello word"; try { File file = new File("f0f0f0f.txt"); FileWriter fileWriter = new FileWriter(file); fileWriter.write(text1); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
<java>
2016-04-09 06:10:53
LQ_EDIT
36,513,754
How to assign onclick to a variable in a canvas?
<p>I'm trying to make the circle I've made in canvas have an onclick event. I tried the following with no success. If anyone can offer some pointers, that would be great.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="type"&gt;&lt;/div&gt; &lt;canvas id="ctx2" width="500" height="500" style="border: solid 1px;"&gt;&lt;/canvas&gt; &lt;script&gt; var ctx = document.getElementById("ctx2").getContext("2d"); //var message = 'Hello John, this is your canvas.'; //ctx.fillStyle = 'red'; //ctx.font = '30px Arial'; //ctx.opacity = 0; //ctx.fillText(message,50,50); ctx.beginPath(); ctx.arc(100,75,50,0,2*Math.PI); ctx.stroke(); ctx.onclick = displayDate(); // This is what I used (stack overflow) function displayDate() { document.getElementById("type").innerHTML = Date(); } document.getElementById("type").innerHTML = typeof ctx &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<javascript>
2016-04-09 06:59:30
LQ_CLOSE
36,514,533
How to avoid FileNotFoundException?
<p>I'm wondering how to make it so that my program creates a file if it does not already find it there?</p> <pre><code>public void load() throws Exception { try { File log = new File(FILE_NAME); //opens the file FileInputStream fileIn = new FileInputStream(log); ObjectInputStream in = new ObjectInputStream(fileIn); //de-serializes videosList = (ArrayList)in.readObject(); // de-serializes in.close(); //closes the file fileIn.close(); } catch(Exception i) { i.printStackTrace(); } </code></pre> <p>And this is the error I am getting:</p> <pre><code>java.io.FileNotFoundException: Users/hanaezz/Desktop/output.ser (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:138) at videostore.BinaryFile.load(BinaryFile.java:31) at videostore.VideoStore.&lt;init&gt;(VideoStore.java:33) at videostore.VideoStore$6.run(VideoStore.java:430) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) </code></pre> <p>All the extra stuff there is because my program is also a GUI program. And then I also have a method that's supposed to write my object to a file...</p> <pre><code>public void writeToFile() throws Exception{ FileOutputStream outputStream = new FileOutputStream(FILE_NAME); ObjectOutputStream oos = new ObjectOutputStream(outputStream); oos.writeObject(videosList); oos.close(); outputStream.close(); } </code></pre> <p>This throws the same exception. How can I avoid this? I'm not sure how to modify the FIS/OIS to create the file if they don't find it.. or I suppose it would be more efficient for the FOS/OOS to do it instead?</p>
<java><arraylist><file-io><exception-handling>
2016-04-09 08:31:41
LQ_CLOSE
36,515,411
How to do some operations on other website in PHP/JS
<p>How I can do some operations like for example filling forms on the other website using PHP or JS/JQuery ?</p>
<javascript><php><jquery><ajax><html>
2016-04-09 10:11:49
LQ_CLOSE
36,516,019
addding a counting colum to a numpy array in python
I have a 2d numpy array ans i.e ans=[8,5,9,2,4] i want to convert it into a 2d array like ans= {[1,8], [2,5], [3,9], [4,2], [5,4]} the first column is in sequence [1,2,3......500,501..] how to do this in python
<python><numpy>
2016-04-09 11:14:41
LQ_EDIT
36,516,269
Sort Data with Python
<p>I am totally new in Python and I have a snippet of my code below</p> <pre><code>class student: def __init__(stu, code, name, number): stu.code = code stu.name = name stu.number = number student = [ stu("901", "Joh Doe", "123456") stu("902", "Mary Mount", "566665") stu("903", "David Lee", "394624") ] </code></pre> <p>I would like to sort the last data below from Highest to Lowest, may i know how to do it?</p> <p>From:</p> <pre><code>901 Joh Doe 123456 902 Mary Mount 566665 903 David Lee 394624 </code></pre> <p>To:</p> <pre><code>902 Mary Mount 566665 903 David Lee 394624 901 Joh Doe 123456 </code></pre> <p>Really appreciate your kind help Thanks</p>
<python><sorting>
2016-04-09 11:42:30
LQ_CLOSE
36,516,575
MargeSort algorithm
I can't figure out what is wrong with my MargeSort function. This is my code: void Marge(int* A, int p, int q, int r) { int B[100], i = 0, j = 0, k = 0; i = p; k = p; j = q + 1; while (i <= q && j <= r) { if (A[i] <= A[j]) { B[k] = A[i]; k++; i++; } else { B[k] = A[j]; k++; j++; } } while (i <= q) { B[k] = A[i]; k++; i++; } while (j <= r) { B[k] = A[j]; k++; j++; } for (i = p; i<r; i++) { A[i] = B[i]; } } void MargeSort(int A[], int p, int r) { int q; if (p<r) { q = (p + r) / 2; MargeSort(A, p, q); MargeSort(A, q + 1, r); Marge(A, p, q, r); } } int main(void) { int N[10]; N[0] = 4; N[1] = 5; N[2] = 8; N[3] = 12; N[4] = 7; N[5] = 3; N[6] = 23; N[7] = 1; N[8] = 90; N[9] = 26; MargeSort(N, 0, 9); for (int i = 0; i<10; i++) { cout << N[i] << endl; } } The output of program is: 1, 3, 1, 4, 5, 7, 7, 7, 26, 26, what is obviously wrong, but just don't see what is wrong in code, to me everthing looks good. I goole some c++ codes of MargeSort and try to debug it but i can't find mistake. Anyone see it?
<c++><algorithm><sorting>
2016-04-09 12:11:09
LQ_EDIT
36,516,798
check this recursive code c# webbrowser control. need help ASAP
i need to execute a method based on the visibility of the following html element. <div id="loading" style="height: 201px; width: 793px; visibility: hidden;"> the method i used to check the visibility property works fine. public bool isloading() { string v; v= webBrowser1.Document.GetElementById("loading").Style; if (v.Contains("visible")) { return true; } if (v.Contains("hidden")) { return false; } else return false; } i m using it like this. the app freezes upon coming to this code. need help public void battleloop() { if (!isloading()) { universalclcikbutton(); } else { battleloop(); } } i know it is calling a method within a method. anyone please give me alternatives ASAP!!!!!!!!!!!
<c#><html><visual-studio-2012><recursion>
2016-04-09 12:31:09
LQ_EDIT
36,517,100
css clouds animation issue
im having trouble integrating this css clouds animation into my website. the overflow : hidden and scroll are causing my problems. and I don't want the clouds scrolling outside of the blue box background area, but don't know how . please see http://www.filehostfree.com/cloudcsstest/cssanimation.html ive left a comment in the source code. please see ,highlights my issue. any help is appreciated.thanks
<html><css><css-animations>
2016-04-09 12:59:41
LQ_EDIT
36,517,316
How to change button CSS click / drag color?
<p>You can checkout my website here: <a href="https://www.counterboosting.com/buy-csgo-rank-boosting/" rel="nofollow">https://www.counterboosting.com/buy-csgo-rank-boosting/</a></p> <p>When dragging the "Buy Now" button, it will randomly turn green. If anyone could help me keep it orange as it is. Thanks!</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.col-boosting .btn-pay-rank { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-pay-rank:hover { height: 65px; background: #dd5a22; font-weight: bold; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-pay-rank[disabled] { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-default { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-primary { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-pay-rank-primary:hover, .col-boosting .btn-pay-rank-primary:focus, .col-boosting .btn-pay-rank-primary:active, .col-boosting .btn-pay-rank-primary.active, .open &gt; .dropdown-toggle.btn-pay-rank-primary { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open &gt; .dropdown-toggle.btn-primary { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; } .col-boosting .btn-primary:active, .col-boosting .btn-primary.active { height: 65px; font-weight: bold; background: #e06b38; border: none; box-shadow: 0 7px 0 0 #c7511f; }</code></pre> </div> </div> </p> <p>As you can see, I pretty much tried everything and I can't seem to find a solution. Some help would be greatly appreciated. Thanks!</p>
<javascript><html><css><wordpress><button>
2016-04-09 13:20:24
LQ_CLOSE
36,519,061
JavaScript - if loop stopping and not working
if (skin_var == 1) { skin = "%kraken"; skin_var = 2; } if (skin_var == 2) { // this won't activate skin = "%mercury"; skin_var = 3; } if (skin_var == 3) { skin = "%shark"; skin_var = 4; } if (skin_var == 4) { // this won't activate either skin = "%banana"; skin_var = 5; } if (skin_var == 5) { skin = "%nuclear"; skin_var = 6; } if (skin_var == 6) { skin = "%space_dog"; skin_var = 7; } if (skin_var == 7) { skin = "%t_rex" skin_var = 8; } if (skin_var == 8) { // gets stuck right here skin = "%spy" skin_var = 1; } That's my code above. As you can see by the comment lines, they always don't work or get stuck at some point. Any more effecient way to do this or how to fix it? ( i just want to change skin to something every second forever, and i have used setInterval(); but it only seems to do "%kraken" to "%shark" to "%nuclear" to "%t_rex" and then it cycles before i added "%spy" )
<javascript>
2016-04-09 15:45:38
LQ_EDIT
36,519,712
creating a movie database
<p>Hi is there anyway I can incorporate an entire movie database to an android application ? I am using java to code and I cannot figure out whether to use sql lite. But even if that is the case I don't know how to exactly I am supposed to code all that considering I need to classify the movies according to genres, year, duration, a trailer and plot.Thank you.</p>
<java><android>
2016-04-09 16:37:31
LQ_CLOSE
36,519,731
want sql query for this senario
tbl_employee empid empname openingbal 2 jhon 400 3 smith 500 tbl_transection1 tid empid amount creditdebit date 1 2 100 1 2016-01-06 00:00:00.000 2 2 200 1 2016-01-08 00:00:00.000 3 2 100 2 2016-01-11 00:00:00.000 4 2 700 1 2016-01-15 00:00:00.000 5 3 100 1 2016-02-03 00:00:00.000 6 3 200 2 2016-02-06 00:00:00.000 7 3 400 1 2016-02-07 00:00:00.000 tbl_transection2 tid empid amount creditdebit date 1 2 100 1 2016-01-07 00:00:00.000 2 2 200 1 2016-01-08 00:00:00.000 3 2 100 2 2016-01-09 00:00:00.000 4 2 700 1 2016-01-14 00:00:00.000 5 3 100 1 2016-02-04 00:00:00.000 6 3 200 2 2016-02-05 00:00:00.000 7 3 400 1 2016-02-08 00:00:00.000 here 1 stand for credit and 2 for debit i want oput put like empid empname details debitamount creditamount balance Dr/Cr date 2 jhon opening Bal 400 Cr 2 jhon transection 1 100 500 Cr 2016-01-06 00:00:00.000 2 jhon transection 2 100 600 Cr 2016-01-07 00:00:00.000 2 jhon transection 1 200 800 Cr 2016-01-08 00:00:00.000 2 jhon transection 2 200 1000 Cr 2016-01-08 00:00:00.000 2 jhon transection 2 100 900 Dr 2016-01-09 00:00:00.000 2 jhon transection 1 100 800 Dr 2016-01-11 00:00:00.000 2 jhon transection 2 700 1500 Cr 2016-01-14 00:00:00.000 2 jhon transection 1 700 2200 Cr 2016-01-15 00:00:00.000 3 smith opening Bal 500 Cr 3 smith transection 1 100 600 Cr 2016-02-03 00:00:00.000 3 smith transection 2 100 700 Cr 2016-02-04 00:00:00.000 3 smith transection 2 200 500 Dr 2016-02-05 00:00:00.000 3 smith transection 1 200 300 Dr 2016-02-06 00:00:00.000 3 smith transection 1 400 700 Cr 2016-02-07 00:00:00.000 3 smith transection 2 400 1100 Cr 2016-02-08 00:00:00.000
<sql><sql-server>
2016-04-09 16:38:57
LQ_EDIT
36,519,836
AjaxContent cannot be loaded in any browsers.
<p>Why is it my ajaxContent not loaded? It was working before I created the text files and the ajax function. Now it cannot be loaded in Chrome or Firefox. What am I doing wrong?</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;title&gt;My website&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.11.0.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css"&gt; function ajax(url) { $("#ajaxContent").load(url); } $(document).ready(function() { ajax('Aboutus.txt'); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="wrapper"&gt; &lt;header&gt; &lt;nav&gt; &lt;ul&gt; &lt;li&gt;&lt;a href onClick="ajax('Aboutus.txt')"&gt;About us&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Menu&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Events&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Gallery&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Booking&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Shop&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href onClick="ajax('Menu.txt')"&gt;Contacts&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;/header&gt; &lt;article id="ajaxContent"&gt;&lt;/article&gt; &lt;footer&gt; &amp;copy; 2016 &lt;/footer&gt; &lt;/div&gt;&lt;!-- .wrapper --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<javascript><jquery><html><ajax>
2016-04-09 16:47:03
LQ_CLOSE
36,520,251
does python find errors where there are none?
<p>while plotting functions with heaviside function I came up with this piece of code, in Idle:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt n_i = [-5, 5] n = np.linspace(n_i[0], n_i[1], 1E3) u1 [n+30&gt;=0] = 1 u2 [n-15&gt;=0] =1 u3 = u1 - u2 x = np.sin(2*np.pi*(n/15))*u3 plt.axis([-30,15,-5,5]) plt.xlabel('$n$',fontsize=20) plt.ylabel('$x(n)$',fontsize=20) plt.stem(n, x, "--k", linefmt='black', basefmt='black') plt.grid() plt.show() </code></pre> <p>and prior to today, it ran without errors, same with all other of my plots, I've been dealing with python for two years now and throughout classes it had the habit of finding errors where even teachers don't see them. am I missing something here? it says "u1 is not defined", but it is. I even compared with coworkers and classmates alike, haven't seen it put in any other way in the code for the plot. help!</p>
<python><plot>
2016-04-09 17:25:33
LQ_CLOSE
36,520,506
Convert decimal number to BigInteger in Java
<p>I am trying to convert <code>10000000000000000000000000000000</code> to <code>BigInteger</code>. But it is not converting. My code is </p> <p><code>BigInteger number = BigInteger.valueOf(10000000000000000000000000000000);</code> </p> <p>It is showing <code>The literal 10000000000000000000000000000000 of type int is out of range</code>.</p> <p>Is there any way to convert this number as I have to use this number as integer in my programme?</p>
<java><type-conversion><biginteger>
2016-04-09 17:48:51
LQ_CLOSE
36,520,960
ValueError: 0 is not in list - Index of max number in list
I need to find the index of the biggest number in the list (bitonic list) i wrote func that find the number (and correct i think) and then try to find the index using index method but i get Error when i try to debug it, i can see why it's going wrong, but i dont know how to fix it Thanks! def find_maximum(n): b = find_max_number(n) return n.index(b) def find_max_number(n): middle = len(n)//2 if len(n) == 1 : return (n[0]) if len(n)>2: if n[middle] > n[middle-1] and n[middle] > n[middle+1] : return (n[middle]) if (n[middle-1] < n[middle]): return find_maximum(n[middle:]) else : return find_maximum(n[:middle])
<python><list><max>
2016-04-09 18:29:17
LQ_EDIT
36,521,430
How are private variables accessed in operator overloading?
<p>How can private variables be accessed in operator overloading (obj.real,obj.imag,res.real,res.imag) in this code. Can someone explain</p> <pre><code>#include&lt;iostream&gt; using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i =0) {real = r; imag = i;} // This is automatically called when '+' is used with // between two Complex objects Complex operator + (Complex const &amp;obj) { Complex res; res.real = real + obj.real; res.imag = imag + obj.imag; return res; } void print() { cout &lt;&lt; real &lt;&lt; " + i" &lt;&lt; imag &lt;&lt; endl; } }; int main() { Complex c1(10, 5), c2(2, 4); Complex c3 = c1 + c2; // An example call to "operator+" c3.print(); } </code></pre>
<c++>
2016-04-09 19:09:46
LQ_CLOSE
36,522,412
Value of float is different from what was scanned
<p>So I have this program in which I need to compare values in 0.0X range and if I scan for example 50.21 with this little thing</p> <pre><code>scanf("%f",bill); </code></pre> <p>the value stored in var. bill is actually 50.2099990845... which messes up calculations later in program. Is there any way to turn this number into 50.210000? Thanks for your time. </p>
<c>
2016-04-09 20:38:21
LQ_CLOSE
36,523,375
Changing values of dictionary to integers
<p>I'm currently setting up a dictionary and am attempting to convert the values associated with a key from strings to integers. So I'm trying to go from this:</p> <pre><code> {'Georgia': ['18', '13', '8', '14']} </code></pre> <p>To this:</p> <pre><code> {'Georgia': [18, 13, 8, 14]} </code></pre> <p>Any ideas on how I would go about doing this?</p>
<python><dictionary>
2016-04-09 22:16:43
LQ_CLOSE
36,525,305
Program Not Working As Expected
I am writing a program that allows the user to type in a "stop word" (https://en.wikipedia.org/wiki/Stop_words) and returns which language that stop word is contained within. The program is crashing, I almost said inexplicably, but I am no expert at C so I'm sure there is an explanation. I'm here because I cannot figure it out. I hate to post my entire code, but I really don't know where my problem lies, and I want to supply you with replicable code. Here is my code followed by an example stop word file. #StopWords.c #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <stddef.h> #include <string.h> typedef struct { char languageName[60]; //FILE fp; char stopwords[2000][60]; int wordcount; } LangData; typedef struct { int languageCount; LangData languages[]; } AllData; AllData *LoadData(char *); int main(int argc, char **argv) { AllData *Data; Data = LoadData(argv[1]); char word[60]; //Get word input from user printf("Enter a word to search: "); fgets(word, 60, stdin); //Search for word and print which languages it is found in. int i = 0; int k = 0; int found = -1; while(i < Data->languageCount) { while(k < Data->languages[i].wordcount) { if(strcmp(word, Data->languages[i].stopwords[k]) == 0) { found = 0; printf("Word found in %s", Data->languages[i].languageName); k++; } } i++; } if(found == -1) printf("Word not found"); return 0; } AllData *LoadData(char *path) { //Initialize data structures and open path directory int langCount = 0; DIR *d; struct dirent *ep; d = opendir(path); //Checks whether directory was able to be opened. if(!d) { perror("Invalid Directory"); exit(-1); } // // Only executed if directory is valid. // v v v v v v v v v v v v v v v v v v //Count the number of language files in the directory while(readdir(d)) langCount++; //Account for "." and ".." //langCount = langCount + 1; langCount = langCount - 2; //Allocate space in AllData for languageCount AllData *data = malloc(offsetof(AllData, languages) + sizeof(LangData)*langCount); data->languageCount = langCount; int i = 0; int k = 0; //Initialize Word Counts to zero for all languages for(i = 0; i < langCount; i++) { data->languages[i].wordcount = 0; } //Reset the directory in preparation for reading names rewinddir(d); //Get name of language for each file i = 0; while((ep = readdir(d)) != NULL) { if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, "..")) { //Filtering "." and ".." } else { int size = strlen(ep->d_name); strcpy(data->languages[i].languageName, ep->d_name); data->languages[i].languageName[size - 4] = '\0'; i++; } } //Reset the directory in preparation for reading data rewinddir(d); //Copy all words into respective arrays. char word[60]; i = 0; k = 0; int j = 0; while((ep = readdir(d)) != NULL) { if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, "..")) { //Filtering "." and ".." } else { FILE *entry; char fullpath[100]; memset(fullpath, 0, sizeof fullpath); strcpy(fullpath, path); strcat(fullpath, "\\"); strcat(fullpath, ep->d_name); entry = fopen(fullpath, "r"); while(fgets(word, 60, entry) != NULL) { j = 0; while(word[j] != '\0') { data->languages[i].stopwords[k][j] = word[j]; j++; } k++; data->languages[i].wordcount++; } i++; fclose(entry); } memset(ep, 0, sizeof *ep); } return data; } #english.txt consider seven without know very via you'll can't that doesn't getting hereafter whereas somewhat keeps soon their better awfully non ever but it's got within hello above came seems appreciate nd particularly especially useful when never need be here yourselves alone we're down able whose going perhaps didn't really want twice there yours used against gotten ltd wonder concerning actually only were anything hadn't thru sometimes various first it overall between onto won't best about indicates gets over saying ought according hence let serious everywhere there's nine mean has ex a than c's necessary following around tends still if yes these uses secondly t's am changes up each available otherwise seen nobody seeming outside apart cause off thereafter could hereby new specify get fifth sent toward during sorry another i'll hopefully should anyhow keep for welcome aren't etc thanks vs insofar whole happens whereupon isn't seem relatively near despite plus meanwhile they'll look eg greetings whereafter i'm self selves almost un did inner oh after four five follows com nearly some say like later further being somehow beforehand you think his ones aside forth its however novel rather name does again both nothing what right formerly accordingly allows theres please thats will towards sub they're well thereby possible entirely a's had among probably c'mon quite th let's regarding clearly beside until besides at might less the causes where's doing howbeit contains respectively and thereupon somewhere ain't same wouldn't haven't took whence others namely any before certainly willing although else unlikely use those throughout she so along merely we'd using no where everybody once usually asking not therein least it'd someone anyway under you're maybe particular because out downwards looks rd saw appropriate theirs definitely furthermore whenever qv you've wherever next knows gone instead who's do somebody comes shouldn't wants more as inasmuch seriously come an known are nevertheless inward thoroughly anybody amongst far either something considering described them most moreover last regardless regards us sup per herein seeing already they your while course thank by tell here's becoming having he mainly help okay our other unfortunately often behind everything nor ours don't see obviously whither himself reasonably take wasn't thanx therefore now enough across would taken two then or which placed they've one specifying former it'll have sometime believe with sure shall such that's they'd from every co how was ok on liked truly exactly seemed given been indicated try gives latter unless corresponding likely anywhere weren't thorough cant except anyone currently second go everyone third can too beyond my anyways specified we've tries wish hasn't noone sensible thus became said elsewhere to brief we since herself him whom needs i've would much ask you'd goes who inc hardly cannot done this thence whereby viz neither myself presumably themselves immediate whoever uucp value whatever appear old latterly itself lately also even together few ourselves went yourself six provides just of hereupon nowhere hi contain many followed her wherein he's become unto though indicate may is allow in none becomes upon afterwards et i what's normally mostly zero we'll example edu several always through que three all way associated containing indeed whether i'd couldn't why trying own lest below ignored yet kept hither re little looking eight me must ie consequently hers away certain tried says different into When I run the program (I am using Windows, sue me) this is the command I would type: StopWords C:\Users\Name\Desktop\Stop_Words_Directory The parameter is simply a path to the directory in which the language files (e.g. english.txt) are located. I apologize again for the mountain of code, but I am lost here and would be extremely grateful if someone can help.
<c>
2016-04-10 03:08:24
LQ_EDIT
36,525,693
Why is my number coming up as 0?
<p>I am trying to make a calculator that calculates the amount of calories that have been burned in a certain amount of time, but whenever I run it, I get 0 as the output. I have tried setting the calorieCountOut variable to an arbitrary number, and then it works fine, but every time I run it with this code here, I get 0. Here is my code:</p> <pre><code>const AGECONST = 0.2017; const WEIGHTCONST = 0.09036; const HRCONST = 0.6309; const SUBTRACTCONST = 55.0969; const TIMECONST = 4.184; //var gender = document.getElementById("gender").innerHTML; var gender = "male"; var weight = document.getElementById("weight"); var age = document.getElementById("age"); var time = document.getElementById("time"); var hr = 140;//dummy number function calculate(){ if (gender = "male"){ var calorieCount = ((age * AGECONST) - (weight * WEIGHTCONST) + (hr * HRCONST) - SUBTRACTCONST) * time / TIMECONST; } //else if (gender = "female"){ //} var calorieCountOut = calorieCount.toString(); document.getElementById("output").innerHTML = calorieCountOut; } </code></pre>
<javascript><html>
2016-04-10 04:11:42
LQ_CLOSE
36,526,214
How to use a decrypted python string as a zip file to import files from?
<p>i have encrypted a python zip file made with zipfile module, in my code I'm decrypting the zip file it's self and returning string. If i make this string an actual .zip file it works like a zip file. But i want to store the decrypted string as a dynamic in memory zip and, import files from it so the encrypted zip won't be touched or decrypted. How can i do this?</p>
<python>
2016-04-10 05:32:37
LQ_CLOSE
36,527,656
How do I make an auto popup box for my website?
<p>I have looked everywhere to get a good popup box that auto pops up when the page loads but had no luck. I want a auto popup box that is centered and has overlay and that auto pops up. I want a popup box like this: <a href="http://imgur.com/A0NIPny" rel="nofollow">http://imgur.com/A0NIPny</a></p> <p>Can you tell me the code for it and how to do it?? Sorry I'm kinda new at html and stuff but I know the basics and no I don't wanna use WordPress for this</p>
<javascript><php><html><css>
2016-04-10 08:42:34
LQ_CLOSE
36,528,043
How do dynamically generate this kind of nested li objects using javascript/jquery?
<p>I want to dynamically generate following kind of nested li objects in my jsp. How Should I do this. I am unable to solve by using simple document.createElement("LI"); and appendElement as I also want to add class to that elements.</p> <pre><code>&lt;li class="level1"&gt; &lt;div class="thumb"&gt; &lt;a href="detail.html#"&gt;&lt;img src="images/comments1.gif" alt="" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="desc"&gt; &lt;div class="commentlinks"&gt; &lt;a href="detail.html#" class="reply"&gt;Reply&lt;/a&gt; &lt;a href="detail.html#" class="like"&gt;Like&lt;/a&gt; &lt;a href="detail.html#" class="dislike"&gt;Dislike&lt;/a&gt; &lt;/div&gt; &lt;h5&gt; &lt;a href="detail.html#" class="colr"&gt;By MySebbb:&lt;/a&gt; &lt;/h5&gt; &lt;p class="time"&gt;7 months ago&lt;/p&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;p class="txt"&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed elit. Nulla sem risus, vestibulum in, volutpat eget, dapibus ac, lectus. Curabitur dolor sapien.&lt;/p&gt; &lt;/div&gt; &lt;/li&gt; </code></pre>
<javascript><jquery><html><css><jsp>
2016-04-10 09:27:30
LQ_CLOSE
36,528,775
Is it possible to write a python program that will enable you to sort the content of a text file in python
<p>I have been writing a maths quiz and the program asks the students questions and then saves their score like so:</p> <pre><code>class_number = prompt_int_big("Before your score is saved ,are you in class 1, 2 or 3? Press the matching number") filename = (str(class_number) + "txt") with open(filename, 'a') as f: f.write("\n" + str(name) + " scored " + str(score) + " on difficulty level " + str(level_of_difficulty) + "\n") with open(filename) as f: lines = [line for line in f if line.strip()] lines.sort() if prompt_bool("Do you wish to view previous results for your class"): for line in lines: print (line) else: sys.exit("Thanks for taking part in the quiz, your teacher should discuss your score with you later") </code></pre> <p>However I have been instructed to save the last three scores to a students name and then display an average of these last three scores. This requires scores to be saved to students name. I am thinking about outsourcing this to excel however I don't know how to do this using a test file or whether a text file will even open in excel.</p> <p>Here is the rest of code:</p> <pre><code>import random import sys def get_input_or_quit(prompt, quit="Q"): prompt += " (Press '{}' to exit) : ".format(quit) val = input(prompt).strip() if val.upper() == quit: sys.exit("Goodbye") return val def prompt_bool(prompt): while True: val = get_input_or_quit(prompt).lower() if val == 'yes': return True elif val == 'no': return False else: print ("Invalid input '{}', please try again".format(val)) def prompt_int_small(prompt='', choices=(1,2)): while True: val = get_input_or_quit(prompt) try: val = int(val) if choices and val not in choices: raise ValueError("{} is not in {}".format(val, choices)) return val except (TypeError, ValueError) as e: print( "Not a valid number ({}), please try again".format(e) ) def prompt_int_big(prompt='', choices=(1,2,3)): while True: val = get_input_or_quit(prompt) try: val = int(val) if choices and val not in choices: raise ValueError("{} is not in {}".format(val, choices)) return val except (TypeError, ValueError) as e: print( "Not a valid number ({}), please try again".format(e) ) role = prompt_int_small("Are you a teacher or student? Press 1 if you are a student or 2 if you are a teacher") if role == 1: score=0 name=input("What is your name?") print ("Alright",name,"welcome to your maths quiz." " Remember to round all answers to 5 decimal places.") level_of_difficulty = prompt_int_big("What level of difficulty are you working at?\n" "Press 1 for low, 2 for intermediate " "or 3 for high\n") if level_of_difficulty == 3: ops = ['+', '-', '*', '/'] else: ops = ['+', '-', '*'] for question_num in range(1, 11): if level_of_difficulty == 1: max_number = 10 else: max_number = 20 number_1 = random.randrange(1, max_number) number_2 = random.randrange(1, max_number) operation = random.choice(ops) maths = round(eval(str(number_1) + operation + str(number_2)),5) print('\nQuestion number: {}'.format(question_num)) print ("The question is",number_1,operation,number_2) answer = float(input("What is your answer: ")) if answer == maths: print("Correct") score = score + 1 else: print ("Incorrect. The actual answer is",maths) if score &gt;5: print("Well done you scored",score,"out of 10") else: print("Unfortunately you only scored",score,"out of 10. Better luck next time") class_number = prompt_int_big("Before your score is saved ,are you in class 1, 2 or 3? Press the matching number") filename = (str(class_number) + 'txt') with open(filename, 'a') as f: f.write("\n" + str(name) + " scored " + str(score) + " on difficulty level " + str(level_of_difficulty) + "\n") with open(filename) as f: lines = [line for line in f if line.strip()] lines.sort() if prompt_bool("Do you wish to view previous results for your class"): for line in lines: print (line) else: sys.exit("Thanks for taking part in the quiz, your teacher should discuss your score with you later") </code></pre>
<python><excel><sorting><random><average>
2016-04-10 10:50:50
LQ_CLOSE
36,528,939
getElementById returns an object instead of an element
<p>I have an input with an id of <code>name</code>:</p> <pre><code>&lt;input type="text" id="name"&gt; </code></pre> <p>When I run <code>document.getElementById("name")</code> in the console, I get the element itself (<code>&lt;input type="text" id="name"&gt;</code>), but as soon as I assign it to a variable (<code>var name = document.getElementById("name");</code>), I get the string <code>"[object HTMLInputElement]"</code>.</p> <p>Why does that happen? Why can't I just get the selected input element, instead of the input element object?</p> <p>Thanks.</p>
<javascript><getelementbyid>
2016-04-10 11:08:02
LQ_CLOSE
36,529,164
Writing a numpy matrix to a text file
I am trying to write a numpy array to a text file. But it deos not work. My problem follows. I am trying to get the RGB pixel values of a picture using `matplotlib.image` and save the values obtained from my program to some file for future use. The values are returned in the form of an array, which I tried to write to a text file using the following code. But the file does not open. Nor does it show an error message. import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np img=mpimg.imread('kitten5.jpeg') print(img) f=open('kitten.dat','w') f.write(img) f.close() imgplot=plt.imshow(img) plt.show() Can someone help? It is not mandatory that the data has to be saved to a text file alone. Other suggestions are equally welcome.
<python><arrays><numpy><file-io><matplotlib>
2016-04-10 11:34:30
LQ_EDIT
36,529,260
An Issue with pushing elements to a nested JSON
In the following code, I want to push new elements to JSON array: var temp = []; for(var i in resultDb){ temp.push({'ID':resultDb[i].ID}); temp.push({'Label':resultDb[i].Label}); temp.push({'User':[{'Name':resultDb[i].Name , 'ScreenName':resultDb[i].ScreenName}]}); temp.push({'TDate':resultDb[i].TDate}); } for(var i in temp){ console.log(temp[i].User.ScreenName); } The result that I got is `Cannot read property 'ScreenName' of undefined`. The problem specifically is with `User` but the others are fine; they can be printed.
<javascript>
2016-04-10 11:42:30
LQ_EDIT
36,529,435
Deleting undesired characters at the end of a char
<p>With this code below I dont know how to delete the undesired characters appearing at the end of the message array. It is compulsory for me to use char, can't use strings, because of the rest of my code. recvbuf is also a char* recvbuf=new char</p> <pre><code> char* message=new char[140]; for (int i=1; i&lt;141; i++){ message[i-1]=recvbuf[i]; } printf("Message: %s\n", message); delete[]recvbuf; </code></pre>
<c++>
2016-04-10 12:00:43
LQ_CLOSE
36,530,563
Arithmetic operations on float values return unexpected answer
<p>If i print the value of x for : </p> <pre><code>int a=1; int b=6; float x=(a/b); </code></pre> <p>The output is 0.0</p> <p>But if i change the third line to float x = (float)a/(float)b;</p> <p>The output is 0.1666667(which it should be)</p> <p>Why the difference?</p>
<java>
2016-04-10 13:45:31
LQ_CLOSE
36,530,943
Neural network weird prediction
<p>I try to implement a neural network. I'm using backpropagation to compute the gradients. After obtaining the gradients, I multiply them by the learning rate and subtract them from the corresponding weights. (basically trying to apply gradient descent, please tell me if this is wrong). So the first thing I tried after having the backpropagation and gradient descent ready, was to train a simple XOR classifier where the inputs can be (0,0), (1,0), (0,1), (1,1) and the corresponding outputs are 0, 1, 1, 0. So my neural network contains 2 input units, 1 output unit and one hidden layer with 3 units on it. When training it with a learning rate of 3.0 for >100 (even tried >5000), the cost drops until a specific point where it gets stuck, so it's remaining constant. The weights are randomly initialized each time I run the program, but it always gets stuck at the same specific cost. Anyways, after the training is finished I tried to run my neural network on any of the above inputs and the output is always 0.5000. I thought about changing the inputs and outputs so they are : (-1,-1), (1, -1), (-1, 1), (1, 1) and the outputs -1, 1, 1, -1. Now when trained with the same learning rate, the cost is dropping continuously, no matter the number of iterations but the results are still wrong, and they always tend to be very close to 0. I even tried to train it for an insane number of iterations and the results are the following: [ iterations: (20kk), inputs:(1, -1), output:(1.6667e-08) ] and also [iterations: (200kk), inputs:(1, -1), output:(1.6667e-09) ], also tried for inputs(1,1) and others, the output is also very close to 0. It seems like the output is always mean(min(y), max(y)), it doesn't matter in what form I provide the input/output. I can't figure out what I'm doing wrong, can someone please help?</p>
<machine-learning><neural-network>
2016-04-10 14:22:29
LQ_CLOSE
36,531,318
How do you eliminate spaces from a list? Python
<pre><code>val = [] for c in f: val.append(ord(c)) val = [w - 5 if w &gt; 20 else w for w in val] </code></pre> <p>The original text file contains a sentence which has many spaces in it. When converting the text file into its ASCII code it also converts the spaces into its ASCII code.</p>
<python><list><text-files>
2016-04-10 14:57:36
LQ_CLOSE
36,531,545
Listen cmd.exe by external application
<p>ı want to listen cmd.exe with my own application. I want to this. my application is running someone write cmd.exe and press enter button, my application realize that and take this command. Please someone answer me.</p>
<windows><cmd>
2016-04-10 15:19:07
LQ_CLOSE
36,531,988
iOS Xcode Swift
override func viewDidAppear(animated: Bool) { if let vid = self.selectedVideo { self.titleLabel.text = vid.videoTitle self.descriptionLabel.text = vid.videoDescription let width = self.view.frame.size.width let height = width/320 * 180 let videoEmbedString = "<html><head><style type=\"text/css\">body {background-color: transparent;color: white;}</style></head><body style=\"margin:0\"><iframe frameBorder=\"0\" height=\"" + String(height) + "\" width=\"" + String(width) + "\" src=\"http://www.youtube.com/embed/" + vid.videoId + "?showinfo=0&modestbranding=1&frameborder=0&rel=0\"></iframe></body></html>" self.webView.loadHTMLString(videoEmbedString, baseURL: nil) } I have problems on the last line: fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)
<ios><swift><fatal-error>
2016-04-10 15:55:45
LQ_EDIT
36,532,027
php extract standalone numbers from a line
<p>I want to extract standalone numbers from this line</p> <pre><code>4000123456789000/01/20/202/sssss/500 address/400 city/366 </code></pre> <p>to have this result</p> <pre><code>4000123456789000/01/20/202/366 </code></pre> <p>the problem that the codes gives me this result</p> <pre><code>4000123456789000/01/20/202/500/400/366 </code></pre> <p>I don't want the numbers which have the text along with it and I don't want to remove the delimiter </p>
<php><string><numbers><line><extract>
2016-04-10 15:59:28
LQ_CLOSE
36,533,710
How do i remove remove properly letters from my string?
I am trying to get a path for my xml file. i got one string with the `.exe` file- `string exe_location = System.Reflection.Assembly.GetExecutingAssembly().Location;` and another string to contain the resault- `string xml_location = exe_location.Remove(exe_location.Length, -11);` and when im running the code, the debugger suddenly says: "_Count cannot be less than zero.\r\nParameter name: count_" im not sure how i managed to fail with this simple mission. any ideas?
<c#><xml><path><visual-studio-2015>
2016-04-10 18:23:10
LQ_EDIT
36,534,020
How to see videos from a network stream(http)?
<p>I was wondering: how does youtube or any other website containing videos, send such data to clients? When using the web browser, and asking for a webpage, what happens is that the browser sends an HTTP GET request to the server, which returns the html page; but how does the video data get transferred? Is it opened an additional connection to do that? And, is there a way to capture this stream in a program using some software library?</p> <p>What i want to achieve is something like the VLC's network stream feature, which allows you to watch videos from youtube, but i don't know where to start from.</p> <p>Thanks</p>
<c++><c><http><video><youtube>
2016-04-10 18:47:31
LQ_CLOSE
36,535,112
c++ // wrong output ... what is going on?
<p>please can somebody explain this to me</p> <pre><code>#include &lt;iostream&gt; #include &lt;math.h&gt; using namespace std; int main() { int sum = 0; for(int j = 0; j &lt; 3; j++) { sum += 24 * pow(10, 3 - j - 1); } cout &lt;&lt; sum &lt;&lt; endl; return 0; } </code></pre> <p>This is my little program and it is printing out wrong answer (2663 instead of 2664), but when I write <strong>1</strong> * pow(...) instead of 24 everything is good. I am so confuse</p>
<c++>
2016-04-10 20:22:17
LQ_CLOSE
36,535,583
C - Char to hexa
<p>I have str:</p> <pre><code>char *str = "lala"; </code></pre> <p>Now, I would like convert any chars in str to hexadecimal, example:</p> <pre><code>str = convert(str); print str: 0x6C 0x61 0x6C 0x61 ^ l ^ a ^ l ^ a </code></pre> <p>How I can do that ?</p>
<c>
2016-04-10 21:09:22
LQ_CLOSE
36,536,507
Combining two data frames
<p>I have two data frames from a study, datlighton and datlightoff, They both have roughly the same data since what separates the observations is that off takes place before midnight and on takes place after. I need to combine them into a single data frame called datlight but I'm not sure how to do it. I've tried using cbind and merge but I'm new to R and I don't quite understand how to make it do exactly what I want. When I try <code>merge(datlighton,datlightoff)</code> it gives me a data frame with all the column names but none of the rows. This is <a href="http://file:///Users/brittabergren/Desktop/Ecology/Term%20Paper/Term%20Paper%20Work/datlighton.html" rel="nofollow">datlighton</a> and <a href="http://file:///Users/brittabergren/Desktop/Ecology/Term%20Paper/Term%20Paper%20Work/datlightoff.html" rel="nofollow">datlightoff</a>, I converted it to an html since I don't know to upload them as dataframes from R. Basically I just need to put all the rows from one frame into the other and have them match up with the appropriate column name.</p>
<r>
2016-04-10 22:54:43
LQ_CLOSE
36,538,070
Order function by increasing growth rate?
<p><strong>What is the order of the functions by increasing growth rate:</strong></p> <p>1^(nlogn), n^logn, 2^5, sqrt(logn), 2^(n!), 1/n, n^2, 2^logn, n!, 100^n</p> <p><strong>Here's my attempt:</strong></p> <p>1^(nlogn)</p> <p>2^5</p> <p>1/n</p> <p>sqrt(logn)</p> <p>n^2</p> <p>n^logn</p> <p>2^logn</p> <p>100^n</p> <p>n!</p> <p>2^(n!)</p>
<algorithm><data-structures><time-complexity><big-o>
2016-04-11 00:32:24
LQ_CLOSE
36,538,341
C++ Phising code
Hi I need some help with my c++ phising code. I got it to work but not as what i intended. When I run the code it scans my text file i inputted and only output one of the words in the text file that match the array in my code and when i add other words to the text file that is in the array it gives me a error. #include <fstream> #include <iostream> #include <cmath> #include <iomanip> #define SIZE 30 using namespace std; const char *Phish[SIZE] ={"Amazon","official","bank","security", "urgent","Alert","important","inform ation", "ebay", "password", "credit", "verify", "confirm", "account","bill", "immediately", "address", "telephone","SSN", "charity", "check", "secure", "personal", "confidential", "ATM", "warning","fraud","Citibank","IRS", "paypal"}; int point[SIZE] = {2,2,1,1,1,1,2,2,3,3,3,1,1,1,1,1,2,2,3,2,1,1,1,1,2,2,2,2,2,1}; int totalPoints[SIZE]; void outputResults(); int main(void) { FILE *cPtr; char filename[100]; char message[5000]; char *temp[100]; int i; int counter=0; int words=0; char *tokenPtr; cout << "Enter the name of the file to be read: \n"; cin >> filename; if ( (cPtr = fopen(filename,"rb")) == NULL) { cout <<"File cannot be opened.\n"; } else { fgets(message, 5000, cPtr); tokenPtr = strtok(message, " "); temp[0] = tokenPtr; while (tokenPtr!=NULL) { for(i=0; i< SIZE; i++) { if(strncmp(temp[0], Phish[i], strlen(Phish[i]))==0) { totalPoints[i]++; break; } tokenPtr =strtok(NULL, " "); temp[0] = tokenPtr; words++; } outputResults(); cout << "\n"; return 0; } } } void outputResults() { int i; int count =0; int a; cout<<left<<setw(5) << "WORD "<< setw(7)<<"# OF OCCURRENCE "<< setw(15)<<"POINT TOTAL"; for(i=0; i<SIZE; i++) { if(totalPoints[i] !=0) { cout<<"\n"<<left << setw(10)<< Phish[i] << setw(11)<< totalPoints[i]<< setw(13)<< point[i]*totalPoints[i]; count += point[i] * totalPoints[i]; } } cout<< "\nPoint total for entire file: \n"<< count; }
<c++>
2016-04-11 01:13:05
LQ_EDIT
36,538,477
Read a excel file in c++ using visual studio
<p>I have a project where I must read from an excel file into a c++ program. I must then be able to use this data to carry out calculations, sorting, searching, etc. In the excel file, there are about 20 lines of information that is necessary not necessary for the calculations. after, there are are about 100 lines of raw data to spanning several columns. My question is how to read the first 20 lines and store them, but not use them, and how to read the other 100 lines and columns into a structure, so that I can access their data.</p>
<c++><excel><structure>
2016-04-11 01:31:32
LQ_CLOSE
36,539,551
How to implement Task Scheduler Manager on C# ?
I want to write a Scheduler Manager. My Scheduler Manager contain 3 type of running task - each XX seconds ( ex. each 15 seconds ) - every day at same time ( ex. every day at 7 a.m ) - emergency task - this is task that UI can add and will run imitatively My problem is that i don't know how to implement the alarm that will popup at the time that the task need to run. I can calculate the time between 'now' and the target time and using Timer.Interval that will wait for the right time to popup the task But is there better way to implement this ?
<c#>
2016-04-11 03:52:04
LQ_EDIT
36,539,609
How can I delay an event in c#
I would like to delay the execution of an instruction without executing any other one meanwhile. Here's the program.[enter image description here][1] [1]: http://i.stack.imgur.com/iP1rm.png Thank You
<c#><.net><async-await><delay>
2016-04-11 03:57:51
LQ_EDIT
36,541,120
How to send button value to datagridview?
How to send a button value to data grid view ,if the data grid view cell is last focus then the button value goes to last focus cell.
<c#>
2016-04-11 06:15:52
LQ_EDIT
36,541,344
Using Malloc() to create an integer array using pointer
<p>I'm trying to create an integer array using the defined ADT below using the malloc() function. I want it to return a pointer to a newly allocated integer array of type intarr_t. If it doesn't work - I want it to return a null pointer. </p> <p>This is what I have so far - </p> <pre><code>//The ADT structure typedef struct { int* data; unsigned int len; } intarr_t; //the function intarr_t* intarr_create( unsigned int len ){ intarr_t* ia = malloc(sizeof(intarr_t)*len); if (ia == 0 ) { printf( "Warning: failed to allocate memory for an image structure\n" ); return 0; } return ia; } </code></pre> <p>The test from our system is giving me this error </p> <pre><code>intarr_create(): null pointer in the structure's data field stderr (empty) </code></pre> <p>Where abouts have I gone wrong here?</p>
<c><pointers><abstract-data-type>
2016-04-11 06:29:44
LQ_CLOSE
36,541,980
i want to have xpath of this code with html agility pack
<dt>Category</dt> <dd> <ol> <li> <a href="http://www.shophive.com/apple?cat=10">Mac / Macbooks</a> (165) </li> <li> <a href="http://www.shophive.com/apple?cat=18">iPhone</a> (459) </li> <li> <a href="http://www.shophive.com/apple?cat=20">iPad</a> (221) </li> <li> <a href="http://www.shophive.com/apple?cat=486">Watch</a> (129) </li> <li> <a href="http://www.shophive.com/apple?cat=16">iPod</a> (85) </li> <li> <a href="http://www.shophive.com/apple?cat=574">More</a> (69) </li> </ol> </dd> i want to have xpath from this code till 'More' but there are other li and a tag too below this code, my code is selecting those li and a tags too. help me find the xpath of this expression
<html><xml><xpath><html-agility-pack>
2016-04-11 07:06:00
LQ_EDIT
36,542,083
What is the difference between the 2 structs?
are these different or do the produce the same result? struct command { char * const *argv; }; nr 2 which also looks like a pointer to a pointer struct command { const char **argv; }; Is there a difference or are both pointer to a pointer?
<c><posix><pipeline>
2016-04-11 07:11:36
LQ_EDIT
36,543,983
Traverse javascript array of objects
<p>I have an javascript array of objects as follows :</p> <pre><code>list = [ { "employee_work_rights_id":74, "amazon_id":173, "employee_id":3, "work_rights":"australian_citizen", "document_type":"password", "display_name":"a.pdf", "filename":"abc.pdf", "s3bucket":"xyz", "filepath":"employer27\/employee3\/" }, { "employee_work_rights_id":75, "amazon_id":175, "employee_id":3, "work_rights":"australian_citizen", "document_type":"password", "display_name":"a.pdf", "filename":"xyz.pdf", "s3bucket":"zyx", "filepath":"employer27\/employee3\/" } ] </code></pre> <p>I tried to access amazon_id as follows :</p> <pre><code>console.log(list[0].amazon_id); </code></pre> <p>This is giving me undefined. How can I access this ?</p>
<javascript>
2016-04-11 08:52:46
LQ_CLOSE
36,544,238
apply inline css to rails
<p>I wish to apply CSS in inline rails code.</p> <pre><code>&lt;%= form_for @wishlist, html: { class: 'ajax_form', id: 'change_wishlist_accessibility' } do |f| %&gt; &lt;%= f.radio_button :is_private, true %&gt;&amp;nbsp;&lt;%= Spree.t(:private) %&gt; &lt;%= f.radio_button :is_private, false %&gt;&amp;nbsp;&lt;%= Spree.t(:public) %&gt; </code></pre> <p>&lt;% end -%> I want to apply <code>margin-left: 600px;</code> tot the form.</p> <p>How can I do this?</p> <p>Thanks</p>
<css><ruby-on-rails>
2016-04-11 09:03:36
LQ_CLOSE
36,544,950
Visual C# problems
Im having some trouble with visual studio as it says it wont compile. I cant figure out what the problem is it says something like it can't convert from void to bool even though they're is no 'bool'. Here is my code: using System; namespace ConsoleApplication14 { class Program { static void Main(string[] args) { Console.WriteLine(myFunction(14)); } public static void myFunction(int x) { return x + 2; } } Please help me!!
<c#><.net>
2016-04-11 09:35:38
LQ_EDIT
36,545,540
Search for specific keyword or regex pattern on git
<p>How do you search through all commit messages in a git repository for a specific keyword or regex pattern?</p>
<regex><git><commit>
2016-04-11 10:02:48
LQ_CLOSE
36,548,279
How to return all users in Django
<p>I don't know how to print names of all users in my system. I got code like this:</p> <pre><code> from django.contrib.auth.models import User users = User.objects.all() return Response(len(users)) </code></pre> <p>This returns only number of users but I want to get their names. What should I add to return all users names?? </p>
<python><django>
2016-04-11 12:08:03
LQ_CLOSE
36,549,108
Is it suitable to use 200 http code for forbidden web page
what is the difference when we use 200 response code for a forbidden page with an error message saying 'access denied' instead of using 403 response code? are there any security implications of this
<http>
2016-04-11 12:47:00
LQ_EDIT
36,549,418
I am finding it hard to understand inheritance in C#
<p>Am wondering of this case: Employee inherits from Person and Manager inherits from Employee, which statement will be correct?</p> <pre><code>Person alice = new Employee(); Employee bob = new Person(); Manager cindy = new Employee(); Manager dan = (Manager)(new Employee()); </code></pre>
<c#><inheritance>
2016-04-11 12:59:58
LQ_CLOSE
36,552,893
PHP/Maths Percentage of Percentage
<p>I am working out what the changes of a horse winning a race is from the previous records of each horses.</p> <p>Horse 1 has won 5% of his races</p> <p>Horse 2 has won 7% of his races</p> <p>Horse 3 has won 12% of his races</p> <p>Now if 3 horses are running in this final race, how do I split 100% between these 3 horses?</p>
<php><math>
2016-04-11 15:25:12
LQ_CLOSE
36,553,102
C++ change from struct to classes?
<p>How can I change from using struct to class? The code doesn't have any problem. But I wanna how can I put put it in classes. What would you suggest in way of changing it over. There is no problem there. just a simple change over question.</p> <p>This is my header file in the c++.</p> <pre><code>struct SpaceShip { int ID; int x; int y; int lives; int speed; int boundx; int boundy; int score; }; struct Bullet { int ID; int x; int y; bool live; int speed; }; struct Comet { int ID; int x; int y; bool live; int speed; int boundx; int boundy; }; </code></pre> <p>and this is my main.cpp file.</p> <pre><code>#include &lt;allegro5\allegro.h&gt; #include &lt;allegro5\allegro_primitives.h&gt; #include &lt;allegro5\allegro_font.h&gt; #include &lt;allegro5\allegro_ttf.h&gt; #include "objects.h" //GLOBALS============================== const int WIDTH = 800; const int HEIGHT = 400; const int NUM_BULLETS = 5; const int NUM_COMETS = 10; enum KEYS { UP, DOWN, LEFT, RIGHT, SPACE }; bool keys[5] = { false, false, false, false, false }; //prototypes void InitShip(SpaceShip &amp;ship); void DrawShip(SpaceShip &amp;ship); void MoveShipUp(SpaceShip &amp;ship); void MoveShipDown(SpaceShip &amp;ship); void MoveShipLeft(SpaceShip &amp;ship); void MoveShipRight(SpaceShip &amp;ship); void InitBullet(Bullet bullet[], int size); void DrawBullet(Bullet bullet[], int size); void FireBullet(Bullet bullet[], int size, SpaceShip &amp;ship); void UpdateBullet(Bullet bullet[], int size); void CollideBullet(Bullet bullet[], int bSize, Comet comets[], int cSize, SpaceShip &amp;ship); void InitComet(Comet comets[], int size); void DrawComet(Comet comets[], int size); void StartComet(Comet comets[], int size); void UpdateComet(Comet comets[], int size); void CollideComet(Comet comets[], int cSize, SpaceShip &amp;ship); int main(void) { //primitive variable bool done = false; bool redraw = true; const int FPS = 60; bool isGameOver = false; //object variables SpaceShip ship; Bullet bullets[NUM_BULLETS]; Comet comets[NUM_COMETS]; //Allegro variables ALLEGRO_DISPLAY *display = NULL; ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; ALLEGRO_FONT *font18 = NULL; //Initialization Functions if (!al_init()) //initialize Allegro return -1; display = al_create_display(WIDTH, HEIGHT); //create our display object if (!display) //test display object return -1; al_init_primitives_addon(); al_install_keyboard(); al_init_font_addon(); al_init_ttf_addon(); event_queue = al_create_event_queue(); timer = al_create_timer(1.0 / FPS); srand(time(NULL)); InitShip(ship); InitBullet(bullets, NUM_BULLETS); InitComet(comets, NUM_COMETS); font18 = al_load_font("arial.ttf", 18, 0); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_register_event_source(event_queue, al_get_display_event_source(display)); al_start_timer(timer); while (!done) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &amp;ev); if (ev.type == ALLEGRO_EVENT_TIMER) { redraw = true; if (keys[UP]) MoveShipUp(ship); if (keys[DOWN]) MoveShipDown(ship); if (keys[LEFT]) MoveShipLeft(ship); if (keys[RIGHT]) MoveShipRight(ship); if (!isGameOver) { UpdateBullet(bullets, NUM_BULLETS); StartComet(comets, NUM_COMETS); UpdateComet(comets, NUM_COMETS); CollideBullet(bullets, NUM_BULLETS, comets, NUM_COMETS, ship); CollideComet(comets, NUM_COMETS, ship); if (ship.lives &lt;= 0) isGameOver = true; } } else if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { done = true; } else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { switch (ev.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: done = true; break; case ALLEGRO_KEY_UP: keys[UP] = true; break; case ALLEGRO_KEY_DOWN: keys[DOWN] = true; break; case ALLEGRO_KEY_LEFT: keys[LEFT] = true; break; case ALLEGRO_KEY_RIGHT: keys[RIGHT] = true; break; case ALLEGRO_KEY_SPACE: keys[SPACE] = true; FireBullet(bullets, NUM_BULLETS, ship); break; } } else if (ev.type == ALLEGRO_EVENT_KEY_UP) { switch (ev.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: done = true; break; case ALLEGRO_KEY_UP: keys[UP] = false; break; case ALLEGRO_KEY_DOWN: keys[DOWN] = false; break; case ALLEGRO_KEY_LEFT: keys[LEFT] = false; break; case ALLEGRO_KEY_RIGHT: keys[RIGHT] = false; break; case ALLEGRO_KEY_SPACE: keys[SPACE] = false; break; } } if (redraw &amp;&amp; al_is_event_queue_empty(event_queue)) { redraw = false; if (!isGameOver) { DrawShip(ship); DrawBullet(bullets, NUM_BULLETS); DrawComet(comets, NUM_COMETS); al_draw_textf(font18, al_map_rgb(255, 0, 255), 5, 5, 0, "Player has %i lives left. Player has destroyed %i objects", ship.lives, ship.score); } else { al_draw_textf(font18, al_map_rgb(0, 255, 255), WIDTH / 2, HEIGHT / 2, ALLEGRO_ALIGN_CENTRE, "Game Over. Final Score: %i", ship.score); } al_flip_display(); al_clear_to_color(al_map_rgb(0, 0, 0)); } } al_destroy_event_queue(event_queue); al_destroy_timer(timer); al_destroy_font(font18); al_destroy_display(display); //destroy our display object return 0; } void InitShip(SpaceShip &amp;ship) { ship.x = 20; ship.y = HEIGHT / 2; ship.ID = PLAYER; ship.lives = 3; ship.speed = 7; ship.boundx = 6; ship.boundy = 7; ship.score = 0; } void DrawShip(SpaceShip &amp;ship) { al_draw_filled_rectangle(ship.x, ship.y - 9, ship.x + 10, ship.y - 7, al_map_rgb(255, 0, 0)); al_draw_filled_rectangle(ship.x, ship.y + 9, ship.x + 10, ship.y + 7, al_map_rgb(255, 0, 0)); al_draw_filled_triangle(ship.x - 12, ship.y - 17, ship.x + 12, ship.y, ship.x - 12, ship.y + 17, al_map_rgb(0, 255, 0)); al_draw_filled_rectangle(ship.x - 12, ship.y - 2, ship.x + 15, ship.y + 2, al_map_rgb(0, 0, 255)); } void MoveShipUp(SpaceShip &amp;ship) { ship.y -= ship.speed; if (ship.y &lt; 0) ship.y = 0; } void MoveShipDown(SpaceShip &amp;ship) { ship.y += ship.speed; if (ship.y &gt; HEIGHT) ship.y = HEIGHT; } void MoveShipLeft(SpaceShip &amp;ship) { ship.x -= ship.speed; if (ship.x &lt; 0) ship.x = 0; } void MoveShipRight(SpaceShip &amp;ship) { ship.x += ship.speed; if (ship.x &gt; 300) ship.x = 300; } void InitBullet(Bullet bullet[], int size) { for (int i = 0; i &lt; size; i++) { bullet[i].ID = BULLET; bullet[i].speed = 10; bullet[i].live = false; } } void DrawBullet(Bullet bullet[], int size) { for (int i = 0; i &lt; size; i++) { if (bullet[i].live) al_draw_filled_circle(bullet[i].x, bullet[i].y, 2, al_map_rgb(255, 255, 255)); } } void FireBullet(Bullet bullet[], int size, SpaceShip &amp;ship) { for (int i = 0; i &lt; size; i++) { if (!bullet[i].live) { bullet[i].x = ship.x + 17; bullet[i].y = ship.y; bullet[i].live = true; break; } } } void UpdateBullet(Bullet bullet[], int size) { for (int i = 0; i &lt; size; i++) { if (bullet[i].live) { bullet[i].x += bullet[i].speed; if (bullet[i].x &gt; WIDTH) bullet[i].live = false; } } } void CollideBullet(Bullet bullet[], int bSize, Comet comets[], int cSize, SpaceShip &amp;ship) { for (int i = 0; i &lt; bSize; i++) { if (bullet[i].live) { for (int j = 0; j &lt; cSize; j++) { if (comets[j].live) { if (bullet[i].x &gt;(comets[j].x - comets[j].boundx) &amp;&amp; bullet[i].x &lt; (comets[j].x + comets[j].boundx) &amp;&amp; bullet[i].y &gt;(comets[j].y - comets[j].boundy) &amp;&amp; bullet[i].y &lt; (comets[j].y + comets[j].boundy)) { bullet[i].live = false; comets[j].live = false; ship.score++; } } } } } } void InitComet(Comet comets[], int size) { for (int i = 0; i &lt; size; i++) { comets[i].ID = ENEMY; comets[i].live = false; comets[i].speed = 5; comets[i].boundx = 18; comets[i].boundy = 18; } } void DrawComet(Comet comets[], int size) { for (int i = 0; i &lt; size; i++) { if (comets[i].live) { al_draw_filled_circle(comets[i].x, comets[i].y, 20, al_map_rgb(255, 0, 0)); } } } void StartComet(Comet comets[], int size) { for (int i = 0; i &lt; size; i++) { if (!comets[i].live) { if (rand() % 500 == 0) { comets[i].live = true; comets[i].x = WIDTH; comets[i].y = 30 + rand() % (HEIGHT - 60); break; } } } } void UpdateComet(Comet comets[], int size) { for (int i = 0; i &lt; size; i++) { if (comets[i].live) { comets[i].x -= comets[i].speed; } } } void CollideComet(Comet comets[], int cSize, SpaceShip &amp;ship) { for (int i = 0; i &lt; cSize; i++) { if (comets[i].live) { if (comets[i].x - comets[i].boundx &lt; ship.x + ship.boundx &amp;&amp; comets[i].x + comets[i].boundx &gt; ship.x - ship.boundx &amp;&amp; comets[i].y - comets[i].boundy &lt; ship.y + ship.boundy &amp;&amp; comets[i].y + comets[i].boundy &gt; ship.y - ship.boundy) { ship.lives--; comets[i].live = false; } else if (comets[i].x &lt; 0) { comets[i].live = false; ship.lives--; } } } } </code></pre>
<c++>
2016-04-11 15:35:13
LQ_CLOSE
36,553,289
Sending a MVC project to someone
<p>The company I've applied for internship wanted me to do some mvc project. I've finished the project but I really don't know how to send it to them via email.The project includes a small database. I know I can't compress the solution folder and send it. Do I have to upload the project to a hosting service? If I deploy it to a hosting service and send them a website url then can they evaluate my work?</p>
<asp.net-mvc>
2016-04-11 15:43:05
LQ_CLOSE
36,553,442
Call php file inside an html without using input tag
is there any way to call a php file inside an HTML document without using an input tag. I am trying to display some results of my database (as a table) using the form tag (file2.php) but I realised that the only way to display the results is to have an input tag inside the form tag. Is there any way to simply display the results in my html website without using inputs? My code is --- <html> <body> <img src="file1.php"> <form action="file2.php" method="post"> <input type="submit" value="submit"> </form> </body> <html> My file2.php is --- <?php define('DB_NAME', 'name'); define('DB_USER', 'yyyy'); define('DB_PASSWORD', 'xxxx'); define('DB_HOST', 'localhost'); $link=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link){ die('Could not connect:' .mysql_error()); } $db_selected = mysql_select_db(DB_NAME,$link); if(!$db_selected){ die('Can\'t use' .DB_NAME .':' . mysql_error()); } $cid=$_COOKIE["cid"]; $sql= "SELECT * FROM table WHERE PID='$cid' ORDER BY SUBTIME ASC;"; $result = mysql_query($sql); echo "<table border=1> <tr> <th> SUBMISSION DATE/TIME </th> <th> SYS </th> <th> DIA </th> <th> PULSE </th> <th> WEIGHT </th> </tr>"; while ($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td align='center'>" . $row['SUBTIME'] . "</td>"; echo "<td align='center'>" . $row['SYS'] . "</td>"; echo "<td align='center'>" . $row['DIA'] . "</td>"; echo "<td align='center'>" . $row['PULSE'] . "</td>"; echo "<td align='center'>" . $row['WEIGHT'] . "</td>"; echo "</tr>"; } if(!mysql_query($sql)){ die('Error:' .mysql_error()); } mysql_close(); ?>
<php><html><mysql><sql>
2016-04-11 15:49:15
LQ_EDIT
36,555,834
Unexpected && T_BOOLEAN_AND with username and password form - PHP
<p>So I've got a very simple html page which uses a post php method to send the username and password to the php script. However I get the error: unexpected '&amp;&amp;' (T_BOOLEAN_AND) when the details are passed to the script. Any ideas why?</p> <p>Here's the html form: </p> <pre><code>&lt;form action="login.php" method="post"&gt; &lt;p&gt; Username: &lt;/p&gt; &lt;input type="text" name="username"/&gt; &lt;p&gt; Password: &lt;/p&gt; &lt;input type="text" name="password"/&gt; &lt;input type="submit" value="Submit"/&gt; &lt;/form&gt; </code></pre> <p></p> <p>And here is the login.php script:</p> <pre><code> &lt;?php if ($_POST["username"] == "t5" ) &amp;&amp; ($_POST["password"] == "just4fun") { session_start(); $_SESSION[‘username’] = true; header('Location menu.php'); } else { header('Location loginform.html') } ?&gt; </code></pre> <p>Thanks in advance.</p>
<php><html>
2016-04-11 17:55:47
LQ_CLOSE
36,556,550
How Convert packages to units
<p>I have a question, I'm programming in Java if I have a decimal "3.02" (this is equivalent to 3 packages (1 package = 10 units) and 2 units) and want to convert to "32" (this is equivalent to 32 units ). Does anyone know how to do it? There is a feature that allows java?</p>
<java><decimal><converter>
2016-04-11 18:35:16
LQ_CLOSE
36,557,444
PHP file uploading but can't find in directory
<p>I've checked several methods on stackoverflow but none is able to solve this. I've made an html form to input <strong>file</strong> type through <strong>SELF_PHP</strong> form. <em>Seems like PHP is uploading the file correctly but the directory to which it's being uploaded is empty</em> . Here's the code: <strong>HTML</strong></p> <pre><code>&lt;form method="post" id="fileUpForm" action="&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?&gt;" enctype="multipart/form-data" &gt; Select image to upload: &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt; &lt;input type="submit" value="Upload" name="submit"&gt; &lt;/form&gt; </code></pre> <p><strong>PHP</strong></p> <pre><code>&lt;?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } ?&gt; </code></pre> <p>Additional Info: .php file directory - <code>/var/www/html/FileUp.php</code><br> uploads directory(to store files) - <code>/var/www/html/uploads/</code> Code used(modified) from : '*schools.com'</p>
<php><html><file-upload>
2016-04-11 19:21:14
LQ_CLOSE
36,557,987
Why does `for (var i in null_object)` enter the loop body more than zero times?
I am trying to save and load a Javascript object of the `{'foo':123}` type in localStorage. I have hit a strange behaviour. localStorage .setItem ('names', null); alert ("names is:" + localStorage .getItem ('names')); for (var n in localStorage .getItem ('names')) { alert ("#" + n + "#"); } This gives the following alerts names is:null #0# #1# #2# #3# WTF?
<javascript>
2016-04-11 19:51:53
LQ_EDIT
36,558,341
Asp.net 5 (and MVC 6) hosting
<p>So I just recently started developing a website in Asp.net 5 (mvc 6) and I went to host it on my WinHost site when I realized that they don't support it. At least that's what their technical support said. I assume Microsoft Azure supports it but for a small website and a SQL server, that is $15/month, which is over triple what I was paying for my WinHost. </p> <p>Does anyone know of any other solutions for hosting a asp.net 5 site?</p> <p>Thanks</p> <p>syd</p>
<asp.net><asp.net-mvc><asp.net-mvc-5><asp.net-core>
2016-04-11 20:10:31
LQ_CLOSE
36,559,074
Use of studying different algorithm mechanism for sorting when STL does it crisply
<p>I mean, what is the use of studying different sorting algorithms when it can be done with the help of a single line in c++ using STL? Is it just for the sake of knowing (or any other reason)?</p>
<c++><stl>
2016-04-11 20:55:48
LQ_CLOSE
36,559,500
Location of .bashrc in linux
<p>I made some changes in the <code>.bashrc</code> file some time ago. In which directory is this file supposed to be located exactly?</p>
<linux><bash>
2016-04-11 21:23:17
LQ_CLOSE
36,560,730
How to convert an IP binary address into a decimal in C#?
<p>I'm looking for a function that will convert "10011101.11001001.01001100.00000000" to "157.201.76.0" </p>
<c#><binary><ip><decimal>
2016-04-11 22:57:08
LQ_CLOSE
36,560,958
Is there any way of not creating temp variable for push_back()?
<pre><code>std::vector&lt;Foo&gt; v; v.push_back(Foo()); </code></pre> <p>Does this create a temp variable for Foo, or does this work like emplace_back()?</p>
<c++><stl>
2016-04-11 23:21:36
LQ_CLOSE
36,561,302
in swift, is a string object immutable once created?
<p>In java, once created, string objects are immutable. Some methods appear to change the string object, but what it actually does is creating a new string object from the original string object along with the modifications. I was just wondering if this is the case for String objects in SWIFT? </p>
<string><swift><immutability>
2016-04-11 23:55:17
LQ_CLOSE
36,562,454
CVS how to split and find number of 0's in column
I have 14 columns (A-N) in a CVS file I am looking to to find how many patients(303 in total) have 0 signs for heart disease this would be in column 14(N) anything above 0 would be counted as ill patients and those with 0 are healthy. From what I have in my code so far is this ( i know I am more than likely doing this wrong so please correct me if I made a mistake) import csv import math with open("train.csv", "r") as f: #HP is healthy patient IP is ill patients for c in f.read()14: chars.append(c) num_chars = len(chars) num_IP = 0; num_HP = 0; for c in chars: if c = >0 num_IP += 1 if c = <=0 num_HP += 1
<python><csv>
2016-04-12 02:11:43
LQ_EDIT
36,564,444
String Objects Equality
<p>Why two string objects which are declared using String class constructor with identical string literal are not equal when compared using equality operator '==', but when declared directly by assigning identical string literals are equal.</p> <pre><code>String s1 = new String("hello"); String s2 = new String("hello"); Boolean result1 = (s1 == s2);// returns false String s3 = "hello"; String s4 = "hello"; Boolean result2 = (s3 == s4);// returns true </code></pre>
<java><string>
2016-04-12 05:39:53
LQ_CLOSE
36,565,490
Send jpg image from ANDROID to servlet
<p>I am making an Instagram like application for my college project. </p> <p>CLIENT = Android SERVER = Servlet</p> <p>I want to send an image from android to servlet. I just need the image send and revive code. I have figured out the rest.</p> <p>Thank you for help. </p>
<android><servlets><servlet-3.0>
2016-04-12 06:45:47
LQ_CLOSE
36,565,869
R: How to Delete All Columns in a Dataframe Except A Specified Few By String
<p>I have a data frame in R that consists of around 400 variables (as columns), though I only need 25 of them. While I know how to delete specific columns, because of the impracticality of deleting 375 variables - is there any method in which I could delete all of them, except the specified 25 by using the variable's string name? </p> <p>Thanks. </p>
<r><dataset>
2016-04-12 07:03:52
LQ_CLOSE