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 |
|---|---|---|---|---|---|
160,857 | 160,858 | C++ -using file scope static function | <p>I expected that GetStudent() function returns unique instance of Student. As I expected, that function returns unique instance of Student Class. I double checked the memory address returned by GetStudent() function. But very strange thing was that Student's constructor called every time when I called GetSutent() function. The code like below. The programming enviroment was VC6.0 & MFC project.</p>
<pre><code> //someApp.h
Student& GetStudent();
//someApp.cpp
Student& GetStudent()
{
static Student _student;
return _student;
}
//client1Class.cpp
#include "someApp.h"
void CCliend1Class::DoSomething()
{
GetStudent().DoSomething();
}
//client2Class.cpp
#include "someApp.h"
void CClient2Class::DoSomething()
{
GetStudent().DoSomething();
}
</code></pre>
| c++ | [6] |
4,585,923 | 4,585,924 | Objects as default values in c++ | <p>is there a way to have a default Object for parameters in C++ functions? I tried</p>
<pre><code>void func(SomeClass param = new SomeClass(4));
</code></pre>
<p>and it worked. However how would I am I supposed to know wheter I have to free the allocated memory in the end? I would like to do the same without pointers, just an Object on the stack. is that possible?</p>
| c++ | [6] |
2,063,992 | 2,063,993 | how can i remove parent if click its child | <p>how can i remove an ul if I click one of its children which inside of it? i know this ul .remove not true and How can I set color of "projects" as red? I have to use .find()</p>
<pre><code><ul class="w1m">
<li>
<div>
<img src="img/minus.png" onclick="$(this ul).remove();"/>
<img src="img/link.png"/>
</div>
<div>
inspiration
</div>
</li>
</ul>
<ul class="w1m">
<li>
<div>
<img src="img/minus.png" onclick="$(this ul).remove();"/>
<img src="img/link.png"/>
</div>
<div>
projects
</div>
</li>
<ul>
<li><div><img src="img/minus.png"/><img src="img/link.png"/></div> <div>job board website</div></li>
<li><div><img src="img/minus.png"/><img src="img/link.png"/></div> <div>shopping cart</div></li>
</ul></ul>
</code></pre>
| jquery | [5] |
1,417,012 | 1,417,013 | php code md5 hashing explanation | <p>I am working with the moodle system, but it turns out that it uses md5 salt hashing. I found some come, so maybe you could explaint it to me because I am have only basic knowledge of php.</p>
<pre><code>function validate_internal_user_password($user, $password) {
global $CFG;
if (!isset($CFG->passwordsaltmain)) {
$CFG->passwordsaltmain = '';
}
$validated = false;
if ($user->password === 'not cached') {
// internal password is not used at all, it can not validate
} else if ($user->password === md5($password.$CFG->passwordsaltmain)
or $user->password === md5($password)
or $user->password === md5(addslashes($password).$CFG->passwordsaltmain)
or $user->password === md5(addslashes($password))) {
// note: we are intentionally using the addslashes() here because we
// need to accept old password hashes of passwords with magic quotes
$validated = true;
} else {
for ($i=1; $i<=20; $i++) { //20 alternative salts should be enough, right?
$alt = 'passwordsaltalt'.$i;
if (!empty($CFG->$alt)) {
if ($user->password === md5($password.$CFG->$alt) or $user->password === md5(addslashes($password).$CFG->$alt)) {
$validated = true;
break;
}
}
}
}
if ($validated) {
// force update of password hash using latest main password salt and encoding if needed
update_internal_user_password($user, $password);
}
return $validated;
</code></pre>
<p>}</p>
<p>Would it be hard to change it that after entering simple text it would became hashed?</p>
| php | [2] |
335,381 | 335,382 | Remote service , start remote serivce (on diffrent apk) | <p>I am in the scope of a <code>RemoteService</code> on an APK, and I want to start another <code>RemoteService</code> which is on different APK. I can only know its service name at runtime.</p>
<p>How would I achieve that?</p>
| android | [4] |
178,343 | 178,344 | PHP Multidimensional Look for key=>value and return key? | <p>I am trying to do a search of a multidimensional array in order to append stuff to specific elements. I got a function that does a search and returns the specific part of that array, but I need the key so I can do <code>$array[key]</code> edits.</p>
<p>Function to get array</p>
<pre><code>function arraySearch($array, $key, $value)
{
$results = array();
if (is_array($array))
{
if (isset($array[$key]) && $array[$key] == $value)
$results[] = $array;
foreach ($array as $subarray)
$results = array_merge($results, arraySearch($subarray, $key, $value));
}
return $results;
}
</code></pre>
<p>I don't really know how to edit this to get the key from the array.</p>
| php | [2] |
1,718,773 | 1,718,774 | how to make a specific text on TextView BOLD | <p>i'm facing a bit of difficulty right now.
I don't know how to make a specific text on TextView became BOLD.</p>
<p>its like this</p>
<p>txtResult.setText(id+" "+name);</p>
<p>I want the output to be like this = <strong>1111</strong> neil</p>
<p>"id" and "name" are variable that i have retrieve the value from database, and I want to make the id to bold, but only the id so the name will not affected, I have no idea how to do this.</p>
<p>pardon me, i just recently started to learn android </p>
| android | [4] |
821,690 | 821,691 | accessing objects, static variables in PHP | <p>Here's my code:</p>
<pre><code>class Photograph extends DatabaseObject {
protected static $table_name="photographs";
protected static $db_fields=array('id', 'filename', 'type', 'size', 'caption','album_id');
public $id;
public $filename;
public $type;
public $size;
public $caption;
//public $album_id;
protected static $album_id;
private $temp_path;
protected $upload_dir="images";
</code></pre>
<p>Now, when I use this function below on another page like '$photos = Photograph::find_by_album();' </p>
<p>I get an sql error that says: 'Database query failed: 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 '=' at line 1'</p>
<pre><code>public static function find_by_album($album_id='')
{
return self::find_by_sql("SELECT * FROM ".self::$table_name."WHERE album_id = ".self::$album_id."");
}
</code></pre>
<p>Basically, what I would to happen is to get all values saved in the database from the $table_name where $album_id entered by the user is equivalent to the album_id found in the database. You may find this problem simple, but unfortunately, I am not able to find a solution. Any ideas please? Thanks in advance. :) </p>
<p>EDIT:</p>
<p>Following Mr. Elias Ootegem,</p>
<p>I have modified the code and it now looks like </p>
<pre><code>public static function find_by_album($album_id='')
{ return self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE album_id = ".$album_id."");
}
</code></pre>
<p>However, I still get the same error. I tried using this code: </p>
<pre><code>public static function find_by_album()
{ return self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE album_id = ".$album_id."");
}
</code></pre>
<p>Now another error comes up which says: Undefined variable: album_id </p>
<p>Any other ideas?</p>
| php | [2] |
5,875,737 | 5,875,738 | SkaDate admin panel lock | <p>I have installed <strong>SkaDate</strong>, but it's creating <code>auth.php</code> creating error. I am getting the error: </p>
<blockquote>
<p>bruce attack account is locked.</p>
</blockquote>
<p>Its having auth.php file for validating login details.
Although in MySQL database value for admin username and password same I enter then also getting this error.<br>
SkaDate is a dating software package.</p>
| php | [2] |
5,687,868 | 5,687,869 | I used follwing code for downloadingxml file from ftp in android it is giving exception? | <p>Hi Everyone,
I'm new to android, I used code from this site <a href="http://www.devx.com/wireless/Article/39810/1954" rel="nofollow">http://www.devx.com/wireless/Article/39810/1954</a> it is throwing exception while establishing connection with ftp please help me.</p>
<p>Thank You,</p>
| android | [4] |
5,991,403 | 5,991,404 | Launching an external Java class after a particular condition | <p>I have two java class files, say A and B. Is there any way I can run B from A (this is because I want to check some condition in A and when satisfied run B)?</p>
| java | [1] |
1,391,064 | 1,391,065 | Applicaion_Error event in Global.asax | <p>Application_Error is not firing after publishing web site i had also made custom error mode in the web config off and remote only i had also put the following code in the Application_Error Event</p>
<pre><code>var error = Server.GetLastError();
var code = (error is HttpException) ? (error as HttpException).GetHttpCode() : 500;
if (code != 404 || code!=301 ||code!=302 )
{
System.Web.HttpApplication app = (System.Web.HttpApplication)sender;
string requestedUrl = app.Request.Path.ToLower();
RequestUrls = requestedUrl;
string realUrl = GetRealUrl(requestedUrl.ToLower());
Server.ClearError();
if (!String.IsNullOrEmpty(realUrl))
Response.RedirectPermanent(realUrl,true);
}
</code></pre>
| asp.net | [9] |
2,693,074 | 2,693,075 | jQuery: How to get $(body)[0].scrollHeight with dynamic content? | <pre class="lang-js prettyprint-override"><code>$("#toggle").click(function() {
$("p").toggle(function() {
// $('body')[0].scrollHeight <-- this is it, but not in my case
});
});
</code></pre>
<pre class="lang-html prettyprint-override"><code><a id="toggle">Toggle</a>
<p>content</p>
<p>...</p>
...a hundred more <p>'s that enough to make the scrollbar appear...
<p>...</p>
</code></pre>
<p>I'm trying to get the scrollHeight when the page content is dynamically changed.</p>
<p>The reason I don't want to use the method in the comment line is because I have other events depending on this dynamic scrollHeight, and I don't really want to write the same thing on every single click.</p>
<p>I'm looking for something like</p>
<pre class="lang-js prettyprint-override"><code>$('window').scrollHeightChanged(function() {
// do this
// do that
});
</code></pre>
<p>but not</p>
<pre class="lang-js prettyprint-override"><code>setInterval(function() {
// check scrollHeight
}, 10);
</code></pre>
<p>by the way, I'v tried $('#wrapper').resize(), it only works in IE</p>
<h1>UPDATE</h1>
<p>I found myself a solution: the jQuery resize event plugin, which made resize() work on all elements. It's not exactly what I was looking for, but at least it detects element size change. <a href="http://benalman.com/projects/jquery-resize-plugin/" rel="nofollow">http://benalman.com/projects/jquery-resize-plugin/</a></p>
| jquery | [5] |
2,653,809 | 2,653,810 | simple jquery question | <p>I have the following HTML.</p>
<pre><code><input type="text" class="embeddedLabel" />
</code></pre>
<p>And I wish to tie a function to the focus event of the textbox with...</p>
<pre><code>$(document).ready(function(){
$(input[@class = 'embeddedLabel'].focus(function(){
alert('embeddedLabel textbox found');
});
};
</code></pre>
<p>However, I can't make this work. The alert never fires when I click in the textbox. Is it obvious to anyone what the issue is here?</p>
| javascript | [3] |
2,920,744 | 2,920,745 | c++ getline() function | <p>I dont' quite understand how this function works.</p>
<p>I wrote a simple programming reading one line with getline().</p>
<p>for example:</p>
<pre><code>ifstream in;
in.open("example.txt");
string line;
getline(in, line);
cout << line << endl;
</code></pre>
<p>When I tried to run this program I received an error message like this.</p>
<pre><code>`assign1_2.cpp:33:20: error: cannot convert 'std::string {aka std::basic_string<char>}' to 'const char*' for argument '1' to 'int atoi(const char*)'
</code></pre>
<p>I simply don't understand what went wrong here. Please help!. I am a newbie to c++. </p>
| c++ | [6] |
2,686,302 | 2,686,303 | Compile pyme for Python 2.6 | <p>Has anyone been able to compile pyme (<a href="http://sourceforge.net/projects/pyme/" rel="nofollow">http://sourceforge.net/projects/pyme/</a>)</p>
<p>I installed mingw32 and I can compile other modules like pycrypto without issues, but pyme is proving to be a real pain in the you know what :-)</p>
| python | [7] |
5,094,704 | 5,094,705 | replacing bad code for googles alarm source code | <p>I am getting an error at this point and I don't know what I would change it with</p>
<pre><code>FrameLayout content = (FrameLayout) getWindow().getDecorView()
.findViewById(com.android.internal.R.id.content);
</code></pre>
<p>I am making an Alarm app with google's source code and I am getting an error with it. </p>
| android | [4] |
5,178,768 | 5,178,769 | File Not Found exception thrown when the file is there? | <p>I can see the image file there? so why is it thrown an exception, I have trebled checked, tried different images and folders but no luck they all throw an file not found exception.</p>
<p>Any info welcome please.</p>
<pre><code>File file = new File(Environment.getExternalStorageDirectory()+"/127437025-picsay.jpg");
</code></pre>
| android | [4] |
3,725,130 | 3,725,131 | GridView onTouch | <p>I am trying to set up a GridView of buttons that responds to onTouch. For example, if I swipe my finger across the screen horizontally, vertically or diagonally then I want the buttons which were touched to be selected. I tried setting OnTouchListener's for the buttons, but this didn't work, only the first button in the drag event received the onTouch events. </p>
<p>Next I tried creating an OnTouchListener for the GridView and then using the X,Y coords to determine which buttons where touched. This doesn't seem to work either since the MOTION_DOWN events are only passed to the GridView's onTouch() if I start the drag on the very edge of the GridView. In fact if I drag my finger horizontally across the grid, the onTouch events aren't fired at all unless I start the drag at the edge of the GridView. Does anyone know of a better way to do this?</p>
<p>Thanks in advance.</p>
<pre><code>gridview.setOnTouchListener(new View.OnTouchListener()
{
@Override
public boolean onTouch(@SuppressWarnings("unused") View view, MotionEvent event)
{
float X = event.getX();
float Y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
System.out.println("Down: " + X + "," + Y);
break;
case MotionEvent.ACTION_MOVE:
System.out.println("Move: " + X + "," + Y);
break;
case MotionEvent.ACTION_UP:
System.out.println("Up: " + X + "," + Y);
break;
}
return true;
}
}
</code></pre>
| android | [4] |
1,744,679 | 1,744,680 | Retreiving one element from jQuery each function | <p>basically I am parsing a xml file and retreving certain elements from that xml file using the each function. However I now need to just return the first value, not 'each' value. If anyone could help it would be awesome.</p>
<p>Code so far:</p>
<pre><code>// basic ajax call to retrieve xml file - then on success sent over to checkNotDate function
$('#notifyBox').empty();
$.ajax ({
type: "GET",
url: "anyFeed.xml",
datatype: "xml",
success: checkNoteDate
});
// parse xml and display in alert
function checkNoteDate (xml) {
$(xml).find("entry").each(function()
{
var $item = $(this);
var title = $item.find("title").text();
var link = $item.find("link").attr("href");
var output = "<a href=\"" + link + "\" target=\"_self\">" + title + "<\/a>" + "<br />";
alert(output);
});
}
</code></pre>
<p>So all I need to do is just get the first value and save to a var.
thanks in advance</p>
| jquery | [5] |
3,543,506 | 3,543,507 | Programatically show tooltip after an ajax call | <p>I'm wondering if anyone is aware of a plugin or a tutorial on how to trigger a tooltip after an ajax call. At the moment I'm using <a href="http://flowplayer.org/tools/demos/tooltip/any-html.html" rel="nofollow">jQuery Tools</a> to create the tooltips. But I don't want the tooltips to trigger on a mouseOver event; rather, I want them to show after an ajax call. I can't find any documentation or examples on how to achieve this. For example:</p>
<pre><code><a class="vote">Vote</a>
<div id="tooltip">
Some tooltip with a message.
</div>
$.ajax({
context: this,
dataType: 'json',
success: function(response) {
if (response.result == "success") {
// SHOW TOOL TIP HERE
}
else {
// SHOW ANOTHER TOOL TIP HERE
}
});
</code></pre>
<p>The way jQuery Tools works is by simply binding the element to the tool tip as such: (but this causes the tooltip to open on mouseOver)</p>
<pre><code>$("#myElement").tooltip();
</code></pre>
<p>There is an API with events included in jQuery tools, but I have no clue how to only show the tooltip after the Ajax! Another complicating factor is the I need to have the same tooltip (or multiple tooltips) appear on multiple elements.</p>
| jquery | [5] |
565,255 | 565,256 | Convert.ToInt32(x) the same as (int)x | <p>If x is a value then are the following just syntactically different but effectively the same? Is the second a shortcut for the first?</p>
<pre><code>Convert.ToInt32(x);
(int)x;
</code></pre>
<p>Or can one be used in some circumstances over and above the other? </p>
<p>Looking in <a href="http://msdn.microsoft.com/en-us/library/sf1aw27b.aspx" rel="nofollow">MSDN</a> it seems that the first is doing something different to the second.</p>
| c# | [0] |
3,263,587 | 3,263,588 | applicationWillTerminate gets called in 4.3 | <p>I hv updated SDK and iOS to 4.3. But when i quit my app(press Home button), applicationDidEnterBackground and applicationWillTerminate methods are called.</p>
<p>in 4.2, this problem did not exist - only applicationDidEnterBackground was called.
What could be the possible problem? and solution, if any?</p>
| iphone | [8] |
6,033,175 | 6,033,176 | How to read all the objects in a ArrayList? | <p>I have a ArrayList of Clients, can someone please tell me how to write a loop and get each client in the arraylist</p>
<pre><code>List<Client> Clients = new ArrayList<Client>();
</code></pre>
| java | [1] |
3,686,575 | 3,686,576 | How to manually click a Jquery multiselect box? | <p>I have a few multi select boxes on a page. When the user clicks a certain checkbox, I would like one of the multiselect boxes on the page to automatically be clicked with a certain value. Do you have any idea of how to do this?</p>
<p>Thank you!</p>
<pre><code>$("#select_country").multiselect({
multiple: false,
header: "Select a country",
noneSelectedText: "Select a country",
selectedList: 1
});
</code></pre>
<p>======
so far I've tried these methods with no success:</p>
<pre><code>$("#select_country").multiselect("widget").find("input:checkbox").each(function(){
this.click();
});
$("#select_country").multiselect("widget").find("input:checkbox").triggerHandler('click');
$("#select_country").trigger('click');
</code></pre>
| jquery | [5] |
2,198,813 | 2,198,814 | What is the type of parameter, and what does this function do? | <p>I am having trouble with the code below:</p>
<pre><code>def myprogram(x):
if x == []:
return x
else:
return myprogram(x[1:]) + [ x[0] ]
</code></pre>
<p>What is the parameter type <code>(x)</code>?
What does this function do?</p>
<p>I'm supposed to write code that calls this function with a parameter and find the return value, but i can't do that without understanding what is going on here. any help/feedback would be appreciated.</p>
| python | [7] |
3,615,383 | 3,615,384 | how to integrate the newsstand in app | <p>I would like to integrate new feature of iOS5 NEWSSTAND in my app. But i m get confused how to start. Can anybody help me ? is there any sample code for it ? can anybody know how to implement it in our app.
Thx</p>
| iphone | [8] |
1,177,815 | 1,177,816 | PHP's filter_var() Function Generating Warning | <p>Does any body know why the filter_var() function below is generating the warning? Is there a limit on how many characters can be in a character class?</p>
<pre><code>$regex = "/^[\w\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\072\073\074\075\076\077\100\133\134\135\136\140\173\174\175\176]*$/";
$string = "abc";
if(!filter_var($string, FILTER_VALIDATE_REGEXP, array("options" => array("regexp"=>$regex))))
{
echo "dirty";
}
else
{
echo "clean";
}
</code></pre>
<p>Warning: filter_var() [function.filter-var]: Unknown modifier ':'</p>
| php | [2] |
5,965,530 | 5,965,531 | How to skip arguments when their default is desired | <p>If I have a function like this:</p>
<pre><code>function abc($a,$b,$c = 'foo',$d = 'bar') { ... }
</code></pre>
<p>And I want <code>$c</code> to assume it's default value, but need to set <code>$d</code>, how would I go about making that call in PHP?</p>
| php | [2] |
2,281,073 | 2,281,074 | Multiplying a subset of a list of integers together in python | <p>Let's say I have a list of 10 integers and I want the result of multiplying the first 5 together. Is there a pythonic way of doing this? Python seems to be great with lists :)</p>
| python | [7] |
5,072,994 | 5,072,995 | Convert couple of characters to int | <p>How can I convert couple of characters to int, to keep the question simple let's assume this :</p>
<pre><code>char c1 = '1';
char c2 = '4';
char c3 = '5';
</code></pre>
<p>What would be the efficient way to get <code>145</code> type int.</p>
| java | [1] |
1,038,002 | 1,038,003 | Why does this trigger a force close on Android? | <p>Why does this code trigger a force close in Android?</p>
<pre><code>`score.setText(Integer.parseInt((String) score.getText())+1);`
</code></pre>
<p><code>score</code> is a TextView, and I am simply increasing the number by 1. I have predefined a String resource to be the initial number in the score TextView.</p>
<p>I am quite frustrated.</p>
| android | [4] |
320,389 | 320,390 | getting Python variable name in runtime | <p>This is different from retrieving variable/object name at run time.</p>
<pre><code> 2G_Functions={'2G_1':2G_f1,'2G_2':2G_f2}
3G_Functions={'3G_1':3G_f1,'3G_2':3G_f2}
myFunctionMap=[2G_Functions,3G_Functions]
for i in myFunctionMap:
print i.??? "\n"
for j in i:
print str(j)
</code></pre>
<p>I want the output look like below.</p>
<p>2G_Functions:</p>
<p>2G_1</p>
<p>2G_2</p>
<p>3G_Functions:</p>
<p>3G_1</p>
<p>3G_2</p>
<p>How can I get the name of dictionary variable in my code?I dont know which I am calling in the loop to know its name beforehand.</p>
| python | [7] |
522,799 | 522,800 | Should I upgrade my Galaxy Nexus to 4.1 when I am developing for 4.0? | <p>My question pertains to possible issues that I may encounter if I upgrade to JellyBean. I am currently developing my app to run on Ice Cream Sandwich, but that upgrade notification is starting to annoy me, plus I really want 4.1. But I am still developing the app and still learning android development. Should developers always develop their app on the target API level? Do experienced developers believe I should stick to ICS until I am done? Also, has anyone encountered any quirks when running there apps on Jelly Bean. I appreciate any advice I can get on this matter as it will obviously help me understand best practices in these cases.</p>
| android | [4] |
5,822,394 | 5,822,395 | ListView android recycle() | <p>Am working on a list view that has many small images, however i keep getting an out of memory error have tried to use the recycle method but its not working or may be am implementing it wrongly<br>
please show me a working example on how to use recycle from scratch.
please assist thanks</p>
| android | [4] |
752,510 | 752,511 | Java EE how to start? Am I doing it right? | <p>Ok so lately I've been reading a bit bout Java EE and I'm really hyped up because of it and I'm even thinking about doing it professionally (I'm in my 4th year of university, out of 5, so I need to decide what I want to do I guess). So I was wondering what's the best way to get round to learning it?</p>
<p>I'm getting a Head First JSP/Servlets book next week (huge Head First fan here) and I plan on reading the Sun tutorial simultaneously, as a start. But then what? Should I go with EJB (obviously Head First EJB) or JPA/Hibernate (I was recommended Manning: Java Persistence with Hibernate)?</p>
<p>I know it will depend on the company, but what is the bare minimum an employer would expect from a candidate for a Java EE post?</p>
| java | [1] |
1,955,854 | 1,955,855 | Which is better: Parcelable or Context? | <p>I'm on the situation where I have to share variables between activities... but I have one doubt. Which is better: Parcelable object or set it on a custom Application object.</p>
<p>When something is just going to be used in next activity I just pass it as a Parcelable object, and when it is going to be used in more than one activity, I put it on Application context.</p>
<p>What do you think? Is it right? Which is better in performance?</p>
<p>Thanks!</p>
| android | [4] |
191,747 | 191,748 | whether to use hashmap or Cursor for checking if data available in local database | <p>I have a situation where rows are inserted into the local database after getting response from server while doing synchronization.The composite key is say key1 and key2.As such I have set them as unique constraint.But while doing synchronization second time,I may get same rows once again.So while it tries to insert these rows second time,it fails to insert because of the constraint.To reduce the database interaction I am saving the unique key as "key1-key2" in hashMap and then checking if the record is already contained in local db.As such the contain() method can be used which I guess takes less time for searching for a value(say if the number of records from server is 300)</p>
<p>Do you think that the above solution is perfect or should I loop through the cursor that retrieves key1 and key2 from database.But in this case each time we get a record we have to loop through the cursor(consider we have 300 rows in the cursor).</p>
<p>Which of the above solution should be followed or is there some better solution to this?</p>
<p>Thanks in advance</p>
| android | [4] |
427,375 | 427,376 | what is the meaning of thread status "timed-wait" in eclipse Dalvik Debug Monitor Service (DDMS) | <p>I am running a thread in my App with sleep(1000). Eclipse DDMS shows <strong>my thread status as timed-wait</strong> always. What is the meaning of this?</p>
<p>Thanks</p>
| android | [4] |
3,832,540 | 3,832,541 | JQuery invalid argument post | <p>I have this code:</p>
<pre><code><script type="text/javascript">
var loader = "#loader";
$(function() {
$("#selUsers").change(function() {
if ($(this).val() != "") {
$(loader).show();
$.ajax({
type: "POST",
url: "",
data: {
userID: $(this).val()
},
success: function(msg) {
$("#Firstname").val(msg[0].Firstname || "");
$("#Surname").val(msg[0].Surname || "");
$("#Email").val(msg[0].Email || "");
$("#Phone").val(msg[0].Phone || "");
$("#Mobile").val(msg[0].Mobile || "");
$("#Address").val(msg[0].Address || "");
$("#Zipcode").val(msg[0].Zipcode || "");
$("#City").val(msg[0].City || "");
$(loader).hide();
},
error: function() {
$(loader).hide()
}
});
} else {
$(":input[type=text]").val("");
$("#BookingNotes").val("");
}
});
});
</script>
</code></pre>
<p>And I have included these:</p>
<pre><code><script src="/Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
</code></pre>
<p>And I get invalid argument.... can't see which row of those, since row 127 is a html-tag only..</p>
<p>As I recall this worked before, maybe I have included wrong javascript?</p>
<p>You guys have any clue what might be wrong?</p>
<p>/M</p>
| jquery | [5] |
674,503 | 674,504 | Using database on another development machine | <p>I am developing an ASP.NET website. I wanted to shift whole of my work to another PC of mine. I copied the website to the other PC>Open>Create ASP.NET folder>App_Data</p>
<p>and pasted the database.mdf and database.ldf files there. I was getting some exception when I was trying to run the website as it showed the "could not open the connection from <code>con.open()</code>". Is there some other step too that I am missing?</p>
| asp.net | [9] |
2,938,912 | 2,938,913 | PHP string to array | <p>I have a string that when I var_dump returns the following</p>
<pre><code>string(20) "{\"key1\":\"key1_value",\"key2\":\"key2_value\"}"
</code></pre>
<p>How can I convert that into an array that will return the following when I var_dump?</p>
<pre><code>array(2) { ["key1"]=> string(20) "key1_value" ["key2"]=> string(20) "key2_value" }
</code></pre>
<p>Thanks,<br>
Tee</p>
| php | [2] |
531,149 | 531,150 | How to write simple code in LInq | <p>I have the following in my NotSelectedList. </p>
<pre><code>public List<TestModel> SelectedList = new List<TestModel>();
public List<TestModel>NotSelectedList = new List<TestModel>();
NotificationDetailsModel projects = new NotificationDetailsModel();
projects.ProjectID = Convert.ToInt32(Row["ProjectID"]);
projects.Valid= Convert.ToBoolean(Row["Validity"]);
NotSelectedList.Add(projects);
</code></pre>
<p>How can I write a simple code in LINQ to select from the NotSelectedList where Validity == True and store the data in SelectedList?</p>
| c# | [0] |
4,177,366 | 4,177,367 | Display a list of results with numbers in ASP.NET | <p>I have a common problem in an ASP.NET web form. I'm just surprised that I haven't found a common solution :)</p>
<p>I have a list of results being returned from a SQL Server database. I want to show those results in my web page with number to the left of them. For instance, my result set may look like the following:</p>
<pre><code>New York | NY
Chicago | IL
Los Angeles | CA
</code></pre>
<p>In my web page, I would like to show them as:</p>
<pre><code>1. New York, NY
2. Chicago, IL
3. Los Angeles, CA
</code></pre>
<p>I was surprised that I can't find a way to make the numbers automatically appear. Am i doing something wrong? If not, what is the recommended approach?</p>
<p>Thanks</p>
| asp.net | [9] |
2,428,850 | 2,428,851 | Avoid std::bad_alloc. new should return a NULL pointer | <p>I port a middle-sized application from C to C++. It doesn't deal anywhere with exceptions, and that shouldn't change.</p>
<p>My (wrong!) understanding of C++ was (until I learned it the hard way yesterday) that the (default) new operator returns a NULL pointer in case of an allocation problem. However, that was only true until 1993 (or so). Nowadays, it throws a std::bad_alloc exception.</p>
<p><strong>Is it possible to return to the old behavior without rewriting everything to using std::nothrow on every single call?</strong></p>
| c++ | [6] |
360,469 | 360,470 | Connection String Problem | <p>I am a programmer trying to teach myself C#. I am trying to connect the the <code>Northwind.mdf</code> database in a form. I have used the Database Explorer to attach the database to the form, and the test connection button worked. For the connection string I am using <code>"server=.\\sqlexpress; Trusted_Connection=yes; database=Northwind"</code> This connection fails in <code>SqlDataAdapter dataAdapter = new SqlDataAdapter(selectCommand, connectionString);</code> Google has been no help. Any ideas?</p>
| c# | [0] |
3,327,765 | 3,327,766 | How to auto hide message box? | <p>I want a timer type of property for message boxes. After displaying error, it must disappear without user intervention after 5 seconds.</p>
| c# | [0] |
4,254,028 | 4,254,029 | Activity not starting | <p>I can get the progress dialog to stop, but the TabbedView activity never starts, just goes to a black screen. Any ideas?</p>
<pre><code> class DownloadWebPageTask extends AsyncTask<String, Void, String> {
private final ProgressDialog dialog = new ProgressDialog(MainScreen.this);
@Override
protected void onPreExecute() {
dialog.setMessage("Gathering data for\n"+selectedSportName+".\nPlease wait...");
dialog.show();
}
@Override
protected String doInBackground(String... urls) {
String response = "";
updateMaps();
return response;
}
@Override
protected void onPostExecute(String result) {
dialog.dismiss();
startTabbedViewActivity();
}
}
private void startTabbedViewActivity(){
Intent intent = new Intent(this, TabbedView.class);
intent.putExtra(SPORT_NAME_EXTRA, selectedSportName);
intent.putExtra(HEADLINES_FOR_SPORT_EXTRA, existingSportHeadlines.get(selectedSportName));
intent.putExtra(SCORES_FOR_SPORT_EXTRA, existingSportScores.get(selectedSportName));
intent.putExtra(SCHEDULE_FOR_SPORT_EXTRA, existingSportSchedule.get(selectedSportName));
startActivity(intent);
}
</code></pre>
<p>I have looked over the Manifest file, and I'm not seeing anything weird looking. Can't figure this one out.</p>
| android | [4] |
674,959 | 674,960 | font in iphone sdk? | <p>is it possible to bring another language font in iphone sdk and to insert that font value (for example,chinese) in UILabel value? any help please?</p>
| iphone | [8] |
3,606,217 | 3,606,218 | getting the amount of properties in an object then getting the last one of them in a for loop | <p>This should be very easy but I don't know how to do it.</p>
<p>I have this object:</p>
<pre><code>var obj = eval(result);
</code></pre>
<p>Now I want to know how many properties contains to put it in a loop</p>
<pre><code>var finalAmount = obj.length;
</code></pre>
<p>Now I go for the loop</p>
<pre><code>for (var i in obj) {
--- some other code in here
</code></pre>
<p>Now here the problem I need to do something when the loop reaches the final property of the obj, so this is what Ive tried:</p>
<pre><code>if (i+1 == finalamount){
//do something
} else {
//do something else
}
</code></pre>
<p>so basically using the <code>i</code> as a pointer to compare it to the var that contains how many items there are and when finding the final one of the loop then do something...</p>
| javascript | [3] |
4,440,307 | 4,440,308 | Assign a variable with list() | <p>When we have to return only one value parsed by sscanf / fscanf, should we assign a list of one variable or use optional assigned values?</p>
<p>E.G.</p>
<pre><code>list($number) = fscanf($handle, "%d\n")
</code></pre>
<p>or</p>
<pre><code>fscanf($handle, "%d\n", $number)
</code></pre>
<p>Is there any difference in execution speed of these expressions?</p>
| php | [2] |
320,314 | 320,315 | Wrapping quotes around a php id in XML | <p>I've got this line of code:</p>
<pre><code>$xml_output .= "\t<Event=" . $x . ">\n";
</code></pre>
<p>And it will output:</p>
<pre><code><Event=0>
<Event=1>
<Event=2>
</code></pre>
<p>etc etc through my loop.</p>
<p>I need it to output as this (with the quotes around the number):</p>
<pre><code><Event="0">
<Event="1">
<Event="2">
</code></pre>
<p>Any help, and I'm sure it's simple would be greatly appreciated!</p>
| php | [2] |
316,621 | 316,622 | CONVERT MM/DD/YYYY HH:MI:SS AM/PM to DD/MM/YYYY in C# | <p>How can I convert MM/DD/YYYY HH:MI:SS AM/PM into DD/MM/YYYY using C# ?I am using C#2008.</p>
<p>Thanks</p>
| c# | [0] |
2,110,036 | 2,110,037 | C# doubt in GetType, Managed CodeGen | <p>Consider the code, </p>
<pre><code>Type t0 = Type.GetType("System.Drawing.dll");
Type t1 = Type.GetType("System.Drawing.Font");
</code></pre>
<p>Here in order to find type of "System.Drawing.Font" the assembly "System.Drawing.dll" is needed. how to use it.?</p>
<p>i.e wat if i do, so that value of <strong>t0</strong> wont be null.??</p>
<p>Consider i ave a dll, <strong>proj.dll</strong> and i need to find the type of the class <strong>Class1</strong> that is present in the dll.</p>
| c# | [0] |
2,461,867 | 2,461,868 | Reading data from file into array | <p>I am trying to read specific data from a file into two 2D arrays. The first line of data defines the size of each array so when I fill the first Array i need to skip that line. After skipping the first line, the first array fills with data from the file until the 7th line in the file. The second array is filled with the rest of the data from the file. </p>
<p>Here's a labeled image of my data file:
<img src="http://i.stack.imgur.com/CSU6v.png" alt="enter image description here"></p>
<p>and here's my (flawed) code so far:</p>
<pre><code>#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream inFile;
int FC_Row, FC_Col, EconRow, EconCol, seat;
inFile.open("Airplane.txt");
inFile >> FC_Row >> FC_Col >> EconRow >> EconCol;
int firstClass[FC_Row][FC_Col];
int economyClass[EconRow][EconCol];
// thanks junjanes
for (int a = 0; a < FC_Row; a++)
for (int b = 0; b < FC_Col; b++)
inFile >> firstClass[a][b] ;
for (int c = 0; c < EconRow; c++)
for (int d = 0; d < EconCol; d++)
inFile >> economyClass[c][d] ;
system("PAUSE");
return EXIT_SUCCESS;
}
</code></pre>
<p>Thanks for the input everyone.</p>
| c++ | [6] |
188,832 | 188,833 | Connect PC to Phone | <p>I want to know how to connect my PC to phone.I'm doing an Android Programme and want to run it on my phone.How should I "build and run" it in from the android-eclipse to my samsung P500 phone?</p>
| android | [4] |
3,174,875 | 3,174,876 | request for explaining code on form's reference | <p>How can the lines mark with * in <code>Form2</code> be referred back to <code>Form1</code>?
I mean when <code>Form1</code> is instantiated, it can only be referenced by
the name Form1. But in the lines with *, <code>Form1</code> is used as a type
not a object. However, you can use the m_parent as reference for
<code>Form1</code> in the form called <code>Form2</code>
(I hope someone may get what I was trying to ask.)</p>
<pre><code>public partial class Form2 : Form
{
* private Form1 m_parent;
* public Form2(Form1 frm1)
{
InitializeComponent();
* m_parent = frm1;
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
</code></pre>
| c# | [0] |
3,335,368 | 3,335,369 | How to execute jquery/javascript code inside a .html() of jquery | <p>Inside jQuery.html(), I want to execute the following script.</p>
<pre><code>$("#row1").html("<td id="cellId"><script>if (selectedStr) {var elem = $(\"#cellId\");
$(elem).bind(\"onRefresh\", function() {loadColor(selectedStr); storeStr(selectedStr);});$(elem).trigger(\"onRefresh\");) }</script><td>")
</code></pre>
<p>Requirement:</p>
<p>I had a testPage.jsp which contains table with cells. When a particular cell is selected and "submit" button is clicked, a popup opens. In the popup page, some data is changed and is processed through ajax. The resultant ajax response has to be dynamically set to the parent row. The ajax response builds the whole content that is to be set.This is where I fail.
The Ajax response will be something like this.
<code><td>.....<td></code>
<code><td>.....<td></code>
<code><td>content<script>...</script></td></code>
<code><td>.....<td></code>
<code><td>content<script>...</script></td></code>
...
Moreover the "selectedStr" is a javascript global variable in testPage.jsp.</p>
<p>Problems:
1. "selectedStr is undefined" is the browser error msg. I couldn't get reference to the global variable.
2. The element binding is not happening.</p>
<p>I tried to make use of jQuery.getScript(), jQuery.globalEval, jQuery.eval.
I couldn't understand the {{html}} of JQuery.</p>
<p>Thanks!</p>
| jquery | [5] |
3,863,209 | 3,863,210 | returning the least cost! | <p>Hi
I have written such a code below but it returns wrong output which is not the least value.</p>
<pre><code> private Element heuristic_Function(List<Element> objectList) {
System.out.println(objectList.toString());
Element node =objectList.get(objectList.size() - 1);
double leastValue = objectList.get(0).getGreedy();
System.out.println(leastValue);
for (Element e : objectList) {
if (leastValue > e.getGreedy()) {
leastValue = e.getGreedy();
node = e;
}
}
System.out.println(node.toString());
System.out.println(leastValue);
return node;
}
</code></pre>
<p>I send a list to this method several times but it will return wrong output.</p>
<p>output:</p>
<pre><code>[digit:1 greedy2.87 , digit:2 greedy3.67 ,digit:3 greedy3.24 , digit:4 greedy3.67 ] //System.out.println(objectList.toString());
2.87 //System.out.println(leastValue);
digit:4 greedy3.67 //System.out.println(node.toString());
2.87 //System.out.println(leastValue);
[digit:1 greedy2.87 , digit:2 greedy3.67 , digit:3 greedy3.24 , digit:1 greedy3.67 , digit:2 greedy4.47 , digit:3 greedy4.3500000000000005 ] // System.out.println(objectList.toString());
2.87 //System.out.println(leastValue);
digit:3 greedy4.3500000000000005 //System.out.println(node.toString());
2.87 //System.out.println(leastValue);
</code></pre>
<p>MY question is: why it doesn't return the node which has the least greedy (least value)?
thanks</p>
| java | [1] |
2,674,078 | 2,674,079 | Get_File_contents and MINE TYPE | <pre><code><?php
$file = file_get_contents('http://domain.com/background.gif');
echo $file;
?>
</code></pre>
<p>it echo a very long string(GIF89aÅÕ2cŒ®³¾J}BvUyš±µÁJr•O€d,,,,), not a image, how to fix it?</p>
| php | [2] |
1,835,046 | 1,835,047 | Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster | <p>I've read countless posts on this topic, and tried several solutions but I'm still seeing this error. I'm running iis6, .NET 2.0 on a single server. When clicking a link on my form, and new page is opened that allows the user to enter a bunch of data (it's an order form). When clicking save, I see this error:</p>
<p>"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."</p>
<p>I've verified that the page has finished loading before clicking the save button.</p>
<p>I've tried:</p>
<ul>
<li><p>adding enableViewStateMac="false" to the Page directive</p></li>
<li><p>adding this to the web.config <code><machineKey validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps"
validation="SHA1"/></code></p></li>
<li><p>adding viewStateEncryptionMode="Never"in the page tag in the web.config</p></li>
<li><p>adding enableEventValidation="false" in the page tag in the web.config (which I'm not sure I should do)</p></li>
<li><p>adding renderAllHiddenFieldsAtTopOfForm="false" in the page tag in the web.config</p></li>
</ul>
<p>And I've checked for coding errors, but everything is working fine locally. Does anyone have another suggestions? Thanks</p>
| asp.net | [9] |
4,885,558 | 4,885,559 | jquery - thumbnails fading altogether instead of only the one I have my mouse over | <p>I have a few thumbnails set up to fade on hover and reveal the post metadata. The problem is when I hover over one thumbnail, all of them fade.</p>
<p>You can see what I mean here: <a href="http://jsfiddle.net/LDs6C/10/" rel="nofollow">http://jsfiddle.net/LDs6C/10/</a></p>
<p>How can I make it so only the thumbnail I'm hovering over fades?</p>
| jquery | [5] |
1,095,740 | 1,095,741 | Creating Android vpn profile | <p>I want to Programmatically create vpn profile; somehow i figure out how to access <code>android.net.vpnmanager</code> and <code>android.net.vpn.vpnprofile</code> (they are not part of offical API and are part of hide APIs) but they have no function create new vpn profile. any suggestions?</p>
| android | [4] |
2,356,672 | 2,356,673 | Optimize custom Object Property in Array with Javascript | <p>Look at the 3 lines of code within this Javascript function. Assume that <code>y</code> will always be a <em>String</em>:</p>
<pre><code>function example(x, y) {
var s = {};
s[y] = x;
return s;
}
</code></pre>
<p>Bearing in mind the following:</p>
<ol>
<li>Without wrapping it further within a function</li>
<li>Without using <code>;</code></li>
</ol>
<p>Is it possible to condense the 3 lines of code into one?</p>
| javascript | [3] |
3,915,681 | 3,915,682 | asp.net gridview template column | <p>In my asp.net gridview, I am placing a template column which displays an image.</p>
<p>Inside the template column I added an image control, and it successfully displaying the images from the database. I am also using paging.</p>
<p>Paging also happening but when I do paging images are not coming in the gridview in proper order for example first three pages it diplays suppose a.jpg, b.jpg,c.jpg and when I click on page number it repeats the same picture instead of remaining pictures, i am using <code>if(!ispostback)</code> in the load event also. please help me out.</p>
<p>my code in page load event is:</p>
<p>da = new SqlDataAdapter("select * from t1", con);
ds = new DataSet();
da.Fill(ds);
path = Server.MapPath(@"~\images");
if (!IsPostBack)
{
GridView1.DataSource = ds;
GridView1.DataBind();</p>
<pre><code> ASCIIEncoding asc = new ASCIIEncoding();
int j = GridView1.Rows.Count;
for (int i = 0; i < j; i++)
{
GridViewRow r=GridView1.Rows[i];
b = (byte[])ds.Tables[0].Rows[i]["photo"];
string name = asc.GetString(b);
Image img = (Image)r.FindControl("Image1");
img.ImageUrl = path + @"\" + name;
}
}
</code></pre>
<p>and my code in paging event is</p>
<p>GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = ds;
GridView1.DataBind();
ASCIIEncoding asc = new ASCIIEncoding();
int j = GridView1.Rows.Count;</p>
<pre><code> for (int i = 0; i < j; i++)
{
GridViewRow r=GridView1.Rows[i];
b = (byte[])ds.Tables[0].Rows[i]["photo"];
string name = asc.GetString(b);
Image img = (Image)r.FindControl("Image1");
img.ImageUrl = path + @"\" + name;
}
</code></pre>
<p>thank in advance
sangita</p>
| asp.net | [9] |
2,947,468 | 2,947,469 | Is there any way to make a direct download link for song ? When i do something like this: It opens the website in the browser | <p>when i click on download button it go to the page of website.I upload my song on the <a href="http://picosong.com/cdn/859add1109b307d65e4faa029a9397ee/" rel="nofollow">url</a>.Is there any way to make it on single button click download.plz help me..</p>
| android | [4] |
756,189 | 756,190 | Implementing a nytimes-style "end of article suggestion slider" | <p>I want to implement something like this on my site:</p>
<p><img src="http://cl.ly/0U19060B1A3c03172C1Q/Screen_shot_2011-02-24_at_6.04.54_PM.png" alt=""></p>
<p>The slider should appear when the user scrolls to the end of an article</p>
<p>Is there a jQuery plugin that handles this? <a href="http://imakewebthings.github.com/jquery-waypoints/#documentation" rel="nofollow">jQuery Waypoints</a> looks promising, but I was hoping someone had a more specific solution.</p>
| jquery | [5] |
2,410,389 | 2,410,390 | Request for member X of Y which is of non-class type Z | <p>When trying to compile the following snippet of C++ code (complete source below)</p>
<pre><code>A::A(istream& i) {
vector<string> words( istream_iterator<int>(i), istream_iterator<int> );
words.begin();
}
</code></pre>
<p>I'm getting the error</p>
<pre><code>istream_it.cpp:12: error: request for member ‘begin’ in ‘words’, which is of non-class type
‘std::vector<int, std::allocator<int> >(
std::istream_iterator<int, char, std::char_traits<char>, long int>,
std::istream_iterator<int, char, std::char_traits<char>, long int>)’
</code></pre>
<p>I know this error is usually caused by accidentally declaring a function using the no-parameters operator, as in</p>
<pre><code>string s(); s.size();
</code></pre>
<p>but in this case, I've already stripped all unnecessary code, and still cant see what exactly is going wrong, or what the correct syntax would be.</p>
<p>Full source:</p>
<pre><code>#include <sstream>
#include <vector>
#include <iterator>
#include <string>
using namespace std;
class A {
public:
A(istream& i) {
vector<int> words(istream_iterator<int>(i), istream_iterator<int> );
words.begin();
}
};
int main(int argc, char** argv)
{
istringstream iss("1 2 3");
A a(iss);
return 0;
}
</code></pre>
| c++ | [6] |
1,070,810 | 1,070,811 | Generate random number between 0000 and 9999 | <p>I need to generate a 4 digit number from 0000 to 9999 and I can't seem to do so. I have this code, but it will generate 762 sometime, and I can't let it do that. I do need to use these methods though to generate it. </p>
<pre><code>private java.util.Random rndGenerator = new java.util.Random();
private int randomValue;
public final static int NUMBER_OF_VALUES = 9999;
public GuessRandomValue() {
randomValue = rndGenerator.nextInt(NUMBER_OF_VALUES);
}
public void setAnswer() {
randomValue = rndGenerator.nextInt(NUMBER_OF_VALUES);
}
</code></pre>
| java | [1] |
793,728 | 793,729 | Combine php and html code or not? | <p>I'm very new in php. So i realize from my first steps is this language that we have the opporunity to combine or not php code and html code. Could anyone answer to me, which is the most appropriate way:To combine html and php code or to keep them seperately?and why?</p>
| php | [2] |
4,193,210 | 4,193,211 | implementation of the set | <p>is it possible to find in the net the full implementation of the STL Set, particularly I'm interested in the iterator, thanks in advance</p>
| c++ | [6] |
5,641,815 | 5,641,816 | Test a function on all the values in a list? | <p>I have this list in python:</p>
<pre><code>fileTypesToSearch = ['js','css','htm', 'html']
</code></pre>
<p>and I want to do something like (using pseudo-javascript):</p>
<pre><code>if (fileTypesToSearch.some(function(item){ return fileName.endsWith(item); }))
doStuff();
</code></pre>
<p>What's the neatest way to do this in python? I can't find a <code>some</code> function!</p>
| python | [7] |
5,545,948 | 5,545,949 | How do I change the Text in TabHosts? | <p>I have a tabhost that I am trying to change dynamically, but I cant seem to find a way of
changing it without first clearing all the tabs first.</p>
<p>Any ideas?</p>
<p>Thanks</p>
| android | [4] |
1,224,492 | 1,224,493 | subViews frame when oreiantion changes | <p>in my app i am having many ViewControllers.Most of them have tableViews as subView.Many cells of the tableView have label and textField as subView.When from potrait mode to landscape mode i change,tableView gets resized (i.e width and height of tableView gets adjusted to that of screen).But my labels and textField width wont get changed.Also actionsheets.If i print width and height in landscape it is(320.0,460.0).so how to adjust the size of my subViews when there is change in orientation</p>
| iphone | [8] |
5,175,322 | 5,175,323 | problems with implicit intents | <p>now i am learning intent filters..I got some some example like view contacts,make call.But all in those examples they used default in android.manifestfile..</p>
<pre><code>< intent-filter >
<action android:name="android.intent.action.MAIN" >
<category android:name="android.intent.category.LAUNCHER" >
< /intent-filter>
</code></pre>
<p>this is ok for single .java file application.If i am using implicit intent in my second activity, then how will be the of my second activity manifest file?..just take the examplw of view contact....
Intent contact=new Intent(Intent.ACTION_VIEW,ContactsContract.Contacts.CONTENT_URI);
my class name is ViewContacts.java and package name is com.phone.contact...</p>
| android | [4] |
3,040,738 | 3,040,739 | Is it better to do toString() or cast the Object to String | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/676363/string-or-tostring">(String) or .toString()?</a> </p>
</blockquote>
<p>I have an Object. Is it better to do like this</p>
<pre><code> final String params = myObject.toString();
</code></pre>
<p>or </p>
<pre><code> final String params =(String)myObject;
</code></pre>
| java | [1] |
1,668,288 | 1,668,289 | Does not display the PDF files in listview thumbnail format c# 2008 | <p>im trying to display the PDF files in the listview thumnail like windows explorer. I have not any idea about this.</p>
<p>How to display the pdf files. plz suggest some idea.</p>
<p>thanks in advance.</p>
| c# | [0] |
1,138,986 | 1,138,987 | check if numbers have the same sign | <p>I came across this:
<a href="http://stackoverflow.com/questions/66882/simplest-way-to-check-if-two-integers-have-same-sign">http://stackoverflow.com/questions/66882/simplest-way-to-check-if-two-integers-have-same-sign</a></p>
<p>How can this be extended to more than two numbers (not necessarily integers)? Say, check if 4 numbers have the same sign (+ve or -ve).</p>
<p>I don't want to use bit operations as far as possible ... only logical conditions.</p>
<p>Thanks.</p>
| c++ | [6] |
5,443,668 | 5,443,669 | How to know how many event listeners there are on the page | <p>I am building a fairly large application in Javascript. It is a single page that can change different views. All the views have their own variables, events, listeners, elements, etc.</p>
<p>When working with large collections and multiple events it's sometimes good to know what exactly is happening on the page.</p>
<p>I know all the browsers have developer tools, but sometimes it's hard to click trough all the elements etc. And some options I can not find.</p>
<p>One thing I am interested in is to know how many events there currently listened for on the page. This way I can confirm that I am not creating zombies.</p>
<p>If the sollution is a developer tool, please let me know where to look and what to do. And most important, which browser to choose.</p>
| javascript | [3] |
5,598,755 | 5,598,756 | Is there a C# language construct/framework object to apply a function to each line of a file? | <p>What I'm looking for is something along these lines:</p>
<pre><code>var f = UsefulFileObject(@"c:\temp.log");
f.ForEachLine( (line) => line.Trim() );
</code></pre>
<p>After that I'd expect each line in the file to be trimmed.</p>
<p>Is there such an object in the framework already or should I start making my own one?</p>
| c# | [0] |
639,724 | 639,725 | How to apply css for dynamically adding button inside datalist in asp.net c# | <p>How to apply css for dynamically adding button inside datalist?</p>
<pre><code>List<Button> buttons = new List<Button>();
Button b1 = new Button();
b1.Text = "First";
b1.Attributes.CssStyle["CssClass"] = "button";
buttons.Add(b1);
</code></pre>
| c# | [0] |
5,734,809 | 5,734,810 | Get Alt value from clicked element and fadein div named element alt value | <p>I'm trying to get div id from clicked img alt value and fade in into that div. I'm here because I'm not jQuery master but trying to learn. Here is my code:</p>
<pre><code>$('#div1').bind('click',function(){
var $this = $(this);
var $divid = $this.attr("alt");
$divid.fadeIn(3000);
});
</code></pre>
<p>div sample;</p>
<pre><code><div id="div1" alt="div2"></div>
<div id="div2" style="display:none"></div>
</code></pre>
| jquery | [5] |
2,796,251 | 2,796,252 | how will alternative to Split('sunset.jpg') in PHP shows output? | <p>Please help me to find the answer for the following php code in 5.3.5 and above.</p>
<pre><code>$file_name ="sunset.jpg";
if(isset($file_name))
{
$exts = split("[/\\.]", $file_name) ;
$n = count($exts)-1;
echo $n;
$exts = $exts[$n];
echo $exts;
}
else
{
echo "error";
}
</code></pre>
<p>I know that split() function is deprecated and we have to use preg_split (or) explode instead. But my question here is how should I modify my code to get the output as just 'jpg' only. When I tried to use explode and preg_split I got the result as 'sunset.jpg'.
Help to find the result.</p>
| php | [2] |
2,120,767 | 2,120,768 | Java : Is it possible to know JVM instance used by a web server | <p>I have 4 webservers of a Single Web application running in production .</p>
<p>Is there anyway by which i can know that all of them sharing/using a same JVM ??</p>
<p>Is it possible to know any such information ??</p>
<p>By the way we are using 4 instances of Jetty Web servers for scalability controlled by a Load Balancer in front and JDK 1.6 version .</p>
| java | [1] |
1,194,630 | 1,194,631 | Conditional forms with jQuery (on selecting an <option>, show element) | <p>Riddle me this: How can I use jQuery to display an element ONLY when a specific option is selected in a box? </p>
<p>.click clearly isn't the right event— but i've been hunting around and can't find out to work with form options.</p>
<p>EX:</p>
<pre><code> $('option[name="publish_on"]').click(function(){
$('.secret').fadeIn();
})
</code></pre>
| jquery | [5] |
2,165,986 | 2,165,987 | android - how to make a textview scroll? | <p>Actually im showing some data in a textview but its half of the data is going out of the screen so i need help to make a textview scroll or any other thing that can scroll down the screen.</p>
<p>Any help would be appreciated!</p>
| android | [4] |
5,892,513 | 5,892,514 | When does a class need "New" to instantiate. Why a class does NOT need New? | <p>I am new to Java. One thing confuses me is to why some of the classes need <code>new</code> to instantiate, and why some others do NOT need <code>new</code> to instantiate.</p>
<p>For example, I am looking at log4j, it does not need <code>new</code>. </p>
<pre><code>// get a logger instance named "com.foo"
Logger logger = Logger.getLogger("com.foo");
logger.setLevel(Level.INFO);
</code></pre>
<p>Why do some other classes need new? For example, an Employee class: </p>
<pre><code>Employee X = new Employee (John);
X.getwork();
</code></pre>
<p>etc etc.</p>
<p>Why we did not say , <code>Logger logger = new Logger(...);</code>? and why were we able to use it even without <code>new</code>, like <code>logger.setLevel()</code>, etc.</p>
| java | [1] |
5,735,577 | 5,735,578 | How to login with python and save cookie, then use that info to view page for member only | <p>I am quite new in python and trying to write a script to login to the page at <a href="http://ryushare.com/login.python" rel="nofollow">http://ryushare.com/login.python</a>.</p>
<p>I have try many attempt, but it fails to login and i have no idea why.
After login to the page, I wish to get the return of <a href="http://ryushare.com/file-manager.python" rel="nofollow">http://ryushare.com/file-manager.python</a></p>
<p>Here's the code I try to attempt by reading the example from others.</p>
<pre><code>import urllib, urllib2, cookielib
username = 'myusername'
password = 'mypassword'
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'login' : username, 'password' : password})
opener.open('http://www.ryushare.com/login.python', login_data)
resp = opener.open('http://ryushare.com/file-manager.python')
print resp.read()
</code></pre>
<p>I check the source code of the login page, it said the username and password value is "login and password" so i change it.
I have try some other example which can be found here like google news feed, It also can not able to login : (</p>
| python | [7] |
3,579,435 | 3,579,436 | Android market doesnt show my app | <p>I have released my app in android market under category Travel and Local. My app is visible only when i search with particular keyword.
My app is also not visible in market under more apps from this developer. I dont know why this happening?
Can anyone please give me suggesstion for app to view all in market.</p>
| android | [4] |
4,545,737 | 4,545,738 | Android music files location? | <p>I'm writing a music player app and I'm wondering where should I look for the user's music files. I want to find all the songs that the Music app normally finds and I'm curious how that app finds the songs. Is there an enum variable for a specific folder? Just a recursive search of the sd card? I know on my phone's sd card there's a Music folder; is that how it is on every android device and should I just recursively search that folder? Or should I just ask the user to find the folder?</p>
| android | [4] |
5,137,676 | 5,137,677 | Error when set multi style properties in Javascript | <pre><code><script>
document.getElementById('style').style.color = "FFFF00";
document.getElementById('style').style.fontWeight = "bold";
document.getElementById('style').style.font= "italic bold 20px arial,serif";
</script>
</code></pre>
<p>When i using multi css, code is error, how to fix it in javacript ?</p>
| javascript | [3] |
2,451,247 | 2,451,248 | document.forms.gallery_form.submit is not a function | <p>I swear, I have this exact thing working on another page. I'm such a javascript noob it's embarrassing...</p>
<pre><code>function delete_gallery() {
var gallery = document.getElementById('gallery_id').value;
var form = document.getElementById('gallery_form');
form.setAttribute('action', 'index.php?action=delete&section=galleries&id='+gallery);
document.forms['gallery_form'].submit();
}
</code></pre>
<p>Inspecting the element shows that it's updating the action correctly :</p>
<pre><code><form method="post" action="index.php?action=delete&amp;section=galleries&amp;id=12" name="gallery_form" id="gallery_form"><input type="hidden" value="12" id="gallery_id" name="gallery_id"><p>Name: <input type="text" name="name" value="Woo"></p><p>Description:<br><textarea name="description">Dee</textarea><input type="hidden" value="2" name="artist"></p><p><input type="submit" value="Submit" name="submit">
</p></form>
</code></pre>
<p>Here's the button I use to call the function, it's in a table below the form:</p>
<pre><code><button onclick="delete_gallery()" type="button">Delete Gallery</button>
</code></pre>
<p>EDIT:</p>
<p>I should have mentioned I tried using the getElementById method first, ala forms.submit(); - I had the same error, which is why I switched to using document.forms[] instead.</p>
| javascript | [3] |
536,105 | 536,106 | equality operator, odd results? | <p>I have a question about the following piece of code:</p>
<pre><code>public class Equivalence {
public static void main(String[] args) {
Integer n1 = new Integer(47);
Integer n2 = new Integer(47);
System.out.println(n1 == n2);
System.out.println(n1 != n2);
}
}
</code></pre>
<p>The resulting output surprised me: </p>
<pre><code>false
true
</code></pre>
<p>I have checked the constructor in Javadoc online, nothing help from there.</p>
<p>Thanks in advance</p>
<p>Thank you </p>
| java | [1] |
2,391,247 | 2,391,248 | running different JavaScript based on browser | <p>Canvas clearing gets vastly different perfomance on different browsers. See <a href="http://jsperf.com/canvas-clearing2" rel="nofollow">http://jsperf.com/canvas-clearing2</a> .</p>
<p>I need to clear a canvas every frame and how I do it has a huge impact on mobile safari vs Desktop safari performance. Desktop Safari likes canvas.width = width but mobile safari prefers canvas.drawRect() .</p>
<p>Is there a way to detect what browser is what an run different JavaScript based on it? I would prefer to do this through JavaScript rather than server side.</p>
<p>Also, I've found that jQuery's $.browser doesn't help because it doesn't distinguish between mobile safari and desktop safari. the navigator object has similar problems.</p>
| javascript | [3] |
224,541 | 224,542 | Android: Updating the sent box afer sending an sms | <p>My app sends an sms and I would like to update the phone sent box
as if the sms was sent bu the user.
How can this be done ?</p>
| android | [4] |
2,023,517 | 2,023,518 | Try Catch cannot work with require_once in PHP? | <p>I can't do something like this ?</p>
<pre><code>try {
require_once( '/includes/functions.php' );
}
catch(Exception $e) {
echo "Message : " . $e->getMessage();
echo "Code : " . $e->getCode();
}
</code></pre>
<p>No error is echoed, server returns 500.</p>
| php | [2] |
5,146,709 | 5,146,710 | Why in a try catch finally, the return is always that of finally? | <p>What happens to the <code>return A</code> code in my catch block?</p>
<pre><code>public class TryCatchFinallyTest {
@Test
public void test_FinallyInvocation()
{
String returnString = this.returnString();
assertEquals("B", returnString);
}
String returnString()
{
try
{
throw new RuntimeException("");
}
catch (RuntimeException bogus)
{
System.out.println("A");
return "A";
}
finally
{
System.out.println("B");
return "B";
}
}
}
</code></pre>
| java | [1] |
714,210 | 714,211 | List to unicode conversion python | <p>Unicode conversion.How we convert </p>
<pre><code>[(1, '=', 1)]
</code></pre>
<p>in unicode object in python.</p>
| python | [7] |
1,470,180 | 1,470,181 | How to set a radio button if we know the id of that button in android? | <p>I want to set radio button with the Id of the button I have. How to do that?</p>
| android | [4] |
4,224,452 | 4,224,453 | How do I input one character and one integer to get a triangle answer? | <p>so i came up with this but it only prints in a straight line not triangle, i want it to look like a triangle</p>
<p>this is my code</p>
<pre><code> string character;
int width;
Console.WriteLine("Enter a number");
width = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter a character");
character = Console.ReadLine();
int size = width, i = size;
while (Math.Abs(--i) < size)
Console.WriteLine( character, size - Math.Abs(i));
Console.ReadLine();
</code></pre>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.