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 |
|---|---|---|---|---|---|
5,626,648 | 5,626,649 | Save image path name from sdcard to Sqlite database | <p>am having a little trouble here. i am trying to store and retrieve images from an sqlitedatabase by storing their image path name. the images are stored in the sdcard. I tried this code, but its not working.</p>
<p>saving image path:</p>
<pre><code> String filename = "/sdcard/barn.jpg"
ContentValues vals2 = new ContentValues(); //create content values and store it.
vals.put(ImageDB.SHOW, filename);
imagedb.tagImage(vals2);
public long tagImage(ContentValues val){
Log.d(TAG,"tagged Images");
return db.insert(DATABASE_TABLE, null, val);
}
</code></pre>
<p>retrieving :</p>
<pre><code>Cursor cursor = imagedb.retrieveTag(tag);
/*method for retrieving*/
public Cursor retrieveTag(String tag){
String[] condition = {tag)};
Cursor cursor = db.query(DATABASE_TABLE, condition, null, null, null, null, null);
cursor.moveToNext();
return cursor;
}
</code></pre>
<p>The cursor is not returning anything and i sometimes get a CursorIndexOutofBoundsException.
Is this a correct way to save and retrieve from an sqlitedatabase or does the filename pose a problem for the sqlite database?.. How can i store it correctly?.. Thank you.</p>
| android | [4] |
1,842,987 | 1,842,988 | How to overload the ->* operator? | <p>I tried this, and some variations on it:</p>
<pre><code>template<class T>
class Ptr {
public:
Ptr(T* ptr) : p(ptr) {}
~Ptr() { if(p) delete p; }
template<class Method>
Method operator ->* (Method method)
{
return p->*method;
}
private:
T *p;
};
class Foo {
public:
void foo(int) {}
int bar() { return 3; }
};
int main() {
Ptr<Foo> p(new Foo());
void (Foo::*method)(int) = &Foo::foo;
int (Foo::*method2)() = &Foo::bar;
(p->*method)(5);
(p->*method2)();
return 0;
}
</code></pre>
<p>But it <a href="http://ideone.com/oUJLG">doesn't work</a>. The problem is that I don't really know what to expect as a parameter or what to return. The standard on this is incomprehensible to me, and since Google did not bring up anything helpful I guess I'm not alone.</p>
<p><em>Edit:</em> Another try, with C++0x: <a href="http://ideone.com/lMlyB">http://ideone.com/lMlyB</a></p>
| c++ | [6] |
3,706,815 | 3,706,816 | Specify region codes when writing a dvd using C# | <p>How to specify region codes when writing a dvd using C#</p>
| c# | [0] |
5,961,204 | 5,961,205 | How to add title in the is the ListView in android | <p>How to add title in the is the ListView in android.</p>
<p>Means </p>
<h2>Subject From <--------Title</h2>
<p>hiiiii | Raj <--------List Content<br />
hello | srss</p>
<p>Here I have used</p>
<p>EfficientAdapter extends BaseAdapter .</p>
| android | [4] |
4,173,006 | 4,173,007 | C# - If/Else Help [User and Computer Input Interaction] | <p>I am trying to figure out a way to get the Computer player to respond to my moves basically by seeing "This spot is taken, I should see if another is free and take it".</p>
<p>So far, I'm not making any improvements (been like 5 hours). I want the computer to realize if a certain button (which it chose at random) is taken, it should consider another choice. Not sure where the if/else should actually go or where/what I should put in for it to try another location.</p>
<p>Here's the snippet of code with comments on my idea (likely wrong placement where I want to do things):</p>
<pre><code>if (c.Enabled == true) //if the button is free
{
if ((c.Name == "btn" + Convert.ToString(RandomGenerator.GenRand(1, 9)) )) //if a specific button is free
{
if ((c.Text != "X")) //if its empty
{
//do this
c.Text = "O"; //O will be inside the button
c.Enabled = false; //button can no long be used
CheckComputerWinner(); //check if it finishes task
return;
}
else //if it is an X
{
//try a different button choice instead
//see if that button is empty
//do stuff
//else
//... repeat until all buttons are checked if free
}
}
}
</code></pre>
<p>My question is simply: How can I fix this and understand what is going on? Or do it more efficiently?</p>
| c# | [0] |
2,828,758 | 2,828,759 | how to write new lines in CLI and web browser? | <p>I am running a php script from CLI command and web browser. I need to dispaly new lines properly in both ways so that it does not print <code>"<br />"</code> in CLI and it shows new lines in browsers. Does anyone know how to write php function for this?</p>
<p>thanks for any helps</p>
| php | [2] |
5,282,454 | 5,282,455 | How can I find out if a File is a file or directory if it does not exist? | <p><code>File.isFile()</code> and <code>File.isDirectory()</code> both return false not only when the <code>File</code> is not the specified type, but also when the <code>File</code> itself does not exist on the filesystem. How can I determine whether the <code>File</code> represents a file or a directory when it does not exist?</p>
| java | [1] |
5,292,112 | 5,292,113 | Using Cordova PhoneGap... how to set layout for landscape and Portrait view | <p>here is my code below... is there a way to do a screen orientation and choose to loadUrl index.html for portrait and then maybe land/index.html for landscape. </p>
<pre><code>import org.apache.cordova.*;
public class MainScreen extends DroidGap {
//Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
WebSettings ws = super.appView.getSettings();
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
}
}
</code></pre>
| android | [4] |
2,366,481 | 2,366,482 | compare Long value in java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7672317/integer-int-allowed-in-java">Integer == int allowed in java</a> </p>
</blockquote>
<p>What is the difference between the following two statements</p>
<pre><code>Long l1 = 2L;
if(l1 == 2)
System.out.println("EQUAL");
if(l1.longValue() == 2)
System.out.println("EQUAL");
</code></pre>
<p>They both are giving same result "EQUAL".But my doubt is Long is object. How is it equal?</p>
| java | [1] |
3,530,110 | 3,530,111 | Compare elements of a 2D array | <p>I have all several files that contain the data I collected this data as a two-dimensional array now I must veriefie there is data in the file (file1) and if they redandante in other files :means (i have transforemed my files to array) for example tab [0] [j] with another tab [ i][j] except intersection with him self (i! = 0)
tab[0][0]="a"; tab[0][1]="b"; tab[0][2]="ac"; tab[0][3]="n"; tab[1][0]="g"; tab[1][1]="a";
tab[1][2]="h"; tab[1][3]="b"; tab[2][0]="gdd"; tab[2][1]="a"; tab[2][2]="hd"; tab[2][3]="b";
my program must allow me to compare always tab[0][] with others
I hope that I'm clear this time and thanks for your help</p>
| php | [2] |
3,235,823 | 3,235,824 | ASP.NET Intranet and Internet website | <p>I am designing ASP.NET website for Intranet users. At the end of Phase-I this will be available to Intranet users.</p>
<p>But after Phase-II, the same site needs to be opened to certain users that are outside this office.</p>
<p>Can I can use ASP.NET Membership provider?</p>
<p>Any other design recommendations?</p>
<p>I appreciate your input.</p>
| asp.net | [9] |
1,163,835 | 1,163,836 | Defining a class member with a class type defined later in C++ | <p>Like I would want to do something like this,</p>
<pre><code>class Object {
public:
World * Parent_World; //This here
Object(World * Parent_World=NULL) : Parent_World(Parent_World) {}
};
class World {
public:
Object * Objects = new Object[100];
}
</code></pre>
<p>That doesn't work because of the order.
And I can't just simply define world earlier because I want also to have access to class Object from the World</p>
| c++ | [6] |
2,732,263 | 2,732,264 | C++ sign extension | <p>I am working on a homework problem, printing from a binary file.
I have searched and found out that my problem is a sign extension problem.</p>
<p>In c the correct action would be to cast to an (unsigned char)</p>
<p>I have tried this solution and it does not work with cout</p>
<p>output with (unsigned) is:</p>
<pre><code>4D 5A FFFFFF90 00 03 00 00 00 04 00 00 00 FFFFFFFF FFFFFFFF 00 00
</code></pre>
<p>output with (unsigned char) is:</p>
<pre><code>0M 0Z 0ê 0� 0 0� 0� 0� 0 0� 0� 0� 0ˇ 0ˇ 0� 0�
</code></pre>
<p>Any guidance would be most helpful;</p>
<p>Here is the code:</p>
<pre><code>void ListHex(ifstream &inFile)
{
// declare variables
char buf[NUMCHAR];
unsigned char bchar;
while(!inFile.eof())
{
inFile.read(buf,NUMCHAR);
for (int count = 0; count < inFile.gcount(); ++count)
{
cout << setfill('0') << setw(2) << uppercase << hex <<
(unsigned)buf[count] << ' ';
}
cout << '\n';
}
}
</code></pre>
| c++ | [6] |
3,378,776 | 3,378,777 | comparing string with enumeration | <p>I am analyzing the following piece of code using a static analysis tool called FindBugs.</p>
<pre><code>if(str.equals(enum.SOMEVALUE)) {// do something};
</code></pre>
<p>where str is a String and enum is an enumeration. The tool generates the following warning for this code, and states</p>
<blockquote>
<p>This method calls equals(Object) on two references of different class types with no common subclasses. According to the contract of equals(), objects of different classes should always compare as unequal; therefore, according to the contract defined by java.lang.Object.equals(Object), the result of this comparison will always be false at runtime. </p>
</blockquote>
<p>if I replace the above line of code with this:</p>
<pre><code>if(str.equals(enum.SOMEVALUE.toString())) {// do something};
</code></pre>
<p>then the warning disappears.But I am not sure if the warning that the tool generates is really true and whether I am fixing it the right way ? because I've seen such comparisons before and it appears to be working correctly.</p>
| java | [1] |
5,177,500 | 5,177,501 | PHP get website root absolute URL in server? | <p>I rely heavily in <code>$_SERVER["DOCUMENT_ROOT"]</code> to get absolute paths. However this doesn't work for sites which URLs don't point to the root.</p>
<p>I have sites stored in folders such as:</p>
<ul>
<li>site1</li>
<li>site2</li>
</ul>
<p>all directly inside the root. Is there a way to get the path in the server where the current site root is?</p>
<p>It should return:</p>
<pre><code> /var/chroot/home/content/02/6945202/html/site1 // If the site is stored in folder 'site1'
/var/chroot/home/content/02/6945202/html // If the site is stored in the root
</code></pre>
| php | [2] |
4,180,298 | 4,180,299 | How do I (in ASP.NET) determine if the connection is a remote connection? | <p>I'm trying to implement a bit of functionality that will behave much like the CustomError pages: if the connection is remote function A() will run; else function B() will run. </p>
<p>The only problem I'm having is that I'm not sure the best way to determine a "remote" connection. Does it matter if I'm running my code on a shared web host? Can I rely on just comparing "my" IP to the request's IP?</p>
| asp.net | [9] |
740,614 | 740,615 | Error - the program is not giving output while calling the print method | <p>This is a simple program I created - one table class, one main class. In the table class I created a print method which simply outputs my name. From the main class I am calling the print method but not getting the output.</p>
<pre><code>namespace ConsoleApplication3
{
class table
{
public static void print()
{
Console.WriteLine("My name is prithvi-raj chouhan");
}
}
class Program
{
public static void Main()
{
table t = new table();
t.print(); // Error the program is not giving output while calling the print method
}
}
}
</code></pre>
| c# | [0] |
4,648,340 | 4,648,341 | Check for previous version of application | <p>I want to show a What's New form in my application. However I need to detect whether it's a new install, or an upgrade.</p>
<p>I'm using the following code to upgrade the settings:</p>
<pre><code>if (Properties.Settings.Default.settingsUpgrade)
{
WhatsNew WhatsNew = new WhatsNew();
WhatsNew.Show();
WhatsNew.BringToFront();
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.settingsUpgrade = false;
Properties.Settings.Default.Save();
}
</code></pre>
<p>The <code>Properties.Settings.Default.settingsUpgrade</code> is set to <code>True</code> by default. However this code will bring up the Whats New form always, even with a new installation.</p>
<p>The <code>Properties.Settings.Default.Upgrade();</code> doesn't have an event or something which is fired when the upgrade actually was needed, so I have no idea if there was a previous version (and thus show the Whats New form). How do I know if there was a previous version?</p>
| c# | [0] |
5,403,848 | 5,403,849 | PHP - add item to beginning of associative array | <p>How can I add an item to the beginning of an associative array? For example, say I have an array like this:</p>
<pre><code>$arr = array('key1' => 'value1', 'key2' => 'value2');
</code></pre>
<p>When I add something to it as in <code>$arr['key0'] = 'value0';</code>, I get:</p>
<blockquote><pre>Array
(
[key1] => value1
[key2] => value2
[key0] => value0
)</pre></blockquote>
<p>How do I make that to be</p>
<blockquote><pre>Array
(
[key0] => value0
[key1] => value1
[key2] => value2
)</pre></blockquote>
<p>Thanks,<br>
Tee</p>
| php | [2] |
5,887,200 | 5,887,201 | How do I round to one place but force extra 0 so it looks like normal price? | <p>In JS How do I round to one place but force extra 0 so it looks like normal price?</p>
<p>There are many answers on the topic but what I want to achieve is to get rid of the pennies/cents last digit.
So for example instead of 15.98 I can show 16.00 or instead of 14.49 I can show 14.50.</p>
<p>The below rounds to one place but how do I force to show extra zero?</p>
<pre><code>c = Math.round(c_ft*10,2)/10
form.ans.value=c
</code></pre>
| javascript | [3] |
3,456,544 | 3,456,545 | view terminates when scrolling | <p>my problem is, that if i scroll my table view very fast, the screen freazes. i get the following:
<em>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewControllerWrapperView isEqualToString:]: unrecognized</em>
perhaps someone can help me!
Thx</p>
| iphone | [8] |
2,426,537 | 2,426,538 | How do I find the 1st and 3rd columns from a 3byX grid | <p>I have the following foreach</p>
<pre><code>foreach( $array as $v )
{
if( SOME LOGIC HERE ) $class = "first";
if( SOME LOGIC HERE ) $class2 = "third";
print '<span class="$class $class2">$v["name"]</span>';
}
</code></pre>
<p>I want to set $class1 to be 'third' for every 1st, 4th, 7th, 10th (3n - 2) and $class2 to be set to 'third' for 3rd, 6th, 9th, 12th </p>
| php | [2] |
2,018,503 | 2,018,504 | create a two dimensional array from simple array for csv use | <p>to create a csv file with php, the expected input is a two dimensional array, so as 1 row = 1 internal array.</p>
<pre><code>$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('"aaa"', '"bbb"')
);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
//output result in file.csv
aaa,bbb,ccc,dddd
123,456,789
"""aaa""","""bbb"""
</code></pre>
<p>so i have the following array:</p>
<pre><code>$list = array('item1','item2','item3','item4','item5','item6');
</code></pre>
<p>i need to take this array and break it into smaller arrays within 1 array for the csv. Each small array needs to have '999999' at index 0, followed by the next two items in the <code>$list</code> array. So the final result would be like this:</p>
<pre><code>$newList = array( array(999999, "item1" , "item2"),
array(999999, "item3" , "item4"),
array(999999, "item5" , "item6")
);
</code></pre>
<p>the original list array may contain up to 100 values at sometimes. What is the best way to achieve this?</p>
| php | [2] |
5,627,636 | 5,627,637 | How to sort std::list<..> | <p>i have a list of Elemtents of a custom type:</p>
<pre><code>std::list<CDataTransferElement*> m_list;
</code></pre>
<p>The class is defined like this:</p>
<pre><code> class CDataTransferElement
{
public:
CDataTransferElement(void);
~CDataTransferElement(void);
CString Name;
double PercentValue;
double MOLValue;
int PhaseIndex;
};
</code></pre>
<p>I have x Items in the m_list Object, that have to be sorted by the PhaseIndex Variable in a new Object (what type of ever).
In the end i need x lists of the CDataTransferElement Elements where each list has only Elements with the same PhaseIndex.</p>
<p>How do i do that at best?</p>
<p>regards
camelord </p>
| c++ | [6] |
1,653,342 | 1,653,343 | how to call the array in $$variable | <pre><code>$var = "array";
$$var=array("1","2");
</code></pre>
<p>How can I call the array in <code>$$var</code> without using <code>foreach</code>? I want a method like <code>$$var[0]</code>, but this doesn't work.</p>
| php | [2] |
5,029,477 | 5,029,478 | Display Chinese text in activities | <p>I want to write Chinese text in activities but when i run the program i am getting error.</p>
<p>How to write Chinese text in activities? And We need to import any other files???</p>
| android | [4] |
2,327,210 | 2,327,211 | JQuery Tabs Custom CSS | <p>I need to apply Custom CSS for jquery tabs....
I have two Jquery tab panels on single View...How to apply diffrent CSS for both Tab panels</p>
<p>Css for Selected and hover and default </p>
<p>Please give me suggestion</p>
<p>Thanks
Narasimha</p>
| jquery | [5] |
2,608,120 | 2,608,121 | Need of serialization in Java | <p>Can anyone tell me what is the need of Serialization in Java and an example scenario to explain the need . I dont need the definition .</p>
| java | [1] |
4,133,818 | 4,133,819 | How do i perform an action on click of a particular link available on website? | <p>I have an application in which i have added a menu.</p>
<p>Clicking on this menu opens up a website.</p>
<p>There is a list of links(zip files) available on this website.</p>
<p>Clicking on a particular link should result in that zip file to be downloaded to the assets folder of my application.</p>
<p>I am able to load the website.</p>
<p>Code for this:</p>
<pre><code>String url = "http://almondmendoza.com/android-applications/";
Intent k = new Intent(Intent.ACTION_VIEW);
k.setData(Uri.parse(url));
startActivity(k);
</code></pre>
<p>I am referring to the example given on <a href="http://www.tutorialforandroid.com/2009/04/open-urlwebsite-from-android.html" rel="nofollow">this website</a> </p>
<p>What i am curious to know is that whether it is possible to perform an action on click of a particular link available on website. If it is possible then how can i accomplish this task?</p>
| android | [4] |
2,531,534 | 2,531,535 | jquery to find data-attr where | <p>Using the url of the page I have been able to get the value edc into a variable but what I need to do is find the data-ttl where data-uri is equal to edc.</p>
<p>If PHP this would be easy but I'm unsure how to go about it in jQuery</p>
<blockquote>
<p>domain.com/media-centre/video/edc</p>
</blockquote>
<p><strong>HTML</strong></p>
<pre><code> <li class="item" data-id="id-7" data-type="services">
<a href="#" data-uri='edc' data-ttl='Engineering'>
<img src="/assets/img/media-centre/videos/edc.png">
<div class="itemcontent">
<h2>Engineering</h2>
</div>
</a>
</li>
</code></pre>
<p><strong>JQUERY - my tried and failed attempt</strong></p>
<pre><code>var permatitle = $('a').attr('data-uri').val('edc');
</code></pre>
<p><strong>SORTED</strong></p>
<blockquote>
<p>var permatitle = $('a[data-uri="edc"]').attr('data-ttl');</p>
</blockquote>
| jquery | [5] |
3,893,996 | 3,893,997 | jQuery each() and "on success"? | <p>I'm using <code>$().each()</code> to loop through some items. I want to make sure that the action that follows after this piece of script is only executed when <code>each()</code> has completed.</p>
<p>Example:</p>
<pre><code>$('something').each(function() {
// do stuff to items
});
// do something to one of these items
$('item').etc
</code></pre>
<p>It seems to work at this point, because it's a really basic action. But sometimes it fails and it seems like the <code>each()</code> part is still busy, causing the action of the follow-up script to be overwritten by the <code>each()</code> actions.</p>
<p>So... is this possible? Or is code below the each() function always executed <em>after</em> the previous code. I know that e.g. AJAX calls have a "success" function, to force code to only execute when the parent action is completed. Is this needed/possible here? I tried something like the following, but this doesn't seem to be working:</p>
<pre><code>$('something').each(function() {
// do stuff to items
}, function () {
// do stuff when the each() part has completed
});</code></pre>
| jquery | [5] |
5,594,277 | 5,594,278 | jQuery: keydown event fires multiply times | <p>At present, when I press the Ctrl button and hold it pressed for a while, the handler that I binded to the keydown event with the help of jQuery is triggered multiply times - I would like to avoid triggering it more than once per a separate press. How would I accomplish that?</p>
| jquery | [5] |
4,140,312 | 4,140,313 | Why does variable in setTimeout callback not have expected value? | <pre><code><div id="image_cont">
<img src="images/pic1.jpg" alt="pic1" />
<img src="images/pic2.jpg" alt="pic2" />
<img src="images/pic3.jpg" alt="pic3" />
</div>
$(document).ready(function() {
slide(3, "image_cont", 5000, 600);
});
function slide(numberOfImages, containerId, timeDelay, pixels) {
//start on first image
var i = 0;
var style = document.getElementById(containerId).style;
window.setInterval(function() {
if (i >= numberOfImages){
i = 0;
}
var marginLeft = (-600 * i);
var pixelMovement = pixels/15;
////////////////////////////////////////LOOK HERE//////////////////////////////
for (var j = 0; j * pixelMovement < 600; j++){
window.setTimeout(function(){
//alert('marginLeft: ' + marginLeft + ' j: ' + j + ' pixelMovement: ' + pixelMovement);
//this alert shows j is 15 when it should be 0, what's going on?
/////////////////////////////////////////END//////////////////////////////////
style.marginLeft = (marginLeft - j * pixelMovement) + "px";
}, 150);
}
i++;
}, timeDelay);
}
</code></pre>
| javascript | [3] |
4,373,867 | 4,373,868 | else statement doesn't seem to execute | <p>i'm a complete begginner and was hoping to get some help on my first script.</p>
<p>basically i want one link that when clicked makes a div slide down and changes the links text, when its clicked again the process reverses.</p>
<p>here is my code:</p>
<pre><code>$(function() {
if ($('#link1:contains("link text")')) {
$('#link1').click(function() {
$('#div1').slideDown(2000);
$('#link1').text('hide div 1');
});
}
else {
$('#link1').click(function() {
$('#div1').slideUp(2000);
$('#link1').text('link text');
});
}
});
</code></pre>
<p>Any help would be appreciated, thanks guys.</p>
| jquery | [5] |
1,449,693 | 1,449,694 | Imploding an array issue in php | <p>I have this code above which i use to implode some variable.
The issue is that i need to create the same thing for <code>$hostess_name[]</code> as i did for <code>$hostess_id_selected[]</code>.
I don't know what am i doing wrong.
I need to implode it the same way as i did with <code>$hostess_id_selected1</code></p>
<pre><code> foreach($hostess_id as $val) {
$hostess_id_selected[] = $val;
$sqlnomehostess="SELECT nome_hostess FROM hostess where id='$val'";
$resultnomehostess=mysql_query($sqlnomehostess)or die(mysql_error());
$hostess_name= array();
while ($row=mysql_fetch_array($resultnomehostess,MYSQL_ASSOC)) {
$hostess_name[] = $row['nome_hostess'];
}
}
$hostess_id_selected1 = implode("-",$hostess_id_selected);
</code></pre>
| php | [2] |
1,936,640 | 1,936,641 | JS revision for jQuery 1.7+ | <p>So I have a code that looks something like this</p>
<pre><code>$(".something").live({
mouseover:function(e){
//do stuff
},
mouseout:function(e){
//do or undo other stuff
}
});
</code></pre>
<p>But since this <code>.live</code> method is depricated in jQuery1.7+, i have to do a bit of revising.
To start with, it should look like:</p>
<pre><code>$(document).on("mouseover",".something",function(e){
//do stuff here
});
</code></pre>
<p>How about the <code>mouseout</code> thingy? Any quick way to merge the two or will I be forced to make separate coding for them?
Thanks.</p>
| jquery | [5] |
362,326 | 362,327 | How can you do something with each argument in a JavaScript function? | <p>Given this function:</p>
<pre><code>function foo( a,b,c ) {
//
}
</code></pre>
<p>How can you do something, say use console.log() for each argument? I know you can see the arguments by using the arguments keyword. Arguments seems to return what looks like an Array (but is of type "object" [suprise.. not]) but it doesn't support .forEach, I am using Chrome.</p>
<p>I tried modifying the function to this, and expected it to work:</p>
<pre><code>function foo( a,b,c ) {
arguments.forEach(function( arg ){
console.log( arg );
});
}
</code></pre>
<p>You get the error that TypeError: Object # has no method 'forEach'.</p>
| javascript | [3] |
744,561 | 744,562 | how to change backgroundcolor of uibutton programatically | <p>I want to change the background color of a button to black.</p>
<p>i have tried so many codes. but didn't works fine.</p>
<p>how it is possible</p>
<p>Regards</p>
<p>K L BAIJU</p>
| iphone | [8] |
2,994,154 | 2,994,155 | Testing android apps | <p>What exactly are mock tests...I need to know the mock and performance tests available in android for testing android apps..what is the best tool for testing android apps and how..</p>
| android | [4] |
5,252,393 | 5,252,394 | How do you use Web Site Administration Tool without installing VS 2010 | <p>I am running a website using asp.net Web Site Administration Tool. </p>
<p>I dont want to install vs on the web server.</p>
<p>Is there a way around it?</p>
<p>Thanks</p>
| asp.net | [9] |
5,434,101 | 5,434,102 | About NSPredicate in Core Data Fetch | <p>I have two entities, User & Message.</p>
<ul>
<li>Message has a created_at timestamp;</li>
<li>Message has a sender[to one relationship with User];</li>
<li>User has a sentMessages[to many relationship with Message];</li>
</ul>
<p>However I want to fetch all users who have sent any messages and with their latest sent message fetched together.</p>
<p>I've try fetch message and set predicate </p>
<pre><code>created_at = sender.sentMessages.@max.created_at
</code></pre>
<p>but the compiler told me unable to parse sql statement?
How can I do that?</p>
| iphone | [8] |
2,764,389 | 2,764,390 | Method overriding and exceptions | <p>I was going through SCJP 6 book by Kathe sierra and came across this explanations of throwing exceptions in overridden method. I quite didn't get it. Can any one explain it to me ?</p>
<blockquote>
<p>The overriding method must NOT throw checked exceptions that are new
or broader than those declared by the overridden method. For example, a
method that declares a FileNotFoundException cannot be overridden by a
method that declares a SQLException, Exception, or any other non-runtime
exception unless it's a subclass of FileNotFoundException.</p>
</blockquote>
| java | [1] |
5,449,465 | 5,449,466 | How to increase the buffer size for reading text files in android emulator? | <p>I am developing an application which will read the text file from the SD-Card. I am able to store the details into sd-card in a text format. However, I am unable to display the data from the text file due to default buffer size limitation.</p>
<p>Please let me know the procedure to increase the buffer size.</p>
<p>Regards,
Serenity.</p>
| android | [4] |
5,099,501 | 5,099,502 | Is there really no secret stream copy method in the Java runtime? | <p>I know about IOUtils and I know about FileChannel transferTo.
But I would really like to know if there is a stream copy method somewhere hidden in the normal Java runtime.</p>
<p>Something like public long copy( InputStream is, OutputStream os){...}</p>
<p>I know I can write it myself but I am curious.</p>
| java | [1] |
1,879,243 | 1,879,244 | App crashes when multiple files "write to file" simultaneously | <p>Here is my code.</p>
<pre><code>- (void) connectionDidFinishLoading: (NSURLConnection *) connection
{
//Each connection has its own "downloadedData".
BOOL writeFlag = [downloadedData writeToFile: filePath atomically: YES];
}
</code></pre>
<p>I have multiple NSURLConnections at the same time.Each connection corresponds to one download item.App crashes when multiple downloads finish at the same time.Is this method thread-safe?</p>
<p>It says:</p>
<pre><code>_serverConnectionDiedNotification. Info -- notification=NSConcreteNotification 0x11d90470{name = AVController_ServerConnectionDiedNotification; object = <AVController: 0x11d855a0>},
AVController = <AVController: 0x11d855a0>,currentTime = 0.00
Program received signal: “0”.
warning: check_safe_call: could not restore current frame
</code></pre>
<p>THANKS!</p>
| iphone | [8] |
3,382,543 | 3,382,544 | How to not lock two files with Assembly.Load | <p>If I copy a file</p>
<pre><code>File.Copy(src, dst);
</code></pre>
<p>and then load the copy</p>
<pre><code>var asm = Assembly.LoadFile(dst);
</code></pre>
<p><strong>Why are <em>both</em> files locked by my process?</strong> </p>
<p>If I delete the src before I load the dst, and then recopy the dst back to the src I get my desired end result. But the delete and copy seem a little unnecessary.</p>
<pre><code>File.Copy(src, dst);
File.Delete(src);
var asm = Assembly.LoadFrom(dst);
File.Copy(dst, src);
</code></pre>
<p>Yes I am building a plugin-design application. Yes I could be using AppDomains with Shadow Copy (http://msdn.microsoft.com/en-us/library/ms404279.aspx). Yes I will have to manage my own type cache (as each assembly load will give a different type as far as my AppDomain is concerned). But these are not answers to my question.</p>
<p>Note that src and dst are strings. No other stream is opened on the files.</p>
| c# | [0] |
2,514,839 | 2,514,840 | How can be achived the parallelism in java code with single CPU? | <p>How come in JMS(Java Messaging Services) technology we achieved two thread execute simultaneously on single CPU based system?</p>
| java | [1] |
5,398,898 | 5,398,899 | All O(1) functions take exactly the same amount of time to run. True or False? | <p>"All O(1) functions take exactly the same amount of time to run." True or false? Can anybody explain the answer to me?</p>
| python | [7] |
3,598,927 | 3,598,928 | Rotate an image around center | <p>How can I rotate an image around it's center point? This rotates it but also moves it:</p>
<pre><code> Matrix mat = new Matrix();
mat.postRotate(45);
Bitmap bMapRotate = Bitmap.createBitmap(dialBM, 0, 0, dialBM.getWidth(),dialBM.getHeight(), mat, true);
dial.setImageBitmap(bMapRotate);
</code></pre>
<p>I've checked other examples on this site, but they either fail to work or use canvas, I do not wish to use canvas.</p>
| android | [4] |
1,386,999 | 1,387,000 | Transisting to different link when clicking on imageview android | <p>I have used an <code>ImageView</code> and added a link to it. I have set listeners to it. Here is the code:</p>
<pre><code>case R.id.imgLogo:
String url = "http://www.xyz.com";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
break;
</code></pre>
<p>But upon clicking on the imageview what ever is the "www.xyz.com" value it is taking to some different webpage.</p>
<p>Can I know what is the mistake?</p>
| android | [4] |
3,397,468 | 3,397,469 | php objects, how to access a simplexmlelement | <p>I have the following object:</p>
<pre><code>object(SimpleXMLElement)#337 (1) { [0]=> string(4) "1001" }
</code></pre>
<p>But I can't seem to access it using [0] or even not using foreach($value as $obj=>$objvalue)</p>
<p>What am I doing wrong?</p>
| php | [2] |
5,083,533 | 5,083,534 | Convert Hex to RGB for imagegif function | <p>The function below is designed to take an input hex (with or without the "#" prefix) and apply the color update to the portion of the image between startPixel and endPixel.</p>
<p>I can get the function to work fine on localhost tests when (1) supplying red, green, blue and (2) running the file directly as a stand alone (ie, just saving the contents of the function to a file and executing it). </p>
<p>However, I have two problems I can't seem to resolve. (1) I need to pass in a hex and get the function to work without requiring rgb hard codes and (2) I need the function to work inside my functions.php file in wordpress while saving my theme options. I'm getting a "failed to open stream" error each time I try to call the function on save.</p>
<p>` function: </p>
<pre><code> function set_theme_color($hex)
{
//hexToRGB($hex); DOES NOT WORK. ALWAYS RETURNS BLACK
$token = "images/sidebar-bg";
$red = 0;
$green = 0;
$blue = 202;
$startPixel = 601;
$endPixel = 760;
$img = imagecreatefromgif('images/sidebar-bg.gif');
$color = imagecolorallocate($img, $red, $green, $blue);
for ($i = $startPixel-1; $i < $endPixel; $i++)
{
imagesetpixel($img, $i, 0, $color);
}
imagegif($img, $token.'.gif');
}
function hexToRGB ($hexColor)
{
$output = array();
$output['red'] = hexdec($hexColor[0].$hexColor[1]);
$output['green'] = hexdec($hexColor[2].$hexColor[3]);
$output['blue'] = hexdec($hexColor[4].$hexColor[5]);
return $output;
}
set_theme_color('#cccccc');
</code></pre>
<p>`</p>
| php | [2] |
2,688,933 | 2,688,934 | Install PHP5 with Apache on Win7 PC | <p>I have installed Apache 2.2 and PHP5 in my laptop. Apache seems to work fine. When I view a php page the text in the html body section displays fine but the php section does not get displayed at all. I am thinking I must have missed some entry in the apache config file to tell it where PHP is installed?</p>
<p>Apache c:\server\apache2
PHP c:=Program Files\PHP</p>
<p>simple example</p>
<pre><code> <html>
<body>
See this line
<?php
echo "Hello World";
?>
</body>
</html>
</code></pre>
<p>Can anyone offer some suggestion?</p>
<p>Thanks
Dan</p>
| php | [2] |
5,796,135 | 5,796,136 | How do I set a background color for each item in a list view based on content | <p>So I've been modifying the notepad tutorial code: <a href="http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html" rel="nofollow">http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html</a> . </p>
<p>Basically what I want to do is to create specific layout styles (i.e. background color) for different rows within the ListView based on the content. So for example, the text for the title is "1" so the background of that row will be red. Or, if the text for the title is "2" then the background of that row (or list item) will be green.</p>
<p>What I'm trying to accomplish is to have a summary of the the rows in the database and color-code each row based upon what category (numerical field) the item is stored as.</p>
| android | [4] |
5,842,451 | 5,842,452 | Multisocket - how to count how many datagram packets are coming up | <p>So I am sending audio over UDP via multicast.
And the sender is sending a raw audio UDP packet every 10 ms. Unfortunately every now and then it misses a packet. So what I did was try to time the send/receive so that I can work out if I have missed one.</p>
<p>Here is what I currently have: </p>
<pre><code>prevReceived = System.currentTimeMillis();
socket.receive(recv);
long messageReceived = System.currentTimeMillis();
if (dateDiff > 20) {
... Missed packet add the previous packet
</code></pre>
<p>The problem that I am having is that sometimes the java multisocket receive method is taking 70ms to receive a message. But when I check with Microsoft network monitor the sending is still sending messages. </p>
<p>So I was wondering if there is a way to look at if the multisocket object has any pending packets: socket.count() or something.
or does the datagrampacket received time from the socket time. eg something like recv.timestamp().</p>
<p>So far I have not found anything and cannot work out why it is taking 70ms to process the message when Microsoft network monitor is processing it every 10 ms.</p>
| java | [1] |
246,613 | 246,614 | getElementById vs. getElementsByTagName | <p>Basic question.</p>
<pre><code>document.getElementById("yy").onmouseover = hi;
//document.getElementsByTagName("li").onmouseover = hi;
...
</code></pre>
<p>In this example, <a href="http://jsfiddle.net/8fURz/1/" rel="nofollow">http://jsfiddle.net/8fURz/1/</a> why does the first line work, but not the second line (when it is un-commented, of course)?</p>
<p>I know I can do this easily with jQuery, just wonderin...</p>
| javascript | [3] |
59,846 | 59,847 | adding weekdays - clears the time | <p>I've tired to add 10 weekdays to now. Everything is OK, but it clears the time part. Do you know why?</p>
<pre><code>$now = date("Y-m-d H:i:s");
echo $now.'<br>';
$mod = strtotime($now." +10 weekdays");
echo $mod.'<br>';
echo date("Y-m-d H:i:s",$mod).'<br>';
</code></pre>
<p>Output:</p>
<pre><code>2011-05-23 14:34:02
1307311200
2011-06-06 00:00:00
</code></pre>
<p>My expected output were:</p>
<pre><code> 2011-06-06 14:34:02
</code></pre>
<p>Thanks.</p>
| php | [2] |
3,462,740 | 3,462,741 | Can I use <%= ... %> to set a control property in ASP.NET? | <pre><code><asp:TextBox ID="tbName" CssClass="formField" MaxLength="<%=Constants.MaxCharacterLengthOfGameName %>" runat="server"></asp:TextBox>
</code></pre>
<p>The code above does not work. I can set the MaxLength property of the textbox in the code behind but i rather not. Is there away I can set the MaxLength property in the front-end code as above?</p>
| asp.net | [9] |
4,108,766 | 4,108,767 | Most efficient approach in inherited fields? | <p>Consider a certain class hierarchy consisting of a root class and some subclasses </p>
<pre><code> R
|
.--+--+------.
| | ... |
S1 S2 ... Sn
</code></pre>
<p>Class R has a field <code>x</code> of a certain type, say <code>X</code>, which is not a simple type, that every subclass should inherit. Subclasses can do sorts of internal processing on field <code>x</code> as well as expose it as a property.
Sort of a discussion arose about which of these two coding style was preferrable:</p>
<h3>1st solution</h3>
<p>Have class <code>R</code> declare <code>x</code> as a private field and provide public getter and setter</p>
<pre><code>class R {
....
private X x;
....
public X getX() { ... }
public void setX(X ax) { ... }
}
</code></pre>
<h3>2nd solution</h3>
<p>Have class <code>R</code> declare <code>x</code> as a protected field</p>
<p>Which one, in your opinion, could be the preferrable solution?</p>
| java | [1] |
2,776,880 | 2,776,881 | unlisted android process | <p>Is there a way to craft a daemon process as to make it "unlistable" to a process viewer?</p>
<p>OR</p>
<p>is there a way to dynamically change a process name?</p>
<p>I'd like to design a security application without having to modify the firmware, if possible (yes I know about "security through obscurity"...).</p>
| android | [4] |
2,281,134 | 2,281,135 | build an object without using of "new" | <p>How can this object be rewritten so you don't need to declare it with "new"?</p>
<pre><code>var Lang = new function(){
this.get = function(str, trans){
if(TRANSLATE[str]){
var str = TRANSLATE[str][LANG];
if(count_obj(trans) > 0){
for(var key in trans){
str = str.replace('%'+key+'%', trans[key]);
}
}
}
return str;
};
};
</code></pre>
<p>To something like this:</p>
<pre><code>var Lang = {
get : function(){}
};
</code></pre>
| javascript | [3] |
3,611,665 | 3,611,666 | Regarding joining of threads | <p>I have developed the below program on java threads , I have two threads which are executing and accessing the method inside run() now if I want to first thread to begin first and then second thread that I have done through synchronization mechanism but if I want first thread to end first and then began with second thread that could be achievable through join() , please advise me how this can be done by implementing join, </p>
<pre><code>public class MyThread2 extends Thread {
public void run()
{
//synchronized (this)
//{
//System.out.println(Thread.class);
for(int i=0;i<20;i++)
{
try{
Thread.sleep(500);
System.out.println(Thread.currentThread().getName());
System.out.println(i +"\n"+ "..");
}catch(Exception e)
{e.printStackTrace();
}
}
//}
</code></pre>
<p>}</p>
<pre><code>public static void main(String... a )
{
MyThread2 obj = new MyThread2();
Thread x = new Thread(obj);
x.setName("first");
x.start();
Thread y = new Thread(obj);
y.setName("second");
y.start();
}
</code></pre>
| java | [1] |
238,858 | 238,859 | How to call a function when using a map constructor? | <p>I found this code at <a href="http://www.cplusplus.com/reference/stl/map/map/" rel="nofollow">here</a>. How does the compiler know to use the function defined in classcomp?</p>
<p>struct/fucntion</p>
<pre><code>struct classcomp
{
bool operator() (const char& lhs, const char& rhs) const
{
return lhs<rhs;
}
};
</code></pre>
<p>Map Construction</p>
<pre><code> map<char,int,classcomp> fourthm;
</code></pre>
<p>Constructor Prototypes from link above:</p>
<pre><code>explicit map ( const Compare& comp = Compare(),const Allocator& = Allocator() );
template <class InputIterator> map ( InputIterator first, InputIterator last,const Compare& comp = Compare(), const Allocator& = Allocator() );
map ( const map<Key,T,Compare,Allocator>& x );
</code></pre>
| c++ | [6] |
3,595,485 | 3,595,486 | Memcpy from a char * buffer to a wchar_t * buffer | <p>Basically I have</p>
<pre><code>void FileReader::parseBuffer(char * buffer, int length)
{
//start by looking for a vrsn
//Header seek around for a vrns followed by 32 bit size descriptor
//read 32 bits at a time
int cursor = 0;
char vrsn[5] = "vrsn";
cursor = this->searchForMarker(cursor, length, vrsn, buffer);
int32_t size = this->getObjectSizeForMarker(cursor, length, buffer);
cursor = cursor + 8; //advance cursor past marker and size
wchar_t *version = this->getObjectForSizeAndCursor(size, cursor, buffer);
cout << version << "\n";
delete[] version;
}
wchar_t* FileReader::getObjectForSizeAndCursor(int32_t size, int cursor, char *buffer) {
wchar_t *destination = NULL;
destination = new wchar_t[(size/2)+1];
memcpy(destination, buffer + cursor, size);
return destination;
}
</code></pre>
<p>in my example say i have the following bytes</p>
<p>7672736E - marker vrsn</p>
<p>00000040 - size of string to follow</p>
<p>0032002E0030002F00530065007200610074006F002000530063007200610074006300680020004C004900560045002000440061007400610062006100730065 - string</p>
<p>the string uses 16 bytes per character, so i cannot use a char * for the actual string, wchar_t seems like the best bet.</p>
<p>However when i memcpy these bytes to a wchar_t i get 0x7fe7abc037e0 in cout which i assume is a pointer?</p>
<p>which seems wrong. when i use wcout i get nothing in the terminal.</p>
<p>Will memcpy not work for this?</p>
<p>also should my wchar_t size be halved since i only have half as many wchar_t's as i would have chars?</p>
<p>size is a byte count.</p>
| c++ | [6] |
396,727 | 396,728 | Base and derived class allocation | <p>In the code below, <code>drvdCls</code> derives from <code>bseCls</code>. This code compiles and runs as it is. I however find an issue here: <code>newBse</code> will get deallocated after <code>Test()</code> exits. Am I right?</p>
<pre><code>bseCls* Test()
{
bseCls* newBse = new drvdCls();
drvdCls newDrvd;
newBse = &newDrvd;
return newBse;
}
</code></pre>
| c++ | [6] |
2,269,530 | 2,269,531 | php form refresh send form again (prevent) | <p>when a form is filled and send, if you refresh the page, its says that the form will send again. (submit the form again).</p>
<p>What is a good way to prevent this from happening? or kill this session?</p>
<p>any guidance in this?</p>
<p>thank you</p>
| javascript | [3] |
2,744,017 | 2,744,018 | Python - go to two lines above match | <p>In a text file like this:</p>
<p>First Name last name #<br />
secone name<br />
Address Line 1<br />
Address Line 2<br />
Work Phone: <br />
Home Phone:<br />
Status:<br /></p>
<p>First Name last name #<br />
....same as above...</p>
<p>I need to match string 'Work Phone:' then go two lines up and insert character '|' in the begining of line. so pseudo code would be:</p>
<p>if "Work Phone:" in line:
go up two lines:
write | + line
write rest of the lines.</p>
<p>File is about 10 mb and there are about 1000 paragraphs like this.
Then i need to write it to another file. So desired result would be:</p>
<p>First Name last name #<br />
secone name<br />
|Address Line 1<br />
Address Line 2<br />
Work Phone: <br />
Home Phone:<br />
Status:<br /></p>
<p>thanks for any help.</p>
| python | [7] |
285,481 | 285,482 | Message box in front of all windows in console application? | <p>I am trying to get a message box to pop up in front of all windows so the user will see it. I have the following code but it seems to put the message box to the very back.</p>
<pre><code>DialogResult dlgResult = MessageBox.Show(new Form() { TopMost = true }, "Do you want to continue?", "Continue?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dlgResult == DialogResult.Yes)
{
Console.WriteLine("YES");
}
else if (dlgResult == DialogResult.No)
{
Console.WriteLine("NO");
}
</code></pre>
<p>The above code is run in a thread is this my problem and how would I fix this?</p>
<p>Thanks</p>
| c# | [0] |
97,543 | 97,544 | How to add support-v4.jar javadoc into my project? | <p>I have created a project and the support-v4.jar is already inside the libs and dependency.(It this normal? Cause I know people were trying to import the .jar manually).
But when I hovered my mouse over the class it said the javadoc doesn't exist. How do I solve this problem?? I created the project and if that comes with the support-v4.jar already, why isn't the javadoc?</p>
| android | [4] |
3,040,281 | 3,040,282 | how to show only the last four digit of a credit card number | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/773396/how-to-show-only-part-of-an-int-in-c-sharp-like-cutting-off-a-part-of-a-credit">How to show only part of an int in c# (like cutting off a part of a credit card number)</a> </p>
</blockquote>
<p>I want to display a string in which only the last four digit of the Credit Card # are shown. Also I want to show the reason description. </p>
<p>The credit card number is inputted in the "textbox1"
the value reason description is taken from the combobox "cmbreason"</p>
<p>I want to show the string-> "Received returned card ending in (last 4 cc #) due to (reason) Will dispose off after 45 days"</p>
<p>The string is passed to the variable noteline1.</p>
<p>How will I achieve it? Please help!</p>
| c# | [0] |
1,271,375 | 1,271,376 | Creating custom and stylized GUI in Android Apps | <p>Guys, whant to get any kind of info about sources in global net about developing stylized GUI, using any kind of tools (graphical editors: photoshop, gimp, Illustrator; android resources, such as drawable and so on), web-sites, books, videos, would be great if it has samples. </p>
<p>Thanks everybody for any kind of information)))</p>
| android | [4] |
897,458 | 897,459 | ASP.NET: Why ALWAYS use 2 RequiredFieldValidator controls when validating 2 behaviors? | <p>I always wonder why to check (i)if a field is not empty and also (ii)if the user submitted the initial value presented to him, we always need 2 RequiredFieldValidators.</p>
<p>Is there any reason they made it that way? Why not just adding a <strong>bool</strong> property such as "<strong>NullOrEmptyAllowed</strong>", for instance?</p>
<p>Thanks for helping.</p>
| asp.net | [9] |
1,681,386 | 1,681,387 | Resolving an ambiguous reference | <p>I'm trying to create a manager class to use with my charting tool, the problem is the tool I use, uses the same names for both a 3d and 2d charts which is resulting in ambiguous reference when I try to add the 2d library.. any ideas how best to resolve this?</p>
<p>For example,</p>
<pre><code>using tool.2dChartLib;
using tool.3dChartLib;
</code></pre>
<p>BorderStyle is a member of both of these</p>
<p>I've tried casting the areas where I use BorderStyle. I suppose it could work if i just reference <code>tool</code> but then that would mean I'd have hundreds of <code>tool.class</code> lines instead of <code>class</code></p>
| c# | [0] |
4,869,519 | 4,869,520 | How can be achived the parallelism in java code with single CPU? | <p>How come in JMS(Java Messaging Services) technology we achieved two thread execute simultaneously on single CPU based system?</p>
| java | [1] |
1,698,108 | 1,698,109 | Can a python subclass be store in a seperate module from its superclass | <p>I've written some code that contains a main and a number of subclasses that inherit variables from a superclass.</p>
<p>E.g.</p>
<pre><code>class superclass(object):
def __init__(self, var1, var2):
self.var1 = var1
self.var2 = var2
class subclass1(superclass):
def method1(self):
pass
class subclass2(superclass):
def method1(self):
pass
</code></pre>
<p>The main isn't shown, nor an option factory which is used to choose the subclass to call, but hopefully the info given will be sufficient.</p>
<p>I wish to convert those classes to standalone modules that can be imported.
It is expected that additional subclasses will be written in the future so I was wondering if it is possible to save each subclass and the superclass as seperate modules and that the subclasses will still be able to use/have access too the superclass variables and definitions.</p>
<p>The reasoning behind this is to simplify the writing of any future subclasses. Meaning they can be written as a stand alone module and the previous subclasses and the superclass don't have to be touched as part of the development, but they will still be able to use the suberclasses variables and definitions.</p>
<p>I'm not sure how it would work or if it can be done that way. Whether I just save all the classes as superclass.py, subclass1.py and subclass2.py and import them all?????</p>
<p>Hope that made sense.</p>
<p>Thanks.</p>
| python | [7] |
162,595 | 162,596 | Is there EVER a reason to NOT use "var" when initially declaring a Javascript variable? | <p>I already know the difference between using "var" and not using "var" to declare a Javascript variable. Using "var" ensures that the variable exists as a distinct entity strictly within the local scope of the code block, whereas not using "var" would effectively make the variable global. I also know that if you declare a variable at the global level, it doesn't matter whether you use "var" or not.</p>
<p>So my question is, is there ever a situation where it would be better to NOT declare a variable using "var"? </p>
<p>So far, I'm under the impression that it never hurts to always use "var" to declare a variable. Are there exceptions to this?</p>
| javascript | [3] |
3,325,136 | 3,325,137 | Split based by a-z character in an alphanumeric string in python | <p>I have strings like "5d4h2s", where I want to get 5, 4, and 2 from that string, but I also want to know that 5 was paired with d, and that 4 was paired with h, etc etc. Is there an easy way of doing this without parsing char by char?</p>
| python | [7] |
6,014,912 | 6,014,913 | Is include()/require() with "side effects" a bad practice? | <p>Is doing something like</p>
<pre><code>_________________________
//index.php
...
require("header.php");
...
_________________________
_________________________
//header.php
printHeader()
function printHeader(){
echo 'something';
...
}
_________________________
</code></pre>
<p>considered a bad practice to avoid?</p>
<p>I personally believe that the execution of a <code>require()</code> (or <code>require_once()</code> or <code>include()</code>, that's not the point) call should only add a "link" to other functions/objects and never execute anything on its own. In other words in my opinion a require should behave in a very similar way to the import/using of other oo languages.</p>
<p>The example that I've written above is pretty trivial but obviously I'm writing also against every kind of "side effects". The define function or some tricks with sessions are other abuses that I have found often in some included files.</p>
| php | [2] |
5,761,685 | 5,761,686 | Android handle HTML links and typed links in a TextView | <p>I am trying to handle both HTML and typed links in TextViews and I am unable to find a combination of the built in tools to do this. I can make one or the other work but not both.</p>
<p>Given the following formats</p>
<pre><code>http://google.com
<a href="http://google.com/">Google!</a>
</code></pre>
<p>Using .setMovementMethod(LinkMovementMethod.getInstance()) I can make the anchor tag turn into a link and open a webpage on click. Using .setAutoLinkMask(Linkify.ALL) I can make the typed link work as expected. The problem is setAutoLinkMask disables the setMovementMethod functionality and removes the highlighting it creates on the html link as well as its clicking functionality.</p>
<p>I tried searching for others with this issue and I believe I am being blocked by a lack of proper terms for this situation. Has anyone else come across a solution to handle both cases seamlessly?</p>
<p>This is what I have currently, only the typed link is linked in the TextView, the anchor just displays the text it wraps.</p>
<pre><code>mTextViewBio.setText(Html.fromHtml(htmlstring));
mTextViewBio.setAutoLinkMask(Linkify.ALL);
mTextViewBio.setMovementMethod(LinkMovementMethod.getInstance());
mTextViewBio.setLinksClickable(true);
</code></pre>
<p>TextView output:</p>
<p><a href="http://google.com" rel="nofollow">http://google.com</a><br />
Google!</p>
| android | [4] |
2,835,893 | 2,835,894 | Can I check is a page present w/ jQuery | <p>If I have a URL, can I check if the page is present or not with jQuery? For example if it returns 400 Error, I'll execute one command and if not 400, another command?</p>
<p>Would I use AJAX call for it? Or what's the best way to handle it?</p>
<p>Sorry, did not realise this was important. URL is not on the same domain...</p>
| jquery | [5] |
1,542,068 | 1,542,069 | Can I put my own app on just my iphone? | <p>I want to create an iphone app for personal use. </p>
<p>Can I just put it on my phone and use it or do I have to go through the iphone store process to get it on my phone?</p>
<p>Thanks.</p>
| iphone | [8] |
871,705 | 871,706 | Android Sliding gesture based tabs | <p>Google docs app uses swipable gesture based tabs using which you can navigate to different tab/category.
How do we achieve this?
<img src="http://i.stack.imgur.com/7R4bu.jpg" alt="enter image description here"></p>
| android | [4] |
89,703 | 89,704 | PHP Getting apart of Name in to <a href=" | <p>So I have this code: More explanation below</p>
<pre><code><?php
include_once 'imdb.class.php';
$oIMDB = new IMDB('Green Lantern');
if ($oIMDB->isReady)
{
echo '<li class="withimage"><span class="name">' . $oIMDB->getTitle()
. '</span><span class="comment">' . $oIMDB->getYear()
. '</span><span class="arrow"></span></a></li>';
} else {
echo '<p>Movie not found!</p>';
}
?>
</code></pre>
<p>I want to get the "Green Lantern" word inside of a <code><a href=""></code> tag. I tried to use something with <code>'.$oIMDB->get().'</code>, but it doesn't work.</p>
| php | [2] |
1,774,748 | 1,774,749 | why i get Permission Denial on trying to access sms messages? | <p>i wrote the simple code </p>
<pre><code> ContentResolver contentResolver = this.getContentResolver();
Uri uriSMSURI = Uri.parse("content://sms/");
// HERE I GET THE EXCEPTION
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null);
int count = cur.getCount();
</code></pre>
<p>I get an exception about Permission Denial in the third line. </p>
<p>How can i get the Permission ? how can i access the messages ? </p>
| android | [4] |
1,572,452 | 1,572,453 | Good programming practices versus speed of ad-hoc programming | <p>I know good programming practices always help in the "long run" for a project, but sometimes they just seem to cost a lot of time. For instance, its suggested that I maintain a header file and a cpp file for each class that I make, keep only the declarations in the headers while definitions in cpp. Even with 10-12 classes, this process becomes very cumbersome. Updating the makefile each time a new class is added dependecies and evthing .. takes a lot of time... </p>
<p>While I am busy doing all this, others would just write evthing in a single fie, issue a single compile command and run their programs ... why should I also not do the same? Its fast and it works?</p>
<p>Even trying to come up with short, meaningful names for variables and functions takes a lot of time, otherwise you end up typing 30 character long names, completely unmanagable without auto complete</p>
<p>Edit :</p>
<p>Okay let me put it a little differently : Lets say i am working on a small-medium size project, that is never going to require any maintenance by a different developer (or even me). Its basically a one time development. Are programming practices worth following in such a case. I guess my question is, do the good programming practices actually help during the development, or they just pay off during maintenance ?</p>
| c++ | [6] |
4,971,869 | 4,971,870 | Java code to Prevent duplicate <Key,Value> pairs in HashMap/HashTable | <p>I have a HashMap as below (assuming it has 10,0000 elements)</p>
<p><code>HashMap<String,String> hm = new HashMap<String,String>();</code><br>
<code>hm.put("John","1");</code><br>
<code>hm.put("Alex","2");</code><br>
<code>hm.put("Mike","3");</code><br>
<code>hm.put("Justin","4");</code><br>
<code>hm.put("Code","5");</code> </p>
<pre><code>==========================
Expected Output
==========================
</code></pre>
<p><code>Key = John",Value = "1"</code><br>
<code>Key = Alex",Value = "2"</code><br>
<code>Key = Mike",Value = "3"</code><br>
<code>Key = Justin",Value = "4"</code><br>
<code>Key = Code",Value = "5"</code><br>
===========================</p>
<p>I need Java code to prevent <code>Addition of Duplicate <Key,Value> Pairs</code> in HashMap such<br>
that below conditions are staisfied.<br>
1> <code>hm.put("John","1"); is not accepted/added again in the Map</code><br>
2> <code>hm.put("John","2"); is not accepted/added again in the Map</code> </p>
<p>Hope its clear.
Java code provided will be appreciated.(generic solution needed since i can add any duplicate to the existing map) </p>
| java | [1] |
4,736,284 | 4,736,285 | Android AnimationDrawable start | <p>I'm using AnimationDrawable to show missing network connection.
Show/hide logic is linked to network status change receiver. It works fine.
But when start activity knowing status and try to start animation - animated drawable shows and freezes on first frame. I've read in documentation - 'do not start animation in OnCreate'.
So I wrote code in onResume, but animation still not playing - only shows first frame.
Starting from button or event works fine.
Tried to start with separate thread and wait some time - but this doent sounds good.</p>
<p>Any idea?</p>
<p>This code works when called from net status change handler</p>
<pre><code>private void _NetStatus(boolean start)
{
if (start)
{
m_NetStatus.setVisibility(View.VISIBLE);
m_NetStatusFrameAnimation.start();
}
else
{
m_NetStatusFrameAnimation.stop();
m_NetStatus.setVisibility(View.INVISIBLE);
}
}
</code></pre>
| android | [4] |
1,911,578 | 1,911,579 | Passing JavaScript Parameters via Calling URL | <p>I have a JavaScript file that embeds a widget on a website. I want to be able to call this widget using a URL of the form:</p>
<pre><code>http://domain.com/widget.js?variable=test
</code></pre>
<p>Within the JS script I want to be able to read in the value of the URL parameter 'variable' which is this case is 'test' and use it in the HTML code the JS outputs. I tried using window.location but that is returning the URL of the main webpage and not the URL that is being called to load the script.</p>
<p>Any ideas what the JS code looks like to read in a passed parameter? Thanks in advance!</p>
| javascript | [3] |
4,050,835 | 4,050,836 | how to print a php page with table data | <p>I have a search results in a form which displays a particular persons details.
Here what I need is I should have a print page button and print that search result.
How is that posible in PHP?</p>
| php | [2] |
244,538 | 244,539 | Javascript object in an other object | <p>I searching for an hour now (w/o any success), that how can I define an object in an other object (in javascript):</p>
<pre><code>function UserStat(arr) {
var arrx = arr;
this.day = function(dateofday) {
//Some code going here which results will be stored variables like:
this.a = someInnerFunction();
this.b = someOtherFunction();
}
}
</code></pre>
<p>I'd like to access these variable when I create an instance of the outer function, somehow like this if this is possible:</p>
<pre><code>var value = new UserStat(arr1).day('2012-10-20').a
</code></pre>
<p>Thank you in advance for any help!</p>
| javascript | [3] |
3,706,778 | 3,706,779 | Is there a more agile way to re-factor the following string formating code | <p>I need to format a string as bellow :</p>
<pre><code>print "%8s%-32s%-32s%-32s" % (' ', 'CAT A', 'CAT B', 'CAT C')
</code></pre>
<p>Since the number of cat is a variable, here is what I code.</p>
<pre><code>values = [' ', ]
format = "%8s"
# width is a variable
width = house.get_width()
for cat in range(house.get_cat_count()):
format = format + '%-' + str(width) + 's'
values.append('CAT ' + chr(ord('A') + operator))
# format is "%8s%-32s%-32s%-32s"
# values is [' ', 'CAT A', 'CAT B', 'CAT C']
${format % tuple(values)}
</code></pre>
<p>The code doesn't seem short and agile. Is there any other way to code it in <code>python</code> style?</p>
| python | [7] |
731,183 | 731,184 | How to define level of multidimensional array | <p>Example</p>
<pre><code>Array
(
[key11] => value11
[key12] => Array
(
[key21] => value21
[key22] => value22
[key23] => Array
(
[key31] => value31
[key32] => value32
[key33] => value33
)
[key24] => value24
)
[key13] => Array
(
[key25] => value25
)
)
</code></pre>
<p>Answer: key11 - 1, key21 - 2, key31 - 3.</p>
<p>P.S. Names for keys and values I created just for example! In fact, names arn't so simple. Thanks!</p>
| php | [2] |
2,316,776 | 2,316,777 | is posible to excute codebehind Event first while dropdown change | <p>I have code like</p>
<pre><code><asp:DropDownList ID="SiteIDDropdownList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="SiteIDDropdownList_OnSelectedIndexChanged" onChange="javascript:markItUpApply();">
</asp:DropDownList>
</code></pre>
<p>Here I need fire first "OnSelectedIndexChanged" then "onChange"</p>
<p>is It possible?</p>
| asp.net | [9] |
262,420 | 262,421 | How can you know the calling method type in PHP? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1647735/how-to-tell-whether-im-static-or-an-object">How to tell whether I’m static or an object?</a><br>
<a href="http://stackoverflow.com/questions/3824143/how-can-i-tell-if-a-function-is-being-called-statically-in-php">How can I tell if a function is being called statically in PHP?</a> </p>
</blockquote>
<p>I meant if you call the method in this way <code>class::method()</code> or in this way
<code>$class->method()</code> How do I know which way was called method in the same method?</p>
| php | [2] |
2,781,318 | 2,781,319 | Possible to receive touch screen events in the background? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3540076/get-co-ordinates-touch-screen-in-a-background-service">Get co-ordinates touch screen in a background service</a> </p>
</blockquote>
<p>I'm experimenting with an accessibility project -- is it possible to detect touchscreen events in the background, e.g. from a service? Assume I'm using a wakelock to keep my service alive in the background.</p>
<p>This is just a proof-of-concept, so I don't have to worry about the battery for now.</p>
| android | [4] |
5,612,550 | 5,612,551 | How to stop from refiring an event on a page refresh | <p>I have form data that I insert into a database when the user clicks on a submit button. The problem is that after the original submission if the user refreshes the page the form data will be resubmitted and thus inserted into the database a second time. How can I fix this?</p>
| c# | [0] |
43,152 | 43,153 | jquery ajax post and response evaluation | <p>i am relatively new to javascript and jquery in particular, so please bear with me, i am trying to loop through multiple s and then serialize() the data with jquery and post it using ajax to my page, this's happening alright, and the data is posted, and my php script echos 1 and everything is taken care off, but for some strange reason, the following code is not working, specially the "success" variable, it's not increasing at all! would you please help me?</p>
<pre><code> $('.submitB').click(function(){
var success = 0;
var times = 0;
var alertText;
$('.input').each(function(){
times++;
var serializedForms = $(this).serialize();
$.post('<?=$this->config->site_url()?>crud/additem/forms', serializedForms ,function(data){
if (data)
{
success++;
}
});
});
if (times)
{
alertText = "تم إدخال " + success + " مدخل من إصل " + times + " بنجاح.";
alert(alertText);
}
})
</code></pre>
<p>the Arabic text just says "success + Entries from + times + were entered successfully"..</p>
<p>thank you in advance.</p>
| jquery | [5] |
3,694,033 | 3,694,034 | How to i display all in box messages in a list? | <p>i am new to android.</p>
<p>i am developing one application related to send and receiving sms.</p>
<p>i want to display all receiving sms in a list.</p>
<p>if any one know please help me</p>
<p>thanks in advance.</p>
| android | [4] |
4,024,511 | 4,024,512 | Android Socket event when other side closes? | <p>I'm writing software for an Android device that's used as a remote control for an industrial process run by a program on a PC. The PC is always listening and the Android device opens the connection to the PC using the Android Socket class. After that happens it can send commands or request data. (so I guess you could think of the Android as the client and the PC as the server). </p>
<p>Either side can close the connection. On the PC there's a WinSock event handler which gets called when the Android closes the connection, but I don't know how to do the same thing on the Android side. I didn't see anything in the Android Socket documentation (<a href="http://developer.android.com/reference/java/net/Socket.html" rel="nofollow">http://developer.android.com/reference/java/net/Socket.html</a>) about events or callbacks. How can my code be notified when the PC has asynchronously closed the connection so I can notify the user, close my end of the connection, or take other action in response?</p>
<p>Thanks in advance.</p>
| android | [4] |
2,733,088 | 2,733,089 | Clickable layout | <p>I have a clickable linear layout that I've generated programmaticly, and I want it to turn green when it is pressed to indicate that it is clickable, like a button would. How would I go about doing this?</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.