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,820,429
Get average of numbers
I am supposed to calculate the double of three numbers and get its average. I am required to use the following two methods, no changing them: getNumbers(); which only gets the user inputs. no returns, no arguments. getAverage(); which calculate the average of the three double numbers. returns the average, and has no argument. My question is everytime I run it on CMD, it shows that method does not work and will not print an output. For me to enter three numbers, and get its average at the end. If someone can give me advice as to what I am doing wrong, it will be greatly appreciated. import java.util.Scanner; public class ComputeAverage{ double firstNum; double secondNum; double thirdNum; double sum; double average; public void getNumbers(){ Scanner keyboard = new Scanner(System.in); System.out.println("Enter your first number: "); double firstNum = keyboard.nextDouble(); System.out.println("Enter your second number: "); double secondNum = keyboard.nextDouble(); System.out.println("Enter your third number: "); double thirdNum = keyboard.nextDouble(); Test.println("The average is: " + average); } public double getAverage(double firstNum, double secondNum, double thirdNum){ double average = firstNum + secondNum + thirdNum / 3; return average; } }
<java>
2016-04-24 07:28:22
LQ_EDIT
36,820,736
print all the permutaions using recursion
I coded as below to print all the permutaions of three number :1,2,3. <i><b>But the output is:</b></i><br> 1,1,1<br> 1,1,2<br> 1,1,3<br> 1,2,1<br> 1,2,2<br> 1,2,3<br> <b><i>the code is as follows:</i></b> #include<stdio.h> #include<conio.h> void perm(int); int a[10],l=2; int main() {int k; k=0; perm(k); getch(); return 0;} void perm(int k) { int i; for(a[k]=1;a[k]<=3;a[k]++) { if(k==2) { for(i=0;i<3;i++) { printf("%d ",a[i]); } printf("\n"); } else { k++; perm(k); } } } Pl. give the correct code:)
<c><recursion>
2016-04-24 08:09:53
LQ_EDIT
36,823,769
How to activate a function after a given time?
<p>I would like to activate a function after a sound is played and complete. I assume that NSTimer needs to be included, but I am not sure of how to implement in order to make it. It is helpful if you could give me some code that works. </p>
<ios><swift><audio><nstimer>
2016-04-24 13:28:59
LQ_CLOSE
36,825,001
I need help for my form validation.I dont get error msgs all at once but appears only at the first text of name 'first name'
my Html code:<body> <img id="logo2" src="logo2.jpg"> <div id="request-container"> <h2>REQUEST A DEMO</h2> <div id="request"> <p>First Name *</p> <input id="1" type="text"> <span id="empty"></span> <p>Last Name *</p> <input id="2" type="text"> <span id="empty"></span> <p>Email *</p> <input id="3" type="email"> <span id="empty"></span> <p>Phone *</p> <input id="4" type="tel"> <span id="empty"></span> <p>Company Name *</p> <input id="5" type="text"> <span id="empty"></span> <p>Company Website *</p> <input id="6" type="email"> <span id="empty"></span> <p>Country *</p> <select id="country"> <option></option> <option>India</option> <option>USA</option> <option>Canade</option> <option>Australia</option> <option>China</option> <option>South Africa</option> <option>Russia</option> <option>Germany</option> </select> <span id="empty"></span> <div id="demo" onclick="return validateForm()">Schedule a Demo!</div> </div> </div> My Javascript code: <script type="text/javascript"> function validateForm() { var ok=true; var first=document.getElementById('1').value; var last=document.getElementById('2').value; var email=document.getElementById('3').value; var phone=document.getElementById('4').value; var company=document.getElementById('5').value; var website=document.getElementById('6').value; if (first == "" || first== null) { document.getElementById('empty').innerHTML="This field is required"; ok=false; } if (last == ""|| last== null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } if (email == ""|| email== null) { document.getElementById('empty').innerHTML="This field is required"; ok=false; } if (phone == "" || phone==null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } if (company == ""|| company== null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } if (website == ""|| website== null) { document.getElementById('empty').innerHTML="This field is required"; ok= false; } return ok; } document.getElementById('demo').onclick = function () { validateForm(); } </script>
<javascript><html><css><forms><validation>
2016-04-24 15:16:43
LQ_EDIT
36,825,266
Using python to code Ev3 windows
<p>I was going around the internett and i found out that you can code Mindstorm with python, however it was for Linux only and im running windows. Is there a way/website where i can learn how to connect python up to mindstorms and get sensor data?</p>
<python><linux><windows><mindstorms>
2016-04-24 15:36:21
LQ_CLOSE
36,825,793
How do I code an image generator that will generate every 64 x 64 picture ever?
<p>So I want to make a website where I can generate EVERY SINGLE Minecraft skin (which are 64 px by 64 px) possible (And put it up on a web page), by using many different combinations of many different coloured pixels in many different positions. (Or in fact, ALL of them.)</p> <p>Similar to a generator which generates every black/white pixel combination in a 1x2 grid (I made a gif on that here, <a href="https://gyazo.com/071a5d482852fc8eea9963e841f5dbc1" rel="nofollow">https://gyazo.com/071a5d482852fc8eea9963e841f5dbc1</a>, but it's very small so you'll have to look at your screen closely), except using all colours and on a much larger scale.</p> <p>But the problem is, I don't know what coding language to code it in.</p> <p>And there are many different coding languages, like PHP, SQL, JavaScript, Ruby, Python, and others, but I just don't know which one to use to create a generator like this. (And I also don't know how to actually get it onto the web page so it can generate onto the web page real-time.)</p> <p>If anyone could help me on this then that would be greatly appreciated.</p> <p>Thanks.</p>
<javascript><python><html><css>
2016-04-24 16:22:35
LQ_CLOSE
36,826,063
slideshow javascript onmouseover
My code is running well ... but there is one thing i cant solt it ,,, when i over my mouse on the pic its start well ,,, but when i over again it's became more faster and faster ,,, this is my code :) <html> <head></head> <body> <script type="text/javascript"> var Image =new Array("Image/welcome.png","Image/To.png", "Image/My.png","Image/WepPage.png","Image/inphp.png"); var Image_Number=0; var Image_Length= Image.length; function change_image(num){ Image_Number = Image_Number + num; if(Image_Number > Image_Length) Image_Number = 0; if(Image_Number < Image_Length) document.slideshow.src = Image[Image_Number]; return false; Image_Number = Image_Length; } function auto () { setInterval("change_image(1)", 1000); } </script> <!--Slide____________________________________________________Show --> <img src="Image/Welcome.png" name="slideshow" onmouseover="auto()" /> </body> </html>
<javascript><html><slideshow>
2016-04-24 16:48:47
LQ_EDIT
36,826,418
ruby on rails identifier error 1
<p>Everytime i run this code i get an error can't find what i had did wrong it said something about synatic error tidentifier, expecting keyword_do or '{' or '('. Anyone has any suggestion on what it could be?</p> <hr> <p>_form.html.haml</p> <pre><code> = simple_form_for @pin, html: { multipart: true } do |f| = if @pin.errors.any? #errors %h2 = pluralize(@pin.errors.count, "error") prevented this pin from saving %ul - @pin.errors.full_messages.each do |msg| %li = msg .form-group = f.input :title, input_html: { class: 'form-control' } .form-group = f.input :description, input_html: { class: 'form-control' } = f.button :submit, class: "btn btn-primary" </code></pre>
<ruby-on-rails><ruby><ruby-on-rails-4>
2016-04-24 17:18:04
LQ_CLOSE
36,826,583
I want to collect datas in websites and store them in a database using php
i am working on a personnal web project with php. i want to collect some type of information from website and store them in a table of my database. these informations are related to products and services in sale on these website. these informations are presented differently on the websites i want to use. how can somebody give me clues about how to perform it ? Thanks.
<javascript><php>
2016-04-24 17:31:59
LQ_EDIT
36,827,050
Change value of div while scrolling
<p>how could I change a position of a div, based on scroll level of my website? I have a landing screen (whole page fullscreen background) only with big centered logo. What I'm asking is, how to do that it'll scale down and catch into a navbar, where it'll be sticked, untill it would be scrolled up again.</p> <p>I did a video showcase, how I mean it. <a href="https://www.youtube.com/watch?v=3fecyRsOkz8&amp;feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=3fecyRsOkz8&amp;feature=youtu.be</a></p> <p>I'm so glad for any help, have a nice day, senior coders! :)</p>
<javascript><jquery><html><css>
2016-04-24 18:15:19
LQ_CLOSE
36,827,730
How to divide div into 3x3 equivalent divs?
<p>Now i have a task to solve. I would like you to share with any way to divide 1 div into 3x3 DIVS only in percents and without bootstrap and flex model. Thanks</p>
<css><web>
2016-04-24 19:16:47
LQ_CLOSE
36,829,016
Java - Finding the Highest Value Card of the Same Suit
I am trying to program a card game, but am stuck on one step. I have four card objects c1, c2, c3, c4 of random values and suits. Structured : Card(int Suit, int Value); I'm trying to find the highest Value card of the SAME suit as c1, in other words. The person who put down the highest card that has the same suit as card c1, i.e. Spades, Hearts, Clubs, Diamonds, wins the pile of those four cards. The person that put down the c1 card can still win the pile if they have the highest value card since it has the same suit as the original (it being the original). I have methods already coded for returning the suit and value of the cards i.e. getSuit() & getValue(). Is there an easy way to do this? I can only imagine lots of nested if conditions to attain this.
<java>
2016-04-24 21:19:25
LQ_EDIT
36,829,207
IPv6 structure definition error
<pre><code> common.c:150:17: error: ‘const struct sockaddr_in6’ has no member named ‘sa_family’ </code></pre> <p>This is the error I get when solving resolution of my incoming IPv6 from client. Please advice</p>
<c><sockets><ipv6>
2016-04-24 21:40:57
LQ_CLOSE
36,829,334
Null pointer exception during ParseJSON
<p>When i am trying to parse the json, its throwing a null pointer exception. Also nothing is showing when i am trying to display the values.</p> <p>code:</p> <pre><code>public class ParseJSON { //public static String[] ids; public static String[] names; public static String[] message; public static final String JSON_ARRAY = "users"; // public static final String KEY_ID = "id"; public static final String KEY_NAME = "username"; public static final String KEY_EMAIL = "message"; private JSONArray users = null; private String json; public ParseJSON(String json){ this.json = json; } protected void parseJSON(){ JSONObject jsonObject=null; try { jsonObject = new JSONObject(json); users = jsonObject.getJSONArray(JSON_ARRAY); //final String TAG = events.class.getSimpleName(); //Log.d(TAG, "username value: \n" + KEY_NAME); for(int i=0;i&lt;users.length();i++){ JSONObject jo = users.getJSONObject(i); // ids[i] = jo.getString(KEY_ID); names[i] = jo.getString(KEY_NAME); message[i] = jo.getString(KEY_EMAIL); } } catch (JSONException e) { e.printStackTrace(); } } } </code></pre> <p>but when i am trying to display the the parse values, i am displaying it in a separate page, there if i can try to display values using LOG.d, it is showing values.</p> <p>list_view.java</p> <pre><code> private void sendRequest(){ StringRequest stringRequest = new StringRequest(JSON_URL, new Response.Listener&lt;String&gt;() { @Override public void onResponse(String response) { showJSON(response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(list_view.this,error.getMessage(),Toast.LENGTH_LONG).show(); } }); RequestQueue requestQueue = Volley.newRequestQueue(this); requestQueue.add(stringRequest); } private void showJSON(String json){ final String TAG = events.class.getSimpleName(); Log.d(TAG, "showJSON: \n" + json); ParseJSON pj = new ParseJSON(json); pj.parseJSON(); CustomList cl = new CustomList(this,ParseJSON.names,ParseJSON.message); listView.setAdapter(cl); } @Override public void onClick(View v) { sendRequest(); } } </code></pre> <p>Here is the error;</p> <pre><code>04-24 21:49:39.449 15992-15992/? D/events: showJSON: {"users":[{"username":"varun","message":"hello word, my first message "},{"username":"varun","message":"hello word, my first message "},{"username":"rahul","message":"hello world"},{"username":"rahul","message":"world: its cool"},{"username":"rahul","message":"awesom"},{"username":"rahul","message":"ranom"},{"username":"rahul","message":"randimagain"},{"username":"rahi","message":"is it me again"},{"username":"rahull","message":"hi rahul"},{"username":"rahul","message":"world, am bacj"},{"username":"rahul","message":"hello parents"},{"username":"","message":""},{"username":"","message":""},{"username":"","message":""},{"username":"","message":""},{"username":"","message":""},{"username":"varun","message":"google world"},{"username":"rahul","message":"ollaaa"},{"username":"rahul","message":"ollaaa"},{"username":"rahul","message":"where are others"},{"username":"rahul","message":"where are others"},{"username":"varun","message":"oil spil"},{"username":"varun","message":"phone"},{"username":"vatun","message":"tttt"},{"username":"varun","message":"poiuytrew"},{"username":"rahui","message":"yregh"},{"username":"varun","message":"huiokgddfv"},{"username":"rahi","message":"poiutghklnbfd"},{"username":"rahui","message":"qwerty"},{"username":"varub","message":"hi eat pineapple"},{"username":"varun","message":"hi prabh"},{"username":"rahul","message":"hi world"},{"username":"ggjdjjf","message":"yhvdhhj"},{"username":"tgggg","message":"hhhh"},{"username":"rahul","message":"lqvrl"},{"username":"hhhh","message":"ghh"},{"username":"tff","message":"gg"},{"username":"hfdhn","message":"hnnnme"},{"username":"popo","message":"plpl"},{"username":"rahulpop","message":"op music"},{"username":"rtrt","message":"tyty"},{"username":"hlpo","message":"opop"},{"username":"hlpoghhj","message":"opop"},{"username":"tt","message":"hhh"},{"username":"ttere","message":"hhh"},{"username":"gytgjyg","message":"lajdhd"},{"username":"topo","message":"ptpt"},{"username":"jgj","message":"rtr"},{"username":"ry","message":"yr"},{"username":"ry","message":"yr"},{"username":"y","message":"q"},{"username":"u","message":"t"},{"username":"tt","message":"pp"},{"username":"q","message":"z"},{"username":"w","message":"v"},{"username":"e","message":"e."},{"username":"ui","message":"ui"},{"username":"yi","message":"yi"},{"username":"gg","message":"g"},{"username":"e","message":"e"},{"username":"h","message":"hh"},{"username":"j","message":"j"},{"username":"j","message":"k"},{"username":"v","message":"v"}]} 04-24 21:49:39.459 15992-15992/? D/AndroidRuntime: Shutting down VM 04-24 21:49:39.459 15992-15992/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40c1ea68) 04-24 21:49:39.529 15992-15992/? E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NullPointerException at com.weavearound.schools.weavearound.ParseJSON.parseJSON(ParseJSON.java:43) at com.weavearound.schools.weavearound.list_view.showJSON(list_view.java:76) at com.weavearound.schools.weavearound.list_view.access$000(list_view.java:22) at com.weavearound.schools.weavearound.list_view$1.onResponse(list_view.java:51) at com.weavearound.schools.weavearound.list_view$1.onResponse(list_view.java:45) at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67) at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30) at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99) at android.os.Handler.handleCallback(Handler.java:605) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4517) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760) at dalvik.system.NativeStart.main(Native Method) 04-24 21:49:39.559 403-420/? E/android.os.Debug: !@Dumpstate &gt; dumpstate -k -t -n -z -d -o /data/log/dumpstate_app_error </code></pre>
<java><android>
2016-04-24 21:54:12
LQ_CLOSE
36,829,817
PHP Check if User is already registered
<p>I have an issue with my code to check if a username is already registered. I did a search on here to look at the different solutions and implemented some of them on my code but I still can't seem to get it to work. I tried registering the same username multiple times it still lets register without alerting me that the username is already taken. I apologize if this is easy to solve as I am new to php and mysql.</p> <p>I tried multiple solutions but none seem to work for me. This is my latest iteration of my code.</p> <pre><code>&lt;?php session_start(); if (isset($_POST['submit'])) { $dbCon = mysqli_connect("localhost", "root", "badassrichv", "FootballDB"); if (mysqli_connect_errno()) { echo "Failed to connect: " . mysqli_connect_error(); } $username = strip_tags($_POST['name']); $password = strip_tags($_POST['password']); $email = strip_tags($_POST['email']); $checkName = 'SELECT * FROM user WHERE username = "$username"'; $run = mysqli_query($dbCon, $checkName); $data = mysqli_fetch_array($run, MYSQLI_NUM); if ($data[0] &gt; 0) { echo "&lt;script&gt;alert('Name already registered. Input a different name')&lt;/script&gt;"; exit(); } else { $sql = "INSERT INTO user (username, password, email) VALUES ('$username', '$password', '$email')"; } ....More code </code></pre>
<php><mysql><login><registration>
2016-04-24 22:53:05
LQ_CLOSE
36,829,926
Picturerbox dispose causing the picturebox invisible
I would like to knw when i put pictureBox1.Dispose (), the picturebox becomes invisible. Is there any ways which I could allow the picturebox stays with is being Dispose
<c#><winforms>
2016-04-24 23:07:24
LQ_EDIT
36,833,629
What exactly onCreate() method will do in a Fragment Life Cycle in an Android Application
<p>I am confusing onCreate() method in both Activity and Fragment. What onCreate() will do in Fragment and What are differences onCreate() method between Activity and Fragment.Please help me i am learning by myself.</p> <p>Thanks......</p>
<android><android-fragments><android-activity><android-lifecycle><fragment-lifecycle>
2016-04-25 06:43:34
LQ_CLOSE
36,833,847
PHP MYSQLI Call to a member function bind_param()
<p>my code is </p> <pre><code>$query1 = "SELECT `user_id` FROM `it_user` WHERE (user_email_address = ? AND user_mobile_number_verified = NULL)"; $stmt1 = $mysqli-&gt;prepare($query1); $stmt1-&gt;bind_param("s",$email); $stmt1-&gt;execute(); if ($stmt1-&gt;affected_rows == 1) { //set registration flag to 1 stating that the users mobile number is already verified echo '&lt;meta http-equiv="refresh" content="0; URL=\'../signin/\'"/&gt;'; } else { $registration_flag = 2; //redirect user to error page //echo '&lt;meta http-equiv="refresh" content="0; URL=\'../error/\'"/&gt;'; } </code></pre> <p>i am getting this error :: </p> <p>Call to a member function bind_param() on a non-object in ***** on line 62</p> <p>where as my email variable is working corrrect and also the query.</p>
<php><mysqli>
2016-04-25 06:56:50
LQ_CLOSE
36,834,387
Error in SQL query (SQL update)
<p>The query is :</p> <pre><code>Update t1 set t1.paper_attempt = 1 from table1 as t1 JOIN table2 as t2 ON t2.user_id = t1.user_id JOIN table3 as t3 ON t3.id = t2.company_id where t3.candidate_id = 'CAND024'; </code></pre> <p>I am using HeidiSQL, on running the query, it is showing a Syntax error. Please help!</p>
<mysql><sql>
2016-04-25 07:28:51
LQ_CLOSE
36,836,638
Is it possible to use greater than equal to operator in group by?
<p>Please suggest me the way to use greater than equal to operator in group by in sql.</p>
<sql><sql-server><database>
2016-04-25 09:28:12
LQ_CLOSE
36,836,886
Git: Change name and email across entire repository history
<p>In git, I would like to amend my name and email address for the entire history of a repository.</p> <p>Is there a command to do this and if there is, are there any risks associated with doing this?</p>
<git>
2016-04-25 09:40:00
LQ_CLOSE
36,837,370
I am trying to display session count from weblogic server and trying to display in java
<p>Can anyone help me in this. How to fetch value from weblogic and display in front end.</p>
<weblogic><weblogic12c>
2016-04-25 09:59:12
LQ_CLOSE
36,837,512
Will it be possible to do live video streaming in a webpage without using server side scripting or programming?
<p>Will it be possible to do live video streaming in a webpage without using server side scripting or programming?, if possible, Can anyone help me to do live video streaming in my website using jQuery or JavaScript? </p>
<javascript><jquery><html><live-streaming>
2016-04-25 10:05:41
LQ_CLOSE
36,837,919
The manually added controller can not be opened using url in mvc 5
I'm new on asp.net mvc. I created a basic controller and I tried to open it using url. But rendering is not finished and my controller didn't display in several minutes. I did not change anything from default asp.net 5 mvc project also my controller's index method return only hello world string. I don't is there any problem on iis or VS. Any idea about that problem? Thanks for help.
<c#><asp.net><asp.net-mvc><visual-studio><iis>
2016-04-25 10:25:53
LQ_EDIT
36,838,336
Making Azure Virtual Machine VPN-Ready
<p>My company is integrating with this company to enable us both consume services built on each other's platform to provide joint services extended to external users.</p> <p>They recently sent me a file containing their VPN configuration with spaces provided to enter ours as well. Now I am not so savvy about VPNs plus our server is hosted in an Azure VM (windows server 2012 R2). I don't know if our hosting arrangement is VPN-ready by default. How am I supposed to go about this? Any helpful articles or guidance is a welcome boon at this time.</p> <p>PS. My knowledge on networking is next to nothing. Just know the basest of things there.</p>
<azure><vpn><azure-virtual-machine><azure-virtual-network>
2016-04-25 10:44:48
LQ_CLOSE
36,838,546
How to assign $_GET value via 'a href'
<p>This is what I've done so far, but the $_GET['c_id'] is not assigned (URL looks like this <code>http://localhost/srs_stuff.php?c_id=</code> Results are surely stored in $r variable since c_name is normally displayed as clickable link with the name I want.</p> <pre><code>foreach ($results as $r) { echo "&lt;a href='srs_stuff.php?c_id='" . $r['c_id'] . "&gt;" . $r['c_name'] . "&lt;/a&gt;&lt;/br&gt;"; } </code></pre> <p>Even better solution would be, that the c_id would be set in SESSION variable, before redirection to new page. Is this possible?</p>
<php>
2016-04-25 10:53:54
LQ_CLOSE
36,839,605
Convert VB Date code to C#
I am converting an existing vb application to .net, in the existing code i found the condition below.How can I write this condition in C# ? Thanks in Advance if CLng(Right(request("yr"),4))=CLng(Year(Date())) then //I am confused only in Year(Date()) how can I replace these functions in C#
<c#><.net><vb.net><datetime>
2016-04-25 11:45:03
LQ_EDIT
36,840,016
Zoom image on hover
<p>How can I make a image in my social feed to zoom when I hover over it.</p> <p>similar to the instagram feed on the left in <a href="http://defiance-theme.tumblr.com" rel="nofollow">this site</a>.</p> <p>I tried this in the hover css:</p> <pre><code>opacity: 0.5; filter: alpha(opacity=50); </code></pre> <p>but I couldn't get it to zoom.</p>
<html><css>
2016-04-25 12:02:28
LQ_CLOSE
36,840,086
Deployment target iOS 9.0 to 7.0
<p>I have developed the application using iOS 9 components(Stack view and CNContact).</p> <p>While developing on project i have given deployment target is iOS9.0, now i have to support iOS 7.0, so iam trying to change deployment target 9.0 to 7.0 but i am getting lot of errors.</p> <p>Request you to give me suggestion to solve these issues.</p>
<ios><objective-c><swift><swift2>
2016-04-25 12:05:24
LQ_CLOSE
36,840,880
who define variable in function and use in class
i want create new variable in class by function: CLASS book{ public function set($name){ newvar($name); } } function newvar($str){ ***???? /// what is code for here*** } -------------------------- example: $x = new BOOK(); $x->set('title'); $x->title = 'jack'; echo 'book title is: ' . $x->title; echo '<br>-----------------------------<br>'; $x->set('writer'); $x->writer = 'tom'; echo 'book writer is: ' . $x->writer; result: book title is jack; ---------------------------------- book writer is tom;
<php><variables>
2016-04-25 12:40:17
LQ_EDIT
36,842,304
Store *.xls *.csv *.xlsx into Microsoft Sql Server
<p>I have a java application with <code>apache-poi 3.5</code>.</p> <p>My database is <code>Microsoft Sql Server</code>.</p> <p>In my application i do an upload and i want to know if it's possible to store my file (<code>*.xls</code>, <code>*.csv</code>, <code>*.xlsx</code>) directly in my database ?</p>
<java><sql-server><apache-poi>
2016-04-25 13:40:21
LQ_CLOSE
36,843,488
Are asserts disabled in release build?
<p>Are asserts disabled in 'release' build?</p> <p>How optional flags like <code>-O0</code>,<code>-O3</code>,<code>-g</code> of <code>g++</code> affects it's behaviour?</p>
<c++><linux><g++><assert>
2016-04-25 14:28:37
LQ_CLOSE
36,843,563
php merge Boolean variable
I have some Boolean variables and I want merge those (Calculation) I used `implode()` but always return true! <?php $myarray = array(true,false,false,true,false); implode(''&&'', $myarray); ?> How to do it !
<php><arrays><boolean>
2016-04-25 14:32:09
LQ_EDIT
36,843,718
Static field requires null instance, non-static field requires non-null instance. Parameter name: expression
<p>I have seen possible solutions to this error, but I just don't understand how to fix mine. My code looks like this:</p> <pre><code>} /// &lt;summary&gt; /// Gets our data reader /// &lt;/summary&gt; /// &lt;param name="reader"&gt;The reader to return&lt;/param&gt; /// &lt;returns&gt;&lt;/returns&gt; private Func&lt;IDataReader, T&gt; GetReader(IDataReader reader) { Delegate resDelegate; // For each field, add to our columns List&lt;string&gt; readerColumns = new List&lt;string&gt;(); for (int index = 0; index &lt; reader.FieldCount; index++) readerColumns.Add(reader.GetName(index)); // Determine the information about the reader var readerParam = Expression.Parameter(typeof(IDataReader), "reader"); var readerGetValue = typeof(IDataReader).GetMethod("GetValue"); // Create a Constant expression of DBNull.Value to compare values to in reader var dbNullValue = typeof(DBNull).GetField("Value"); var dbNullExp = Expression.Field(Expression.Parameter(typeof(DBNull), "System.DBNull"), dbNullValue); // Loop through the properties and create MemberBinding expressions for each property List&lt;MemberBinding&gt; memberBindings = new List&lt;MemberBinding&gt;(); foreach (var prop in typeof(T).GetProperties()) { // Determine the default value of the property object defaultValue = null; if (prop.PropertyType.IsValueType) defaultValue = Activator.CreateInstance(prop.PropertyType); else if (prop.PropertyType.Name.ToLower().Equals("string")) defaultValue = string.Empty; // If the column exists if (readerColumns.Contains(prop.Name)) { // Build the Call expression to retrieve the data value from the reader var indexExpression = Expression.Constant(reader.GetOrdinal(prop.Name)); var getValueExp = Expression.Call(readerParam, readerGetValue, new Expression[] { indexExpression }); // Create the conditional expression to make sure the reader value != DBNull.Value var testExp = Expression.NotEqual(dbNullExp, getValueExp); var ifTrue = Expression.Convert(getValueExp, prop.PropertyType); var ifFalse = Expression.Convert(Expression.Constant(defaultValue), prop.PropertyType); // Create the actual Bind expression to bind the value from the reader to the property value var mi = typeof(T).GetMember(prop.Name)[0]; var mb = Expression.Bind(mi, Expression.Condition(testExp, ifTrue, ifFalse)); memberBindings.Add(mb); } } // Create a MemberInit expression for the item with the member bindings var newItem = Expression.New(typeof(T)); var memberInit = Expression.MemberInit(newItem, memberBindings); // Create the lambda expression var lambda = Expression.Lambda&lt;Func&lt;IDataReader, T&gt;&gt;(memberInit, new ParameterExpression[] { readerParam }); resDelegate = lambda.Compile(); // Return our delegate return (Func&lt;IDataReader, T&gt;)resDelegate; } </code></pre> <p>and as the title says, the error I get is:</p> <blockquote> <p>Static field requires null instance, non-static field requires non-null instance. Parameter name: expression</p> </blockquote> <p>which is this line:</p> <pre><code>var dbNullExp = Expression.Field(Expression.Parameter(typeof(DBNull), "System.DBNull"), dbNullValue); </code></pre> <p>Can anyone tell me why I am getting the error and how to fix it?</p>
<c#>
2016-04-25 14:38:07
LQ_CLOSE
36,843,822
How should I read this regex pattern of bash?
<p>I want to ask about read the regex pattern. I have a regex pattern </p> <pre><code>"/^[ \t]*\/\*&lt;O$firstline&gt;\*\//,/^[ \t]*\/\*&lt;\/O$firstline&gt;\*\//s/\/\///g" $Path/DebugVersion.c </code></pre> <p>How should I read this pattern? I need an explanation about this regex. If anyone can explain this to me you can reply this questions. I'm thankful if you answer this question.</p> <p>Regard, Gustina M.S</p>
<regex><bash>
2016-04-25 14:42:41
LQ_CLOSE
36,846,837
What is the time complexity of the following code in which a variable jumps multiple of 2?
int i, j, k = 0; for (i = n/2; i <= n; i++) { for (j = 2; j <= n; j = j * 2) { k = k + n/2; } } Here the outer loop runs exactly n/2 times and then in the inner loop runs for the input 2,4,6,8.... upto n(if even) else runs upto n-1(if n is odd)
<c><algorithm><loops><time-complexity><big-o>
2016-04-25 17:06:29
LQ_EDIT
36,847,402
How can i SELECT row with max value
` select NATIONALPLAYERS.FIRSTNAME||' '|| NATIONALPLAYERS.LASTNAME as PlayerName,NATIONALPLAYERS.EXPERIENCEID, experience from NATIONALPLAYERS INNER JOIN (select experienceid, MAX( experiences.nationalgames + experiences.internationalgames ) as experience from experiences group by experiences.EXPERIENCEID)plexperience on plexperience.experienceid = NATIONALPLAYERS.experienceid;` > It displays all the records from "PlayerName", "ExperienceID" and "Experience" even though i asked only for the maximum value of experience.
<sql><oracle>
2016-04-25 17:38:07
LQ_EDIT
36,848,752
How to perform student t test contain mulitple observation in R
Here is my data, 900000 obs of 9 variables in R. I've tried apply function but unable to give parameters in apply function. Data looks like this, please help. ID A1 A2 A3 A4 A5 B1 B2 B3 B4 1 10 12 11 13 15 50 55 56 57 2 20 22 23 21 20 60 76 78 71 3 10 12 13 15 14 50 55 52 53 ... 90000 11 12 13 15 12 21 22 23 24 I need to perform 900000 times two sample student t test from those 9 variables divide into 2 groups (group A and B). Can anyone post a code here?Thanks.
<r><statistics><apply>
2016-04-25 18:51:05
LQ_EDIT
36,851,070
How does this code I found work? Cipher
<p>So I found this cool cipher, im making a project for school (its kinda like, show us everything you learned kinda of project) and were allowed to get heavy look at other peoples code online (as long is its not a complete copy and paste). I want to understand how it works and make my own version (without copy and pasting), ive put comments for the parts I understand, and question marks for the parts I dont.</p> <pre><code> Function EncryptDecrypt(ByVal text1 As String, ByVal key As String, ByVal isEncrypt As Boolean) As String //yea got this Dim char1 As String //Defining char one Dim char2 As String //Defining char two Dim cKey As Byte //Defining a key as a byte Dim strLength As Integer //Defining strLength as an integer Dim Result As String = "" //Defining Result as String equal to nothing Dim j As Integer = -1 //Defining j as an integer equal to -1 If text1 &lt;&gt; "" And IsNumeric(key) Then //if text1 is not nothing and the key is numeric then... strLength = text1.Length //making strLength equal to the length of the text. For i As Integer = 0 To strLength - 1 //Do until strLenth is less than 1 ??? char1 = text1.Substring(i, 1) //Char one is equal to If j &lt; key.Length - 1 Then //if j (-1) is less than the key's length - 1 then... j = j + 1 //add one to j Else //no explanation needed j = 0 //no explanation needed End If //no explanation needed cKey = Val(key.Substring(j, 1)) //?? cKey is equal to value of the current character it is looking at (j, 1)?? If isEncrypt Then //if were encypting it If (Asc(char1) + cKey) &gt; 255 Then //???? char2 = Chr(Asc(char1) + cKey - 255) //???? Else //no explanation needed char2 = Chr(Asc(char1) + cKey) //?? End If //no explanation needed Else //no explanation needed If (Asc(char1) - cKey) &lt; 1 Then //???? char2 = Chr(Asc(char1) - cKey + 255) //????? Else //no explanation needed char2 = Chr(Asc(char1) - cKey) //????? End If //no explanation needed End If //no explanation needed Result &amp;= char2 //????? Next //no explanation needed Else //no explanation needed MsgBox("Enter text or key!") //no explanation needed End If //no explanation needed Return Result //no explanation needed End Function //no explanation needed No explanation needed for these either VVVV Private Sub btCrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCrypt.Click txtResult.Text = EncryptDecrypt(txtText.Text, txtKey.Text, True) End Sub Private Sub btDecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDecrypt.Click txtResult.Text = EncryptDecrypt(txtText.Text, txtKey.Text, False) End Sub End Class </code></pre> <p>I kinda understand that each "letter" has an "Asc" value, but im not entirely sure how that works. Can anyone help, would be really great and helpful for me!</p>
<vb.net>
2016-04-25 21:06:00
LQ_CLOSE
36,852,074
The definition of graph in C
<p>I set the definition of adjacency list node like this:</p> <pre><code>typedef struct node_type{ int data; struct node_type *link; }node; </code></pre> <p>The definition of adjacency list:</p> <pre><code>typedef node *list; </code></pre> <p>The definition of graph:( A graph is an array of adjacency lists)</p> <pre><code>typedef struct graph_type{ int no_of_vertex; list *array; }graph; </code></pre> <p>Was it a correct definition anyway?</p>
<c>
2016-04-25 22:15:37
LQ_CLOSE
36,853,242
How to create a list of random numbers?
<p>So I am trying to create a method in which random numbers between 1000 and -1000 are declared and stored in an arraylist. The issue is, I need to use a user inputted number to determine how many random numbers I need. Therefore, I assume I need some sort of loop which will create a random number(within the given boundaries) for the given amount of times the user desires. To make things clear, if the user inputted the number 10, than 10 random numbers would be created and stored in the arraylist.</p> <p>For this example, the user inputted data is gathered from a jtextField called n2sInput.</p> <p>If anyone could explain, or create a sample code of how to do this, I would greatly appreciate it!</p> <p>Thanks</p>
<java>
2016-04-26 00:12:38
LQ_CLOSE
36,854,711
Not sure why this Java Null Pointer Exception is happening
<p>I have a method that return an array of files in a given directory that is giving me a null pointer exception when executed. I can't figure out why.</p> <pre><code>private ArrayList&lt;File&gt; getFiles(String path) { File f = new File(path); ArrayList&lt;File&gt; files = new ArrayList&lt;&gt;(Arrays.asList(f.listFiles())); return files; } </code></pre> <p>thanks for your help</p>
<java><nullpointerexception>
2016-04-26 03:23:15
LQ_CLOSE
36,854,980
i am writing code in angularjs using html . in this minlength and maxlength validations are not working .here my code
html code : <input type="text" id="healthcomplaint" ng-model="userDetails.healthcomplaint" style="color:#4a5665;" class="form-control" name="healthcomplaint" ng-required="true" ng-minlength="3" ng-maxlength="120" ng-pattern="/^[a-zA-Z0-9\s\[\]\.,\_\/\-#']*$/" tabindex="8"> <span class="ng-hide error_txt" ng-show="submitted && info.healthcomplaint.$error.required">Please enter health complaint.</span> <span class="ng-hide error_txt" ng-show="info.healthcomplaint.$error.minlength">health complaint should have at least 3 characters.</span> <span class="ng-hide error_txt" ng-show="info.healthcomplaint.$error.maxlength">health complaint should not exceed 120 characters.</span>
<javascript><html><angularjs>
2016-04-26 03:54:53
LQ_EDIT
36,855,902
How to add date and time seperately in java
static final String DATE_FORMAT = "yyyy-MM-dd"; static final String TIME_FORMAT = "HH:mm:ss"; private static final int ADD_MINUTES = 2; static final String FromDate = "2016-01-01 00:00:00"; public static void main(String[] args) throws Exception { DateFormat df = new SimpleDateFormat(DATE_FORMAT); DateFormat d_f = new SimpleDateFormat(DATE_FORMAT); DateFormat tf = new SimpleDateFormat(TIME_FORMAT); Calendar cal = Calendar.getInstance(); cal.setTime(df.parse(FromDate)); cal.add(Calendar.MINUTE, ADD_MINUTES); record.append("\t"); record.append(d_f.format(cal.getTime())); record.append("\t"); record.append(tf.format(cal.getTime())); record.append("\t"); records.add(record.toString()); } Here i want to add date and time seperately i mean in different tab, used \t still i am not getting the required output.
<java>
2016-04-26 05:24:37
LQ_EDIT
36,856,651
Broadcast receiver does not reaceive sms in android?
I am using broadcast receiver in my app to read Otp sent from server,I did not mentioned any permission in menifest.xml . but it does not read OTP .I don't know where is the problem kindly rectify it please.please help me. public BroadcastReceiver br = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final Bundle bundle = intent.getExtras(); try { if (bundle != null) { Object[] pdusObj = (Object[]) bundle.get("pdus"); assert pdusObj != null; for (Object aPdusObj : pdusObj) { @SuppressWarnings("deprecation") SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) aPdusObj); String phoneNumber = currentMessage.getDisplayOriginatingAddress(); String message = currentMessage.getDisplayMessageBody(); Log.e(s_szTAG, "Received SMS: " + message + ", Sender: " + phoneNumber); // checking sms sender address.... if (phoneNumber.toLowerCase().contains("+919971599909".toLowerCase())) { // verification code from sms m_szOtpCode = getVerificationCode(message); assert m_szOtpCode != null; String input = m_szOtpCode.trim(); Log.e(s_szTAG, "OTP received: " + m_szOtpCode); COTPVerificationDataStorage.getInstance().setM_szOtp(input);// getting otp from SMS and set to otpverificationstorage class } else { return; } } } } catch (Exception e) { Log.e(s_szTAG, "Exception: " + e.getMessage()); } } @SuppressWarnings("JavaDoc") private String getVerificationCode(String message) { String code; int index = message.indexOf(":"); if (index != -1) { int start = index + 2; int length = 6; code = message.substring(start, start + length); return code; } COTPVerificationDataStorage.getInstance().setM_szOtp(m_szOtpCode); return null; } }; private IntentFilter inf; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { m_Main = inflater.inflate(R.layout.otp_auto_verified, container, false); inf = new IntentFilter(); inf.addAction("android.provider.Telephony.SMS_RECEIVED"); getUserDetails();// getuser deatails.... init();// initialize controls... return m_Main; }
<android>
2016-04-26 06:16:06
LQ_EDIT
36,857,171
how can I creat button and picture horizontal
I want creat more button and picture horizontal or vertical to be this picture [enter image description here][1] [1]: http://i.stack.imgur.com/ouNm1.png pleas help me
<android><android-layout><android-studio>
2016-04-26 06:43:46
LQ_EDIT
36,858,166
Scroll an element inside a Div up to visible area
How to Scroll an element inside a Div. There are multiple div and each div content an element <span> Like < div class="parent" ><p ><span ></span ></p ></ div > < div class="parent" ><p ><span ></span ></p ></ div > < div class="parent" ><p ><span ></span ></p ></ div > < div class="parent" ><p ><span ></span ></p ></ div > and the are generate dynamically (infinite scroll) where <div class="parent" > is self scrolling div how to put <span ></span > element in visible part of div when page load AND/OR more data load on ajax call
<javascript><jquery><ajax>
2016-04-26 07:31:10
LQ_EDIT
36,859,274
regular expression
I want regular expression for below code can anyone help greatly appreciated abc-def-smdp-01 Here i want to match all hypen and smdp i want ignore abc and def and 01 can anyone help like this --smdp-
<regex><preg-match>
2016-04-26 08:23:22
LQ_EDIT
36,859,397
matrix row sum in cuda
<p>i am trying to calculate matrix row sum in the cuda. since cuda is used for parallel processing so there is no need of looping. I have done matrix sum operation and the code is</p> <pre><code>__global__ void MatAdd(int A[][N], int B[][N], int C[][N]){ int i = threadIdx.x; int j = threadIdx.y; C[i][j] = A[i][j] + B[i][j]; } </code></pre> <p>but in the same case not able to convert it into matrix row sum. i tried following code</p> <pre><code>__global__ void rowSums(float* matrix, float* sums, int rows, int cols) { int row = blockIdx.y * blockDim.y + threadIdx.y; int col = blockIdx.x * blockDim.x + threadIdx.x; if (i &lt; N &amp;&amp; j &lt; M) sums[j] += matrix[i][j]; } </code></pre>
<matrix><cuda>
2016-04-26 08:28:41
LQ_CLOSE
36,859,666
How run python with html or php?
<p>2 file is in the root: index.html or index.php , script.py I want to run the python program by clicking on the button on the Html(or php) page. is it possible? if yes, please guide me. if no, what solution you recommend?</p>
<php><python><html>
2016-04-26 08:41:23
LQ_CLOSE
36,859,831
Configuration Linux Kernel
<p>I need to compile kernel linux 3.4.4. I use "make menuconfig" to have a user-friendly interface to choose configuration.</p> <p>I haven't understood an aspect of the kernel configuration: what is the difference between i choose to include an option during the configuration and i choose to include, as a module, an option during the configuration?</p> <p>Thanks</p>
<c><linux><linux-kernel>
2016-04-26 08:48:49
LQ_CLOSE
36,860,585
Parse retrieving value of nested object
Lets say i have object like this: var a = { b: { c: 1, d: 2 } } And i have saved this object in Parse. There are 100 objects, but with different c and d values. Can i do search searching only objects which contains d:2. Or the only way is to query all objects and then use for loop which will search for d:2? Dont read this! Writting this line just to get posted, because system does not allow to post me question, dont know why Thank you
<javascript><parse-platform>
2016-04-26 09:20:17
LQ_EDIT
36,861,230
copying and pasting values to the next empty row
<p>I have multiple Excel files which i will open automatically. I would like to copy the values of the opened Excel files and paste it to the next empty row in my master file. </p> <p>How can i do this ?</p>
<vba><excel>
2016-04-26 09:47:08
LQ_CLOSE
36,861,255
How to size an array in c? 32 bit mcu
<p>The following line of c code creates an array to store a picture from a camera. The images are about 22kb. </p> <pre><code>uint8_t picturearray[32*1024]; </code></pre> <p>The mcu is 32 bit. I'm just wondering why it is <code>32*1024</code>? Is it 32 because it is 32 bit? Why would it be 1024?</p> <p>Thanks </p>
<c><arrays><microcontroller>
2016-04-26 09:48:03
LQ_CLOSE
36,862,361
#python #guessing game not working #error_unexpected indent
import random computerguess=random.randint(0,200) while True: userguess=int(input("enter your number:")) if userguess<computerguess: print("guess higher") elif userguess>computerguess: print("guess lower") else: print("hey!!!! CONGO MAN YOU GOT THE RIGHT NUMBER ") break
<python>
2016-04-26 10:32:25
LQ_EDIT
36,862,764
Iam Applying Autolayouts programatically But i received below type of message Can anyone pls help me
Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "<NSLayoutConstraint:0x7f844b716390 H:|-(30)-[UIButton:0x7f844b4be3c0'LOGIN'] (Names: '|':UIView:0x7f844b492a80 )>", "<NSLayoutConstraint:0x7f844b706ee0 H:[UIButton:0x7f844b4be3c0'LOGIN'(100)]>", "<NSLayoutConstraint:0x7f844b705dd0 H:[UIButton:0x7f844b4be3c0'LOGIN']-(80)-[UIButton:0x7f844b4c0520'SIGNUP']>", "<NSLayoutConstraint:0x7f844b706f30 H:[UIButton:0x7f844b4c0520'SIGNUP'(100)]>", "<NSLayoutConstraint:0x7f844b7147c0 H:[UIButton:0x7f844b4c0520'SIGNUP']-(30)-| (Names: '|':UIView:0x7f844b492a80 )>", "<NSLayoutConstraint:0x7f844b519f70 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f844b492a80(375)]>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x7f844b705dd0 H:[UIButton:0x7f844b4be3c0'LOGIN']-(80)-[UIButton:0x7f844b4c0520'SIGNUP']>
<ios><objective-c><xcode><nslayoutconstraint>
2016-04-26 10:51:04
LQ_EDIT
36,865,442
save all the effect of a webpage forever
<p>Suppose i have a webpage having a button, and when i press the button it will create another button bellow that.Now i want to save the effect, that means when i will open the webpage again it will direct show the button bellow the button. How can i store this effect in data base or in some other way?</p>
<javascript><html><css><sql>
2016-04-26 12:47:57
LQ_CLOSE
36,867,920
Calculating age in Javascript with YYYY-mm-dd format
<p>I have birthday in following format: </p> <pre><code>1982-09-20 </code></pre> <p>I need to get the exact age of the person from that birthdate ( compared with the current date). </p> <p>What's the easiest way to do this in JS? Can someone help me out please?</p> <p>Thanks!</p>
<javascript><date><datetime>
2016-04-26 14:29:15
LQ_CLOSE
36,868,321
Filter with a condition
<pre><code>df &lt;- data.frame(month_key = c(rep(201504, 2), rep(201505, 3)), id = c(1, 2, 1, 2, 3)) </code></pre> <p>I have a dataframe like df, for each month ID are not necessary distinct. I want to filter my dataframe and keep only the ID with appears in the first month_key (in my exemple id = 1 and 2). I don't want to select my id for the first month and inner_join with the other month ... Thank you</p>
<r><dplyr>
2016-04-26 14:45:16
LQ_CLOSE
36,868,980
Need help creating a relevancy calculator in JavaScript
<p>folks,</p> <p>I admit that I'm not super strong with JS when it comes to math, so I'm reaching out here for some help. What I need to do is come up with a relevancy calculator that does the following:</p> <p>Users have two number fields, the first is labeled '# of people', and the second is labeled '# irrelevant stories'. When the user enters a value for each field, the output on submit is calculated with the following: (# of people value x 0.20$) x (# irrelevant stories value x 30 seconds).</p> <p>Any guidance or direction would be greatly appreciated!</p>
<javascript>
2016-04-26 15:12:46
LQ_CLOSE
36,870,842
Graphing any rational functions in python considering the asymptotes
<p>How to graph any rational function in python matplotlib (considering the asymptotes)</p> <pre><code>numerator = input ("numerator: ") denominator = input ("denominator: ") </code></pre>
<python><python-3.x><numpy><matplotlib><tkinter>
2016-04-26 16:38:06
LQ_CLOSE
36,871,127
Understanding Liskov Substituion Principle
<p>My sample program like below;</p> <pre><code> public class Animal { public virtual string MakeSound() { return "General Sound"; } } public class Dog : Animal { public override string MakeSound() { return "Bow..Bow.."; } } } static void Main(string[] args) { Animal obj1 = new Animal(); Console.WriteLine("General Animal's sound id " + obj1.MakeSound()); Dog obj2 = new Dog(); Console.WriteLine("Dog Animal's sound id " + obj2.MakeSound()); //Violate LSP Animal obj3 = new Dog(); Console.WriteLine("Animal's sound id " + obj3.MakeSound()); Console.ReadKey(); } </code></pre> <p>Here as my understanding when we create Dog instance for Animal like obj3, we are violating LSP. Please confirm my understanding. If yes, please tell me how to achieve in this case to understand better. I think my coding is conceptionwise correct</p>
<c#><design-patterns><liskov-substitution-principle>
2016-04-26 16:53:00
LQ_CLOSE
36,871,297
Using the GPU on IOS for combining images
I am working on some image processing in my app. Taking live video and adding an image onto of it to use it as an overlay. Unfortunately this is taking massive amounts of CPU to do which is causing other parts of the program to slow down and not work as intended. Essentially I want to make the below code use the GPU instead of the CPU. Thanks for your time. - (UIImage *)processUsingCoreGraphics:(UIImage*)input { CGRect imageRect = {CGPointZero,input.size}; NSInteger inputWidth = CGRectGetWidth(imageRect); NSInteger inputHeight = CGRectGetHeight(imageRect); // 1) Calculate the location of Ghosty UIImage * ghostImage = [UIImage imageNamed:@"myImage"]; CGFloat ghostImageAspectRatio = ghostImage.size.width / ghostImage.size.height; NSInteger targetGhostWidth = inputWidth * 2;//0.25; CGSize ghostSize = CGSizeMake(targetGhostWidth, targetGhostWidth / ghostImageAspectRatio); //CGPoint ghostOrigin = _currentPositionForNotification;//CGPointMake(inputWidth * 0.5, inputHeight * 0.2);//CGPointMake(inputWidth * 0.5, inputHeight * 0.2); CGRect ghostRect = {_currentPositionForNotification, CGSizeMake(1000, 100)}; // 2) Draw your image into the context. UIGraphicsBeginImageContext(input.size); CGContextRef context = UIGraphicsGetCurrentContext(); CGAffineTransform flip = CGAffineTransformMakeScale(1.0, -1.0); CGAffineTransform flipThenShift = CGAffineTransformTranslate(flip,0,-inputHeight); CGContextConcatCTM(context, flipThenShift); CGContextDrawImage(context, imageRect, [input CGImage]); CGContextSetBlendMode(context, kCGBlendModeSourceAtop); //CGContextSetAlpha(context,0.5); CGRect transformedGhostRect = CGRectApplyAffineTransform(ghostRect, flipThenShift); CGContextDrawImage(context, transformedGhostRect, [ghostImage CGImage]); // 3) Retrieve your processed image UIImage * imageWithGhost = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); //CGContextRelease(context); //CFRelease(imageRef); return imageWithGhost;
<ios><opengl><opengl-es>
2016-04-26 17:01:55
LQ_EDIT
36,871,856
Php function creates new array (data) from input or references to it?
<p>I have a general php question. I have an array of size lets say size of 3. And I pass it as an input to a function in an included file. So, does it copy the array (more memory) or actually make the function to references it ?</p> <pre><code>$arr = array('a', 'b', 'c'); include(functions.php); //doSomething() resides here $result = doSomething($arr); </code></pre>
<php><arrays><reference>
2016-04-26 17:31:05
LQ_CLOSE
36,872,789
Javascript - how to combine AJAX with JSON?
I'm trying to read all information from the JSON string. I'm also trying to read it with the help of AJAX. The purpose is to fill an innerHTML with the information, but nothing happends. What is wrong with the code and how can it be solved? function getResults() { var obj = [ { "number": "Bob", "position": "forward", "shoots": "left" }, { "number": "John", "position": "forward", "shoots": "right" } ]; var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (xhttp.readyState == 4 && xhttp.status == 200) { var return_data = request.responseText; document.getElementById("sportresults").innerHTML = return_data; } }; xhttp.open("GET", obj, true); xhttp.send(); }
<javascript><json><ajax>
2016-04-26 18:18:10
LQ_EDIT
36,872,970
Connecting multiple phone calls visa VOIP using c#
I am trying to achieve below Me (customer) press a button to speak to agent (from mobile app - Xamarin) Then login tries to connect to (gets top 5 agents list from database / JSON - top 5 agents will vary every time based on time) Agent 1 - rings agent 1 mobile phone as normal call, if No answer after 25 seconds Agent 2 - ring for 25 secs Agent 3 - ring, connected Once call finished log date time of call I am happy to use any VOIP provider or any other solutions.
<c#><voip>
2016-04-26 18:28:24
LQ_EDIT
36,875,122
Dynamic char array from class dont printing the proper result
<p>i am making a project in which user will add the info of car and one function will show all the available cars.But the i cannot be able to copy names of car from one array to another here is the code.</p> <pre><code>#include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;conio.h&gt; #include &lt;string.h&gt; using namespace std; const int SIZE=10; class car { public: int car_no=0; char car_name[SIZE][20]; char car_model[SIZE][20]; char car_colour[SIZE][20]; char reg_id[SIZE][20]; int rate_per_day[SIZE]; char cars_in_lot[SIZE][20]; }; addcar() { char choice; do{ car*newcar=new car; cout&lt;&lt;"\t\t\t\t(-&gt;) Name : "; cin&gt;&gt;newcar-&gt;car_name[newcar-&gt;car_no]; strcpy(newcar-&gt;cars_in_lot[newcar-&gt;car_no],newcar-&gt;car_name[newcar-&gt;car_no]); cout&lt;&lt;endl; cout&lt;&lt;"\t\t\t\t(-&gt;) reg!str@t!0n number : "; cin&gt;&gt;newcar-&gt;reg_id[newcar-&gt;car_no]; cout&lt;&lt;endl; cout&lt;&lt;"\t\t\t\t(-&gt;) c0l0ur : "; cin&gt;&gt;newcar-&gt;car_colour[newcar-&gt;car_no]; cout&lt;&lt;endl; cout&lt;&lt;"\t\t\t\t(-&gt;) Model : "; cin&gt;&gt;newcar-&gt;car_model[newcar-&gt;car_no]; cout&lt;&lt;endl; cout&lt;&lt;"\t\t\t\t(-&gt;) Rate of Rent Per Day : "; cin&gt;&gt;newcar-&gt;rate_per_day[newcar-&gt;car_no]; newcar-&gt;car_no++; cout&lt;&lt;"Want to add another car [y/n]"&lt;&lt;endl; cin&gt;&gt;choice; }while(choice == 'y' || choice == 'Y'); } void show_cars_in_lot() { cout&lt;&lt;"Avaialable Cars in Lot are : "&lt;&lt;endl; car*newcar=new car; for(int i=0;i&lt;SIZE;i++) cout&lt;&lt;i+1&lt;&lt;"\t"&lt;&lt;newcar-&gt;cars_in_lot[i]&lt;&lt;"\t"&lt;&lt;newcar-&gt;car_colour[i] &lt;&lt;"\t"&lt;&lt;newcar-&gt;car_model[i]&lt;&lt;"\t"&lt;&lt;newcar-&gt;reg_id[i]&lt;&lt;endl; getch(); } void display1() { cout&lt;&lt;"\t\t\t(1) Show Cars in Lot"&lt;&lt;endl; cout&lt;&lt;"\t\t\t(2) Add Cars"&lt;&lt;endl; }// end of display1 int main() { char option; int desire_car; do { int choice; display1(); cout&lt;&lt;"Enter Your Choice : "; cin&gt;&gt;choice; switch(choice) { case 1: show_cars_in_lot();break; case 2: addcar();break; default: cout&lt;&lt;"You Entered Wrong Input"&lt;&lt;endl; } cout&lt;&lt;"Go To Main Menu [y/n]";cin&gt;&gt;option; }while(option == 'y' || option == 'Y'); return 0; } </code></pre>
<c++><class><oop><dynamic><char>
2016-04-26 20:29:04
LQ_CLOSE
36,876,517
Another, but specific play/pause issue
<p>I'm trying to implement play/pause and stop buttons in a toolbar for a simple stopwatch app. See code at <a href="http://swiftstub.com/722226472" rel="nofollow">http://swiftstub.com/722226472</a> I'm experiencing strange behavior: at first the play button does nothing. If I click on the stop button, the icon disappears and then the play/pause toggles and works correctly. Suggestions? I'm using the latest swift and Xcode</p>
<ios><swift><uibarbuttonitem>
2016-04-26 21:56:51
LQ_CLOSE
36,877,360
get multiple Elements By Tag Name in JavaScript?
<p>Hello there am trying to make an image gallery for example lets say that I have multiple images and I want to change their opacity when I hover over them by using JavaScript I know that this is possible with CSS but am trying to accomplish this with JavaScript I tried using get Elements By Tag Name method but the problem it just can access one element by time so can I do that thanks </p>
<javascript><jquery><html><css>
2016-04-26 23:05:34
LQ_CLOSE
36,877,472
C+ Programming what am I doing wrong
Create an Employee class. Items to include as data members are employee number, name, date of hire, job description, department, and monthly salary. The class is often used to display an alphabetical listing of all employees. Include appropriate constructors and properties. Override the ToString ( ) method to return all data members. Create a second class to test your Employee class." I've created an Employee class with the proper variables, properties, and constructors, but am having trouble "testing" it through a second class. The code I have written runs without errors, but doesn't display anything (presumably the goal of the testing). Where am I going wrong in the calling section? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EmployeeProgram { public class EmployeeProgram { private int employeeNumber; private string name; private string hiredate; private int monthlySalary; private string description; private string department; public employee(int employeeNumber, string name, string dateOfHire, int monthlySalary, string description, string department) { this.employeeNumber = 456; this.name = "Joyce"; this.hiredate = "12/15/14"; this.monthlySalary = 3200; this.description = "Manager"; this.department = "Accounting"; } public int EmployeeNumber { get { return employeeNumber; } set { employeeNumber = value; } } public string Name { get { return name; } set { name = value; } } public string Hiredate { get { return hiredate; } set { hiredate = value; } } public int MonthlySalary { get { return monthlySalary; } set { monthlySalary = value; } } public string Department { get { return department; } set { department = value; } } public string Description { get { return description; } set { description = value; } } public override string ToString() { return "Employee ID: " + employeeNumber + "Employee Name: " + name + "Employee Hire Date: " + hiredate + "Employee Monthly Salary: " + monthlySalary + "Employee Description: " + description + "Employee Department: " + department; } public void Print() { Console.WriteLine(this.ToString()); } }
<c#>
2016-04-26 23:17:24
LQ_EDIT
36,877,844
MVC, C# - Not All Code Paths Return A Value
<p>I'm creating a basic MVC Copy File App and am returning a Not All Code Paths Return a Value error in my GetSource method. I've researched the issue and have tried a few things, but the error still generates. I believe the error is in the foreach loop somewhere, but I tried returning a null afterwards, which just threw up a different error. Any help is appreciated as I am a beginner. Thanks!</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.IO; namespace April24 { public class Andrew { public string Copy() { return "Done Copying"; } public string GetSource() //Error is here { copyFiles(10); } public static string production = @"C:\Users\test\Desktop\Production"; public static string renameFolder = @"C:\Users\test\Desktop\RenameFolder\"; static private void copyFiles(int numberOfFiles) { List&lt;string&gt; files = System.IO.Directory.GetFiles(production, "*").ToList(); IEnumerable&lt;string&gt; filesToCopy = files.Where(file =&gt; file.Contains("Test_Name")).Take(10); foreach (string file in filesToCopy) { string destfile = renameFolder + System.IO.Path.GetFileName(file); System.IO.File.Copy(file, destfile, true); }; /*tried return null; here but still threw error*/ } } } </code></pre>
<c#><asp.net-mvc>
2016-04-26 23:53:45
LQ_CLOSE
36,877,861
Why is correct id is not inserting into table
I want the following code to insert the cars id in customer_payment table but it only select 477 id. I don't know why. As it can be seen in image bellow only product_id 477 is inserted not any other if I select 500 it still inserts 477. Please help me on this help will be appreciated. Thank you [enter image description here][1] include 'admin/db.php'; if(isset($_GET['payment_here'])){ //select product id from cart $select_cart = "select * from cart"; $runcart = mysqli_query($conn, $select_cart); $cartwhile=mysqli_fetch_assoc($runcart); $carssid = $cartwhile['P_ID']; $cusid = $cartwhile['C_ID']; //select id from cars $scars = "select * from cars where id=$carssid"; $scarsrun = mysqli_query($conn, $scars); $showcars = mysqli_fetch_assoc($scarsrun); $carsdealer = $showcars['dealer']; //select customer id from customer table //$selectcust = "select * from customer_register where id=$cusid"; //insert data into customer payment table echo $insertpay = "insert into customer_payment (Product_id, customer_id, dealer) values ( $carssid," . $_SESSION['customer_id'] . ", '$carsdealer')"; $run_inserts = mysqli_query($conn, $insertpay); /* if($run_inserts){ echo "<script>window.location.href = 'checkout.php'</script>"; } */ } ?> [1]: http://i.stack.imgur.com/gQccg.jpg
<php><mysqli>
2016-04-26 23:55:26
LQ_EDIT
36,877,968
what's wrong with my return statement and static method
<p>This is not a homework question. It is one of my practices. Please help me understand where i did wrong. The original was static void changeArray, but i changed it to static int changeArray and inserted a return statement at the end, but it still won't update the main code. </p> <p>public class testing{</p> <pre><code>/* * Change the method to also update the key at the main */ static int changeArray(int key, int array[]){ key = key + 7; for (int i = 0; i &lt; array.length; i++){ array[i] = array[i] + key; } System.out.println("*At changeArray *"); System.out.println("The key is: "+ key); return key; } static void printArray(int array[]){ System.out.print("[ "); for (int element:array){ System.out.print(element + " "); } System.out.println("]"); } public static void main(String[] args){ int key = 5; int[] array = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; System.out.println("*At the main *"); System.out.println("The key is: "+ key); printArray(array); changeArray(key, array); System.out.println("*At the main *"); System.out.println("The key is: "+ key); &lt;--- (this is supposed to be 12 after the method is called, but it keeps printing out 5) printArray(array); } </code></pre> <p>}</p>
<java><methods><syntax><parameters><return>
2016-04-27 00:06:27
LQ_CLOSE
36,878,294
TCP android Class Cast Exception
Hi I am trying to send a custom list of objects from Client to server. I am getting a class cast exception. I am using Android studio emulator for my client and running my Server on Eclipse. I even wrote a test code to check to see if it works in eclipse and it does. But for some reason does not work on android. I am new to android import java.io.Serializable; import java.util.Arrays; public class Document implements Serializable { private static final long serialVersionUID = 1L; String id; String name; String address; String[] category; float lattitude; float longitude; String city; double stars; double overallRating; // String attributes[]; Review[] reviews; public Document(String id, String name, String address, String[] category, float longitude, float lattitude, String city, double stars, double overallRating, Review[] review) { super(); this.id = id; this.name = name; this.address = address; this.category = category; this.longitude = longitude; this.lattitude = lattitude; this.city = city; this.stars = stars; this.overallRating = overallRating; this.reviews = review; } @Override public String toString() { return "Document [id=" + id + ", name=" + name + ", address=" + address + ", category=" + Arrays.toString(category) + ", lattitude=" + lattitude + ", longitude=" + longitude + ", city=" + city + ", stars=" + stars + "]"; } } import java.io.Serializable; public class Review implements Serializable { private static final long serialVersionUID = -1595783420656910821L; double stars; String review; public Review(double stars, String review) { this.stars = stars; this.review = review; } } //Part of the server import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.ObjectOutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.util.List; public class CommunicatewithMobileDevice implements Runnable { Socket conn; private InvertedIndexA invertedIndex; private BufferedReader br; private ObjectOutputStream oos; private PrintWriter pw; public CommunicatewithMobileDevice(Socket sock, InvertedIndexA invertedIndex) { conn = sock; this.invertedIndex = invertedIndex; try { br = new BufferedReader(new InputStreamReader(conn.getInputStream())); pw = new PrintWriter(new OutputStreamWriter(sock.getOutputStream()), true); } catch (IOException e) { e.printStackTrace(); } } public void run() { try { String ip = br.readLine(); String input[] = br.readLine().split(" "); System.out.println(ip + " " + input[0] + " " + input[1]); List<Document> docs = invertedIndex.search(ip, Float.valueOf(input[0]), Float.valueOf(input[1])); System.out.println(docs.size()); oos = new ObjectOutputStream(this.conn.getOutputStream()); oos.writeObject(docs); oos.flush(); } catch (IOException e) { e.printStackTrace(); } } } //A singleton or a server import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class Singleton implements Runnable { private ServerSocket conn; private static InvertedIndexA invertedIndex = new InvertedIndexA(Helper.loadCategories()); private boolean isStopped = false; private Singleton() { } public static InvertedIndexA getInstance() { return invertedIndex; } public static void main(String args[]) { new Thread(new Singleton()).start(); } public void acceptsClients() { try { synchronized (this) { conn = new ServerSocket(1503); } while (!isStopped()) { Socket sock = conn.accept(); //System.out.println("Conn accepted"); new Thread(new CommunicatewithMobileDevice(sock, invertedIndex)).start(); } } catch (IOException e) { e.printStackTrace(); } } private synchronized boolean isStopped() { return this.isStopped; } public synchronized void stop() { this.isStopped = true; try { this.conn.close(); } catch (IOException e) { throw new RuntimeException("Error closing server", e); } } @Override public void run() { acceptsClients(); } } //The android client or a part of it import android.Manifest; import android.content.pm.PackageManager; import android.os.AsyncTask; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.PrintWriter; import java.net.Socket; import java.util.ArrayList; import java.util.List; import android.widget.ListView; import android.widget.TextView; import android.content.Context; public class ListOfResults extends AppCompatActivity { CommunicateWithServer comm; GPSTracker gps; String message = ""; List<Document> docs; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_of_results); comm = new CommunicateWithServer(); Bundle bundle = getIntent().getExtras(); message = bundle.getString("message"); //new Communicate().execute(); new Thread(runnable).start(); } Runnable runnable = new Runnable() { @Override public void run() { try { Socket sock = new Socket("129.21.114.74", 1503); PrintWriter pw = new PrintWriter(sock.getOutputStream(), true); pw.println(message); double latitude = 0; double longitude = 0; pw.println(new String(Double.valueOf(latitude) + " " + Double.valueOf(longitude))); ObjectInputStream ois = new ObjectInputStream(sock.getInputStream()); docs = (List<Document>) ois.readObject(); BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream())); //Log.e("print the val",br.readLine()); //System.out.println(docs.size()); Log.e("size", Integer.toString(docs.size())); } catch (IOException | ClassNotFoundException e) { // TODO Auto-generated catch block System.out.println("yeassass"); } } }; public void populate(String result) { Log.e("here", "here"); DocumentAdapter documentAdapter = new DocumentAdapter(this, docs); ListView listView = (ListView) findViewById(R.id.listView1); listView.setAdapter(documentAdapter); } } //This was a test program i wrote to test the server code. Works fine here import java.io.IOException; import java.io.ObjectInputStream; import java.io.PrintWriter; import java.net.Socket; import java.util.List; public class Test implements Runnable { public Test() { // TODO Auto-generated constructor stub } public static void main(String args[]) { Test test = new Test(); new Thread(test).start(); } public void run() { testOp(); } private void testOp() { try { Socket sock = new Socket("localhost", 1503); PrintWriter pw = new PrintWriter(sock.getOutputStream(), true); String location = Helper.getLocation(); location = location.substring(location.lastIndexOf(") ") + 2); String split[] = location.split(","); pw.println("Chinese"); pw.println(new String(split[0] + " " + split[1])); ObjectInputStream ois = new ObjectInputStream(sock.getInputStream()); List<Document> docs = (List<Document>) ois.readObject(); System.out.println(docs); } catch (IOException | ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
<java><android><serialization><classnotfoundexception>
2016-04-27 00:40:52
LQ_EDIT
36,878,737
How do I serialize an object for the query in a GET request?
<p>I'm trying to serialize an object in JavaScript so that I can query it in a GET request.</p>
<javascript>
2016-04-27 01:30:31
LQ_CLOSE
36,879,197
Need clarification on cmd, powershell, developer command prompt etc
<p>those things all have a window for me to type commands in. it has been a while but i still don't know what are the differences. can someone clarify please? Thanks.</p>
<powershell>
2016-04-27 02:26:34
LQ_CLOSE
36,879,381
What is happening in binary IO in C?
<p>I imagine this applies to a lot of other languages as well.</p> <p>I have this code here, and I am wondering what is actually happening and how I can interpret what is written to the file...</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; int main () { //Initialize a variable and load it with input using scanf char write[100] = "Write this."; FILE *fp = fopen("./binFile.txt", "w+"); fwrite(write, sizeof(write[0]), sizeof(write)/sizeof(write[0]), fp); fclose(fp); } </code></pre> <p>and then when I open the text file I see this...</p> <pre><code>5772 6974 6520 7468 6973 2e00 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 </code></pre> <p>But I am having some trouble seeing exactly what is going on here. How does this text break down to binary?</p>
<c><binary>
2016-04-27 02:48:33
LQ_CLOSE
36,879,699
Convert Date Time to Format
I am trying to convert a string which is "20151107" to a date format like this "2015-11-07". Here's my code : public static DateTime CustomDateFormat(this string resultdate) { DateTime dt = DateTime.ParseExact(resultdate, "yyyyMMdd", CultureInfo.InvariantCulture); return dt; } However this returns something like this "11/07/2015 00:00:00.00" Any idea ? Thanks.
<c#><asp.net-mvc><parsing><datetime>
2016-04-27 03:25:28
LQ_EDIT
36,880,338
Directory comparision
path1 : /home/users/term/R1.0/test/mw & path2 : /home/users/term/R1.2/test/mw I would like to compare the above two directory paths and output the path which has highest version. output = /home/users/term/R1.2/test/mw what is the best way to achieve it.
<python>
2016-04-27 04:30:22
LQ_EDIT
36,880,637
How to call an activity from on Itemclick listener
I am trying to call an activity when ever an element from my gridview is clicked it will open in a swiping activity but I am getting an error on setting as 2829-2829/com.union.project E/AndroidRuntime: FATAL EXCEPTION: main Process: com.union.project, PID: 2829 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.union.project/com.union.project.Swipeview.Main3Activity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:302) at android.app.Activity.requestWindowFeature(Activity.java:3605) at com.union.project.Swipeview.Main3Activity.onCreate(Main3Activity.java:19) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)  at android.app.ActivityThread.access$800(ActivityThread.java:151)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:135)  at android.app.ActivityThread.main(ActivityThread.java:5254)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)  04-27 00:39:27.626 2829-2829/com.union.pro this is the error I am getting when I click on anyitem it show the toast but then crashes my fragment code @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view= inflater.inflate(R.layout.fragment_two, container, false); GridView gridView=(GridView)view.findViewById(R.id.gridView2); gridView.setAdapter(new UAdapter(getActivity())); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(getActivity(),"Pic"+(position)+"Selected",Toast.LENGTH_SHORT).show(); Intent intent= new Intent(view.getContext(),Main4Activity.class); intent.putExtra("pic",position); startActivity(intent); } }); return view; } my swipe view code ` protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main4); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); viewPager =(ViewPager)findViewById(R.id.viewpager1); adapter =new CustomeSwipeAdapter2(this); viewPager.setAdapter(adapter); viewPager.setCurrentItem(getIntent().getIntExtra("pic", 0)); }` this is the activity that I want to start but getting the error can some one tell me how to fix this .
<android><android-studio><android-activity><onitemclicklistener>
2016-04-27 04:56:08
LQ_EDIT
36,882,615
how can i get non repeating value? I`m using sql select view
THIS IS MY SELECT VIEW, HOW CAN I GET NON REPEATING VALUES? [duplicated entry][1] *I need only one line in my view. SELECT A.TOTAL_PRESENT, A."LIMIT", A.COST_CENTER, A.ID, A.PLANT, A.BUDGET_YEAR, A."VERSION", B.BUDGET_YEAR, B."VERSION", B.PLANT, B.CHARGE_CC, B.YEAR_DATE_USD FROM CMS.SUM_REPANDMAINT A, CMS.V_SUM_REPANDMAINT B WHERE (A.BUDGET_YEAR = B.BUDGET_YEAR(+)) AND (A."VERSION" = B."VERSION"(+)) AND (A.PLANT = B.PLANT(+)) AND (A.COST_CENTER = B.CHARGE_CC(+)) AND (B.USERNAME = '[usr_name]') [1]: http://i.stack.imgur.com/9ezbS.png
<sql><oracle>
2016-04-27 07:01:40
LQ_EDIT
36,882,639
Convert tab file data to csv or excel format using java
<p>How to extract data from a tab file which has text data in form of rows and column and export it to csv or excel file format? Which language will be best to achieve this?</p>
<java><excel><file><tabs><format>
2016-04-27 07:02:57
LQ_CLOSE
36,883,349
After "iptables -P INPUT DROP in Ubuntu, How can apply my additional rule?
In Ubuntu 16.04LTS, I typed next lines. iptables -F iptables -X iptables -A INPUT -m mac --mac-source 1C:**:2C:**:72:**:78 -j ACCEPT and the result of "iptables -L -nvx" is [the result of it][1] [1]: http://i.stack.imgur.com/DeZ48.jpg but when I access to port 80 for accessing web-page with the PC(1C:**:2C:**:72:**:78), I cannot connect to the web-server. When I try to the web-server with "iptables -P INPUT ACCESS", it works well. Could anyone give me any solution or advicies for this? Thank you for reading. Have a good daay.
<linux><ubuntu><networking><iptables><policy>
2016-04-27 07:39:10
LQ_EDIT
36,883,574
Is there any method to convert seconds to LocalDateTime or ZonedDateTime object in java 8
<p>I have a long value of seconds using which i want to build LocalDateTime object. I could not find direct method which can take long variable and build LocalDateTime object. Please help. I am using java 8.</p>
<java>
2016-04-27 07:50:29
LQ_CLOSE
36,884,681
email validation checking in Javascript
<p>I want to varify if the entered string is in email format or not. I am bit confused. I tried to write below code but failed. Can ayone help me please.</p> <pre><code>Javascript Code: &lt;script&gt; function emailValidation(id) { var emailPattern = var emailPattern = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if (emailPattern.test(id) === false) { alert("not a valid email address."); } document.getElementById(id).value = ""; } &lt;/script&gt; HTML Code: &lt;input type="text" id="empemail" onblur="emailValidation('empemail')" name="email" placeholder="eg: aaa@abc.ca" required=""&gt; </code></pre>
<javascript><html>
2016-04-27 08:45:10
LQ_CLOSE
36,885,990
Having a probelm with a Struck constance, which wont allow me to create a calender
I am trying to create a calendar and have been following a tutorial on YouTube 'calendar ruby on rails' first video. once I inputted the code i had an error 'uninitialized constant CalenderHelper::Struck' <----- that is the error message the code is; module CalenderHelper def calender(date = Date.today, &block) Calender.new(self, date, block).table end **class Calender < Struck.new(:view, :date, :callback)** HEADER = %w[Sunday Monday Tuesday Wednesday Thursday Friday Saturday] START_DAY = :sunday delegate :content_tag, to: :view def table content_tag :table, class: "calender" do header + week_rows end end def header content_tag :tr do HEADER.map { |day| content_tag :th, day }.join.html_safe end end def week_rows week.map do |week| content_tag :tr do week.map { |day| day_cell(day) }.join.html_safe end end.join.html_safe end def day_cell(day) content_tag :td, view.capture(day, &callback), class: day_classes(day) end def day_classes(day) classes = [] classes << "today" if day == Date.today classes << "notmonth" if day.month != date.month classes.empty? ? nil : classes.join(" ") end def weeks first = date.beginning_of_month.beginning_of_week(START_DAY) last = date.end_of_month.end_of_week(START_DAY) (first..last).to_a.in_groups_of(7) end end end line with the error is marker with starts on each side
<ruby-on-rails>
2016-04-27 09:40:05
LQ_EDIT
36,886,501
how to continuously sync local data between iphone to iwatch when iPhone app in background mode ?
When iphone app is enter in background mode then ios automatically terminate app after 180 second. If we require to continuously data sync between iphone app to iwatch app. In this situation what can we do? How to continuously data sync enable between iphone and iwatch when iphone app is in background and time was expired. Lets see answer for more details.
<ios><objective-c><watchkit><watchos-2>
2016-04-27 09:59:45
LQ_EDIT
36,886,503
Sort a list according to a property java
<p>I have a list of Strings </p> <pre><code>ArrayList&lt;String&gt; titles = t1,t1,t2,t2,t3,t3,t3 </code></pre> <p>I want a sublist with the unique values ie. <code>titles2 = t1,t2,t3</code></p> <p>How can I do this? Any help is appreciated</p>
<java><sorting><arraylist>
2016-04-27 09:59:45
LQ_CLOSE
36,887,764
Insert a string on regex match in ruby
<pre><code>str = "This website is &lt;a href='www.google.com'&gt;Google&lt;/a&gt;, some other website is &lt;a href='www.facebook.com'&gt;Facebook&lt;/a&gt;" style_to_add = "style='text-decoration:none;'" </code></pre> <p>I want to add the <code>style_to_add</code> string to every hyperlink. So the result becomes</p> <pre><code>str = "This website is &lt;a href='www.google.com' style='text-decoration:none;&gt;Google&lt;/a&gt;, some other website is &lt;a href='www.facebook.com' style='text-decoration:none;&gt;Facebook&lt;/a&gt;" </code></pre>
<ruby><regex>
2016-04-27 10:55:30
LQ_CLOSE
36,888,178
golang slice copy is not working as expected
In the following golang program, I am creating mySlice1 with 6 elements in it. mySlice2 is initialized with 3 elements. From mySlice1 I am taking 1st two elements into mySlice2. Also using copy function of slice, 3 elements of mySlice1 are overwritten to mySlice2. package main import "fmt" func main() { mySlice1 := []int{1, 3, 5, 7, 9, 11} mySlice2 := make([]int,3) mySlice2 = mySlice1[0:2] copy(mySlice2,mySlice1) fmt.Printf("%T\t%T\n", mySlice1,mySlice2) fmt.Println(mySlice1,mySlice2) } But while printing mySlice2 I am getting two elements only. $ go run main.go []int []int [1 3 5 7 9 11] [1 3] Why does mySlice2 is not getting overwritten while using copy function ? Thank you
<go><slice>
2016-04-27 11:15:41
LQ_EDIT
36,889,081
Goolgle Window Toolkit plugin is not working for chrome browser
i am new user of GWT toolkit. and i was running my application in chrome browser. but it was asking me to download the plugin to run GWT applications. then i gone through the link but it was showing me this problem....NOT COMPATIBLE [enter image description here][1] [1]: http://i.stack.imgur.com/bOyTG.jpg Please provide help.
<gwt><plugins>
2016-04-27 11:56:35
LQ_EDIT
36,889,255
Where to learn android programming?
<p>I already know the basics of Java but where should you go to learn android app development. I want to learn how to make pro apps and one day make a 3D game. Where do/did you go to learn android development? And please don't say university. </p>
<android>
2016-04-27 12:03:27
LQ_CLOSE
36,889,988
Is it faster to concatenate a string or an array in JavaScript?
<p>Which is faster?</p> <pre><code>var str = ''; for(var i=0; i&lt;1000; i++) { str += i; } </code></pre> <p>or</p> <pre><code>var arr = []; for(var i=0; i&lt;1000; i++) { arr.push(i); } var str = arr.join(''); </code></pre> <p>I ask because I have written a CSS parser which works really well, but is very slow for larger stylesheets (understandably). I am trying to find ways of making it faster, I wondered if this would make a difference. Thanks in advance!</p>
<javascript><arrays><string><concatenation><string-concatenation>
2016-04-27 12:34:59
LQ_CLOSE
36,891,079
Locatio Based Android Development
In android once we get the current location's latitude and longitude then after how we can able to get the list of my places which are all marked in Google My Maps within the 10kms radius of current location , i.e if my current location latitude and longitudes are 23.00 & 72.50 respectively so on base of that how can i get the list of my places marked in Google My Maps nearby this location address within the 10 kms radius?
<java><android>
2016-04-27 13:20:40
LQ_EDIT
36,891,354
The Tomcat server is running properly but still error 404 is generated
<p><a href="http://i.stack.imgur.com/JNAOL.png" rel="nofollow">Server working fine but error landing on home page</a></p>
<java><xml><jsp>
2016-04-27 13:32:12
LQ_CLOSE
36,891,918
hi guys i want upload four image in my databese and i dnt know how to go abt it
have been using php for some time now and i can only upload just one image to my database and with directory path.. bt now m trying to upload many files in a form bt its just saving one file out of four images i try to upload.. ur helps will be much apprecited... <!-- begin snippet: js hide: false --> <!-- language: lang-js --> $mypic = $_FILES['upload']['name']; $temp = $_FILES['upload']['tmp_name']; $type = $_FILES['upload']['type']; $id = $_POST['name']; if(($type=="image/jpeg")||($type=="image/jpg")||($type=="image/bmp")) { $directory = "profiles/$id/images"; mkdir($directory, 0777,true); move_uploaded_file($temp,"{$directory}/$mypic"); <!-- language: lang-html --> <form name="upload.php" enctype="multipart/form-data" method="post"> <input type='file' name='upload'><br/> <input type='file' name='upload'><br/> <input type='file' name='upload'><br/> <input type='file' name='upload'><br/> <input type='submit' name='submit'/><br/> </form> <!-- end snippet -->
<php><mysql>
2016-04-27 13:53:58
LQ_EDIT
36,892,875
C# Writing to a excel file
<p>I have Data stored in DataTables and I'm trying to write that data into a .xlsx file, with multiple sheets. I don't how to go about it. Thanks</p>
<c#><.net><excel><winforms>
2016-04-27 14:30:45
LQ_CLOSE
36,893,986
copy list element of key values in dictionary through python language?
I have dictionary which have multiple key and those multiple key have multiple list so i want to copy specific value for a specific key dict1={ '1' : [1,2,3] , '2' : [4,5,6] , '3' :[7,8,9]} output: if key == 1 then print 3 if key == 2 then print 6 if key == 3 then print 9
<python>
2016-04-27 15:16:06
LQ_EDIT
36,895,888
Should we put all css inside HTML document?
<p>I'm trying to make a Site enhancement. The Bootstrap.min.css took 0.5 second to load complete to our website.</p> <p>I thinks solve the 0.5 by place all minified CSS in my HTML Document (In production mode). It's a good idea for run-time enhancement ? Does it make HTML Engine slow to load the CSS ?</p>
<html><css>
2016-04-27 16:41:54
LQ_CLOSE
36,896,418
Why would I choose a Windows Service over a Web API service?
<p>For me, Windows Services are inconvenient and cumbersome enough to question their validity in all apps that aren't "Watch this folder for a change, react to this change."</p> <p>I understand that this oversimplification is ignorant, why would one choose a windows service over the Web API.</p>
<c#><web-services><asp.net-web-api><microservices>
2016-04-27 17:07:14
LQ_CLOSE