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 |
|---|---|---|---|---|---|
4,261,628 | 4,261,629 | get last week in javascript | <p>I am using the following in a script:</p>
<pre><code>var startDate = new Date("10/12/2012");
var endDate = new Date("10/18/2012");
</code></pre>
<p>I would like those dates to be dynamically created with startDate as last Monday and endDate as last Sunday. I have tried the following:</p>
<pre><code>var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay(); // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var startDate = new Date(curr.setDate(first)).format("m/dd/yyyy");
var endDate = new Date(curr.setDate(last)).format("m/dd/yyyy");
</code></pre>
<p>But for some reason this doesn't work - nothing is outputted for the startDate or endDate variables.</p>
<p>Any ideas what I am doing wrong?</p>
| javascript | [3] |
1,122,355 | 1,122,356 | get selected value from multiple <li> using jquery | <p>i have a unordered list of data, and within each <code><li></code> i have a hidden input which contain the different values for each <code><li></code></p>
<pre><code><form>
<ul>
<li><input type="hidden" id="tid" value="1" />Apple</li>
<li><input type="hidden" id="tid" value="2" />Orange</li>
<li><input type="hidden" id="tid" value="3" />Pear</li>
</ul>
</form>
</code></pre>
<p>how do i retrieve the post value from the hidden input when a particular <code><li></code> is clicked through jquery??</p>
| jquery | [5] |
3,390,706 | 3,390,707 | android externel application | <p>Hi form the following site <a href="http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android-apps/2.1_r2/" rel="nofollow">http://grepcode.com/snapshot/repository.grepcode.com/java/ext/com.google.android/android-apps/2.1_r2/</a><br>
i can download the source code of all android app
as jar ,i need the videorecording app from the above jar ,is it possible ie by importing jar in to my app and call like default intent calling eg Intent i=new ... Startactivity().</p>
| android | [4] |
4,056,792 | 4,056,793 | send add to face book | <p>How can I add news to my facebook from web site with what java script code or other ways? </p>
| asp.net | [9] |
3,953,066 | 3,953,067 | JavaScript function on post back | <p>I am maintaining some code someone has created and it uses a few JavaScript functions to make some div's have rounded corners - however, on a post back the corners seem to dissappear. The event for the function is below:</p>
<pre><code>curvyCorners.addEvent(window, 'load', initCorners);
</code></pre>
<p>I'm assuming this is the problem - what event would fire for postbacks too?</p>
| javascript | [3] |
1,398,619 | 1,398,620 | Will this foreach copy the values in memory? | <p>Example:</p>
<pre><code>foreach ($veryFatArray as $key => $value) {
</code></pre>
<p>Will the foreach assign the value behind the $key by reference to $value, or will $value be a copy of what's stored in the array? And if yes, how could I get an reference only? The array values store pretty big amounts of data so copying them is not really good.</p>
| php | [2] |
2,646,274 | 2,646,275 | JSObject: Download it or available in JRE 1.6? | <p>This is a question from a Java noob.</p>
<p>I have eclipse open (JRE 1.6), <a href="http://svn.littleshoot.org/svn/littleshoot/trunk/client/applet/src/main/java/LittleShootApplet.java">I have copied this code into an eclipse class</a>.</p>
<p>The line in question is this:</p>
<pre><code>import netscape.javascript.JSObject;
</code></pre>
<p>Eclipse is complaining that the import can not be resolved. I read that in the docs that the Java Plug-In comes as standard and contains the above. I assumed I don't need any extra JAR files. Is this true?</p>
<p>Or do I need to download something to make use of JSObject?</p>
<p>Thanks all</p>
| java | [1] |
3,153,667 | 3,153,668 | Need to fetch the Contact Account name and Contact Display name from the content provider using a single cursor in Android | <p>I need to list the 'Display name' of all the contacts belonging to a single account.
I am planning to use a cursor adapter for populating the list and hence would require the corresponding fields (Display name, Account info) to be fetched in a single content provider querry.</p>
<p>Looking at the Contacts Database Structure a single table amoung Raw Contacts, Contacts and Data wont be able to provide these two parameters and hence a join is necessary.
As far as i know join wont be possible to fetch the data from the content provider.</p>
<p>Can you please let me know the solution to the problem?</p>
<p>Thanks in advance.</p>
| android | [4] |
2,838,831 | 2,838,832 | How to avoid duplicating complicated catch blocks | <p>I have this code:</p>
<pre><code>try {
do_stuff();
return do_more_stuff();
} catch (UnsupportedEncodingException e) {
throw CustomException.programmer_error(e);
} catch (ProtocolException e) {
throw CustomException.programmer_error(e);
} catch (MalformedURLException e) {
throw CustomException.programmer_error(e);
} catch (SocketTimeoutException e) {
throw new CustomException(e);
} catch (IOException e) {
throw CustomException.unexpected_error(e);
}
</code></pre>
<p>I now need to have all those catch blocks in another similar function. What is the best way to avoid duplication here?</p>
<p>Note that the code inside the two try blocks is not very similar.</p>
<p>Also I can't really put the set of catches higher up.</p>
<p>Note, I'd prefer to avoid:</p>
<pre><code>try {
do_stuff();
return do_more_stuff();
} catch (Exception e) {
handle_exception_via_rtti(e);
}
</code></pre>
| java | [1] |
3,188,680 | 3,188,681 | document.writeln not working as expected | <p>With the following line of code:</p>
<pre><code>document.writeln("blahblahblah")
</code></pre>
<p>I expect the content to be placed on its own line, but instead the content is inserted, but with no new line. Only a space. </p>
<p>Is it expected?</p>
| javascript | [3] |
4,392,427 | 4,392,428 | jQuery get and text return replacement character. How to solve? | <p>If I use:</p>
<pre><code>$.get("url",function(data){$("#destination").text(data);})
</code></pre>
<p>in the <code>.text</code> of <code>#destination</code> the letters like èéàòùì become the <a href="http://www.fileformat.info/info/unicode/char/fffd/index.htm" rel="nofollow">replacement character</a>.</p>
<p>How do I solve it? Set the charsets is useless; I don't want to use <code>.replace("strange character","");</code>.</p>
| jquery | [5] |
1,436,705 | 1,436,706 | Active bluetooth on airplane mode | <p>I need to turn of the gsm network at my application but enable bluetooth.
I know how to change to airplane mode <a href="http://stackoverflow.com/questions/5533881/toggle-airplane-mode-in-android">Toggle airplane mode in Android</a>, but is there a way to keep the bluetooth on (I know that them both working on radio signals), I think it's possible on android 4 cause I saw some application that doing it like "Auto Airplane". </p>
<p>I've tried the code below with no help:</p>
<pre><code>Settings.System.putInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON,1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", 1);
context.sendBroadcast(intent);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.enable();
</code></pre>
<p>thank's,
david</p>
| android | [4] |
2,610,404 | 2,610,405 | APK that needs another apk to function | <p>I am implementing a kind of location provider that I would like to distribute as an apk. If someone implements an application that uses the classes of my apk it is necessary that my apk is installed on the device first. My "location provider" offers an API that can be used by other programmers (it has no UI). </p>
<p>I wonder if it is even possible to do something like this. Normally I would use a jar but it is easier to distribute as a apk. </p>
<p>Is it possible to include an apk in for example Eclipse so that other programmers can use my API for their applications? I tried it but did not get it to work but I am also not an expert in Eclipse. </p>
<p>Hope someone has done something like that already and can give me a hint.</p>
<p>Thanks,
Benjamin</p>
| android | [4] |
540,166 | 540,167 | python check pattern in string | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5319922/python-check-if-word-is-in-a-string">Python - Check If Word Is In A String.</a> </p>
</blockquote>
<p>i have a string which is a url e.g.</p>
<pre><code>my_url = "http://mysite.com/somefolder/somefile"
</code></pre>
<p>I want check if "somefolder" is in the <code>my_url</code> file</p>
<p>how do I do that?</p>
| python | [7] |
5,738,044 | 5,738,045 | Python None and if conditions | <p>I have some code here:</p>
<pre><code>m = None
n = None
if not m:
print "Something happens"
>>> Something happens
</code></pre>
<p>if I do:</p>
<pre><code>if not m and n:
print "Something happens"
</code></pre>
<p>Nothing happens.</p>
<p>But I can do:</p>
<pre><code>m, n = 1,2
if m and n:
print "Something happens"
>>> Something happens
</code></pre>
<p>Why are if and if not handled the same way? Does 'if not', not take 'and' statements?</p>
<p>Thank you </p>
| python | [7] |
4,493,204 | 4,493,205 | How to pass an variable to curl_init in php | <p>In the below code which is to download an file , But i tried to pass an image url in the form of variable to the curl_init , How to use variable in curl_init </p>
<p>// $downlaod="http://image.com/image.jpg";</p>
<p>I used $download variable in the curl_init but it shows errors. </p>
<pre><code><?php
$ch = curl_init('http://my.image.url/photo.jpg');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // buffer output (`true` if you will be redirecting stream to the user, in $result will be your image content)
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); // because image is binary data
$result = curl_exec($ch); // executing requrest (here will be raw image data if RETURNTRANSFER == true)
$response_code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); // getting response code to ensure that request was successfull
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); // getting return content-type
// Listing allowed image types
$allowed_mimes = array(
'image/jpeg',
'image/gif',
'image/png'
);
if ($response_code == 200 AND in_array($content_type, $allowed_mimes) ) {
header( 'Content-Type: '.$content_type );
echo $result; // echoing image to STDOUT
} else
return false;
?>
</code></pre>
| php | [2] |
260,654 | 260,655 | Is it possible to output video of my iPhone application running on a device? | <p>I am working on an app for a client where he will be showing it in a board from to a group of directors for a serious presentation. Because the iPhone is so small, it wouldn't make sense to have him demo the app on the actual device because no one would see anything. </p>
<p>Is it possible to have the screen output on a computer or tv so that everyone in the room can see what is going on?</p>
| iphone | [8] |
4,451,177 | 4,451,178 | calendar code required | <p>Where can I get code to generate a calendar which displays dates in a proper grid?
Or can I get code for a calendar app so that I can make a few changes to it? It will help ma save a lot of time.</p>
| android | [4] |
622,235 | 622,236 | Receiving JPEG images via http GET request | <p>I want to receive images from an IP camera over HTTP via GET request. I have written a program that creates TCP socket connection with the camera and sends the following GET request to the camera:</p>
<pre><code>GET /mjpeg?res=full HTTP/1.1\r\nHost: 143.205.116.14\r\n\r\n
</code></pre>
<p>After that, I receive images with the following function in a while loop:</p>
<pre><code>while((tmpres = recv(sock,(void *) buf, SIZE, 0)) > 0 && check<10)
</code></pre>
<p>.....</p>
<p>where <code>SIZE</code> represents the size of the buffer. I, infact, don't know what size to define here. I am receiving a color image of size 2940x1920. So I define <code>SIZE=2940x1920x3</code>. After receiving the MJPEG image, I decode it with ffmpeg. But I observe that ffmpeg just partially/uncorrectly decodes the image and I just see a half (or even less) of the image. I assume it could be a size problem.
Any help in this regard would be highly appreciated.</p>
<p>Regards,</p>
<p>Khan</p>
| c++ | [6] |
3,534,443 | 3,534,444 | How to make popup window in javascript only show once? | <p>I want to make single pop up window in javascript. No matter how many times the button is pressed from parent page, only the single pop up is activated.</p>
<p>How can I do that in Javascript?</p>
| javascript | [3] |
1,685,051 | 1,685,052 | Why is javascript converting this and what is it converting it to? | <p>I have a string, '0x000000000000090D' that I am passing to a function. However, when I try to display it in an alert in the function, it has been converted it to 2317. Displaying it in an alert in the calling function displays it correctly.</p>
<pre><code>var tagid = msg[post].TagID.toString();
alert(tagid);
ShowDetails(tagid);
function ShowDetails(tagid){
alert(tagid);
}
</code></pre>
<p>Why is it being converted, and what is it being converted in to so I can try to stop it?</p>
<p>Thanks!</p>
| javascript | [3] |
1,203,291 | 1,203,292 | Detect touch on EditText, but not interrupt it? | <p>I need to know when the user touches/taps/clicks the edittext in my activity.</p>
<p>How can I do this without interrupting the events, so the keypad still displays properly?</p>
<p>(And I need to know about it before the OS displays the keypad...if possible)</p>
| android | [4] |
4,117,397 | 4,117,398 | Is it true constructor's prototype cannot overwrite public members? | <p>Example 1:</p>
<pre><code>function Cat(){
this.color = function (){
return "Green";
};
}
Cat.prototype.color = function(){
return "Blue";
}
var kitty = new Cat();
alert(kitty.color()); // Green
</code></pre>
<p>Example 2:</p>
<pre><code>function Cat(){
var color = function (){
return "Green";
};
}
Cat.prototype.color = function(){
return "Blue";
}
var kitty = new Cat();
alert(kitty.color()); // Blue
</code></pre>
<p>Example 2 returns <code>Blue</code>, is it because the constructor cannot overwrite public members or it cannot access private members?</p>
| javascript | [3] |
4,693,548 | 4,693,549 | Memory warning level 1 due to UIImage | <p>I am working on one component where I need to scale and rotate image. following is flow of the component</p>
<p>Select the image from photo library -> show that image in UIImageView -> do the scaling -> save this image in document.</p>
<p>This works fine with image having low resolution.</p>
<p>but once I select the image with high resolution I first get Memory Warning level 1. but I cann't release that image, as I need to proceed further with same image.</p>
<p>I come to know image is unpacked by ( width * height * 4 ) so if I select image of 1800 * 1200 memory consumed is 8.6 MB [ Also checked with instrument ] . </p>
<p>Can any one help me to come over this issue? This creates 2 queuestion</p>
<ol>
<li>can we use images with high resolution ?</li>
<li>what about 2 UIImageview with two high resolution images?</li>
</ol>
<p>Thanks,</p>
<p>Sagar</p>
| iphone | [8] |
4,240,655 | 4,240,656 | The method split(String) is undefined for the type Scanner | <p>Why is it that I cant use split method on <code>input</code>? In Eclipse it says: The method split(String) is undefined for the type Scanner. I dont know what I am doing wrong, if anyone could guide me in the right direction.</p>
<pre><code>btnFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser("C:\\");
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
" Only .txt", "txt");
chooser.setFileFilter(filter);
int code = chooser.showOpenDialog(null);
if (code == JFileChooser.APPROVE_OPTION) {
File selectedFile = chooser.getSelectedFile();
Scanner input;
try {
input = new Scanner(selectedFile); // <-- Here
String[] splits = input.next().split(" "); <-- And here
for (int i = 0; i < splits.length; i++) {
textArea.setText(splits[i]);
System.out.println(splits[i]);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
</code></pre>
<p>Thanks.</p>
| java | [1] |
3,108,614 | 3,108,615 | Javascript bottleneck for server communication (for downloading resources) | <p>I'm writing a javascript application. In my application I want to create my own cache management.</p>
<p>Now my question is: Is there any bottleneck in javascript (e.g. any event on window object) that we can handle and modify all server communications?</p>
<p>many tags in the page can request a resource from server e.g. <code>img</code>, <code>link</code>, <code>script</code>.</p>
<p>In other words I want a bottleneck in javascript that I can be notified that a resource is requested from server. Then I will look into my cache-system and will serve the resource either from my cache or by downloading the content from a generic HTTP handler on my server.</p>
<p>I know it's a bit strange requirement but because I believe javascript is very flexible I though this "bottleneck" may exist.</p>
<p>Thank you.</p>
| javascript | [3] |
543,310 | 543,311 | remove and rebinding li tags to ul is not working | <p>I am trying to rebind the li tags by removing it and again rebinding it. The ul tag is generated dynamically. My code to remove the li tags is this...</p>
<pre><code>$("#ulActivity li").remove();
</code></pre>
<p>this line is removing all li tags perfectly, but append new set of li is not working...</p>
<pre><code>$.each(objTaskActivityList, function(i,v){
$("#ulActivity ul").append('<li><a onclick="javascript:openfile(\''+v.DOCName+'\')">'+v.DOCName+'</a></li>');
});
</code></pre>
<p>where i am doing mistake..</p>
| jquery | [5] |
4,161,945 | 4,161,946 | php, string to int | <p>how convert from string to int?</p>
<pre><code> If i print $width_s, get: 1024
If i print $width, get 0.
</code></pre>
<p>How convert string to integer(number) ?</p>
<pre><code>$width_s = '<script language="javascript">document.write(screen.width)</script>';
$width = (int)$width_s;
var_dump($width);
</code></pre>
| php | [2] |
1,527,233 | 1,527,234 | in php, how can I describe an object's properties and methods? | <p>How can I show what all the objects' methods and properties are?</p>
<p>That is, including the property's values?</p>
| php | [2] |
2,269,468 | 2,269,469 | Making permutations with array of chars | <p>So the problem is like this, user inputs n (integer) and n chars. I have to make program that writes out all combinations of 2 up to n chars from the chars I am given. You can not use same char twice, however user can write same char multiple times so you can use it as many times as he wrote it (say user writes 'a' twice, you can use it up to two times then).</p>
<p>It doesn't matter whether the "words" you type out make sense or not. Also you can treat array of chars as an array of indexes (in other words, if user writes "aa" then you should have following outcome "aa, aa" so first aa represents combination of first a then second a, and second aa represents second a, then first a). So here is an example of how it should look for input of "two" the output should be "tw, wo, to, wt, ow, ot, two, tow, wto, wot, otw, owt" (the order doesn't matter, I may have forgotten some combination, but you get the point).</p>
| c++ | [6] |
4,912,792 | 4,912,793 | Android animation with multiple jpeg files? | <p>I want to build an animation with some jpegs. I need to change the source of a imageview 24 times per second? What is the easiest way of implementing this? (Newbie)</p>
| android | [4] |
5,644,169 | 5,644,170 | How to override base method in asp.net? | <p>I want to create custom Textbox control in asp.net.But i have one doubt when i override the base method i got predefined syntax something like this</p>
<pre><code> base.OnRender(writer);
</code></pre>
<p>Now my question is that from where I should start witting the code means before Base.OnRender or after base.OnRender.</p>
| asp.net | [9] |
260,859 | 260,860 | How to redirect to success / fail pages after php form submission? | <p>I have successfully integrated the following form submission code into my site, and it works great. However I would like to have the code redirect the user to one page if the form submission is successful, and a different page if it fails. How could I adapt the following code to do that? It's really starting to get on my nerves! :-P</p>
<pre><code><?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$enquiry = $_POST['enquiry'];
$formcontent=" From: $name \n Phone: $phone \n Message: $enquiry";
$recipient = "email@email.co.uk";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!";
?>
</code></pre>
<p>EDIT:</p>
<p>Ok I have changed the code to:</p>
<pre><code><?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$enquiry = $_POST['enquiry'];
$formcontent=" From: $name \n Phone: $phone \n Message: $enquiry";
$recipient = "email@email.co.uk";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
if(mail($recipient, $subject, $formcontent, $mailheader)){
header("Location: mailer-success.htm");
}else{
header("Location: mailer-fail.htm");
}
exit;
?>
</code></pre>
<p>This works however it never goes to the fail page. I'm guessing that's because the email is always sent even if fields are empty. I have jquery verification in place (which I have disabled for testing purposes) but that obviously only works for users with javascript enabled. How could I alter the code to only show the success page if the form fields contain data? Any help is appreciated.</p>
| php | [2] |
5,222,889 | 5,222,890 | Send value to php file | <p>I'm try to send a value to a PHP file, but when I check, this value became <code>null</code>.</p>
<p>I send the value by: user_login.php?p_action=New_User</p>
<p>The code of user_login.php is:</p>
<pre><code>require("include/session_inc.php");
require("include/user_handling_inc.php");
require("include/db_inc.php");
start_Session(false, false);
switch ($p_action) {
case 'Login': {
$l_flag = verify_User($p_in_username, $p_in_password);
if ($l_flag == "Not_Found") {
$l_flag = "New_User";
}
break;
}
case 'Save_Profile': {
$l_flag = "Save_Profile";
break;
}
case 'New_User':
$l_flag = "New_User";
break;
case 'Create_New_User':
$l_flag = "Create_New_User";
}
switch ($l_flag) {
case 'New_User': {
include "include/user_new_inc.php";
break;
}
case 'Save_Profile': {
load_User_Data(" username = '$p_in_username' ", false);
include "include/user_profile_save_inc.php";
break;
}
case 'Wrong_Password':
echo "Wrong Pass";
break;
case 'OK':
load_User_Data(" username = '$p_in_username' ", true);
store_User_Cookie($g_userdata->user_id);
include "include/user_profile_inc.php";
break;
case 'Create_New_User':
$l_user_id = create_New_User ($p_in_username, $p_in_email, 'Y');
if ($l_user_id != -1) {
store_User_Cookie($l_user_id);
echo "Success !! <br><br> \n";
echo "<a href\"/index.php\"> Back to Main </a>";
}
break;
}
</code></pre>
| php | [2] |
4,694,160 | 4,694,161 | AutoCompleteTextView: display a mixed list | <p>I have an autocompleteList I would like to present mixed search results in. By mixed i mean two types of entities. After the user selects any/both entities, his selection is added to a ListView. This can be done several times and in this case the ListView will grow.</p>
<p>I have two types of entities I want to present in my list: groups and individuals. I want to be able to fetch those two entity types from different db tables. I need to be able to show the user, on the autocompleteList that there is a difference between groups and individuals. Also in the ListView I need the separation of group & individual because I want to enable the individual to click on the ListView row containing a group when the user wants to drill down and see which individuals are inside the group the user selected. </p>
<p>User story: the user will want to search for competitors. The user can select individual competitors out of a list but sometimes the user will also want to select whole groups of competitors and have a mixed list. Choosing a group of competitors is useful when the user doesn't want to add a large amount of competitors one by one.</p>
<p>Could anyone please give me a direction here? I don't even know what keywords to use in Google :-/</p>
| android | [4] |
2,911,637 | 2,911,638 | order by timestamp without a database? | <p>I have to store some info (timestamp of post, title and link) from various feeds (facebook,twitter,rss and some custom xml) without using a database. So I'm writing what I need to xml files and then pulling everything in using simplexml. This works fine. However, I need output the info from the various feeds in to a un-ordered list that's ordered by the timestamp. I don't know how to do this. I can get the info from each feed aggregated in to one array but how do I order by the timestamp before I output it in to html?</p>
| php | [2] |
4,570,522 | 4,570,523 | PHP: Obligatory params | <p>What would be the best way, when it comes to practices, to return false if some param is not passed to a PHP function?</p>
<p>Mainly because I am calling this function will be called with params that come from the frotend, which means that the user could pass null as a param, and I want to return false if that happens.</p>
<p>At the top of the function I put:</p>
<pre><code>if (empty($param1) || empty($param2) || empty ($param3)) {
return false;
}
</code></pre>
<p>Any better ways of doing this?</p>
| php | [2] |
1,383,723 | 1,383,724 | use js to store current domain, full url, and ip | <p>Im trying to obtain the IP address of the user, current domain, and full page URL when my javascript is run ( for traffic analysis )</p>
<pre><code> var ip = '<!--#echo var="REMOTE_ADDR"-->';
var domain = document.domain;
var page = window.location;
</code></pre>
<p>I keep getting errors in FF3</p>
<pre><code>Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOMLocation.host]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js :: anonymous :: line 12" data: no]
</code></pre>
<p>Any ideas?</p>
| javascript | [3] |
3,900,435 | 3,900,436 | cache the database result in txt file and how to output it? | <p>eg: <code>$results = mysql_query('SELECT title FROM article');</code> now I want to put the result in a text file. Then :</p>
<pre><code> $filepath = 'test.txt';
if (is_file($filepath)) {
echo file_get_contents($filepath);
} else {
// read the databse, and stored the result to the test.txt.
}
</code></pre>
<ol>
<li>How to wirite the else part?</li>
<li>I want to echo the content in list style. how should I do? </li>
</ol>
<p>Thank you</p>
| php | [2] |
5,720,275 | 5,720,276 | how to declare and define a time data? | <p>I have a class that needs to contain a time variable. How to do that? I would like to specify that I communicate with a server and as a response at time section I receive for example: 2011-07-01T14:32:39+02:00 .APPRECIATE. THX</p>
<p>P.S I would like to use the C++ API. </p>
| c++ | [6] |
3,609,362 | 3,609,363 | jQuery validate only by remote | <p>My form has 4 fields and at least one of them must contain a number. I can handle this all by remote but I can't get the snippet below to call the remote function unless I also add a <code>required: true</code> to the rules. <code>codes[25]</code> is just one of the fields. </p>
<pre><code>$("#create-codes-form").validate({
rules: {
'codes[25]': {
remote: {
url: site_url+"codes/validate",
async: false,
type: "post",
data: {
codes: function() {
return $("#create-codes-form").serialize();
}
}
}
}
}
});
</code></pre>
<p>Why, when I submit this form, is the remote call not being made?</p>
<p>EDIT: the remote call is being made if I enter a value in the codes[25] field, but not if I submit the form without touching any of the fields.</p>
| jquery | [5] |
3,585,785 | 3,585,786 | location.reload altering the url | <p>Does anyone know what could cause this piece of javascript to alter the url:</p>
<pre><code><script type="text/javascript">
window.setTimeout(function() {
window.location.reload(true);
}, 5000);
</script>
</code></pre>
<p>The window location accepts fragments and changes the url from /web/page/123321 to just /web/page </p>
<p>Anyone ever seen anything like this before? Could it just be certain browsers?</p>
<p>Thanks </p>
<p>James</p>
| javascript | [3] |
5,125,166 | 5,125,167 | Android ExpandableListView about arrays | <p>I'm planning to add expandablelistview in my activity. I did some researches on the Internet but none of them fits what I want. I read also that expandablelistview has parent and child elements. What I want to do is that the parent would be the categories let's say it's fruits, then its children are Apple, Lemon, Almonds, etc. I'd like to try that by using arrays, but am not so familiar with List and Hash.. Please give me some snippets of codes to start with.. appreciate any help. Thanks.</p>
| android | [4] |
1,039,322 | 1,039,323 | Build a Blog Archives block with code in php? | <p>i am a new learner of php, i only able to read and write some data into mysql database and some basic php knowledge. now, there is a blog programme. i had wrote some articles.i want to build a Blog Archives block with code by myself. but i even don't know how to begin? the Blog Archives block style as this:</p>
<pre><code>2011 year may month
2011 year april month
2011 year march month
....
</code></pre>
<p>expect someone can give me some tips.first i should do then.....and last solve the question. thank you.</p>
<p>ps:first i know i should do a research to the database. now, but i don't know how many fields i should necessary.
i found the article created time as this <code>1305357473</code></p>
| php | [2] |
449,299 | 449,300 | How can i test from code if a phone is htc type? | <p>I want to show a button on a screen just if the phone is htc . How can i test this?</p>
| android | [4] |
4,400,811 | 4,400,812 | Retrieving n values from treemaps in java | <p>I'm using treemaps in my java program. The output of the program is a sorted map as follows</p>
<pre><code>[cat=1, dog=1, pin=3, ball=4, mice=4..... and so on]
</code></pre>
<p>I want to display only first 3 values of the map instead of displaying the whole map.
I want my output as follows</p>
<pre><code>cat=1
dog=1
pin=3
</code></pre>
<p>How can i do this? </p>
| java | [1] |
5,881,278 | 5,881,279 | check style of element with jquery persistently | <p>i need code like this</p>
<pre><code>if($('#someElement').hasClass('test'))
{
...
}
</code></pre>
<p>but i need to check it persistently not in a specific position.
my question is function like bind can help me or i have to use interval for checking?</p>
| jquery | [5] |
5,274,528 | 5,274,529 | Is this an ok use of the comma operator | <p>I've seen other posts in stackoverflow that highly discourage overloading of the comma operator. I was sent a github pull request with comma operator overload, that looked something like the following</p>
<pre><code>class Mylogger {
public:
template <typename T>
Mylogger & operator,(const T & val) {
std::cout << val;
return * this;
}
};
#define Log(level,args...) \
do { Mylogger logv; logv,level, ":", ##args; } while (0)
</code></pre>
<p>then you can use it as follows:</p>
<pre><code> Log(2, "INFO: setting variable \", 1, "\"\n");
</code></pre>
<p>Can someone explain why this is a good or bad usage case? </p>
| c++ | [6] |
6,011,743 | 6,011,744 | Uncaught Error: SecurityError: DOM Exception 18 Canvas | <pre><code>function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
document.body.appendChild(canvas);
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
var dataURL = canvas.toDataURL("image/png");
return dataURL;
}
</code></pre>
<p>I seem to be violating something, just can't seem to find what. Any help on how to fix it?</p>
| javascript | [3] |
3,931,943 | 3,931,944 | place php errors in log file | <p>I am running mac 10.6.4 on an iMac and am using it as a developer server. </p>
<p>I have Apache and Entropy php5 installed, when i write my applications, some pages wont run when php has errors, however these are not recorded on a log file, I created one php_errors.log and entered the following on the php.ini file</p>
<pre><code>error_log = /usr/local/php5/logs/php_errors.log
</code></pre>
<p>However errors are not written to this file and i have </p>
<pre><code>log_errors = true
</code></pre>
<p>What could be the problem</p>
| php | [2] |
2,498,669 | 2,498,670 | timer issue at displaying view | <p>hi i am new to iphone. what i am doign is displaying 20 images as grid and by selecting image it is displayed on imageview after 4 sec it will come back to main screen,for that i am using timer it works fine but there is a small problem with out selecting image the timer is continually running.if i am selecting button on 2 sec late then with in remaining 2 sec it will come back how can i solve this pls help me</p>
| iphone | [8] |
5,168,060 | 5,168,061 | android: how to append text to TextView in another activity every 2 seconds | <p>I have two activities, one is main and I have another activity called Test as well</p>
<p>in the main activity i have a button when I click on this button I go to the Test activity</p>
<p>in the Test activity I want the application to automatically append some text to the textview that it has every 10 seconds</p>
<p>this text can be for example "test"
so every 10 seconds "test" will be added
but, when I leave the activity and go to the main activity, this process will continue happening
so if for example I spend 20 seconds on the main activity and then return to the Test activity, I will see two more "test" strings in the textview..</p>
<p>I tried doing this with timertask and had no success at all</p>
<p>this is the Test activity's code, in the main activity I just have the button that shows me the other activity</p>
<pre><code>public class test2 extends Activity {
/** Called when the activity is first created. */
private TimerTask task;
private Handler handler;
private TextView tv;
private Timer t;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text1);
t = new Timer();
task = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
TextView tv = (TextView) findViewById(R.id.tv1);
tv.append("test");
}
});
}
};
t.schedule(task, 2000);
}
}
</code></pre>
<p>when I click in the button of the main activity in order to go to the Test activity I get the following error:</p>
<pre><code> FATAL EXCEPTION: Timer-0
java.lang.NullPointerException
</code></pre>
<p>thanks in advance</p>
| android | [4] |
5,847,349 | 5,847,350 | Cannot save video to specific folder | <p>I am trying to save video to specific folder like </p>
<pre><code>Intent captureVideoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
File videosFolder = new File(Environment.getExternalStorageDirectory(), "Videos");
if (!videosFolder.exists()) {
videosFolder.mkdirs(); // <----
}
String sfx = getNextName(ConstantData.RESPONSE_TYPE_VIDEO);
videoUri = Uri.fromFile(new File(videosFolder, sfx));
captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT,videoUri);
captureVideoIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(captureVideoIntent,1277);
</code></pre>
<p>videoUri is fine, folder Videos is created and on result when I try to read file like </p>
<pre><code>InputStream inputStream = this.getContentResolver().openInputStream(videoUri);
ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(8 * 8192);
....
</code></pre>
<p>I am getting exception FileNotFound, what is true, there is Videos folder but there is no saved video inside. Does anybody know what is problem and why I cannot save video to specific folder ? Video has extension .3gp and folder is always empty.</p>
| android | [4] |
1,449,555 | 1,449,556 | passing parameters from Javascript | <p>I have the typical HTML "contact me" page, i.e. name, e-mail address and message. Since I want to do input validation on the page itself using Javascript, I can't use a "submit" button, otherwise the attached Javascript function would be ignored. At least that's how I understand it, CMIIW.<br />
I tried to load the next page wrting "location = mail.php" but it appears that the form parameters don't get passed to my php page this way.<br />
How do I validate input in Javascript and pass parameters to my php page when ok?<br />
TIA<br />
Steven</p>
| javascript | [3] |
678,188 | 678,189 | Does minified javascript improve performance? | <p>I'm making an AIR application (so download time doesn't have a huge impact), does combining and minifing all the javascript files affect the performance? How would obfuscating affect the performance.</p>
| javascript | [3] |
5,454,761 | 5,454,762 | Custome control generic | <p>I have a custom control which contains certain fields (textfields) and a button this control is accessed in various other forms .</p>
<p>This user control also contains a Button on click of that button based on what fields are entered i need to do some operation .Now since this user control is used used in many places i do not want others to actually find the control rather do something in a more generalized way .</p>
<p>Like for example :</p>
<p>MyCustom control contains two fields
Name,Last name and a button search but the grid it binds to is in another Personform </p>
<p>In another form i use myCustomecontrol to do something
.
Can anyone suggest the way to go about this ??</p>
<p>Thanks ,
Fran</p>
| c# | [0] |
5,729,735 | 5,729,736 | How can this switch statement be simplified? | <p>I have two switch statement on inside another.<br>
Like this </p>
<pre><code>switch(something)
{
case h:
switch(s)
{
case e:
break;
default:
}
break;
default:
}
</code></pre>
<p>Can i simplify it any way? Is there a way to use only one switch statement?<br>
I thought of moving it to a different function but I'll need to pass a lot of variables.</p>
| c++ | [6] |
5,592,901 | 5,592,902 | Android: dots and line around nine patch images? | <p>I am trying to use the attached nine patch image as the background for a View in my app (the image is from the android-15 sdk resources). As pictured, the image has two vertical dots to the left of image, two horizontal dots above the image, and a horizontal line below the image. These dots/line from the images show in my app. </p>
<p>I copied the file from the sdk folder into my resources directory, and set the drawable resource as the background for my view. What is the proper way to use this image as the background of a view, such that the dots/line do not show? </p>
<p><img src="http://i.stack.imgur.com/mjVLr.png" alt="enter image description here"></p>
| android | [4] |
248,920 | 248,921 | Android: How to make TextView editable? | <p>How I can allow user to edit TextView? Of course, I can use EditText instead, but I don't know how to customize it and also I've read in Android documentation that TextView can be editable. So I tried this:</p>
<pre><code><TextView android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="80sp"
android:text="MyText"
android:editable="true"
android:singleLine="true"
android:inputType="text"
android:focusable="true"
android:clickable="true"
android:cursorVisible="true"/>
</code></pre>
<p>But it still looks like common TextView. Does aneyone know what I missed? Or, may be, how to customize EditText for it look like TextView: without borders and background?</p>
| android | [4] |
2,513,091 | 2,513,092 | Editing a Photo | From ( X by Y ) to ( A by A ) | <p>When I upload my Facebook photo there are no requirements on the x and y dimensions of the photo. However Facebook finds a way to insert a 50px by 50px photo that is not distorted into the news feed. </p>
<p>The only way you could do this, unless I am mistaken, is by cropping the image so that x and y are equal and then scaling to 50px by 50px.</p>
<p>But I never see any photos with like half a face or off-centered. So how do they determine how to do the cropping. Are they using some sort of face detection algorithm or are users required to to this centering manually?</p>
| php | [2] |
559,282 | 559,283 | How to use the varchar data type in c#? | <p>I have this piece of code and I want to make it varchar not string. What is the appropriate syntax to do that in c#</p>
<pre><code> string emri = row["Nome"].ToString();
</code></pre>
<p>I have a query that I have to run and I use emri in it and compare it with a column in table which I have created in mysql. the column in mysql is of type varchar(20). When I execute my code it gives an error in my query and I was guessing maybe it was for this reason </p>
<pre><code>I have this query
string query = "IF NOT EXISTS(SELECT * FROM clienti WHERE CodCliente= " + id + " AND Nome = '" + emri + "' AND RagioneSociale=' " + ragSoc + " ' AND PartitaIVA=' " + piva + " ') INSERT INTO clienti VALUES(" + id + " ,' " + emri + " ',' " + ragSoc + " ',' " + piva + " ') else UPDATE clienti SET( " + id + " ,' " + emri + " ',' " + ragSoc + " ',' " + piva + " ')";
</code></pre>
<p>and it gives me this problem </p>
<pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS(SELECT * FROM clienti WHERE CodCliente= 1 AND NomeCliente = 'Jo' at line 1
</code></pre>
| c# | [0] |
3,924,037 | 3,924,038 | Android: ContextMenu and ItemSelected in Context Menu | <p>This is the onCreate and oncontextitemslected code </p>
<pre><code>@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
Toast toast;
if(item.getItemId() == R.id.context_menu_edit)
{
Log.d("ContextCheck","EDIT!");
toast = Toast.makeText(this, "Edit!", Toast.LENGTH_SHORT);
toast.show();
}
if(item.getItemId() == R.id.context_menu_delete)
{
Log.d("ContextCheck","DELETE!");
toast = Toast.makeText(this, "Delete!", Toast.LENGTH_SHORT);
toast.show();
}
return super.onContextItemSelected(item);
}
</code></pre>
<p>and before that is i used the method <code>registerForContextMenu(event_list)</code> where <code>event_list</code> is a ListView , no i don't know why when ever i click an item from the context menu, it doesn't do anything, it won't show the toast and won't log into the logcat... is the item.getItemId() same for OptionsMenu and ContextManu?.. i don't know what is wrong with my code..</p>
<p>PS
the context menu is called inside a dialog box in a listview</p>
| android | [4] |
4,221,920 | 4,221,921 | eq(n) and hover() | <pre><code>$('.rUl li').eq(0).click();
</code></pre>
<p>Show first item of my news rotator. But with <code>$('.rUl li').eq(0).hover();</code> the first item not visible. What is the difference between click() and hover() in this issue?
How can I show first item with hover()?
Thanks in advance</p>
| jquery | [5] |
645,053 | 645,054 | [ milli | micro | nano ]second granularity using tv_usec or tv_nsec | <p>I'm working on a project, and I need to need a finer granularity than whole second (i.e. time()). I was looking through opengroup.org and I notice there are data structures with memebers tv_usec and tv_nsec.</p>
<pre><code>#include <stdio.h>
#include <time.h>
int main (void) {
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
printf("%lis %lins\n", ts.tv_sec, ts.tv_nsec);
return 0;
}
test.cpp(5) : error C2079: 'ts' uses undefined struct 'main::timespec'
test.cpp(6) : error C2065: 'CLOCK_REALTIME' : undeclared identifier
test.cpp(6) : error C3861: 'clock_gettime': identifier not found
</code></pre>
<p>Is there an easy way to get a high precision time value by using the standard lib? I don't actually need high accuracy, but I do need increments for relative time.</p>
| c++ | [6] |
5,764,675 | 5,764,676 | I wanna play a video streaming live from network or local source but i want to add some stopper condition ? | <p>I wanna play a video streaming live from network or local source but i want to add some stopper condition so that user can download and play whole video first time and next time he downloads the video, video will play for 0nly 20sec? i am new in android , can anyone suggest me or provide some link. Thanks in advance.</p>
| android | [4] |
2,749,945 | 2,749,946 | combining effects in jquery | <p>How would I alter the below page and code so that when my 'news' P fades out the content below it... slides smoothly up instead of jumping.</p>
<pre><code> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("a").click(function ()
{
$("p").fadeOut(2000);
return false;
});
});
</script>
<style>
p {
position:relative;
width:400px;
height:90px;
background-color:#0099CC;
}
</style>
</head>
<body>
<p>
this is a news box. it will fade out when the x is clicked that is all. (<a href="#">x</a>)
</p>
<br />
does this shift up after fade out.<br />
</body>
</html>
</code></pre>
| jquery | [5] |
5,696,532 | 5,696,533 | Look for various substrings and return the position of the one found | <p>I want to analize a string for a substring and return the position of the substring if it was found.</p>
<pre><code>function analize(t) {
if (t.indexOf(" a ") > -1 || t.indexOf(" b ") > -1 || t.indexOf(" c ") > -1) {
alert(t.indexOf(" a "));
}
</code></pre>
<p>The problem is that I'm looking for more than one substring and I cant echo its position since I don't know which was found. While this example only has 3 strings, I need to do it with a lot more in my code. How can I check for various items and return the position of the one that's found?</p>
| javascript | [3] |
3,848,977 | 3,848,978 | Suppress output from subprocess.Popen | <p>How do you stop the output from subprocess.Popen from being output? Printing can sometimes be slow if there is a great deal of it.</p>
| python | [7] |
4,936,951 | 4,936,952 | Fire onchange event when hidden input changes | <p>I have various inputs that I want to set a dirty flag.</p>
<p>However the onchange event does not fire if these inputs are modified by javascript.<br>
Many of the inputs are customised data entry moodules written by many other people and have hidden input and javascript UI layer to modify the hidden input.</p>
<p>I want to detect when these hidden inputs change. (without modifying the original author's script)<br>
Also normal inputs do not trigger the 'onchange' event until 'blur' but I could get round this with the onkeyup event.</p>
| javascript | [3] |
4,252,404 | 4,252,405 | Setting checkbox input when specific value equals variable in jquery | <p>I am trying to use JQuery to set a checkbox to checked if the input value of the checkbox is equal to some other variable that I have. This is what my code looks like: </p>
<pre><code>var test_val = "test";
$('#checkbox[value='+test_val+']').attr('checked', true);
</code></pre>
<p>This does not seem to be working, thanks for the help</p>
| jquery | [5] |
671,750 | 671,751 | Redirection not working | <p>I have an asp.net application running on integrated pipeline and I have this specified in the web.config:</p>
<pre><code><customErrors mode="On">
<error statusCode="404" redirect="404Error.aspx" />
</customErrors>
</code></pre>
<p>However, my site still shows the generic 404 asp.net error.</p>
<p>Why is this?</p>
| asp.net | [9] |
3,309,828 | 3,309,829 | jquery modal dialog form | <p>Can someone please help </p>
<p><a href="http://jqueryui.com/demos/dialog/#modal-form" rel="nofollow">http://jqueryui.com/demos/dialog/#modal-form</a></p>
<p>I want onclick event instead of button click , that is i want a link to appear create new user instead of button . </p>
<p>Please help </p>
| jquery | [5] |
445,912 | 445,913 | Parse error: syntax error, unexpected '?' | <p>I have code that is supposed to select all of the rows of data from a database, and echo them all into a checkbox for for deletion. But for some reason it won't work. I keep getting the error: Parse error: syntax error, unexpected '?' in \delete.php on line 13</p>
<p>My code is:</p>
<pre><code><form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<?php
$connect= mysqli_connect("localhost", "root", "", "friends_list");
$query= "SELECT * FROM people";
$result= mysqli_query($connect, $query);
while ($row= mysqli_fetch_array($result))
{
echo '<input type="checkbox" value=" '<?php echo $row['id']; ?>'" name="todelete[]"/>' .
echo $row['first_name'] . ' ' . $row['last_name'] . ' ' . $row['age'] . '<br/>';
}
mysqli_close($connect);
?>
<input type="submit" value="remove" name="remove"/>
</form>
</code></pre>
<p>What am I doing wrong?</p>
| php | [2] |
2,063,005 | 2,063,006 | Disoriented when writing JavaScript - Architectural Integration - Grockage | <p>I'm a reasonably experience programmer (10+ years), and have only hacked JavaScript. I don't feel comfortable writing more than a few lines of it, but I'm seeing it more and more unavoidable to learn properly.</p>
<p>I get the same feeling writing JavaScript as I first did writing Unix shell scripts. I didn't fully understand the environment, where things are going, and so forth. It took a few well-timed suggestions to sort it all out.</p>
<p>I have a hard time with Js tools. I'm okay with almost any text editor, but is there anything other than alert('foo') and Firefox error console to see what the heck is going on?</p>
<p>Ps. I have bought books. Yes, I can write code snippits, but nothing sufficiently explained the whole paradigm. It's all code snippits, with no larger picture of how to integrate it architecturally with server side scripts, and not have to duplicate everything on the server side. </p>
<p>Maybe that's the answer. . write some on the server side?</p>
<p>edit: </p>
<p>tl;dr AMA OO PHP programmer. how do I quickly and completely grok javascript/jquery? </p>
| javascript | [3] |
5,058,223 | 5,058,224 | how handle error in NSPredicate | <p>when i try to match regular expression for Data . sometime application crashes with error</p>
<p>here is error description </p>
<p>'Can't do regex matching, reason: Can't open pattern U_REGEX_INVALID_RANGE (string Ertyu, pattern [a-Z], case 0, canon 0)'</p>
<p>here is my code</p>
<pre><code> - (BOOL)isValidateString:(NSString *)inString ForRE:(NSString *)inRE {
BOOL isValidate=NO;
NSPredicate *thePredicate= [NSPredicate predicateWithFormat:@"SELF MATCHES %@", inRE];
isValidate= [thePredicate evaluateWithObject:inString];
return isValidate;
</code></pre>
<p>}</p>
<p>and in this method RE is getting from server.</p>
| iphone | [8] |
4,602,593 | 4,602,594 | How do I resolve the "maximum request length exceeded" exception? | <p>please any one help me when I upload image i had this error</p>
<p>maximum request length exceeded</p>
| asp.net | [9] |
3,131,835 | 3,131,836 | I keep getting a unterminated string literal error | <p>It keeps giving me a unterminated string litereral error below but I can't see the problem. How can it be fixed below:</p>
<pre><code> var $fileImage = $("<form action='upload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='startUpload();' >
<p class='f1_upload_process'>Loading...<br/><img src='Images/loader.gif' /><br/></p><p class='f1_upload_form'><br/><label>
File: <input name='fileImage' type='file' class='fileImage' /></label><label><input type='submit' name='submitBtn' class='sbtn' value='Upload' /></label>
</p> <iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px solid #fff;'></iframe></form>");
$image.append($fileImage);
</code></pre>
| javascript | [3] |
2,549,169 | 2,549,170 | Are classes and objects the same thing in PHP? | <p>Just starting out with OOP in PHP and in general. From what I have been reading so far the two seem to be synonyms. Is this the case, and if not, practically speaking when people refer to objects and classes do they generally use the terms interchangeably?</p>
| php | [2] |
3,946,018 | 3,946,019 | JQuery page loading dynamically | <p>i search for jquery page load. </p>
<p>I always face that people use something like that</p>
<pre><code>jQuery("#popup").fadeIn(4000); //function to redirect the page after few seconds
window.location.replace("http://"+a_href);
}, 3000)
</code></pre>
<p>They sets timeout 3000 .However, there is a possibilty that the page could not be loadded after 3 sec.</p>
<p>Is there a way to do this dynamically ?</p>
| jquery | [5] |
5,110,849 | 5,110,850 | fadeIn() on a tr cause display:block - bug? | <p>If you try to do a <code>.fadeIn()</code> on a <code><tr></code> in jQuery, it adds (on Firefox and IE7) the element <code>display:block;</code>. (on IE7 also zoom:1).</p>
<p>I'm using the version 1.5 of jQuery. Is it a bug? And how can I fix this problem?</p>
| jquery | [5] |
4,652,687 | 4,652,688 | Javascript if in x | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/5252650/test-for-value-in-javascript-array">Test for value in Javascript Array</a><br>
<a href="http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array">Best way to find an item in a JavaScript Array ?</a><br>
<a href="http://stackoverflow.com/questions/237104/javascript-array-containsobj">Javascript - array.contains(obj)</a> </p>
</blockquote>
<p>I usually program in python but have recently started to learn JavaScript.</p>
<p>In python this is a perfectly valid if statement:</p>
<pre><code>list = [1,2,3,4]
x = 3
if x in list:
print "It's in the list!"
else:
print "It's not in the list!"
</code></pre>
<p>but I have had poblems doing the same thing in Javascript.</p>
<p>How do you check if x is in list y in JavaScript?</p>
| javascript | [3] |
3,875,780 | 3,875,781 | Modify userInput on submit | <p>I need help with this javascript, if a user inputs anything in the filed the field will print that value, but i want to modify specific part of the value. users are going to submit image urls which have a specific string that i need to modify.</p>
<p>For instance user input something like: <strong>http://www.domain.com/photos/1.jpg</strong></p>
<p>The result should be: <strong>http://www.domain.com/photos-d/1.jpg</strong></p>
<p><strong>Here is the code:</strong></p>
<pre><code><script type="text/javascript">
function changeText2(){
var userInput = document.getElementById('userInput').value;
document.getElementById('result').innerHTML = userInput;
}
</script>
<input type='text' id='userInput' onblur="if(this.value.length == 0) this.value='Enter Image URL';" onclick="if(this.value == 'Enter Image URL') this.value='';"/>
<input type='button' onclick='changeText2()' value='Generate'/>
<p>Output: <a id='result'></a> </p>
</code></pre>
<p>your help will be much appreciated - Thanks, </p>
| javascript | [3] |
565,322 | 565,323 | can anyone help me to give the java code to access tweets? | <p>i am working on a project that get tweets about a specific topic and than analysis these tweets, and conclude a result.
In first phase of my project, I have to write the code to access the tweets about a specific topic or concept.
Can anyone help me in this code, i am a newer in these type of research projects, thanks</p>
| java | [1] |
2,357,788 | 2,357,789 | Remove hover with on() | <p>I would like to have both a hover and remove hover event. The nodes which have this event are added dynamically, so I wish to use on(). When adding a hover event, it works great (the #second list below). For some reason when I add the off hover event, not even the add hover event will work (#first list below).</p>
<p>Please provide any clues. A live example is located at <a href="http://jsfiddle.net/NV7hR/" rel="nofollow">http://jsfiddle.net/NV7hR/</a></p>
<p>Thanks</p>
<pre><code>$(document).ready(function() {
$("#first").on("hover", "a", function(event) {
$(this).parent().css("background-color", "yellow");
}, function(event) {
$(this).parent().css("background-color", "");
});
$("#second").on("hover", "a", function(event) {
$(this).parent().css("background-color", "yellow");
});
});
<body>
<ul id="first">
<li><a href="#"/>Link</a></li>
<li><a href="#"/>Link</a></li>
<li><a href="#"/>Link</a></li>
</ul>
<ul id="second">
<li><a href="#"/>Link</a></li>
<li><a href="#"/>Link</a></li>
<li><a href="#"/>Link</a></li>
</ul>
</body>
</code></pre>
| jquery | [5] |
4,902,971 | 4,902,972 | Tools required for jailbroken Device applications | <p>I like to know about teh various tools required to develop for jailbroken application. </p>
<p>I have seen many links dealing with jailbroken devices says about the Open Toolchain . Does it really required for developing applications for jailbroken devices. Can anyone clearly elaborates regarding the open toolchain and other development tools required.</p>
<p>Do we need to sign the applications developed for jailbroken devices. Cant we use the normal provision profile downloaded from apple developer site for signing the application to run in the jailbroken devices.</p>
<p>Any help would be greatly appreciated. </p>
<p>Best Wishes,
Mohammed Sadiq.</p>
| iphone | [8] |
4,426,909 | 4,426,910 | Remove placeholder span after form submitted | <p>I'm using a placeholder span in my input fields. Using jQuery, I show/hide the span depending on whether there is a value entered into the field. The problem: When I implement this type of placeholder in a form, after submitting the form the span isn't hidden, despite the presence of a value in the input field. After the search is performed, the value remains as does the placeholder. Is there a way to correct that so the placeholder is hidden? Here is the jQuery I'm using:</p>
<pre><code>$(function() {
$("span.holder + input").keyup(function() {
if($(this).val().length) {
$(this).prev('span.holder').hide();
} else {
$(this).prev('span.holder').show();
}
});
$("span.holder").click(function() {
$(this).next().focus();
});
});
</code></pre>
| jquery | [5] |
4,514,229 | 4,514,230 | Learn Python the Hard Way 2nd Edition. Exercise 45 | <p>I'm going through Learn Python the Hard Way 2nd Edition and I've just done the exercise where am suppose to write down the is-a/has-a relationships. Am able to use classes somehow but i find is-a/has-a confusing. So I have no ideas if what I've done is correct, any pointers will be appreciated. Thanks.</p>
<pre><code>## Animal is-a object (yes, sort of confusing) look at the extra credit
class Animal(object):
pass
## ?? Dog is-a object
class Dog(Animal):
def __init__(self, name):
## ?? Dog has-a name
self.name = name
## ?? Cat is-a object
class Cat(Animal):
def __init__(self, name):
## ?? Cat has-a name
self.name = name
class Person(object):
def __init__(self, name):
## ?? Person has-a name
self.name = name
## Person has-a pet of some kind
self.pet = None
## ?? Employee is-a object
class Employee(Person):
def __init__(self, name, salary):
## ?? hmm what is this strange magic?
super(Employee, self).__init__(name)
## ?? Employee has-a salary
self.salary = salary
## ?? Fish is-a object
class Fish(object):
pass
## ?? Salmon is-a object, type of a fish
class Salmon(Fish):
pass
## ?? Halibut is-a object, type of a fish
class Halibut(Fish):
pass
## rover is-a Dog
rover = Dog("Rover")
## ?? satan is-a Cat
satan = Cat("Satan")
## ?? mary is-a person
mary = Person("Mary")
## ?? mary has-a pet called satan
mary.pet = satan
## ?? frank is-a Employee on 120000 salary
frank = Employee("Frank", 120000)
## ?? frank has-a pet called rover
frank.pet = rover
## ?? flipper is Fish
flipper = Fish()
## ?? crouse is-a Salmon
crouse = Salmon()
## ?? harry is-a Halibut
harry = Halibut()
</code></pre>
| python | [7] |
1,103,764 | 1,103,765 | Code to detect all words that start with a capital letter in a string | <p>I'm writing out a small snippet that grabs all letters that start with a capital letter in python . Here's my code </p>
<pre><code>def WordSplitter(n):
list1=[]
words=n.split()
print words
#print all([word[0].isupper() for word in words])
if ([word[0].isupper() for word in words]):
list1.append(word)
print list1
WordSplitter("Hello How Are You")
</code></pre>
<p>Now when I run the above code. Im expecting that list will contain all the elements, from the string , since all of the words in it start with a capital letter.
But here's my output:</p>
<pre><code>@ubuntu:~/py-scripts$ python wordsplit.py
['Hello', 'How', 'Are', 'You']
['You']# Im expecting this list to contain all words that start with a capital letter
</code></pre>
| python | [7] |
433,860 | 433,861 | jQuery Object Not able to find the class | <p>I am not sure why but jQuery find function is not able to find the class using the class name. </p>
<p>Here is the result from Visual Studio immediate window which shows that there is a class called TBLCONTENTS but when searched using the find method it returns nothing.</p>
<pre><code>optionRows[0].className
"TBLCONTENTS"
optionRows.find(".TBLCONTENTS")
{...}
context: {object}
jquery: "1.7.1"
length: 0
prevObject: {...}
selector: ".TBLCONTENTS"
</code></pre>
<p>Can I remove rows based on the filter: </p>
<pre><code>$(optionRows).filter(".TBLCONTENTS").not(":first").remove();
</code></pre>
| jquery | [5] |
537,532 | 537,533 | How the instantiation is happening in this java code snippet | <p>my code is</p>
<pre><code>class Alpha
{
public void foo()
{
System.out.print("Alpha ");
}
}
class Beta extends Alpha
{
public void foo()
{
System.out.print("Beta ");
}
public static void main(String[]args)
{
Alpha a = new Beta();
Beta b = (Beta)a;
a.foo();
b.foo();
}
}
</code></pre>
<p>Output:-</p>
<pre><code>Beta Beta
</code></pre>
<p>i am new to java and this kind of instantiation i have come across for the first time and thats why i am not able to understand why the output is not </p>
<pre><code>Alpha Beta
</code></pre>
<p>if 'a' is the object of class Alpha then why not Alpha's method is being called?</p>
<p>Please help me out.</p>
| java | [1] |
4,867,757 | 4,867,758 | multiple HashMap implementation | <p>I am trying to implement the use of two HashMaps and it seems to be more or less successful also.But now my problem is i want to update the value of a hashMap based on a check.ie if userId is already existing in the hash i need to update the timestamp corresponding to it...</p>
<p>Below given is my code.How can we accomplish the updation of values .Can that be done usiong setValue..?but how..?please help me friends..</p>
<pre><code>public static void main(String[] args)
{
HashMap sessionTimeStampHash = new HashMap<Long, Long>(); //sessionID is the key and timeStamp is the value
//userID is the key and sessionTimeStampHash object is the value
HashMap<String, HashMap<Long, Long>> userSessionHash = new HashMap<String, HashMap<Long, Long>>();
sessionTimeStampHash.put("sessionID", "timeStamp");
userSessionHash.put("userID", sessionTimeStampHash);
// System.out.println(userSessionHash);
sessionTimeStampHash = new HashMap();
sessionTimeStampHash.put("sessionID1", "timeStamp1");
userSessionHash.put("userID1", sessionTimeStampHash);
// System.out.println(userSessionHash);
sessionTimeStampHash = new HashMap();
sessionTimeStampHash.put("sessionID2", "timeStamp2");
userSessionHash.put("userID2", sessionTimeStampHash);
// System.out.println(userSessionHash);
sessionTimeStampHash = new HashMap();
sessionTimeStampHash.put("sessionID3", "timeStamp3");
userSessionHash.put("userID3", sessionTimeStampHash);
// System.out.println(userSessionHash);
for (Entry<String, HashMap<Long, Long>> entry : userSessionHash.entrySet())
{
String key = entry.getKey();
System.out.println(key);
System.out.println(entry.getValue());
String userId = "userID3";
if (key.equals(userId))
{
System.out.println("Check Successful");
String TimeStamp = newTime;
entry.setValue() // how can i change my timeStamp
}
}
}
</code></pre>
| java | [1] |
2,684,432 | 2,684,433 | Set up variables in a file instead of in a class JAVA | <p>im not sure if the title is correct but currently i have :</p>
<pre><code>private String destinationPDF = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/pdf/";
public static String destination ="D:/Documents/NetBeansProjects/printing~subversion/fileupload/Uploaded/";
public String fileList = "D:/Documents/NetBeansProjects/printing~subversion/fileupload/web/resources/Directory Files/directoryFiles.txt";
</code></pre>
<p>These are defined in the class, across 2 class actually, but this is not a perfect situation for me, i want to know is there a way to store the locations in a txt for example and access that ?</p>
| java | [1] |
397,466 | 397,467 | "unassigned local variable 'mylist' error" given loop containing initiatization will be entered once? And how to make the code recursive? | <pre><code>List<string> Getlist()
{
List<string> mylist;
for (bool successFlag = false; !successFlag; ) //It will definitely enter the loop once.
{
successFlag = true;
mylist = new List<string>();
for (int i = 0; i < n; i++)
{
var CDF = GetCDF(); // IEnumerable, each call of GetCDF() gives different result
if (!CDF.Any())
{
fail++;
successFlag = false;
break;
}
string item = GetNext(CDF);
mylist.Add(item);
}
}
return mylist; // Here IDE poses an error
}
</code></pre>
<p>I guess there is a way to recursively use <code>Getlist()</code> instead of do a <code>for</code> loop and <code>flag</code> retry, maybe some kind of immutable method?</p>
<p>i dont wanna initiate the list outside the loop because i would like to discard the list when <code>successFlag</code> is <code>false</code>;</p>
<p>Discard simply means when <code>successFlag = false</code>, then <code>mylist.removeall</code>. And then start everything over again as fresh, so I am asking for an approach to recursively call <code>GetList()</code> instead of clear the states in the method</p>
<p><strong>Update</strong></p>
<p><code>do while</code> works!</p>
| c# | [0] |
4,797,659 | 4,797,660 | Android autostart functionality | <p>I am working on one application which basically is an auto start application and runs in background.</p>
<p>The Problem is i need to access shared preference before auto start. But if device is not properly booted up how can i access the shared preference.</p>
<p><strong>I want that either if device is completely booted then start my service or i can set any wait to my service to start..</strong>.</p>
<p>Pls help me in this case..</p>
<p>Thanks in advance.</p>
| android | [4] |
1,863,450 | 1,863,451 | problem in creating thumb picture in php | <p>I am using following function to create thumb picture in php</p>
<pre><code>function createThumbnail($img,$imgPath,$newPath,$newWidth,$newHeight,$quality)
{
$path=$imgPath."/".$img;
echo $path;
$original = imagecreatefromjpeg($path);
if($original)
{
echo "occur1";
list($width, $height, $type, $attr) = getimagesize("$imgPath/$img");
$tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image");
imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height) or die("Cant resize copy");
imagejpeg($tempImg, "$newPath/$img", $quality) or die("Cant save image");
// Clean up.
imagedestroy($original);
imagedestroy($tempImg);
return true;
}
else
{
echo "oc";
return false;
}
}
</code></pre>
<p>when calling this function it showing black screen.i am displaying echo statement before and after</p>
<pre><code>$original = imagecreatefromjpeg($path);
</code></pre>
<p>it shows only first echo statement second echo statement not displaying.What is the problem.</p>
| php | [2] |
2,513,794 | 2,513,795 | Running back ground action | <p>I need some thing like sending SMS to inactive users. If some user is inactive for 36hrs he much get a text saying <code>you are away from this site</code> To do this how an ASP.NET page fires the query for every 3 minutes to check for the new user's inactivity in database.</p>
<p>I have a code to perform the query. I need how in ASP.NET to run query for every 3 minutes without opening browser. Do ASCX file does my work? or should I use something else.</p>
| asp.net | [9] |
4,708,574 | 4,708,575 | How to get Activity's content view? | <p>Tell me, what method should I call to get know if Activity has it's contentView, I mean method <strong>setContentView()</strong> has been done?</p>
| android | [4] |
3,865,006 | 3,865,007 | Java subtract two dates in this format | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/453388/calculating-difference-in-dates-in-java">Calculating difference in dates in Java</a><br>
<a href="http://stackoverflow.com/questions/3526485/how-do-you-subtract-dates-in-java">How do you subtract Dates in Java?</a> </p>
</blockquote>
<p>I am parsing two dates from a string that look like:</p>
<pre><code>Oct 15, 2012 1:07:13 PM
Oct 23, 2012 03:43:34 PM
</code></pre>
<p>What I need to do is find the difference between these two dates, ex:</p>
<pre><code>Oct 23, 2012 03:43:34 PM - Oct 15, 2012 1:07:13 PM
</code></pre>
<p>= 8 days 2 hours 36 minutes 21 seconds</p>
<p>^ This is what I need to get with the two date/times I have</p>
<p>I believe I need to parse the format and convert it to another format, then subtract the difference between and do the math to get the days/hours/minutes/seconds between</p>
| java | [1] |
5,767,462 | 5,767,463 | jQuery loses formatting | <p>I am new to jQuery and trying to inject the HTML content of one <code><div></code> into another <code><div></code>.
This is the code I'm using:</p>
<pre><code><div class="relatedItems"> </div>
<script>
jQuery.noConflict();
jQuery(document).ready(function() {
var related = jQuery("div.itemRelated").html();
jQuery("div.relatedItems").html("<div class='itemRelated'>" + related + "</div>");
});
</script>
</code></pre>
<p>The problem is that the injected HTML is not formatted the same way as the original.</p>
<p>I would love to post an image but can't because I'm a new user</p>
<p>Any ideas if I'm missing anything?</p>
| jquery | [5] |
2,600,661 | 2,600,662 | Browse button does not appear in IE(jquery.uploadify.v2.1.4.js) multiple file uploads | <p>i am using "jquery.uploadify.v2.1.4.js" for multiple file upload,</p>
<p>It works fine in all browsers , but browse button does not appear in IE8</p>
<p>please tell me any suggestions</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.