Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
1,750,837 | 1,750,838 | What is a safe way to check that a listbox is empty in JQuery? | <p>What is a safe way to check that a listbox is empty in JQuery ? Alternative question, how to check if there is no item actively selected ?</p>
<p>I have tried :</p>
<pre><code>if(... .val() != "null")
</code></pre>
<p>also </p>
<pre><code>if(... .val() != null)
</code></pre>
<p>as I spotted <code>null</code> value on <code>val()</code> while debugging when the list is empty or nothing is selected, but doesn't seem to work accurately.</p>
| jquery | [5] |
3,366,390 | 3,366,391 | Cookies being created but unable to echo them | <p>At the end of my registration script I set a cookie of 'loggedin' like so</p>
<blockquote>
<p>setcookie("loggedin", $username, time()+60*60*24*30 );</p>
</blockquote>
<p>And then just redirect back to the home page.</p>
<p>I'm trying to echo out the contents of that cookie. I can see it has been created when I go right click > page info > security > view cookies.</p>
<p>The name of the cookie is there, 'logged in' with contents set to as the username I register as. But when I do something like </p>
<blockquote>
<p>print_r ($_COOKIE);</p>
</blockquote>
<p>Nothing shows.</p>
<p>Doing a </p>
<blockquote>
<p>var_dump($_COOKIE);</p>
</blockquote>
<p>Gives</p>
<pre><code>array (size=0)
empty
</code></pre>
<p>Why might this behavior be occurring if I can see that the cookie is indeed there when I follow the previous steps mentioned? </p>
| php | [2] |
3,627,042 | 3,627,043 | Do I need an Alarm or a Service to perform a repetative task? | <p>I am developing a gps tracking for Android i want my application to start when the phone boots up and send gps coordonates from 10 in 10 minutes. </p>
<p>Do i need to use a service or an AlarmManager broadcast receiver can do the job ?</p>
| android | [4] |
3,649,210 | 3,649,211 | displays float into Text View | <p>I want to display a float into Text View</p>
| android | [4] |
1,501,828 | 1,501,829 | multiple matches in regex | <p>Hi I am trying to get the following javascript code to work. When I am typing a line containing all three names
fever, nightsweats and nocturia - I want an alert window to come on reminding me that those three in combination represent a dangerous sign. what am I doing wrong? thanks so much in advance!!! </p>
<pre><code><html>
<script type="text/javascript">
function show_prompt() {
var q = prompt("Please enter your name", "");
var myRegExp1 = ^ ( ? = . * fever)( ? = . * night sweats)( ? = . * nocturia);
var myRegExp2 = /fever,weight-loss,nocturia|weight-loss,fever,nocturia|nocturia,weight-loss,fever/
var string1 = q;
var string2 = q;
var matchPos1 = string1.search(myRegExp1);
var matchPos2 = string2.search(myRegExp2);
if (matchPos1 != -1) {
alert("bingo" + matchPos1);
}
if (matchPos2 != -1) {
alert("symptoms" + matchPos2);
}
}
</script>
<body>
<input type="button" onclick="show_prompt()" value="Show prompt box" />
</body>
</html>
</code></pre>
| javascript | [3] |
3,823,392 | 3,823,393 | easier way of doing both portrait and landscape in one xml file? in android | <p>I have nearly finished my app but still have to make sure landscape orientations is ok, is there any xml code that I can put in layout that will cover both portrait and landscape?</p>
<p>Many thx</p>
| android | [4] |
5,675,195 | 5,675,196 | What is an element vs. a selector in jQuery? | <p>I'm trying to understand the </p>
<blockquote>
<p>jQuery( element )</p>
</blockquote>
<p>part of the <a href="http://api.jquery.com/jQuery/#jQuery1" rel="nofollow">jQuery documentation</a>.</p>
<p>Q: Is this their example of what an element is:</p>
<pre><code>$(myForm.elements).hide();
</code></pre>
<p>It's the last example in the section.
What is an element vs. a selector?</p>
| jquery | [5] |
3,860,157 | 3,860,158 | I don't want $_SESSION to stop after a long period of time | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/514155/extending-session-timeout-in-php">Extending Session Timeout in PHP</a> </p>
</blockquote>
<p>I have php sessions where the problem I could have is that if for a long time I do not use the application, if I refresh the web browser, I suddenly get Notices on all my $_SESSION's. I want to know if it is possible that if I have not used a web page for a long time, that if I refresh a page, the $_SESSIONs remain intact?</p>
<p>I know the @ symbol can be used but is that only to not show the error message? I just don't want it to ever stop the session.</p>
<p>Thanks</p>
| php | [2] |
4,411,149 | 4,411,150 | Java application that uses a string method and length | <p>How do I design and implement a Java application that reads a string from the user and prints it one character per line from right to left?</p>
| java | [1] |
1,836,327 | 1,836,328 | Convert a negative number to a positive one in JavaScript | <p>Is there a math function in JavaScript that converts numbers to positive value?</p>
| javascript | [3] |
1,902,367 | 1,902,368 | keep adding value in php | <p>Initially,the $number = 0. After 1st time clicking Add button, the value becomes 10. When 2nd time clicking, the value is changed to 20. then 3rd time is 30, 4th time 40.</p>
<p>Below is my code, is there anyone know how to fix it? Thanks!</p>
<pre><code><?php
$number = 0;
if(isset($_POST['add'])){
$number = $number +10;
}
?>
<html>
<head>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<?php echo $number; ?>
<input type="submit" name="add" value="Add" />
</form>
</body>
</html>
</code></pre>
| php | [2] |
686,231 | 686,232 | Foreach loop in C++ equivalent of C# | <p>Can any body convert this code to C++ </p>
<pre><code>string[] strarr = {"ram","mohan","sita"};
foreach(string str in strarr) {
listbox.items.add(str);
}
</code></pre>
<p>Thanks in advance.</p>
| c++ | [6] |
852,742 | 852,743 | inline editing with jquery | <p>Are there any guidelines on doing 'inline' editing with jqeury?</p>
<p>I know I am not using the correct term here, but basically you click on a some text and dynamically the area changes to an editable input box with a submit button.</p>
<p>Is there any built in capabilities with jquery?</p>
| jquery | [5] |
4,126,604 | 4,126,605 | Audio controlling | <p>I want to develop a small audio controlling software. Only basic functionality like volume controlling, or / and bass controlling. </p>
| c++ | [6] |
5,673,541 | 5,673,542 | How do you make non-www. links contain www. in php? | <p>Im storing imdb.com links for each movie thats listed in the DB, and check for duplicates before a new movie is inserted. The problem is, some links are <a href="http://imdb.com/whatever" rel="nofollow">http://imdb.com/whatever</a> while others are http://<strong>www</strong>.imdb.com/whatever</p>
<p>What would be the best way to force www. into every link thats submitted? I realize I should be storing the url without http:// or <a href="http://www" rel="nofollow">http://www</a>. which would alleviate this problem all together.... but its too late to make that decision now.</p>
| php | [2] |
3,599,790 | 3,599,791 | How to abort window.print(); | <p>I have a page that uses <code>window.print();</code> which is already printed in the source.</p>
<p>But I want for a certain situation via a link trigger, maybe, to nullify/abort this command.
Basically telling the page not to launch print dialog when something is clicked to launch the page.
Maybe with <code>window.close();</code>, but no idea where to put, because the page has already printed <code>window.print();</code></p>
<p>Allow me to clarify:
page 'MYPAGE' has <code>window.print();</code> printed in the source.</p>
<ol>
<li>Link A opens a new page 'MYPAGE', and launches a Print dialog. Expected.</li>
<li>Link B wants to open the same page ('MYPAGE') for different usage, but do not want the Print dialog.</li>
</ol>
<p>Is it possible with jQuery? </p>
| jquery | [5] |
4,083,519 | 4,083,520 | How can i restore the messages in android | <p>I am able to getting all messages with its data, type ,address,status etc. but i am not able restore these messages.I tried the following way.it insert correctly but it show current date not date of message recieved or send.Please help me how can i restore messages.</p>
<pre><code> ContentValues values = new ContentValues();
values.put("address", "9878782944");
values.put("body", "foo bar");
values.put("date", "1322039220502");
values.put("type", "1");
values.put("status", "-1");
values.put("read", "1");
values.put("protocol", "0");
getContentResolver().insert(Uri.parse("content://sms"), values);
</code></pre>
| android | [4] |
4,565,665 | 4,565,666 | Parsing issues while parsing xml response android | <p>Xml response is like , but in one tag , the text is this:</p>
<pre><code><Description>
&lt;center&gt;&lt;strong&gt;&lt;span&gt;Warehouse / Building Maintenance&lt;/span&gt;&lt;/strong&gt;&lt;/center&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span&gt;I&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;mmediate openings available in the local Perris area for warehouse/building building maintenance positions. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Job Description:&lt;/strong&gt;&lt;br /&gt;
&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Associates will be responsible to define pieces of equipment that will paralyze operations if they fail, and plan whatever level of preventative maintenance necessary. &lt;br /&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt
......
similar text
......
</Description>
</code></pre>
<p>I can't able to parse it in proper way.</p>
<p>I tried using <code>Jsoup.parse((nodeValue))</code></p>
<p>and <code>Html.fromHtml(String)</code> also <code>URLEncoder.encode(String)</code> </p>
<p>but its returning simple <code>&</code> symbol thats it.</p>
<p>How to parse this type of response?</p>
| android | [4] |
1,384,785 | 1,384,786 | addContentView align at the screen's bottom android? | <p>i would like to ask something about the addContentView command.
I have created a custom view apparted from a LinearLayout(fill parent, wrap content) in vertical mode and some buttons..
My question is if it's possible to place my custom view at the bottom of the screen by using the addContentView command.</p>
<p>I now use addContentView but my custom view placed at the top of my screen.
I have already tried to change the height of custom's view in fill parent but then i have a full screen custom view.</p>
<p>Thanks in advance.</p>
| android | [4] |
883,026 | 883,027 | php eval function and performance | <p>Im creating a web app where I want all of the responses to the user stored in a language file for easy editing. So Im using eval() to manage dynamic messages lik so:</p>
<pre><code>$msg = 'Hello $user, your favorite color is $color';
$colors = array("red","green","blue","yellow");
$users = array("bob","craig","ted","dirty sanchez");
foreach($users as $key => $user){
$color = $colors[$key];
eval("\$newmsg = \"$msg\";");
echo $newmsg;
}
</code></pre>
<p>Im wondering if this is the best approach or if there is a better way?</p>
| php | [2] |
1,548,933 | 1,548,934 | Change text property of all items in form | <p>I have many buttons and labels on my c# form. I have a button that changes all butons' and labels' text properties (change language button). Do i have to write all items in click event of button or is there a method that scans all form control items and change their text properties.</p>
<p>There are many other controls that contains labels or buttons. For example a label is added to the control of a panel and when i iterate form controls, i can't reach this label. I want to change all items' text properties at one time.</p>
<p>Thank you.</p>
| c# | [0] |
2,254,264 | 2,254,265 | Unexpected mathematical output | <p>I am trying to count my eggs in an exercise in Learning Python the Hard Way. The formula for counting the eggs is:</p>
<pre><code>print (3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)
</code></pre>
<p>and the suggested answer is <code>7</code>.
I am getting <code>6.75</code> and have no idea why, I think I am putting it in correctly but I could be wrong. The way it is shown above is exactly how I have put it into the program. </p>
<p>Note: The book I am using uses the 2.6 version of Python where I am using the 3.1 version. This might be part of the confusion. Please help.</p>
<p>The URL for reference <a href="http://learnpythonthehardway.org/book/ex3.html" rel="nofollow">here</a>.</p>
| python | [7] |
2,422,952 | 2,422,953 | Does jQuery ship with SharePoint? | <p>Currently, we want to upgrade jQuery in our products, so I want to know if SharePoint use jquery in its js? It will help us to make decision about which jquery version we are going to use. I try to find jquery reference in SharePoint 2010, but I didn't find it. Does it mean there is no jQuery in SharePoint? </p>
<p>I found there is a js called "mQuery.js" in SharePoint 2013, the usage is quite similar with jQuery, and even most of the events'name are same. Why does Microsoft create a js for SharePoint 2013 instead of using jQuery directly? Because some functions in jQuery are unnecessary? Or for easy maintenance?<br>
Thanks in advance!</p>
| jquery | [5] |
2,004,701 | 2,004,702 | How to implement session handling in Java to be servlet container independent? | <p>AFAIK: <a href="http://www.freeopenbook.com/mysqlcookbook/mysqlckbk-CHP-19-SECT-4.html" rel="nofollow">Session handling is done by the servlet Container</a> (e.g. Tomcat, Glassfish...), i would prefer a solution which is servlet container independent, like php does it, implement some handler or filter and let the application deal with it. I have not found any sort of Information regarding self build session handling in Java.</p>
| java | [1] |
5,931,520 | 5,931,521 | How do I tell if an internet url points to a folder or a file using HttpWebRequest in C#? | <p>It should be well known that a internet URL can point to either a folder or a file.<br/>
A folder usually responds with a default page -- e.g. index.html.
A file responds with itself.</p>
<p>In either case, you don't know which one you are getting. Imagine for instance ("http://www.example.com/fileorfolder.html"). Is it an oddly named folder that is returning a default file or is it a file?</p>
<p>How do I tell?</p>
| c# | [0] |
3,770,851 | 3,770,852 | how to use Gridview with a variable number of Imagebuttons? | <p>I need some help for my app. I need a view containing an undefined number of ImageButtons based on a variable. That is, supposing the variable is set to 3, then 3 Imagebutton should be shown on the screen. Is there any way I can build this? I'm trying it using GridView, but it seems that you must provide a fixed number of images to fill <code>Integer[] mThumbIds</code>. Besides, I need the image to change on click event and this doesn't seem possible to accomplish using the GridView.</p>
<p>Another question related to the topic, is there any way I could use an Imagebutton with more than two states? I'd like the Image to display the effect of being establishing a connection when the user taps on it, something like those red stripes that come from the surface of the icon to the outside as if sending a wireless signal, I don't know if you know what I mean...</p>
| android | [4] |
5,430,050 | 5,430,051 | In C# is there a better way to write this boolean evaluation | <p>this seems really awkward ...does anybody have any suggestions for a cleaner approach?</p>
<pre><code> bool case1 = (dte.StartDateTime >= Date) && (dte.StartDateTime < Date.AddHours(_interval));
bool case2 = (dte.EndDateTime > Date) && (dte.EndDateTime < Date.AddHours(_interval));
bool case3 = (dte.StartDateTime <= Date) && (dte.EndDateTime >= Date.AddHours(_interval));
return ((dte.Association == Association) && (case1 | case2 | case3));
</code></pre>
<p>c#, .net 2.0</p>
| c# | [0] |
2,574,344 | 2,574,345 | To grab the data in a Table's TD and display it in a Input Text box | <p>I got a Table with some data inside it like this:<br/></p>
<pre><code><table>
<tr>
<td>
hello world! I am new to JQuery
</td>
</tr>
</table>
<input type="text" id="displayingText" value="">
</code></pre>
<p>I was trying to grab the data in the TD tag of the table and display the data
in the Inout Text field.<br/>
Is it possible to do it in JQuery in this case?</p>
| jquery | [5] |
3,216,681 | 3,216,682 | How to check which UIViewController is active | <p>I need to check which UIViewController is active so I have implemented some cases depending upon the result.</p>
<pre><code>[self.navigationController.visibleViewController className]
</code></pre>
<p>This always returns null. </p>
<p>I am checking with this statement: </p>
<pre><code>if([iDetailController isKindOfClass:[IDetailController class]])
</code></pre>
<p>but it fails, kindly help me if I am doing something wrong here.</p>
| iphone | [8] |
1,404,697 | 1,404,698 | Problem in detecting Internet Connection in Android | <p>I have created a Android application using Google Maps. Now I want to check whether an internet connection is available or not. I search in Google and finally I got solution through Stackoverflow:</p>
<pre><code>boolean HaveConnectedWifi = false;
boolean HaveConnectedMobile = false;
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] netInfo = cm.getAllNetworkInfo();
for (NetworkInfo ni : netInfo)
{
if (ni.getTypeName().equalsIgnoreCase("WIFI"))
if (ni.isConnected())
HaveConnectedWifi = true;
if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
if (ni.isConnected())
HaveConnectedMobile = true;
}
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</code></pre>
<p>I have written my online Google map code if it return true and offline code if it return false.</p>
<p>My problem is its showing an internet connection is available even when it is not. Where have I made a mistake?</p>
| android | [4] |
3,586,252 | 3,586,253 | jquery animation | <p>i dont know what is wrong with this code.. it will just don't work even if it has the same syntax with the other one..</p>
<pre><code>$(document).ready(function(){
$("#inner").animate({height:'200',top:'-100'},1000);
$("#inner").animate({width:'200',margin-left:'-100'},1000);
});
</code></pre>
<p>you can see the example <a href="http://jsfiddle.net/qmuYq/3/" rel="nofollow">here</a>..</p>
| jquery | [5] |
3,650,287 | 3,650,288 | Python: Random combination from two files | <p>New to python, bear with me. I have two text files, each has a word on a line (some funny words). I want to create a third file which has the random combination of those. with a space between them.</p>
<p>Example:</p>
<pre><code>File1:
Smile
Sad
Noob
Happy
...
File2:
Face
Apple
Orange
...
File3:
Smile Orange
Sad Apple
Noob Face
.....
</code></pre>
<p>How can I Python this?</p>
<p>Thanks!</p>
| python | [7] |
4,295,299 | 4,295,300 | how to convert the unopened webpage to pdf using java? | <p>I need to convert unopened web page to PDF. But i have a URL for that particular page. so how can i get that URL page as PDF file with out opened that page in java?</p>
<p>can any one know meet such scenario? </p>
| java | [1] |
1,217,442 | 1,217,443 | javascript function structure | <p>this is an exmaple.</p>
<pre><code>var x=5;
var y=x.multiplied(6); // return y=30;
</code></pre>
<p>how to create a function like <code>.multiplied()</code> function on js?</p>
<p>the function structure is like this</p>
<pre><code>var1.doSomething(var2);
</code></pre>
| javascript | [3] |
4,812,961 | 4,812,962 | How do you use localStorage in JavaScript? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2800238/javascript-html5-localstorage">Javascript + HTML5 localstorage</a> </p>
</blockquote>
<p>What is it for and how do you use it? Thanks.</p>
| javascript | [3] |
4,605,874 | 4,605,875 | Passing a PHP Value from a link | <p>I am new to PHP and learning. I'm trying to pass a value through a url link but it doesn't seem to work.</p>
<p>The link value I am passing is <a href="http://www.mysite.com/index.php?id=f" rel="nofollow">http://www.mysite.com/index.php?id=f</a></p>
<p>I want to run a js script if ID not F seen below but right now when I run it. It doesn't do anything:</p>
<pre><code><?php
$ShowDeskTop = $_GET['id'];
if (isset($ShowDeskTop)){
echo $ShowDeskTop;
if ($ShowDeskTop != "f"){
echo "ShowDeskTop Value is not F";
echo "<script type=\"text/javascript\">";
echo "if (screen.width<800)";
echo "{";
echo "window.location=\"../mobile/index.php\"";
echo "}";
echo "</script>";
};
};
?>
</code></pre>
<p>I know this is easy PHP 101 but I can't figure it out. I have tried everything from w3schools to other sites on Google for the answer and having no luck. Could someone please tell me what I am doing wrong?</p>
<p>Thank you!</p>
| php | [2] |
1,311,009 | 1,311,010 | default value of enumeration element in c#? | <pre><code> public enum DAYS { Monday=1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }
</code></pre>
<p>here suppose i want to override default value of enum element as like monday. here as i know that after giving 1 to monday 2 will be default value of tuesday and next one will have 3 or so on, </p>
<p>let change scenario</p>
<p>public enum days
{
monday = 4,
tuesday=8,
wednesday,
thursday,
friday=25,
saturday,
sunday
}</p>
<p>here what will be value of wednesday,thursday,and saturday,sunday ..?</p>
<p>question 2..</p>
<p>can we assign char and string type of value to the enum element...</p>
<p>question=3;</p>
<p>can we override enum as char or string type ?</p>
<p>like as
public enum name :string
{
first_name="nishant",
Last_name = "kumar"
}</p>
| c# | [0] |
478,349 | 478,350 | contruct dynamically a viewholder | <p>I am managing my view with a viewholder and i am trying to get different textview and image view result according <strong>if condition is verify (see snipset bellow )</strong>
The problem is that when I scroll and then returning to the top the result display become different from the origin . Bellow my snipset code I've been trying .I can't found where the problem come from . Can someone help me on it ?</p>
<pre><code> ViewHolder holder = (ViewHolder) view.getTag();
</code></pre>
<p>compteur=0;
if ("FRA".equalsIgnoreCase(source.trim())) {holder.flag = (ImageView) view.findViewById(R.id.flag);
holder.description = (TextView) view
.findViewById(R.id.description);</p>
<pre><code> holder.flag.setImageResource(R.drawable.flag_bnf);
holder.description
.setText("ReSeller");
holder.flag.setPadding(5, 5, 5, 5);
holder.description.setPadding(60, 5, 5, 5);
compteur = compteur + 25;
LayoutParams lp = (LayoutParams) holder.flag.getLayoutParams();
lp.setMargins(0, compteur, 0, 0);
holder.flag.setLayoutParams(lp);
LayoutParams lpdescription = (LayoutParams) holder.description
.getLayoutParams();
lpdescription.setMargins(0, compteur, 0, 0);
holder.description.setLayoutParams(lpdescription);
compteur += compteur;
holder.flag.setVisibility(View.VISIBLE);
holder.description.setVisibility(View.VISIBLE);
</code></pre>
| android | [4] |
4,446,638 | 4,446,639 | Copying stdin to stdout causes strange results | <p>I've got a super simple program. My intention is to copy standard input to standard output. Here's the source code:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace LALA
{
class LALA
{
static void Main()
{
int bufferSize = 40;
Console.OpenStandardInput().CopyTo(Console.OpenStandardOutput(), bufferSize);
}
}
}
</code></pre>
<p>If I set <code>bufferSize</code> to 40, then for any input I just see 'C o n', 'C o n s', or 'C o n s o l e' etc.
If I set <code>bufferSize</code> to 41, then everything is fine.</p>
<p>My question is am I doing something wrong, and by accident values above 41 work?</p>
<p>To clarify, this is the output when I type asd:</p>
<pre><code>c:\some_path>ConsoleApplication2.exe
asd
C o n
</code></pre>
| c# | [0] |
4,954,674 | 4,954,675 | What effect has a statement like 'var and do_something_with(var)' in Python? | <p>While looking for some answers in a package source code (<em>colander</em> to be specific) I stumbled upon a string that I cannot comprehend. Also my <em>PyCharm</em> frowns on it with 'statement seems to have no effect'.</p>
<p>Here's the code abstract:
</p>
<pre><code>...
for path in e.paths():
keyparts = []
msgs = []
for exc in path:
exc.msg and msgs.extend(exc.messages()) # <-- what is that?
keyname = exc._keyname()
keyname and keyparts.append(keyname) # <-- and that
errors['.'.join(keyparts)] = '; '.join(interpolate(msgs))
return errors
...
</code></pre>
<p>It seems to be extremely pythonic and I want to master it!</p>
<p>UPD. So, as I see it's not pythonic at all - readability is harmed for the sake of shorthand.</p>
| python | [7] |
4,680,084 | 4,680,085 | Setting "submit" | <p>At the top of my file I have</p>
<p>PHP Code:
<code>if (!ISSET ($_POST['submit']))</code>
which tests if the submit has been hit, if not displays the form....</p>
<p>What I'd like to be able to to is generate a link that would be processed directly by the php code that the form would normally be submitted to... (does that make sense ?)</p>
<p>so a generated link in the code looks like ..</p>
<p>PHP Code:
<code>echo '<a href="index.php?submit&s_type=' . $s_type . '&d_height=' . $d_height . '&j_ref=' . $j_ref . '&j_name=' . j_name . '">' . $j_ref . '</a>';</code>
The link generated looks like ..</p>
<p>HTML Code:</p>
<p><code>index.php?s_type=partk&d_height=3312&j_ref=AS0001&j_name=j_name</code></p>
<p>I have tried setting "submit" with links like</p>
<p>HTML Code:</p>
<p><code>index.php?submit=submit&s_type=partk&d_height=3312&j_ref=AS0001&j_name=j_name</code></p>
<p><code>index.php?submit&s_type=partk&d_height=3312&j_ref=AS0001&j_name=j_name</code></p>
<p>How do I create a link that sets "submit so it gets processed rather than going through the form ???</p>
| php | [2] |
5,483,473 | 5,483,474 | How does a C++ object access its member functions? | <p>How does a C++ object know where it's member function definitions are present? I am quite confused as the Object itself does not contain the function pointers.
<code>sizeof</code> on the Object proves this.
So how is the object to function mapping done by the Runtime environment? where is a class's member function-pointer table maintained? </p>
| c++ | [6] |
3,853,730 | 3,853,731 | Transfer session variables over php header redirect | <p>so I can't seem to figure out how to transfer session variables after a PHP header refresh, the code is below: essentially my workflow is User submits form to a php processing page that does stuff with the variables, after its done I want the form to redirect to the 'offers.php' keeping the session variables intact.</p>
<p>thanks for the help</p>
<p>php process page</p>
<pre><code> <?php
session_start();
session_write_close();
header('Location: http://www.examplesite.info/offers.php');
//Get Variables from form
$_SESSION['name'] = $_POST['name'];
$_SESSION['zipcode'] = $_POST['zip'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['insType'] = $_POST['insOption'];
?>
</code></pre>
<p>offers.php page</p>
<pre><code> <?php
session_start();
$name = $_SESSION['name'];
$email = $_SESSION['email'];
$zip = $_SESSION['zipcode'];
$ins = $_SESSION['insType'];
</code></pre>
<p>?></p>
| php | [2] |
1,990,105 | 1,990,106 | Trying to remove duplicate jquery scripts | <p>I've added this</p>
<pre><code><?php wp_enqueue_script("jquery"); ?>
</code></pre>
<p>before</p>
<pre><code><?php wp_head(); ?>
</code></pre>
<p>so that I can just use the wordpress included jquery script, and deleted the extra jquery script I've been loading, but when I go to Inspect Element in Chrome I get</p>
<p>submitForm.js:1Uncaught ReferenceError: $ is not defined</p>
<p>jquery.colorbox-min.js:4Uncaught ReferenceError: jquery is not defined</p>
<p>I'm guessing that I need to modify submitform.js and jquery.colorbox-min.js, I'm just not sure which way to go, if it helps here is the site, transaction-realty.com</p>
<p>Thanks</p>
| jquery | [5] |
5,042,998 | 5,042,999 | Change latin numbers to arabic number by javascript | <p>I have a clock with javascript i want change latin numbers this clock to arabic number by javascript, i tried as following code, but it doesn't work true. How can fix it?</p>
<p><strong>DEMO:</strong> <a href="http://jsfiddle.net/NdzHg/" rel="nofollow">http://jsfiddle.net/NdzHg/</a></p>
<pre><code><script type="text/javascript">
var interval = self.setInterval("clock()", 1000);
function clock() {
var rep = {
'0': '&#1776;',
'1': '&#1777;',
'2': '&#1778;',
'3': '&#1779;',
'4': '&#1780;',
'5': '&#1781;',
'6': '&#1782;',
'7': '&#1783;',
'8': '&#1784;',
'9': '&#1785;',
}
var date = new Date();
var hourOffset = 4;
date.setUTCHours(date.getUTCHours(), date.getUTCMinutes());
var time = date.getTime();
date.setUTCFullYear(date.getUTCFullYear(), 3, 21);
var dstStart = date.getTime();
date.setUTCFullYear(date.getUTCFullYear(), 9, 22);
var dstEnd = date.getTime();
if (time > dstStart && time < dstEnd){ hourOffset = 4;}
date.setUTCHours(date.getUTCHours() + hourOffset, date.getUTCMinutes() + 30);
var output = date.getUTCHours() + ":" + date.getUTCMinutes() + ":" + date.getUTCSeconds();
for (key in rep) {
str = output.split(key).join(rep[key]);
}
$("#clock").html(str);
}
</script>
<div id="clock"></div>
</code></pre>
| javascript | [3] |
2,820,758 | 2,820,759 | How to check and see an images extension using PHP? | <p>How can I check to see if the image is a PNG, GIF, TIFF and JPG and if so create the thumbnail and save it to the thumb file.</p>
<p>So far I can check and save for JPEG images.</p>
<p>Here is the code below.</p>
<pre><code><?php
//Name you want to save your file as
$save = 'members/3/images/thumbs/thumb-pic.jpg';
$file = 'members/3/images/pic.jpg';
echo "Creating file: $save";
list($width, $height) = getimagesize($file) ;
if ($width >= 180){
$modwidth = 180;
$modheight = ((180.0/$width) * $height);
} else {
$modwidth = $width;
$modheight = $height;
}
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
// Here we are saving the .jpg, you can make this gif or png if you want
//the file name is set above, and the quality is set to 100%
imagejpeg($tn, $save, 100) ;
?>
</code></pre>
| php | [2] |
3,687,916 | 3,687,917 | Cant retrieve dhcp info on Android 2.2 | <p>I have this code working on Android 4.0.3 on the Nexus One:</p>
<pre><code>WifiManager wifi = (WifiManager) getSystemService(WIFI_SERVICE);
DhcpInfo info = wifi.getDhcpInfo();
String s_gateway = String.valueOf(info.gateway);
String gatewayString = intToIp(Integer.parseInt(s_gateway));
Log.d("DHCP Info: ", s_gateway+"");
Log.d("DHCP Info: ", gatewayString+"");
</code></pre>
<p>It's return me gateway (PC + Connectify) correctly.</p>
<p>But the same code on Android 2.2 return 0.0.0.0. What is wrong? </p>
| android | [4] |
319,843 | 319,844 | DateTime conversion from Utc to Local in .NET 4.0 | <p>I have a function which among other things does a conversion from Utc to Local and vice-versa.
The problem is that when I run it on a PC with Win 7 it works OK, but when I run it on a PC with Vista the conversion goes wrong.</p>
<p>ex: My current time zone is +2 UTC</p>
<p>MyCurrentTime is set to 27.09.2012, 19:00 and the DateTimeKind is Unspecified.</p>
<pre><code>DateTime utcTime = DateTime.SpecifyKind(MyCurrentTime,DateTimeKind.Utc);
DateTime localTime = new DateTime();
localTime = utcTime.Date.ToLocalTime();
</code></pre>
<p>The output on Win 7 is 27.09.2012, 17:00</p>
<p>The output on Vista is 27.09.2012, 04:00</p>
<p>Any ideas why this happens?</p>
<p>Thanks.</p>
| c# | [0] |
1,405,752 | 1,405,753 | iPhone CAAnimations playing serially | <p>Is it possible to define all CAAnimations at start and play them one after another serially without using delegates, like what we do in CAAnimationGroup, where in animations are played simultaneously. Instead I just want them to play serially.</p>
| iphone | [8] |
3,168,372 | 3,168,373 | Pass a jQuery variable to a string | <p>I have a jQuery object called <code>window.offset</code>. </p>
<p>This object has another object called <code>search</code>. </p>
<p>It has two values, <code>top</code> & <code>left</code>.</p>
<p>Eg: </p>
<pre><code>window.offset.search = {top:200, left:150}
</code></pre>
<p>I want to pass this 'search' object as a variable called 'id'. </p>
<p>How to pass this variable to the <code>window.offset</code> object and get the <code>top</code> & <code>left</code> value.</p>
<p>I tried as this. But it doesn't work.</p>
<pre><code>var offset = 'window.offset.'+id
console.log(offset.left); //undefined
</code></pre>
| jquery | [5] |
1,346,621 | 1,346,622 | if image exists show image else show different image + image path | <pre><code><?php $img = shellImage($data[$y]->kunena_avatar_rows[$z]->avatar, 'noresize'); ?>
<?php if ($img->exist) : ?>
<?php echo $img->draw(); ?>
<?php else: ?>
<img src="media/avatars/resized/size200/nophoto.jpg">
<?php endif; ?>
</code></pre>
<p>Trying to figure out how to add a path to the image.</p>
<p>The value in the database for the image is like this users/avatar.jpg and the full path for the image would be <code>media/avatars/resized/size200/avatar.jpg</code></p>
| php | [2] |
1,930,531 | 1,930,532 | Python : split string by ' and - | <p>How do split string by apostrophe <code>'</code> and <code>-</code> ?</p>
<p>For example, given <code>string = "pete - he's a boy"</code></p>
| python | [7] |
2,871,057 | 2,871,058 | jQuery.map(....).concat is not a function | <p>Why would the following jquery code sometimes throw the error "concat is not a function":</p>
<pre><code>var myArray = $('div.foo')
.filter(function() { return $(this).is('.something'); })
.map(function() {
return [['a', 'b', $(this).val()]];
});
return myArray.concat(anotherArray);
</code></pre>
| javascript | [3] |
1,767,977 | 1,767,978 | draw editview / textview on fingertouch in android | <p>I am newbie in android,in my app i required draw textview/editview on finger touch where user is able to type in that.I searched a lot but find nothing relevant.I found links to draw editview/text but not on fingertouch.so please suggest me, Its urgent
help me</p>
| android | [4] |
4,163,706 | 4,163,707 | How to remove HTTPS to HTTP Security Alert message in .Net | <p>How to disable or block that Security Alert so that when any user access my Secured Page he
will not get Security Alert Dialog. Any help will be appreciated and thank
you in advance. </p>
<p>Thanks
Narendra Singh</p>
| asp.net | [9] |
4,728,277 | 4,728,278 | How to display development credits at the beginning of application? | <p>When the application is opened i would like to display credits by to the user like maybe a screen with the company's logo and some other stuff. How do i go about doing this?</p>
| android | [4] |
1,129,910 | 1,129,911 | Javascript Opera + Safari issue | <p>For some reason this page won't work in Opera + Safari <a href="http://dev.reggi.com/clients/mike2/" rel="nofollow">http://dev.reggi.com/clients/mike2/</a></p>
<p>this is the main code I wrote that I believe is failing:</p>
<pre><code>/*this script finds the multiples of the box_width and makes that the with of the container so the grid can be centred*/
/*sets variables*/
var box_width= 250 + 5 + 5 + 5 + 5;
/*loads the width when page starts*/
$(document).ready(function(){
var w= $(window).width();
w-= (w-10) % box_width;
if (w<box_width) w= box_width;
$('.variable_window_width').width(w);
});
/*loads the new with onpage resize*/
$(window).bind('load resize', resizeFrame);
function resizeFrame() {
var w= $(window).width();
w-=((w-10) % box_width);
if (w<box_width) w= box_width;
$('.variable_window_width').width(w);
};
$(function(){
$("#grid div").corner("4px");
});
</code></pre>
| javascript | [3] |
4,857,162 | 4,857,163 | how to read a file from a Jar file located on remote server | <p>I want to read and copy file from jar file(for eg. application.xml from EAR )located on remote server to local machine. when i search on net for this, i found java.util.jar.JarFile API. This API read jar only from local machine as it takes only string as input and not URL for jar location in constructor. I know org.apache.commons.net.ftp.FTPClient API.This API can copy any file or even jar from remote server to local machine. But my requirement is to copy only single file from jar located on remote server.</p>
<p>Please help me in this regard .</p>
<p>Thanks
Sameer</p>
| java | [1] |
1,100,328 | 1,100,329 | Display byte[] to ImageView in Android | <p>Is it possible to do this? I'm reading an XML file that has the Base64 string of an image. I'm planning to use Base64.decode to have the byte array of the image string. I'm stuck though on how to use it in an ImageView. Do i have to create a 'drawable' class first then set it to ImageView's src property?</p>
<p>Thanks!</p>
| android | [4] |
275,006 | 275,007 | How to set maximum characters per line for text view in android | <p>Hiii all,
this may be a possible duplicate but I couldn't find solution for my problem.I need to limit the number of characters per line when displaying on the textview and display the remaining characters in the next line.I cannot set ems value and I also tried setting maxLength attribute in xml but it is not displaying the remaining characters,Can any one tell me how can I do it.</p>
| android | [4] |
2,809,001 | 2,809,002 | execute a code after the page is loaded completely or delay the execution of the code | <pre><code>$(document).ready(function() {
if($('#upcomeEvent').length > 0)
$('#upcomeEvent').insertAfter('#eventBanner');
});
</code></pre>
<blockquote>
<p>execute a code after the page is loaded completely or delay the execution of the code</p>
<p>I need to execute <code>$('#upcomeEvent').insertAfter('#eventBanner');</code> after the page is loaded completely
Another requirement is to delay the execution of <code>$('#upcomeEvent').insertAfter('#eventBanner');</code> by, say around 10 seconds.
Thanks</p>
</blockquote>
| jquery | [5] |
1,917,112 | 1,917,113 | Can i change the Cursor size in android edit text field? | <p>I want to change the width and color of the cursor that blinks in an Android EditText field. Is that possible?</p>
| android | [4] |
4,084,468 | 4,084,469 | C# Application Path how to get it to work for websites | <p>Here is my question, and I have searched this stackoverflow but cannot find the correct solution. </p>
<p>I have an website, that is stored in (locally on my machine)</p>
<p>C:\websites\Website1 </p>
<p>in the same folder I have </p>
<p>C:\websites\Website1\xmldoc.xml</p>
<p>I want to be able for the program to find and access the C:\websites\Website1\xmldoc.xml. I have hard coded the C:\websites\Website1\xmldoc.xml location into my website but I am trying to figure out if there is a better way. I have tried
Application.StartupPath but it doesn't work. </p>
| c# | [0] |
2,681,740 | 2,681,741 | Encoding of $_SERVER variables like $_SERVER['REQUEST_URI'] | <p>I need to do some string operations on <code>$_SERVER</code> value especially <code>$_SERVER['REQUEST_URI']</code></p>
<p>How PHP encodes such strings? Should I use <code>mb_*</code> family functions?</p>
<p>To understand better my question, let's say I have a page on my webserver called like this:</p>
<pre><code>ããã.php
</code></pre>
<p>And I need to get the second char:</p>
<pre><code>echo mb_substr($_SERVER['REQUEST_URI'],1,1);
</code></pre>
| php | [2] |
3,223,731 | 3,223,732 | Calling a class from another class OOP | <p>I currently have a class called Connect with the following code:</p>
<pre><code>class Connect
{
public $sqlHost='host';
public $sqlUser='user';
public $sqlPass='pass';
public $sqlDB='db';
public $db;
public function __construct() {
$this->db = new mysqli($this->sqlHost, $this->sqlUser, $this->sqlPass, $this>sqlDB);
}
}
?>
</code></pre>
<p>I also have a class called TODO and I was wondering, how could I go about calling $db located in the Connect class from the TODO class?</p>
| php | [2] |
5,987,607 | 5,987,608 | How to embed JavaScript in PHP within div (in an include file)? | <p>I'm trying to get an image to display in a div depending on the URL of the page. This div is in an include file that gets used for all pages of the website. What I want is if it's the homepage (with or without index.php), is for the div to show the image. What I've pieced together so far is:</p>
<pre><code><script type="text/javascript">
var d = location.href
if (d="website.com" || "website.com/index.php")
{
<img src="/images/DSLogo2.jpg" />;
}
</script>
</code></pre>
<p>I'm not sure if this is correct, or even the best way to go about it. Any help is very greatly appreciated, as I am still learning more and more each day.</p>
| javascript | [3] |
4,134,580 | 4,134,581 | Is there a C#-like lambda syntax in JavaScript? | <p>Is there a framework or post processor for JavaScript that supports lambda syntax like in C#?</p>
<p>Function definitions in CoffeeScript seem to look like lambdas but I have not looked into them thoroughly.</p>
<p>Can anyone tell me, <em>can I use lambda syntax in JavaScript?</em></p>
| javascript | [3] |
2,158,315 | 2,158,316 | Function printing correct Output and None | <p>I have defined this function that takes a word and a string of required letters and that returns True if the word uses all the required letters at least once. When I run this, it gives me the correct output but I do not understand why it also outputs 'None'.</p>
<p>Here is my code:</p>
<pre><code> def uses_all(word, allused):
boolean = False
for e in allused:
if e in word:
boolean = True
else:
boolean = False
break
print boolean
print uses_all('facebook', 'd')
</code></pre>
<p>Output:</p>
<pre><code>False
None
</code></pre>
<p>Comments on where I have gone wrong will be appreciated. </p>
| python | [7] |
4,490,806 | 4,490,807 | How do I add leading zeroes to String.Format parameters? | <p>I have the following code:</p>
<pre class="lang-cs prettyprint-override"><code>string textTransDate = String.Format("{0}-{1}-{2} {3}:{4}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute);
</code></pre>
<p>I want to add leading zeroes to the month and day parameters if they are less than 10, how would I accomplish this?</p>
| c# | [0] |
3,061,171 | 3,061,172 | question on string in c++ | <p>does this work on string in c++?</p>
<pre><code>string s="lomi";
cout<<s<<endl;
</code></pre>
<p>what is bad in this code?</p>
<pre><code>#include <iostream>
#include <cstring>
using namespace std;
int main(){
string s=string("lomi");
for (int i=0;i<s.length();i++){
s[i]= s[i]+3;
}
std::cout<<s<<std::endl;
return 0;
}
</code></pre>
<p>?</p>
| c++ | [6] |
471,080 | 471,081 | Using of Toast with thread in android | <pre><code>progressDialog = ProgressDialog.show(GetResponse.this, "", "Loading...");
new Thread()
{
public void run()
{
try
{
// inside i have written code for making connection to the server using SSL connection.
}catch (Exception e)
{
progressDialog.dismiss();
exception(e.getMessage())
}.start();
}
private void exception(String msg)
{
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
this.finish();
Intent i = new Intent(getBaseContext(), LoginPage.class);
startActivity(i);
}
</code></pre>
<p>my LoginPage.java is previous activity.
If the connection is successfull it goes to the next activity ot doesnt give any error,
But if der is any prob with connection then i want progress bar should be stopped and go back to the LoginPage activity and also i want the error msg to be displayed.
From the above im getting some error.. Please help me out on this</p>
| android | [4] |
389,984 | 389,985 | Cannot save a url as a value in a PropertiesConfiguration object | <p>This one has me stumped.</p>
<p>I have something like:</p>
<pre><code>PropertiesConfiguration pc = new PropertiesConfiguration();
pc.setProperty("url", "jdbc:postgres://localhost:5432/somedb");
pc.setBasePath(".");
pc.setFileName("my.properties");
</code></pre>
<p>I have this code in a jar that was built on Linux. When it gets run on a Windows box, then the file that gets saved comes out like:</p>
<pre><code>url = jdbc:postgres:\/\/localhost:5432/somedb.
</code></pre>
<p>This file is going to get consumed by some python code, and it's not at all happy with that URL.</p>
<p>I've searched and searched, but for the life of me, I don't understand why PC would be escaping a forward slash.</p>
<p>Any clues?</p>
| java | [1] |
2,206,337 | 2,206,338 | what next after 'dive into python' | <p>I've been meaning to learn another language than java. So I started to poke around with python. I've gone over 'dive into python' so I have a decent knowledge about python now. </p>
<p>where do you suggest I go from here? I dont want to go through another advanced book again and would like to use the python knowledge towards building 'something'. </p>
<p>I've heard that python is good for web crawling, however, I did not see that in dive into python. Can the community suggest how to use my pythong knowledge towards web crawlers or spiders?</p>
| python | [7] |
545,687 | 545,688 | window.setTimeout Not Firing | <p>I'm sure I'll hate myself when I find out what the issue is, but I can't for the life of me figure out why this won't work. I'm using setTimeout elsewhere in the site just like this and it is working fine.</p>
<pre><code><input type='button' value='Submit Form' onclick='ValidateForm()'/>
var submitFinalTimeout;
function ValidateForm() {
//Performing a number of validations which may return false;
//I know that the following if condition evaluates as true. But just for giggles I tried moving it outside of the if and it still never fires.
if (types.indexOf("K2") != -1) {
submitFinalTimeout = window.setTimeout(function () { alert("Timeout set"); }, 2000);
validateK2();
return true;
}
return true;
}
</code></pre>
<p>When I say validate, I mean I am alerting the use if an issue is found and returning false to prevent the validation from continuing. The return values of true or false do not affect whether or not page posts.</p>
<p>I've tried also removing everything else inside of the curly braces to ensure no other code was conflicting with it. I have literally tried removing ALL other code withing the ValidateForm function except for the setTimeout and it still never fires.</p>
<p>I saw a similar post where the issue was some other javascript error on the page preventing it from working. But neither my developer console in Chrome nor firebug show any errors or any kind on the page. Just a few warnings about interpreting an image.</p>
| javascript | [3] |
3,769,215 | 3,769,216 | Get time remaining of a setInterval | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3144711/javascript-find-the-time-left-in-a-settimeout">Javascript: find the time left in a setTimeout()?</a> </p>
</blockquote>
<p>For example if I have:</p>
<pre><code><script>
var timer = setInterval(function(){ coolfunction() }, 10000);
</script>
</code></pre>
<p>Is there a way to check the time remaining to find out how many milliseconds are left until coolfunction() is run?</p>
| javascript | [3] |
302,055 | 302,056 | How can I order a list of Points so that no lines drawn intersect? | <p>I am getting a List of Points from the user clicking on the screen.</p>
<p>And I want to draw a polygon based on this points. The problem is that the user might not be clicking in the right order (<em>no intersecting segments</em>) to form a correct polygon, therefor I'm looking for a code snippet which would sort that List and arrange the points in the right order to form a good polygon...</p>
<p>Thanks!</p>
<p>picture = BAD POLY!</p>
<p><img src="http://i.stack.imgur.com/drqjI.jpg" alt="enter image description here"></p>
<p>-</p>
<p>picture = GOOD POLY!</p>
<p><img src="http://i.stack.imgur.com/XrNRu.jpg" alt="enter image description here"></p>
| c# | [0] |
3,755,602 | 3,755,603 | Keep mobile Data always on function | <p>If you go through HTC phones, they have an option for mobile data network setting to "Always enable mobile data". As I understand, it helps to maintain a TCP connection. I want to implement the same functionality, how to implement it ?
as I think, need to use wakelock?</p>
| android | [4] |
5,204,760 | 5,204,761 | Create a file in filesystem using java | <p>I am creating an <code>xml</code> file using document object which goes something like this.</p>
<pre><code>DOMSource ds=new DOMSource(doc);
PrintStream ps=new PrintStream("file.xml");
StreamResult sr=new StreamResult(ps);
javax.xml.Transformer.transform(ds,sr);
</code></pre>
<p>The file creation is fine and it is getting created in my local directory. </p>
<p>What I want is this file to be created/uploaded into a file-system (<code>fs:///myresources/myproject/</code>) using java.</p>
<p>How to do it?</p>
| java | [1] |
1,428,329 | 1,428,330 | Returning the first number of a parameter in Python | <p>Edit: Thank you guys for your help, but I had trouble applying it to my actual problem. I was trying to get a general idea of how to do a similar problem to one I was assigned, but I haven't been able to figure it out.</p>
<p>So, my functions is going to take two parameters, both of which are numbers. If the first parameter is equal to 0, I have to set it to the first number that occurs in the second parameter.</p>
<p>so like if</p>
<blockquote>
<blockquote>
<blockquote>
<p>num_call(0, 23)</p>
</blockquote>
</blockquote>
</blockquote>
<p>I would have to return a 2.</p>
<p>Any tips on how to do this? Or would the way you guys have been describing work?</p>
<p>Thanks so much</p>
| python | [7] |
2,547,684 | 2,547,685 | How to make Android app start on pressing on switch | <p>I want to have a situation where an android phone is actually running, so that it might be able receive calls and pressing the on switch, which activates the screen to use apps, actually starts an app running with no further user intervention.</p>
<p>I have seen a similar question which was answered starting with the following advice.
Use BroadcastReceiver that receives Intent of action BOOT_COMPLETED.</p>
<p>However, this appears to be detecting the BOOTING of the phone. In my case a phone is booted and running. I want the app to run because the on switch activates it without any further input. I don't want it to be the on switch and then activating the app from the screen.</p>
| android | [4] |
3,592,211 | 3,592,212 | Java Image Import Display | <p>I am having trouble understanding if I am reading my images in correctly. My code with a random Bill Gates Picture:</p>
<pre><code>import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class ReadingImage {
public static void main(String[] args) {
//readImage("billgates.jpg");
BufferedImage img = null;
try {
img = ImageIO.read(new File("billgates.jpg"));
} catch (IOException e) {
}
}
}
</code></pre>
<p>The problem is that a java icon pops up on the doc(mac user) but no window or anything displays it. This is my first time importing a java image file so bare with me. </p>
<p>Can you save images into arrays and display them on demand, ie is there a function for displaying? I don't recall the above code actually requesting the image to be displayed.</p>
<p>Thanks</p>
| java | [1] |
3,510,787 | 3,510,788 | How to get a list of top 5 links from a google search? | <p>I need a list of top 5 links obtained from a user query about a partiuclar subject.Is there any way by which I can do this ? How can I fetch top 5 links of a google search ?
Is there any API available for it ?Some demo examples will be helpful. </p>
<p>Thanks in advance.</p>
| java | [1] |
589,862 | 589,863 | Boring javascript calling: why a non-desirable js function has been called? | <p>I'm building an aspx page with a button that calls another page in a different window, through javascript:</p>
<pre><code>function assuntos() {
window.open("pg_assuntos.aspx", "List", "scrollbars=no,resizable=no,width=600,height=480");
}
</code></pre>
<p>in the page's Onload event, I have the code:</p>
<pre><code>bot_cadastrar.Attributes.Add("onclick", "assuntos()")
</code></pre>
<p>When I click the button, all gonna be right. But everytime I update a fild that execute a query, the "onclick" event seems to be raised or function seems to be executed, because the window is opened. I also have another code in the onload event for starting a stopwatch javascript function:</p>
<p>VB CODE:</p>
<pre><code>Dim script = "<script language = javascript>" & _
"window.setTimeout('ShowTime()', 1000);</script>"
ClientScript.RegisterStartupScript(Me.GetType, "iniciar", script)
</code></pre>
<p>ASPX CODE (javascript):</p>
<pre><code>function ShowTime() {
var dt = new Date();
var dif = dt - dtIn;
var tim = new Date();
tim.setHours(0, 0, 0, dif);
document.getElementById("<%= cmp_hora.ClientID %>").value = dt.toLocaleTimeString();
document.getElementById("<%= cmp_tempo.ClientID %>").value = tim.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000);
}
</code></pre>
<p>Why the function is starting for itself? I'm fed up whith these popups!</p>
| asp.net | [9] |
5,708,273 | 5,708,274 | Get pixel value from an Android display? | <p>I'm not even concerned with the camera per se. I want at the closest thing to the display screen. Meaning: it could even be the desktop the user is looking at, completw w/ the background and the icons she moves back and forth. </p>
<p>Let's say, at time t=1 sec, the app goes to pixel (78, 300) on that display and obtains its value. What may be at (78, 300) could be a portion of the icon or some speck of tree leaf on the photo being used as desktop background.</p>
<p>I'm familiar with BitmapFactory.decodeFile() for getting at the pixel contents of a file. But what about the display?</p>
<p>Thank you for any assistance.</p>
| android | [4] |
3,496,847 | 3,496,848 | Adding Map to collection of maps | <p>I have collection of maps.</p>
<pre><code>Collection<Map<String,Object>> xyz = (Collection<Map<String,Object>>) someMethod();
xyz.add(new HashMap<>());
</code></pre>
<p>If I try to add another map to this collection it gives me run time exception as</p>
<p>UnsupportedOperation.</p>
<p>What can be done?</p>
| java | [1] |
5,518,474 | 5,518,475 | jquery ajax call with xml query not working. Need advice | <p>I've written some code that is supposed to load an xml file via AJAX, parse a couple variables, and alert them to the screen. It isn't working... Can any guru's out there tell me what I've done wrong?? </p>
<pre><code><html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.get("http://www.greenshipping.com/api/requestAccountSummary.php?UID=7ef364b35ca79b0497f391da7f6776ab", {}, function(xml) {
$('result', xml).each(function(i) {
num_shipments = $(this).find('num_shipments_offset').text();
lbs_carbon = $(this).find('total_lbs_carbon_offset').text();
alert("num_shipments:"+num_shipments+" lbs_carbon:"+lbs_carbon);
});
});
});
</script>
</head>
<body>
</body>
</html>
</code></pre>
| jquery | [5] |
5,446,022 | 5,446,023 | How can change tabspecification text into another tab activity? | <p>I am working in android. I have used tab host and tab widget. i have 4 activity to add as view.</p>
<p>this is my program:</p>
<p>public class TabDemo extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);</p>
<pre><code> TabHost tabHost=getTabHost();
// no need to call TabHost.Setup()
//First Tab
TabSpec spec1=tabHost.newTabSpec("Tab 1");
spec1.setIndicator("Tab 1",getResources().getDrawable(R.drawable.sun));
Intent in1=new Intent(this, Act1.class);
spec1.setContent(in1);
TabSpec spec2=tabHost.newTabSpec("Tab 2");
spec2.setIndicator("Tab 2",getResources().getDrawable(R.drawable.chart));
Intent in2=new Intent(this,Act2.class);
spec2.setContent(in2);
tabHost.addTab(spec2);
tabHost.addTab(spec3);
}
</code></pre>
<p>}</p>
<p>Now in second Activity i want to change this text "Check-In" on a button click. </p>
<p>spec2.setIndicator("Check-In",getResources().getDrawable(R.drawable.chart));</p>
<p>so please tell me how can i do this. means how can i change setIndicator text of super class in its child class.</p>
<p>If any other query related to my question please feel free to ask me anytime.</p>
<p>Thank you in advance.</p>
| android | [4] |
5,441,107 | 5,441,108 | Android and onSaveInstance and Restore | <p>I have a big problem. I have a activity where I have two imageViews. In onCreate I have List pictures where I have 10 pictures. Every time when I start this activity both imageViews get random picture from List and shows them. For example: When I start activity I can see car and pencil and when I start this activity once again I get elephant and book.
Now this is my problem. When I start activity and block my phone and after that unlock I get other pictures. I think that onCreate is called again. I create </p>
<pre><code>@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
}
public void onRestoreInstanceState(Bundle savedInstanceState) {
if (savedInstanceState != null) {
pictureGameLeft.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair().getImageLeft()));
pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair().getImageRight()));
}
}
</code></pre>
<p>pictureGameLeft and Right that is last images which is shows.
I write them after onCreate method.
How I can save last seen picture that if I lock and unlock phone I get the same pictures. Maybe onPause or onStop need called? </p>
<p>edit:
now: </p>
<pre><code>if (savedInstanceState == null) {
game = new Game();
game.initGame();
addElements(result);
game.getCurrentLevel().nextPair();
pictureGameLeft.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
.getImageLeft()));
pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
.getImageRight()));
mRedrawHandler.sleep(1000);
}
else {
pictureGameLeft.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair(
.getImageLeft()));
pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
.getImageRight()));
}
</code></pre>
<p>but I get NullPointerException.</p>
| android | [4] |
446,295 | 446,296 | jQuery each() non-blocking? | <p>Is jQuery's each() function non-blocking?</p>
<p>In the below example, I expect "test in each" to be logged first, but in each test "test out of each" is logged first.</p>
<p>So this is causing the loop to run up to the body (sometimes the document) element before returning an error.</p>
<p>I'm just trying to get a common parent to wrap or if the two elements (firstp and lastp) are the siblings, then wrap those.</p>
<p>But, I'm mostly curious about the performance of the each() function and whether it is non-blocking. </p>
<pre><code>while(firstp[0] !== lastp[0]){
//If parents are siblings, this will do for wrapping.
var isS = false;
firstp.siblings().each( function(index, el){
console.log("test in each");
if(jQuery(el)[0] === lastp[0]){
isS = true;
return true;
}
});
console.log("test out of each");
if(isS === true){ break; }
firstp = firstp.parent();
lastp = lastp.parent();
}
</code></pre>
<p>EDIT:</p>
<p>Sorry guys. This was a false alarm. Paul is correct. My HTML actually had two elements that was matching for firstp. I didn't realize this, so the first one did not have a sibling, causing the error. I was looking at the second element the whole time.</p>
<p>But, I did learn something in the process, so thanks for taking the time to answer.</p>
| jquery | [5] |
350,948 | 350,949 | PHP Mailing Code sending mail to spam/quarantine | <p>The title explains itself. It is a website for in-house employees to buy and sell from each other. Its based solely around Microsoft Outlook emailing addresses. All the emails are supposed to be sent from the seller's email as they post items. Except when I enter <code><php phpinfo(); ?></code> on the action php page it tells me that the sendmail_from attribute thing is sending from a bogus email on the server. It seems to be the automatic email for the php script to send from. This may be why the emails are getting sent to spam, because the email is not valid. Also, I read online about having full and valid headers but most headers seem optional and i cant find anywhere that explains optimal headers. My mailing code: </p>
<pre><code>//send approval email to the approver
$from = isset($_POST['from'])? $_POST['from']:1;
$message = isset($_POST['message'])? $_POST['message']:1;
$message = $message . '<a href="http://dev-corkboard/newapproval.php?id='
.$result[0][0].'"> Click here to approve website post.</a>';
// In case any of our lines are larger than 70 characters, we should use
// wordwrap()
$message = wordwrap($message, 70);
$to = 'clehane@eatonvance.com';
$replyto = isset($_POST['replyto'])? $_POST['replyto']:1;
$subject = isset($_POST['subject'])? $_POST['subject']:1;
$headers = "MIME-Version: 1.0" . "\r\n" . 'From: "'.$from.'"' . "\r\n" .
'Reply-To: "'.$replyto.'"' . "\r\n" .
'Content-Type:text/html;charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
//test message for email
}
header ("location: newindex.php"); `
</code></pre>
<p>Any ideas?</p>
| php | [2] |
111,286 | 111,287 | How to update system clipboard when Toolkit.getDefaultToolkit().getSystemSelection() returns null. | <p>The following code:</p>
<pre><code>Toolkit.getDefaultToolkit().getSystemSelection().setContents(
new StringSelection(a), null);
</code></pre>
<p>returns <code>null</code> because it is not supported on my Computer. But, I am wondering how I set my Computers selection if it does not support this. There has to be another way obviously. But how?</p>
| java | [1] |
6,033,045 | 6,033,046 | How to tell if a class is descended from another class | <p>I have a function that accepts a class (not an instance) and, depending on whether or not it's a specific class <em>or a subclass of that</em>, I need to pass it in to one of two other (third-party) factory functions.</p>
<p>(To forestall any objections, I'm aware this is not very Pythonic, but I'm dependent on what the third-party library accepts.)</p>
<p><code>issubclass</code> only works for instances, not class objects themselves. I suppose I could instantiate the class, do <code>issubclass</code> and throw away the instance, but that seems a bit wasteful.</p>
<p>Here's what I'm doing at the moment, relying on the built-in <strong>mro</strong> attribute to tell if a certain class is in the list of ancestors of my class. Is this safe, and is there any better way of doing it?</p>
<pre><code>if GenericClass in myclass.__mro__:
result = generic_factory(myclass)
else:
result = other_factory(myclass)
</code></pre>
| python | [7] |
4,090,998 | 4,090,999 | Cant read my cookie from the root of my site | <p>I successfully set a cookie with javascript on one page like this:
..
I went to this article and took the code from it:
<strong>UPDATE :</strong> </p>
<pre><code>**http://techpatterns.com/downloads/javascript_cookies.php**
</code></pre>
<p>The code works.. but I can set and read my cookie from one page only, when I go to the document root , the cookie isnt available there anymore..</p>
<p>I set my cookie when i am in a subfolder of my directory</p>
<p>I am also trying to set it this way:</p>
<pre><code> document.cookie =
"landing_page_ref=" + encodeURIComponent("FBLND1") +
"; path=/; " ;
</code></pre>
<p>but i dont know where i am wrong</p>
| javascript | [3] |
2,993,935 | 2,993,936 | Instead of calling the same function twice | <p>I'm first checking if a function returns a valid result, and then, if the result is valid, I need to use that in my script. But instead of checking once, and then coming back again to the function for its result, is there a way to do it all in one go? Here, <code>$strVal</code> is the variable I need to use in an querystring later.</p>
<pre><code>$conn = connect();
encrypt('HIs#$%.-','x');
decrypt('6507A27EB0521AFA0776F1A4F8033041','x');
//If the function returns a valid result,
if (encrypt('Tom','x'))
{
echo 'Success'.$strVal;//I'll use this in a querystring later.
}
else
{
echo 'An error occurred';
}
//Encrypt string
function encrypt($strToEncrypt,$salt)
{
global $conn;
$elements = $conn->prepare("select hex(aes_encrypt(:what,:salt)) as encValue");
$elements->bindParam(':what', $strToEncrypt);
$elements->bindParam(':salt', $salt);
$elements->execute();
$row = $elements->fetch();
$strVal = $row['encValue'];
if(is_null($strVal)){return false;}else{return $strVal;}
}
//Decrypt string
function decrypt($strToDecrypt,$salt)
{
global $conn;
$elements = $conn->prepare("select aes_decrypt(unhex(:what),:salt) as decValue");
$elements->bindParam(':what', $strToDecrypt);
$elements->bindParam(':salt', $salt);
$elements->execute();
$row = $elements->fetch();
if(is_null($row['decValue']))
{echo "Null";}else{echo $row['decValue'];}
}
</code></pre>
| php | [2] |
4,740,231 | 4,740,232 | add and remove class works with blank link but not with page link | <p>I am really noob on jquery but I tried almost more than my best to solved it out by reading old posts created by valuable users of Stackoverflow.
My problem is I try to add class onclick event. Its working only if I set the hyperlink link to blank(#) <code><a href="#">test</a></code> but if i set to hyperlinks status to <code><a href="product.php"</code> then it removes and adds class for a while and after the current page is open, it automatically removes the active class and set it as previous. :(
My js code..</p>
<pre><code>$('ul#menu li a').click(function() {
$('ul#menu li a').removeClass('active');
$(this).toggleClass('active');
});
</code></pre>
| jquery | [5] |
4,460,990 | 4,460,991 | does explode get executed more than once in a foreach? | <pre><code>$array='hello hello2';
foreach(explode(' ',$array) as $v)
echo $v;
</code></pre>
<p>How many times does explode get executed?</p>
<p>And is it better that to use another var like:</p>
<pre><code> $exploded = explode(...);
foreach($exploded as $v)
...
</code></pre>
<p>?</p>
| php | [2] |
4,402,137 | 4,402,138 | How to use intent params to verify the callers calling onActivityResults() method? | <p>I'm wondering if it is possible to verify the the callers calling onActivityResult() method of startActivityForResult();
Here is the situation: I have two widgets in my home screen for invoking the default camera and video of device. Intent has been used with following params for camera: android.provider.MediaStore.ACTION_CAMERA_CAPTURE and video: android.provider.MediaStore.ACTION_VIDEO_CAPTURE.
After this i have called the startActivityForResult(intent, 0) for both from their respective onClick() methods. I have one onActivityResult() method and want to perform some task using if else statements. Now i want to know how to bifurcate the calling intents and hence direct them to their respective code section</p>
<p>e.g.</p>
<pre><code> protected void onActivityResult(int requestCode, int resultCode,
Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);
if(intent.???????){ //here i need some filter which could verify the calling intent.
if (resultCode == RESULT_OK) {
Bundle extras = intent.getExtras();
Bitmap bmp = (Bitmap) extras.get("data");
imv = (ImageView) findViewById(R.id.iVCenterLogo);
imv.setImageBitmap(bmp);
}
}
else {
//code to perform video stuff
}
}
</code></pre>
<p>Any help will be highly appreciated.</p>
<p>mrana...</p>
| android | [4] |
3,705,601 | 3,705,602 | Slide Menu Library error | <p>I used <a href="https://github.com/jfeinstein10/SlidingMenu" rel="nofollow">Slide menu</a> library into my android project and when I include this the eclipse fire and error at project.R.id cause it can't access my project.R</p>
| android | [4] |
2,613,985 | 2,613,986 | JavaScript: Load a script when specific <a> is active | <pre><code><script>
function AdImageTag(){
var q1=document.getElementById( 'ctl00_ContentPlaceHolder1_ctl00_ctl00_Showcase' ).childNodes[1].innerHTML;
var counter1=0;
function iterate(q1,counter1){
q1= document.getElementById( 'ctl00_ContentPlaceHolder1_ctl00_ctl00_Showcase' ).childNodes[1].innerHTML;
if(q1.match(/loader.gif/)){
counter1=counter1+1;
setTimeout(function() {iterate(q1,counter1)},100); //100milli seconds
}else{
function getrakhitagimage(){
var refrencestring = document.getElementsByClassName('mtb-desc');
var maindiv = document.getElementsByClassName('bucket');
for(var i=12;i<maindiv.length;i++){
var current_bucket = maindiv[i];
alert(current_bucket.firstChild.firstChild.innerHTML);
}
}
getrakhitagimage();
}
}
iterate(q1,counter1);
}
AdImageTag();
</script>
</code></pre>
<p>when first time page load my script runs well but on the same page when some other link is clicked and it display content on the same page only but than my script is not running?
so how can i trigger that script when that link is clicked.</p>
| javascript | [3] |
2,621,875 | 2,621,876 | Java switch constant expression... Is there any clever way to get this to compile? | <p>I'm returning to Java dev after many years away from it. Is there anyway to get this code to compile?</p>
<pre><code>class Mpeg4
{
public static final int FourCC2Int(char aA, char aB, char aC, char aD)
{
return (aA << 24) | (aB << 16) | (aC << 8) | (aD);
}
public static void main(String aArgs[]) throws Exception
{
int x = Integer.parseInt(aArgs[0]);
switch (x)
{
case Mpeg4.FourCC2Int('f', 't', 'y', 'p'): // This won't be reduced by the compiler to a constant.
// doSomething();
break;
}
}
}
</code></pre>
<p>I tried also to have a class constant such as</p>
<pre><code>class Mpeg4
{
private static final int KFtyp = Mpeg4.FourCC2Int('f', 't', 'y', 'p');
public static void main(String aArgs[]) throws Exception
{
int x = Integer.parseInt(aArgs[0]);
switch (x)
{
case KFtyp: // Foiled again.
// doSomething();
break;
}
}
}
</code></pre>
<p>The language has changed quite a bit, and I've done Googling. Is there any way I can keep my code tidy
i.e. not manually reducing the 'macro' or having a potentially massive if-then-else-if block?
Maybe compiler optimisation flags might be one route? I find this situation quite lame.</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.