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,510,625 | 5,510,626 | Define class variable which refers to a previous class variable in python | <pre><code>class Foo(object):
a = "/admin'
b = Foo.a + '/hello'
</code></pre>
<p><code>a</code> refers to a base path. And I want to define the class variable <code>b</code> based on <code>a</code>.
How do I achieve this ?</p>
| python | [7] |
1,805,924 | 1,805,925 | How do I check GPU usage of Android device? | <p>I wanted to calculate the GPU usage. Is there any file for GPU similar the way cpu stats are saved at /proc/stat ?</p>
<p>What could be the approach to get the GPU details like frequency etc</p>
<p>Thanks</p>
| android | [4] |
5,438,572 | 5,438,573 | c++ limit process child ignore SIGXCPU | <p>I have this code </p>
<pre><code>static void sigXCPU(int pTmp){
cout<<" .... ";
}
.....
pid_t vPid=fork();
int vStat;
switch(vPid){
case -1: perror("fork");
exit(1);
case 0:
//limit on data
struct rlimit vLimD;
vLimD.rlim_cur = 100000;
vLimD.rlim_max = 1000000;
setrlimit(RLIMIT_DATA, &vLimD);
//limit on cpu time
struct rlimit vLimCPU;
vLimCPU.rlim_cur = 1;
vLimCPU.rlim_max = 1;
execl("./p1","",NULL);
if(signal(SIGXCPU,sigXCPU)==SIG_ERR);
break;
default:
while(wait(&vStat)!=vPid);
break;}
</code></pre>
<p>and the code for p1 is </p>
<pre><code>int main(){
sleep(10);
return 0;}
</code></pre>
<p>Why does the child ignore SIGXCPU?The code are compiled with gcc under FreeBsd 8.0 amd64.</p>
| c++ | [6] |
3,678,507 | 3,678,508 | Most elegant way to apply an operator found as a string in java? | <p>Potentially dumb:
Assuming I have a string containing an operator what's the best way to apply this operator ? </p>
<p>What i tend to do is :</p>
<pre><code>if(n.getString(1).equals("<<")) {
result = tmp1 << tmp2;
}
</code></pre>
<p>for each kind of operator I have. Is there a better way ? </p>
| java | [1] |
1,370,226 | 1,370,227 | Avoiding compiler issues with abs() | <p>When using the <code>double</code> variant of the <code>std::abs()</code> function without the <code>std</code> with g++ 4.6.1, no warning or error is given.</p>
<pre><code>#include <algorithm>
#include <cmath>
double foobar(double a)
{
return abs(a);
}
</code></pre>
<p>This version of g++ seems to be pulling in the <code>double</code> variant of <code>abs()</code> into the global namespace through one of the includes from <code>algorithm</code>. This looks like it is now allowed by the standard (see this <a href="http://stackoverflow.com/questions/4405887/when-the-c-standard-provides-c-headers-bringing-names-into-the-global-namespac">question</a>), but not required.</p>
<p>If I compile the above code using a compiler that does not pull the <code>double</code> variant of <code>abs()</code> into the global namespace (such as g++ 4.2), then the following error is reported:</p>
<pre><code>warning: passing 'double' for argument 1 to 'int abs(int)'
</code></pre>
<p>How can I force g++ 4.6.1, and other compilers that pull functions into the global namespace, to give a warning so that I can prevent errors when used with other compilers?</p>
| c++ | [6] |
3,184,497 | 3,184,498 | PHP Code and Linefeeds/Carriage Returns | <p>Just wondering, would the following code arrangement cause any issues when calling mysql_connect, i.e.:</p>
<pre><code>public function connect() {
mysql_connect($this->host,
$this->username,
$this->password)
or die("Could not connect. " . mysql_error());
</code></pre>
<p>or does it need to be all on one line, i.e.:</p>
<pre><code>mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
</code></pre>
<p>Thanks.</p>
| php | [2] |
2,158,893 | 2,158,894 | How to create an sqlconnection in a class with c# to use in all form? | <ol>
<li>Create sqlserver connection in class</li>
<li>call connection class to use all form.</li>
</ol>
<p>I want to create SQLServer connection in class with C# to use all forms.</p>
<p>Hereabout code of connection in class file </p>
<pre><code>public System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection();
public System.Data.SqlClient.SqlCommand Com = new System.Data.SqlClient.SqlCommand();
public string conStr;
public SQL2(string conStr)
{
try
{
Con.ConnectionString = conStr;
Con.Open();
Com.Connection = Con;
Com.CommandTimeout = 3600;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public bool IsConnection()
{
Boolean st;
if (Con.State==ConnectionState.Open)
{
st=true;
}
else
{
st = false;
}
return st;
}
</code></pre>
<p>Can give me full example code?</p>
| c# | [0] |
3,464,389 | 3,464,390 | onclick is only invoked after second time for dynamically inflated rows android | <p>I am dynamically creating a table. I am inflating the rows using another layout file.
But the onclick event for these dynamic rows is triggered only after the second time.
Please assist.</p>
<pre><code>private void populateRouteDetails(){
TableRow row;
View[] lArray = new View[24];
View lView = null;
LayoutParams lLayoutParams = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
for (int current = 0; current < 24; current++) {
row = new TableRow(this);
row.setPadding(0, 1, 0, 1);
LayoutInflater inflator = LayoutInflater.from(getBaseContext());
// inflate child
View item = inflator.inflate(R.layout.linear_row, null);
lArray[current] = item;
item.setPadding(0, 15, 0, 15);
row.addView(item);
row.setGravity(Gravity.CENTER_HORIZONTAL);
busRoute.addView(row, lLayoutParams);
lView = new View(this);
lView.setBackgroundColor(0xFF00FF00);
busRoute.addView(lView,
new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, 1));
}
for(int lCount = 0;lCount<lArray.length;lCount++){
View lRow = lArray[lCount];
lRow.setClickable(true);
lRow.setFocusable(true);
lRow.setFocusableInTouchMode(true);
lRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View pView) {
Toast.makeText(BusDetails.this, "Hello",Toast.LENGTH_SHORT).show();
}
});
}
}
</code></pre>
| android | [4] |
5,667,277 | 5,667,278 | calling inner-function dynamically in javascript | <p>is it possible to call inner function dynamically(by it's name)?</p>
<p>e.g.</p>
<pre><code>function a(){
function b(){..}
var funcName = "b";
//calling the function b somehow using funcName
}
</code></pre>
<p>I know it's possible by using eval, but I rather not using eval, if b was global function I could use window[funcName] or global[funcName]...</p>
| javascript | [3] |
5,827,645 | 5,827,646 | Parameter argument not working right (beginner) | <p>Newb question, when I write:</p>
<pre><code>def right_indent(s):
print ' '*70+'s' #puts argument after 70 spaces
right_indent('michael')
s
</code></pre>
<p>Why does it return s as a result? Shouldn't it be michael?
This seems really simple but I have no idea what I'm doing wrong</p>
| python | [7] |
5,981,684 | 5,981,685 | will concurrent multi thread upload improve uploadprocess? | <p>i am uploading files to azure by using intent service, i know that it uses one thread, and i have to upload 20 images. right now it is taking 20-30 minits.</p>
<p>if i make 3 threads and uploading simultaneously to azure, will it improve anything and my uploading time will decrease?</p>
<p>if it is, please advise me which process is good for it.</p>
<p>i am using this code to start my uploadintentservice:</p>
<pre><code>@Override
public void onCreate() {
mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
// Display a notification about us starting. We put an icon in the status bar.
showNotification();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
sendIntent();
return START_STICKY;
}
@Override
public void onDestroy() {
// Cancel the persistent notification.
mNM.cancel(NOTIFICATION);
}
private void sendIntent(){
Intent selectIntent = new Intent(this, UploadService.class);
startService(selectIntent);
}
</code></pre>
| android | [4] |
895,994 | 895,995 | Python | How to create complex dictionary | <p>I want to create a data structure that will be parse as a JSON object. The out put must look like this and this should be a dynamic data structure.</p>
<pre><code>{"data": [{"type": "locale", "lat": -34.43778387240597, "lon": 150.04799169921876},
{"type": "poi", "lat": -34.96615974838191, "lon": 149.89967626953126},
{"type": "locale", "lat": -34.72271328279892, "lon": 150.46547216796876},
{"type": "poi", "lat": -34.67303411621243, "lon": 149.96559423828126}]}
</code></pre>
<p>I'm struggling in the middle of implementing this data structure so expecting some good ideas.</p>
<p>Thanks </p>
| python | [7] |
562,550 | 562,551 | setInterval of a private function | <p>i want to do a setInterval of a function that is at the same level as the declaration of the setinterval but not global</p>
<p><strong>Example:</strong></p>
<pre><code>function a()
{
function b(){alert("hi");}
setInterval("b()",1000);
}
</code></pre>
| javascript | [3] |
2,574,378 | 2,574,379 | The Pythonic way to do this? (multiply certain elements in string) | <p>I just want to calculate the product of certain elements (whose index value + 1 is in <strong>N</strong>) of a string.</p>
<p>This works fine:</p>
<pre><code>start = 1
end = 1000000
N = (1, 10, 100, 1000, 10000, 100000, 1000000)
product = 1
concatenated_numbers_str = ''.join([str(x) for x in range(1, end + 1)])
for n in N:
product *= int(concatenated_numbers_str[n - 1])
print(product)
</code></pre>
<p>But what is a better way to do this?</p>
<p>Thank you</p>
| python | [7] |
138,714 | 138,715 | How to append this span if the LI element is parent AND has UL (children or submenu) | <p>I basically want to add arrow if the mousehover my navigation. But two rules should apply:</p>
<ol>
<li>It has to be the TOP parent (I already resolve that in the code)</li>
<li>It has to have CHILD elements (UL) submenu, etc. (Which is the problem!)</li>
</ol>
<p>I can not, no matter what I do get it to only show after conditional if to check if it has children first. Now both links which contaain children, and which not show the arrow.. Please help me.</p>
<p>My code:</p>
<pre><code>$("#menu ul").css({display: "none"}); // Opera Fix
$("#menu li").hover(function(){
if (($(this).parent().attr("id") == 'menu')) {
$(this).append('<span class="arrow"></span>');
}
$(this).find('ul:first').css({visibility: "visible",display: "none"}).slideToggle(500);
},function(){
if ($(this).parent().attr("id") == 'menu') {
$('.arrow').remove();
}
$(this).find('ul:first').css({visibility: "hidden"});
});
</code></pre>
<p>Problem: how to add && conditional if to this.parent().attr("id") == 'menu which checks if the LI has children/sub UL</p>
<p>I tried $(this).next().is('ul') no luck! It still append all items with children, and without.</p>
<p>Need your input on this please.</p>
| jquery | [5] |
5,464,615 | 5,464,616 | dynamic onClick not working | <p>I know im doing something really really stupid here.Im getting the error document.getElementById() is null or not an object. Could some one please help me with this?</p>
<pre><code><body>
<div id="box1" style="width:100px;height:100px;background:#ccc;"></div>
<div id="box2" style="width:100px;height:100px;background:#ccc;"></div>
<div id="box3" style="width:100px;height:100px;background:#ccc;"></div>
<div id="box4" style="width:100px;height:100px;background:#ccc;"></div>
<div id="box5" style="width:100px;height:100px;background:#ccc;"></div>
<script>
for (var i = 0; i < 5; i++) {
document.getElementById('box' + i).onclick = function() {alert('You clicked on box #' + i);};
}
</script>
</body>
</code></pre>
<p>Thank You</p>
| javascript | [3] |
421,496 | 421,497 | Indexpath.row value not updating | <p>in iphone application.</p>
<p>I'm trying to get indexPath.row value (out of didselectedrowatindexpath method) to do something on the basis of row selected in programmatically created tableview.</p>
<p>i need to access indexpath.row out of didselectedrowatindexpath method where if/else will define the action on the basis of indexpath.row.</p>
<p>there are 7 cards images in application and one [menu list]table view. whenever user will click on row of table view,then need to touch the image</p>
<p>I'm trying this code to get the IndexPath.row value. The problem is indexPath.row value is not updating everytime. It's just taking the old value. Please sugggest how to solve this issue.</p>
<pre><code>- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event
{
NSUInteger nSection =[myTableView numberOfSections]-1 ;
NSUInteger nRow = [myTableView numberOfRowsInSection:nSection];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:nRow inSection:nSection];
NSLog(@"No of sections in my table view %d",nSection);
NSLog(@"No of rows in my table view %d",nRow);
NSLog(@"Value of selected indexPath Row %d", [indexPath.row]);
NSLog(@"VAlue of Array arrOperationChk %d",[arrOperationChk count]);
}
</code></pre>
| iphone | [8] |
2,487,490 | 2,487,491 | Invoke gmail, google+, facebook from android activity | <p>I have an application where I want to share some text data using either gmail/google+/facebook/bluetooth or any sharable application.</p>
<p>Please guide me how this can be done.</p>
<p>android.intent.action.SEND invoking only gmail and bluetooth</p>
<p>Regards,</p>
<p>Shankar</p>
| android | [4] |
2,471,187 | 2,471,188 | Help creating textboxes via loop in aspx file | <p>I am having issues with giving id to a text box in the aspx for</p>
<p>heres my code</p>
<pre><code> <%for (int i = 2; i <= 10; i++)%>
<% {%>
<div id="divPerson<%= i %>">
<label for="txtFirstNameFriend<%= i %>">Friends First Name</label>
<asp:TextBox ID="txtFirstNameFriend<%= i %>" MaxLength="50" runat="server"></asp:TextBox>
<br />
<span id="ValFirstNameFriend<%= i %>" class="ValidationError" style="color:Red" visible="false" runat="server"><p>Please enter your First Name</p></span>
<label for="txtLastNameFriend<%=i %>">Friends Last Name</label>
<br />
<label for="txtEmailAddressFriend<%= i %>">Friends Email Address</label>
<asp:TextBox ID="txtEmailAddressFriend<%= i %>" MaxLength="255" runat="server"></asp:TextBox>
<div style="display:none"><asp:TextBox ID="ValFriend<%=i %>" CssClass="ValFriend<%= i %>" MaxLength="255" runat="server"></asp:TextBox></div>
<br />
</div>
<% } %>
</code></pre>
<p>Is there any way of adding in a dynamic id to a textbox created on the aspx file?</p>
| asp.net | [9] |
2,480,165 | 2,480,166 | DataGridView column width settings ignored? | <p>I'm using the designer in Visual C# Express to set the column widths. One column has a fixed width, the other two are auto fill. However, after I populate the grid...</p>
<pre><code>document = XDocument.Load(databasepath);
releases_dataGridView.DataSource = document;
//query
releases_dataGridView.DataSource = q.ToList();
</code></pre>
<p>...these width settings are apparently gone and default width values are used instead. It seems that the set column widths are ignored or switched back.</p>
| c# | [0] |
5,944,896 | 5,944,897 | how to remove attached browser process from my applicaion service | <p>I am working on android application in which</p>
<p>I have started a service in android in which i am using <code>getcontentresolver()</code> for browser.</p>
<pre><code>getcontentresolver().query(uri,String[],null,null,null);
</code></pre>
<p>Data fetched properly, but the problem is "<code>com.android.browser</code>" process also attached with my application process.So that memory consumed by my application increased.</p>
<p>How can i resolve this issue.</p>
| android | [4] |
2,772,320 | 2,772,321 | Where can i find platform android-14 in my computer? | <p>I'm used to find all SDK resources (such as images, that is what I want) in folder <code>android-sdk>platforms>android-[VERSION_NUMBER]>data>res</code> but I can't find the new android-14 folder.</p>
<p><img src="http://i.stack.imgur.com/vAfBw.png" alt="enter image description here"> </p>
<p>I've updated all 4.0 tools (as you can see in the image) and the API 14 emulator works</p>
<p><img src="http://i.stack.imgur.com/zmKIB.png" alt="enter image description here"></p>
<p>I tried downloading the SDK folder from <a href="http://developer.android.com/sdk/index.html" rel="nofollow">Android Developer</a>, but it doesn't contain images. How can I access Android 4.0 resources?</p>
| android | [4] |
4,316,217 | 4,316,218 | Is there an integer equivalent of __toString() | <p>Is there a way to tell PHP how to convert your objects to ints? Ideally it would look something like</p>
<pre><code>class ExampleClass
{
...
public function __toString()
{
return $this->getName();
}
public function __toInt()
{
return $this->getId();
}
}
</code></pre>
<p>I realize it's not supported in this exact form, but is there an easy (not-so-hacky) workaround?</p>
<p>---------------------- EDIT EDIT EDIT -----------------------------</p>
<p>Thanks everybody! The main reason I'm looking into this is I'd like to make some classes (form generators, menu classes etc) use objects instead of arrays(uniqueId => description). This is easy enough if you decide they should work only with those objects, or only with objects that extend some kind of generic object superclass.</p>
<p>But I'm trying to see if there's a middle road: ideally my framework classes could accept either integer-string pairs, or objects with getId() and getDescription() methods. Because this is something that must have occurred to someone else before I'd like to use the combined knowledge of stackoverflow to find out if there's a standard / best-practice way of doing this <strong>that doesn't clash with the php standard library, common frameworks etc</strong>.</p>
| php | [2] |
2,032,903 | 2,032,904 | How to disable GestureListener in android? | <p>I have implemented GestureListener, and it is working perfectly, but how can I remove GestureListener from my view?</p>
<pre><code>@Override
public boolean onTouchEvent(MotionEvent event) {
if ( event.getAction() == MotionEvent.ACTION_UP ) {
// remove gestureDetector
} else {
mGestureDetector.onTouchEvent(event);
}
return true;
}
</code></pre>
<p>Regards,
Nishant Shah</p>
| android | [4] |
660,916 | 660,917 | Recomendations for c++ course | <p>I'm planning on learning c++ and was wondering if someone here would be able to recommend some sort of online c++ course or class. I'm not opposed to using a book but I figured a class would be more interactive and would allow me to ask questions about topics I'm confused about. The extra accountability would also be a positive factor. I'm homeschooled in 8th grade and I'm not particularly concerned about any type of college credit. Any help would be greatly appreciated, thanks!</p>
| c++ | [6] |
1,210,625 | 1,210,626 | Getting elements on page to reset to default size after font increase/decrease | <p>How do I get the elements on my page to reset back to default after font increase/decrease</p>
<p>I've tried the following but with little success (font increase/decrease works):</p>
<p><a href="http://jsfiddle.net/R3NGU/6/" rel="nofollow">jsfiddle</a></p>
<p>Here is my code:</p>
<pre><code>$(".resetFont").click(function () {
});
$(".increaseFont").click(function () {
var fontSize = getFontSize();
var newFontSize = fontSize + 1;
setFontSize(newFontSize);
return false;
});
$(".decreaseFont").click(function () {
var fontSize = getFontSize();
var newFontSize = fontSize - 1;
setFontSize(newFontSize);
return false;
});
function getFontSize() {
var currentSize = $("html").css("font-size");
var currentSizeNumber = parseFloat(currentSize, 12);
if (currentSizeNumber > 24) {
currentSizeNumber = 24;
}
if (currentSizeNumber < 10) {
currentSizeNumber = 10;
}
return currentSizeNumber;
}
function setFontSize(size) {
$("html").css("font-size", size);
$(".actualSize").html(size);
}
</code></pre>
| jquery | [5] |
1,362,034 | 1,362,035 | Warnings when file_get_content wrong url | <p>I have this code:</p>
<pre><code><?php
$url = "http://asdsfsfsfsfsdfad.com";
$file = file_get_contents($url);
if(preg_match("/<title>(.+)<\/title>/i",$file,$m))
print "$m[1]";
else
print "The page doesn't have a title tag";
?>
</code></pre>
<p>It works fine when the url is a proper url, but when I put in nonsense then I get two warning messages:</p>
<pre><code>Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Navn eller tjeneste ukendt in /var/www/web17/web/administration/custom_pages.php(71) : eval()'d code on line 4
Warning: file_get_contents(http://asdsfsfsfsfsdfad.com) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Navn eller tjeneste ukendt in /var/www/web17/web/administration/custom_pages.php(71) : eval()'d code on line 4
</code></pre>
<p>Any way to prevent this?</p>
| php | [2] |
2,681,449 | 2,681,450 | How to pass client id of Item in repeater to javascript | <p>I need to pass div client id to JavaScript of a repeater </p>
<p>I have 3 divs inside a repeater i have onmouseover event i want to grab client id of div element Is there any way i can pass exact client of div element </p>
<p>Can u guys help me out Thanks</p>
| asp.net | [9] |
4,044,607 | 4,044,608 | When to use "::" and when to use "." | <p>Apologies for a question that I assume is extremely basic.</p>
<p>I am having trouble finding out online the difference between the operator :: and . in C++</p>
<p>I have a few years experience with C# and Java, and am familiar with the concept of using . operator for member access.</p>
<p>Could anyone explain when these would be used and what the difference is?</p>
<p>Thanks for your time</p>
| c++ | [6] |
2,678,666 | 2,678,667 | Android dynamic icon in listview | <p>I have a ListActivity in my application. The list is populated from a parsed http response in the form of an ArrayList of hashmaps.</p>
<pre>final ArrayList<HashMap<String,String>> LIST = new ArrayList<HashMap<String,String>>();
...
SimpleAdapter adapter = new SimpleAdapter(this, LIST, R.layout.item_row, new String[]{"author","title"}, new int[]{R.id.text1,R.id.text2});
setListAdapter(adapter);
...
for(Element src : lists){
String title = src.select();
String author = src.select();
HashMap<String,String> temp = new HashMap<String,String>();
temp.put("author", author);
temp.put("title", title);
LIST.add(temp);
}
</pre>
<p>Where author and title are correctly derived from the parsed http.</p>
<p>In the R.layout.item_row XML file I have defined a drawable for text2:</p>
<pre>android:drawableLeft="@drawable/default_icon"</pre>
<p>And i would like to be able to change that icon to "new_icon" on a given row if the hashmap contains a certain string.</p>
<p>For instance, within the for loop above, I would add something like:</p>
<pre>
String status = src.select();
String icon = "default";
if(status.contains("test")){
icon = "should_change";
}
temp.put("icon", icon);
...etc
</pre>
<p>I'm leaving out the specific logic for brevity, but I am able to correctly pass whether the icon should change or not as a string value back to the adapter, however, I am not sure how to then actually change the icon.</p>
<p>I am not experienced with either Java or Android so I am quite likely approaching this backwards.</p>
<p>Any help would be great.</p>
| android | [4] |
2,363,582 | 2,363,583 | How to give event on force close dialog's ok button | <p>Hi I want to know can I perform my own operations on Force Close Dialog's OK Button ?</p>
| android | [4] |
3,210,834 | 3,210,835 | Java convert a HEX String to a BigInt | <p>Hi am trying to convert a hex string such as String hexStr = "1b0ee1e3"; to a bigInt,
ideally i'd like to convert hexStr to a bigint in its decimal form,</p>
<p>I can convert a string to a bigInt w/o issues but when the string contains hex values
i run into problems</p>
| java | [1] |
2,487,045 | 2,487,046 | When to delete objects from the heap in C++? | <p>I am a little confused when/how to delete objects from the heap in C++.</p>
<p>When:</p>
<p>If you are executing a program which is relatively short, computes something and then passes standard output to the console is it worth destroying all your objects just after the console has output the result or would the program destroy automatically upon exiting? In the case of large programs I presume it would definitely be better practice to try and work out when you no longer need any of your objects?</p>
<p>How:</p>
<p>If I have a vector containing pointers to MyClass objects, once I am finished with the vector (and MyClass objects) how do I write a destructor that can destroy all the MyClass objects pointed to by the vector? (Obviously I will need to destroy the vector too).</p>
| c++ | [6] |
2,781,392 | 2,781,393 | Get Row ID when click on link in cell | <p>Lets say I want to get the ID of a row when I click on a span in a cell as below</p>
<pre><code><tr id="theRowID">
<td><span class="getRowID">get this rows ID</span></td>
</tr>
</code></pre>
<p>Would this be accurate?</p>
<pre><code>$(".getRowID").click(function(){
$(this).closest('tr').attr("id");
});
</code></pre>
| jquery | [5] |
118,946 | 118,947 | How to get screen identification number from Screen class | <p>i need to show dialog in screen by its identification number, for example i have this situation
<img src="http://i.stack.imgur.com/YXZyu.png" alt="screen setup on windows"></p>
<p>I want to show something on fourth, when i get all screens by using Screen.AllScreens, my fourth screen is 0 element in array, because AllScreens returns screens not by indent number but by squence.
So mayby someone knows the way how to get identification number from Screen class, or how to get screen coordinates and bounds by its identification number.</p>
<p>UPDATE:</p>
<p>DeviceName is not always corrspont to identification number (see image below):</p>
<p><img src="http://i.stack.imgur.com/2Gle1.png" alt="enter image description here"></p>
| c# | [0] |
5,342,556 | 5,342,557 | Javascript closure | <p>I read the () at the end of the closure will execute it immediately. So, what is the difference between these two. I saw the first usage in some code.</p>
<p>thanks.</p>
<pre><code>for (var a=selectsomeobj(),i=0,len=a.length;i<len;++i){
(function(val){
anotherFn(val);
})(a[i]);
}
for (var a=selectsomeobj(),i=0,len=a.length;i<len;++i){
anotherFn(a[i]);
}
</code></pre>
| javascript | [3] |
4,864,077 | 4,864,078 | Make a hovered element move to the centre (horizontally) of the viewport with jQuery when clicked | <p>I currently have several divs that enlarge when hovered. The user can then open a details DIV (fixed size) on a click function. </p>
<p>What I'm trying to figure out is how to move the hovered element to the middle of the viewport and then open the details div. (timeout function I guess). </p>
<p>When the users mouse leaves the element (function already exists), it slides back and reduces in size back to its original position.</p>
<p>Fiddle: <a href="http://jsfiddle.net/yJ7ps/1/" rel="nofollow">http://jsfiddle.net/yJ7ps/1/</a></p>
| jquery | [5] |
3,617,675 | 3,617,676 | Listview in Listview | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5244797/listview-setadapter-raising-nullpointer-exception">Listview.setadapter raising nullpointer exception.</a> </p>
</blockquote>
<p>Hi, How to create a listview in a listview. I have a tabbar application. The second tab is a list view, when a cell in the listview is clicked, it should showthe next list view. How to do this?</p>
<p>I have tried some thing here
<a href="http://stackoverflow.com/questions/5244797/listview-setadapter-raising-nullpointer-exception">Listview.setadapter raising nullpointer exception.</a></p>
<p>The error is as below. is it possible to do it in the way as in the previous question. are there any easier methods.</p>
| android | [4] |
855,845 | 855,846 | Do headers slow down PHP code? | <p>If you have a large class that executes after output(headers/text) is already sent, will that have any affect on your applications performance?</p>
<p><strong>Edit</strong>: To clear things up, when output is sent, default headers are sent with it.</p>
| php | [2] |
519,958 | 519,959 | How to append div tag dynamically in html using javascript/ | <p>I am creating one div dynamically and want to add it inside another div.</p>
<pre><code> (js) var divtag = document.createElement("div");
divtag.innerHTML = xmlhttp.responseText;//Ajax call working fine
document.getElementById('con').appendChild(divtag);
</code></pre>
<p>html:</p>
<pre><code>enter code here <div id="con"></div>
</code></pre>
<p>The the o/p I am getting from AJAX call is Ok, also i am able to view it in browser, but when I am doing a view source I am unable to see the div and its contents.
It should come as :</p>
<pre><code>enter code here <div id="con">
<div>
Contents added @ runtime
</div>
</div>
</code></pre>
<p>Can somebody suggest where I am going wrong?</p>
| javascript | [3] |
2,252,634 | 2,252,635 | Create bitmap mask programatically | <p>I have an awful feeling this is stupidly easy, but I can't figure it out.</p>
<p>It's also not easy to describe, but here goes. I have this code in onDraw().</p>
<pre><code>radius = drawGmpImage(this.gmpImage, canvas);
canvas.drawCircle(kHorizontalOffset, kScreenVerticalOffset, radius , maskPaint);
</code></pre>
<p>drawGmpImage creates a complex graphic which is a circle with many lines drawn on it. It's a library function which I cannot change. The lines are polygons and can extend beyond the circumference of the circle. </p>
<p>The need is to "blank out" everything drawn outside the circle. </p>
<p>This is a port from iOS and the original developers solution is to use a simple bitmap mask, stored as a resource, with a transparent circle which matches the size of the circle drawn. Simply drawing the bitmap over the drawn circle has the desired effect but is not an option on Android as I need to support all possible resolutions and ratios.</p>
<p>Therefore, the canvas.drawCircle() call is the beginning of my attempt to mask out everything outside the circle. It works fine in that a filled circle is drawn over my drawn circle so that the only thing left are the polygon lines outside the drawn circles circumference. Radius is the radius of the drawn circle.</p>
<p>How can I invert this so that I am left with the contents of the circle?</p>
| android | [4] |
4,716,389 | 4,716,390 | Output HTML from number of strings | <p>I'm trying to figure out how best to organise an inline c# page that makes a number of DB connections and passes values to strings and need some advice.</p>
<p>So basically a CMS in use with my place of work only allows for inline code so I'm doing a course search page that hooks up to some stored procedures and passes the values to strings.</p>
<p>What would be the best way to handle three different stored procedure calls that output different bits of information to strings? In the old VB version I was passing info to strings then outputting them as one large string which probably isn't the best way to handle this.</p>
<p>The code currently goes in this rough format</p>
<pre><code>Stored Procedure 1
Pass x values to string
string = "<p> + xString +</p>"
Stored Procedure 2
Pass y values to string
string = "<p> + yString +</p>"
</code></pre>
<p>Is there a smarter way for me to close off sections as each procedure section usually has a table involved or appends to one larger table and I'm just trying to see what people would suggest would be best practice.</p>
<p>Please note I'm really not much of a programmer and just dipping my toes so apologies if this is a school boy mistake.</p>
| c# | [0] |
3,816,433 | 3,816,434 | Jquery integration with my theme | <p>I want to add a slide side ways jquery to my website, I tried the following code, but seems not to be working</p>
<p>Jquery code:-</p>
<pre><code><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script src="http://tab-slide-out.googlecode.com/files/jquery.tabSlideOut.v1.3.js"></script>
<script type="text/javascript">
$(function(){
$('.slide-out-div').tabSlideOut({
tabHandle: '.handle',
pathToTabImage: 'images/contact_tab.gif',
imageHeight: '122px',
imageWidth: '40px',
tabLocation: 'left',
speed: 300,
action: 'click',
topPos: '200px',
leftPos: '20px',
fixedPosition: false
});
});
</script>
</code></pre>
<p>Div & CSS code:</p>
<pre><code> <style type="text/css">
.slide-out-div {
padding: 20px;
width: 250px;
background: #ccc;
border: 1px solid #29216d;
}
</style>
<div class="slide-out-div">
<a class="handle" href="#">Content</a>
<h3>Contact me</h3>
<p>Hello
</p>
<p>Welcome to my Blog</p>
</div>
</code></pre>
<p>When I tried the above code into my header file, and the div code in the footer file,
The DIV box appears to be slided outside but doesn't goes inside , the jquery is not working and the image contact_tab.gif is not displayed and my google maps on my website doesn't loads, I know this is because of wrong integration of jquery but I don't know how to integrate it with wordpress themes</p>
| jquery | [5] |
4,650,535 | 4,650,536 | How to use php to sync two dir? | <p>Is there a good way?</p>
| php | [2] |
5,515,945 | 5,515,946 | Best way to launch different tasks | <p>I am developing an application for blind people. I have to work all the time with the TextToSpeech module, GPS and Network connection.</p>
<p>I need to do a query like this: Consult the GPS, do a JSON call and calling the TextToSpeech(TTS) module.</p>
<p>I am wondering the best way to deal with the different tasks which communicate with the UI main thread. I have seen so far:
Handler objects and AsyncTask class.</p>
<p>I have to launch each task sequentially, so I want to call the TTS after retrieving data from the network. So I have used "mHandler.post(Runnable)" and inside that runnable calling another one and so on.</p>
<p>However I have seen that is recommendable the use of the AsynTask class. But in this case I think I have to implement a different class for every task, whereas I don't know if those tasks will execute sequentially. Something like:</p>
<pre><code>AsyntaskClass1 at1;
AsyntaskClass2 at2;
AsyntaskClass3 at3;
at1.execute();
at2.execute();
at3.execute();
</code></pre>
<p>Will that tasks execute in order? Cause the TTS module have to wait for the network task to finish...</p>
<p>Thanks for your help,</p>
<p>BR.David.</p>
| android | [4] |
5,327,419 | 5,327,420 | Count folder inside the folder | <p>Can you help me how to count the folders inside the folder.</p>
<p>How can i count the sub folders after the FolderBrowserDialog is popup and choose that main folder consist of 3 folders.</p>
<p>I'm using </p>
<pre><code>FolderBrowserDialog fbdialog = new FolderBrowswerDialog();
</code></pre>
| c# | [0] |
5,216,087 | 5,216,088 | get custom event from control in repeater | <p>I have this markup Main.ascx:</p>
<pre><code>asp:Repeater ID="rptSource" runat="server">
<ItemTemplate>
<uc1:CustomControlsUC ID="CustomControlsUC1" runat="server" DataSource='<%#Container.DataItem %>' />
</ItemTemplate>
</asp:Repeater>
</code></pre>
<p>and in CustomControlsUC.ascx</p>
<pre><code>Public Event Entered(ByVal sender As Object, ByVal e As CommandEventArgs)
</code></pre>
<p>and</p>
<pre><code> Public Sub CustomValidation(sender As Object, args As CommandEventArgs)
RaiseEvent Entered(Me, args)
End Sub
</code></pre>
<p>and in my Main.ascx where is repeater i try to handle this event.</p>
<pre><code>Protected Sub rptSource_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptSource.ItemDataBound
Dim rpt As inc_CustomControlsUC = CType(e.Item.Controls(1), inc_CustomControlsUC)
AddHandler rpt.Entered, AddressOf HandleThis
End Sub
</code></pre>
<p>but in this part AddHandler rpt.Entered, AddressOf HandleThis, I not have this Entered event:</p>
<p>How can i do this?</p>
| asp.net | [9] |
4,295,859 | 4,295,860 | Conversions and Promotions | <p>I just wondering why this works (in Java):</p>
<pre><code>byte b = 27;
</code></pre>
<p>but being method declared like this:</p>
<pre><code>public void method(byte b){
System.out.println(b);
}
</code></pre>
<p>This doesn't work:</p>
<pre><code>a.method(27);
</code></pre>
<p>Gives a Compiler error as follows:</p>
<pre><code>`The method method(byte) in the type App is not applicable for the arguments (int)`
</code></pre>
<p>Reading <a href="http://java.sun.com/docs/books/jls/second%5Fedition/html/conversions.doc.html" rel="nofollow">this</a> doesn't give me any clue (probably i am missunderstanding something).</p>
<p>Thanks in advance.</p>
| java | [1] |
2,885,332 | 2,885,333 | Only showing first x rows of a Database in a listview | <p>I'm building an app that contains a listview that is populated from a database query. The list works fine but I'm worried that I may start to display too much data when database gets larger. I would like to display the top 25 entries then add a list item called "show more" at the bottom of the list where I could append the next 25...</p>
<p>Is it better to preform a second database query for the next 25 and append them to the current list?</p>
<p>Or</p>
<p>Store the entire returned dataset in the ArrayList object on the initial database query and update the ListVew by cycling through the arraylist?</p>
| android | [4] |
797,016 | 797,017 | Different syntax for passing methods as arguments? | <p>I'm currently trying to teach myself more about javascript, and I find myself stumbling over the syntax for passing a method as an argument to another method call. Say you have two functions like these:</p>
<pre><code> function FirstFunction()
{
DoesSomething();
}
function SecondFunction(func)
{
func();
}
</code></pre>
<p>In actually passing the FirstFunction to the SecondFunction, I seem to see a wild variety of variations on doing so:</p>
<pre><code> SecondFunction(FirstFunction);
</code></pre>
<p>or</p>
<pre><code> SecondFunction("FirstFunction()");
</code></pre>
<p>or sometimes, if FirstFunction was defined as follows:</p>
<pre><code> var thisisafunction = function FirstFunction()
{
DoesSomething();
}
SecondFunction(thisisafunction);
</code></pre>
<p>I'm guessing there's no "one right way" to do this, so when is it appropriate to use each way of passing a function? Is it better to use one way over another in a certain situation?</p>
| javascript | [3] |
701,008 | 701,009 | file handling in python | <p><br />
Thanks in advance. I have written a program which works for small files. But that doesn't work for files of 1 GB. Please tell me is there is any way to handle big file. Here is the code.</p>
<pre><code>fh=open('reg.fa','r')
c=fh.readlines()
fh.close()
s=''
for i in range(0,(len(c))):
s=s+c[i]
lines=s.split('\n')
for line in s:
s=s.replace('\n','')
s=s.replace('\n','')
print s
</code></pre>
| python | [7] |
3,885,547 | 3,885,548 | Python iterations | <p>Has anybody any idea why this code fails to run smooth? It seems not to like iterations with the yield keyword:
I am trying to mine all the numbers from any level of lists or dicts ( especially interested in lists ).
At the second iteration it finds [2,3] but fails to print 2 and 3 one after other...Imagine also that I could have many levels of lists.</p>
<pre><code>def digIn( x ):
try:
if isDict(x) or isList(x):
print "X:", x
for each in x:
print "each:", each
if isDict(each) or isList(each):
digIn(each)
else:
yield each
else:
yield x
except Exception,ex:
print ex
print "STARTING OVER"
for i in digIn( [1,[2,3]] ):
print i
</code></pre>
| python | [7] |
2,249,000 | 2,249,001 | How to flip Imageview in Android? | <p>I am working on an application I need to flip image view on touch and transfer control to the second activity. please help me. i tried a lot but i haven't succeed.
thank you all in advance.</p>
| android | [4] |
5,898,800 | 5,898,801 | Get the html from the webview, and then manipulate it and load back | <pre><code>http://stackoverflow.com/questions/3479833/is-it-possible-to-get-the-html-code-from-webview
</code></pre>
<p>got many links to get the html code from webview, but need to manipulate it and then again load it back.
Is it possible to do that.if yes, please give some ideas.
I have not that much idea of java script.</p>
| android | [4] |
3,425,780 | 3,425,781 | Not getting desired output for ArrayList elements, could any one clarify? | <p>I have defined the arraylist as follows:</p>
<pre><code>ArrayList<Node> nodes = new ArrayList<Node>();
</code></pre>
<p>Where Node is a class which has one character data type for storing a single character.</p>
<p>The output is showing some garbage value instead of printing characters:</p>
<p>Here is a code snippet. Can anyone explain why?</p>
<pre><code>for(Node d : nodes){
System.out.println(d);
}
</code></pre>
| java | [1] |
4,139,103 | 4,139,104 | Clarifications on a python script file | <p>Just need some clarification on how to design a python script file test.py.</p>
<ol>
<li><p>When defining functions, do they have to go on the top of the file right after the imports?</p></li>
<li><p>should I be doing that <strong>main</strong> check in my file?</p></li>
<li><p>I want to run this file on my server as a cron job. If the file gets too big (I have my sqlalchemy definitions in it also), how can I break the file into multiple files? I want this easy to deploy by just dropping the files into a folder in my server.</p></li>
</ol>
| python | [7] |
116,957 | 116,958 | limit textbox to x number of characters | <p>I have a textbox on an aspx page which I have limited to accept 250 characters.
This works fine when a user just types data in, but if they paste the textbox will accept way more.
Is there a way I can get around this? I dont want to disable pasting in the textbox though.</p>
<p>thanks again</p>
| asp.net | [9] |
5,295,623 | 5,295,624 | PHP multi dimensional array search | <p>i have an array where i want to search the uid and get the key of the multidimensional array
for eg search 100(uid of first user) and the function should return 0 and if i search 40489 the function should return 2
I tried making loops but i want a faster exxecuting code, Any help :(</p>
<pre><code>$userdb=Array
(
(0) => Array
(
(uid) => '100',
(name) => 'Sandra Shush',
(url) => 'urlof100'
),
(1) => Array
(
(uid) => '5465',
(name) => 'Stefanie Mcmohn',
(pic_square) => 'urlof100'
),
(2) => Array
(
(uid) => '40489',
(name) => 'Michael',
(pic_square) => 'urlof40489'
)
);
</code></pre>
| php | [2] |
5,696,798 | 5,696,799 | I don't know what to do with a .apk file | <p>I was given a library on an .apk file.
see:
<a href="http://code.google.com/p/android-serialport-api/downloads/list" rel="nofollow">http://code.google.com/p/android-serialport-api/downloads/list</a></p>
<p>I assume it contains the package that I will have to import, but what do I do with it? </p>
| android | [4] |
4,020,730 | 4,020,731 | Profile Photo Upload | <p>I thinking to create a option whereby a user able to upload photo to their profile in a website. </p>
<p>When a user upload a photo, a folder with the user login ID can be generated inside a root folder "C:\wamp\www". In other words, each user will have a folder store their profile image, folder name will be the user id. </p>
<p>This is my first project on PHP and I am not sure what I have thought of can be possibly done.
I will need some aid and guide to move further. I will appreciate and make full use of any references given here. Thanks in advance. </p>
| php | [2] |
1,994,567 | 1,994,568 | How to make a new application for the existing developer? | <p>I have a developer account in iOS provisioning portal and already have all the certificates for one application. Now I want to build a new application with a new app ID within the same account.</p>
<p>Should I have to repeat all the steps once more? Can anybody help me with the steps I need to do in iOS provisioning portal?</p>
| iphone | [8] |
1,485,628 | 1,485,629 | How to do an onListItemClick? | <p>I have an <code>Activity</code> and I want to do a <code>setOnListItemClick</code> on my <code>Listview</code> but I seem unable to do it. </p>
<p>I am only able to do it with ListActivity but I need an <code>EditText</code> so I can't use the <code>ListActivity</code>.</p>
<p>Can anyone help me?</p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listview = (ListView) findViewById(R.id.listview);
edittext = (EditText) findViewById(R.id.search_box);
arrayA = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, eventTitle);
setListAdapter(arrayA);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
}
</code></pre>
| android | [4] |
2,213,018 | 2,213,019 | How can I configure EditTextPreference to have scroll bar | <p>In my android application, I have a EditTextPreference as one of my preferences in my PreferenceActivity. My question is how I can add a 'scroll bar' for the text of the EditText Preference? Sometime when the text is too long and when the 'soft keyboard' pops up, I don't see the buttons of the edit text dialog.</p>
<p>Thank you.</p>
| android | [4] |
4,001,245 | 4,001,246 | run jar file without swing libraries | <p>I have program , I create the jar file, but then when I run the jar file nothing is display,
is it because it is not an swing program? How should I run this program?</p>
<pre><code>`package first;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
public class Main {
public static void main(String[] arguments) {
.........
</code></pre>
<p>`</p>
| java | [1] |
1,273,775 | 1,273,776 | Position views at specific location? | <p>Is there a way to place widgets / views on the screen at any specific position required?</p>
<p>Something like a calendar with daily events that could overlap.
e.g. if every hour in a day is represented by 1 hour and there are 2 appointments that overlap partially (say 12:00 - 12:30 and 12:20 - 01:00) this would be drawn in the same row but the 12:20 one positioned slightly below the first.</p>
<p>Also there may be views (Image/TextView) that need to span 2 rows (i.e. 12:30 - 1:30).</p>
<p>I think a SurfaceView is one option (is this efficient?) but am not sure if there is some better layout that could be used.</p>
<p>We could use a TableLayout for the hour rows but not sure if there is a way to place overlapping widgets on this?</p>
<p>TIA</p>
| android | [4] |
2,401,787 | 2,401,788 | what is the efficient way to use google to search duplicate content..? | <p>I am making a software that helps to search duplicate contents(only text) in web. I think I can use google as it is very efficient and faster. So I developed an algorithm But it is not efficient. </p>
<p>Here is my idea. The user enters a content of 300-500 character length. This content is searched in google. 1st page results are considered.</p>
<p>ex: Content is "The definition of a breed is a matter of some controversy. Some groups use a definition that ultimately requires extreme in-breeding to qualify. Dogs that are bred in this manner often end up with severe health problems. Other organizations define a breed more loosely, such that an individual may be considered of one breed as long as, say, three of its grandparents were of that breed".</p>
<p>1st result in google : Brief History of Dogs and Breeds. Dog usually means the domestic dog, ... Some groups use a definition that ultimately requires extreme in-breeding to qualify. Dogs that are bred in this manner often end up with severe health problems. Other organizations define a breed more loosely, such that an individual may be ...</p>
<p>So from 1st result we can say the content is present on web ..</p>
<p>My algorithm</p>
<pre><code> bool checkContentVsResult(string googletext, string content)
{
bool found = false;
int len = 0;
string[] ch = new string[] { "." };
string[] texts = googletext.Split(ch, StringSplitOptions.RemoveEmptyEntries);
int count = 0,qualify=0;
len = text.Length;
if (len > 300)
qualify = 3;
else if (len > 200)
qualify = 2;
else
qualify = 1;
foreach (string s in texts)
{
if (s==" ")
continue;
if (content.Contains(s))
count++;
if (count >= qualify)
{
found = true;
break;
}
}
return found;
}
</code></pre>
<p>As you can see the algorithm is not much efficient.. How to make it more efficient..?</p>
| c# | [0] |
158,841 | 158,842 | how to go back to previous screen in tableview? | <p>My appliaction is viewbased application in which i have one button .
On click of that button i will push to other screen that is table view screen on which what i want when i select any data from row in table view it will get back to previous view automatically instead of selecting the navigation back button generated automatically.</p>
<p>Please help me out its urgent .</p>
<p>Thanks in Advance</p>
| iphone | [8] |
959,666 | 959,667 | How to Make Structure as Null in C#? | <p>How to Make Structure as Null in C# ?</p>
<pre><code>EMPLOYEE? objEmployee = null;
EMPLOYEE stEmployee = objEmployee.GetValueOrDefault();
</code></pre>
<p>but this make <code>stEmployee</code> fields as null,but i want to make this structure as null.
It shows <code>stEmployee.FirstName = null</code>,<code>stEmployee.LastName = null</code></p>
<p>But i want to make <code>stEmployee</code> as null.
How to achieve that ? </p>
| c# | [0] |
2,077,197 | 2,077,198 | When/why to call System.out.flush() in Java | <p>Why do certain streams need to be flushed (<code>FileOutputStream</code> and streams from Sockets) while the standard output stream does not?</p>
<p>Every time someone uses the <code>System.out</code> <code>PrintStream</code> object, be it while calling <code>println()</code> or <code>write()</code>, they never flush the stream. However, other programmers habitually call <code>flush()</code> a <code>PrintStream</code>/<code>PrintWriter</code> with other streams.</p>
<p>I've recently asked this question to several programmers and some believe that there is some background handling in Java to auto-flush the <code>System.out</code> stream but I can't find any documentation on that.</p>
<p>Something like this makes me wonder if simply calling <code>System.out.println()</code> is platform independent as some systems may need you to flush the stream.</p>
| java | [1] |
736,648 | 736,649 | Find webpage get image from text | <p>Now I am creating a dictionary online that have a part: "image dictionary" and I want to find a webpage that when i enter a string ,if it's corressponding, page will return a image with URL.
If you know..please answer to help me.
one star!</p>
| android | [4] |
2,110,051 | 2,110,052 | Error Placement for jquery validation plugin | <p>For some reason its not putting the error messages down in the div with a class of errorContainer and I'm not sure why when there is an error, however how it looks in the jsfiddle looks messed up compared to my actual page.</p>
<pre><code>[http://jsfiddle.net/xtremer360/VtXdk/][1]
</code></pre>
| jquery | [5] |
2,195,535 | 2,195,536 | Do containers of primitive types in C# use value semantics or pointer/reference semantics? | <p>When a <code>List<></code> of primitive types is created in C# (e.g. a <code>List<int></code>), are the elements inside the list stored by value, or are they stored by reference?</p>
<p>In other words, is C# <code>List<int></code> equivalent to C++ <code>std::vector<int></code> or to C++ <code>std::vector<shared_ptr<int>></code>?</p>
| c# | [0] |
4,840,848 | 4,840,849 | Gallery limit fling distance | <p>I'm using an approach for this <a href="http://stackoverflow.com/questions/5426439/how-to-disable-fling-in-android-gallery">thread</a> in order to make gallery change one image per swipe. My problem is that for this image-change to happen user has to drag image for at least 50% of the width of the gallery, which can become unacceptable on large devices.</p>
<p>So, I need to make the drag-distance smaller than it is now(50% by default). How can I achieve it ?</p>
| android | [4] |
661,870 | 661,871 | unable to set textView1.setAutoLinkMask(0) - it remains clickable | <p>I try to reuse a TextView. Sometimes it contains a URL and sometimes not. If I try to set the TextView back to textView.setAutoLinkMask(0) it does unfortunately nothing and the new text remains clickable.</p>
<pre><code>TextView snippet = new TextView();
snippet.setText("someText");
if (ifSomeTextContainsURL) {
// Recognize web URLs
Linkify.addLinks(snippet, Linkify.WEB_URLS);
snippet.setLinksClickable(true);
} else {
Linkify.addLinks(snippet, 0);
snippet.setLinksClickable(false);
snippet.setAutoLinkMask(0x00000000);
}
</code></pre>
<p>I tried the above code but it doesn't work for me.
Thx for help</p>
| android | [4] |
4,313,298 | 4,313,299 | Why does the class get reloaded? | <p>I am creating an android app that will send a SMS to another SIM connected to an electrical circuit. When the receiving SIM gets the message with a particular text, the electrical circuit will be closed and a motor will start running. Here is the program</p>
<pre><code>public class SendSMSActivity extends Activity implements View.OnClickListener{
ImageView image1;
Button turnon;
/** Called when the activity is first created. */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
turnon = (Button) findViewById(R.id.button1);
image1 = (ImageView) findViewById(R.id.image1);
turnon.setOnClickListener(this);
}
public void onClick(View v)
{
String phoneNo = "XXXXXXXXXX";
String message = "Turn On";
if (phoneNo.length()>0 && message.length()>0)
{
sendSMS(phoneNo, message);
image1.setImageResource(R.drawable.greenon);
}
else{
Toast.makeText(getBaseContext(),
"Phone Number and Message not configured correctly.",
Toast.LENGTH_SHORT).show();
image1.setImageResource(R.drawable.redon);
}
}
protected void sendSMS(String phoneNo, String message) {
// TODO Auto-generated method stub
PendingIntent pi = PendingIntent.getActivity(this, 0,
new Intent(this, SendSMSActivity.class), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNo, null, message, pi, null);
}
}
</code></pre>
<p>The problem I have is that after the image comes up on the screen after the click, it doesn't stay on the screen. Instead the class gets reloaded and the image resets back to its original image. How can I get the image to stay on the screen without changing back to the original image.</p>
| android | [4] |
3,092,416 | 3,092,417 | I could not understand this that why to use flush() method of a PrintWriter class? | <p>Why the code here is using <code>flush()</code> method of the <code>PrintWriter</code> class after getting message from <code>messageBox</code> field....?</p>
<pre><code>public void connectToSocket() {
try {
Socket socket = new Socket("localhost", 80);
PrintWriter writer = new PrintWriter(socket.getOutputStream);
System.out.println("Connected Successfully");
}
catch(IOException ex) {
ex.printStackTrace();
}
}
public class sendMessageListener implements ActionListener {
try {
writer.println(messageBox.getText());
writer.flush();
}
catch(IOException ex) {
ex.printStackTrace();
}
}
</code></pre>
| java | [1] |
3,228,313 | 3,228,314 | Browser's zoom-in and zoom-out function calling | <p>Is it possible to trigger a javascript function with Browser's zoom-in and zoom-out?</p>
| javascript | [3] |
3,521,779 | 3,521,780 | Stuck to create Paypal App Id to integrate with iPhone application | <p>I am trying to develop iPhone shopping application. In my app, I integrate with Paypay checkout payment. It request "Paypal App ID".</p>
<p>When I try to create "Paypal App ID" in <a href="http://www.x.com" rel="nofollow">http://www.x.com</a> (login with Paypal account and go to "My Account" and then "New App" ). It request "Testing Information", I have to show "Step-by-Step Payment Flows Instructions" for reviewing by them.</p>
<p>But I did not upload my iPhone app to Apple store yet, I can not show them the demo.
They also do not provide UDID of their iphone/ipad to allow me deploy Ah Hoc Distribution to show them.</p>
<p>What I have to do to pass this step, to allow me get "Paypal App ID"?</p>
<p>Thank you!</p>
| iphone | [8] |
4,855,144 | 4,855,145 | Head First Java example explanation needed | <p>Hi! I'm reading Head First Java and i can't understand the behaviour of the following code:</p>
<pre><code>public class Dog {
String name;
public static void main(String[] args) {
// make a Dog object and access it
Dog dog1 = new Dog();
dog1.bark();
dog1.name = "Bart";
// now make a Dog array
Dog[] myDogs = new Dog[3];
// and put some dogs in it
myDogs[0] = new Dog();
myDogs[1] = new Dog();
myDogs[2] = dog1;
// now acces the Dogs using the array references
myDogs[0].name = "Fred";
myDogs[1].name = "Marge";
// Hmmm... what is MyDogs[2] name?
System.out.print("last dog name is ");
System.out.println(myDogs[2].name);
// now loop through the array
// and tell all dogs to bark
int x = 0;
while (x < myDogs.length) {
myDogs[x].bark();
x = x + 1;
}
}
public void bark() {
System.out.println(name + " says Ruff!");
}
</code></pre>
<p>The output produced by this code is the following:</p>
<pre><code>null says Ruff!
last dog name is Bart
Fred says Ruff!
Marge says Ruff!
Bart says Ruff!
</code></pre>
<p>I have a very hard time understanding this, IMO the code should run to somekind of infinite loop. From what i understand (and i've previously programmed in python): When the class is acticated, the main method gets called, and then inside the main method, two more classes of the same type are created. (Now here comes the incomprehensible part -->) When the new class is created, inside it's main method, 2 more classes are created and so on .. How can it be that it produces the output shown above, when it creates an infinte number of classes, so the code should actually never finish running. </p>
<p>Thank you!</p>
| java | [1] |
2,431,920 | 2,431,921 | PHP script no longer works because of v.4 to v5 migration | <p>Recently my webserver migrated from PHP v.4 to v.5.3. I know, I know, long time coming :)</p>
<p>But now a number of my scripts do not display results when a user enters the required data. Here is the script:</p>
<pre><code><?php
if ($ok) {
if ($heightft == "" || $heightin == "" || $weight == "") {
$error = "<br><FONT COLOR=#FF0000>One of the fields above was not completed.</FONT><br>";
} else {
$bmi = $weight * 703 / (($heightft * 12 + $heightin) * ($heightft * 12 + $heightin));
$bmiString = number_format($bmi,2,".","");
echo "<table border='1' cellpadding='10' bordercolor='0000FF'><tr><td><strong>Your BMI is: " . $bmiString;
echo "<br><br></strong>";
if ($bmi <= 18.50) {
echo "You are classified as <strong>Underweight</strong>.";
} elseif ($bmi <= 24.99) {
echo "You are classified as <strong>Normal</strong>.";
} elseif ($bmi <= 29.99) {
echo "You are classified as <strong>Overweight</strong>.";
} else {
echo "You are classified as <strong>Obese</strong>.</td></tr></table></bordercolor>";
}
}
}
?>
<?php echo $error;?>
</code></pre>
| php | [2] |
3,845,654 | 3,845,655 | killProcess can be used in some cases? | <p>I have a logout button in my activity. In my case the killProcess do what I want to do instead of the finish(), but is it a good idea to use killProcess? I have read that is better not to use killProcess but in some cases seems to be useful. </p>
| android | [4] |
4,196,460 | 4,196,461 | Does foreach do its work on a copy of the input array? | <p>I've been studying some test questions. One of the questions about array iteration. Here it is : </p>
<blockquote>
<p>What is the best way to iterate through the $myarray array, assuming
you want to modify the value of each element as you do?</p>
<pre><code><?php
$myarray = array ("My String",
"Another String",
"Hi, Mom!");
?>
</code></pre>
<p>A. Using a for loop</p>
<p>B. Using a foreach loop</p>
<p>C. Using a while loop</p>
<p>D. Using a do…while loop</p>
<p>E. There is no way to accomplish this goals</p>
</blockquote>
<p>My answer is "of course foreach loop". But according to the answer sheet :</p>
<blockquote>
<p>Normally, the foreach statement is the most appropriate construct for
iterating through an array. However, because we are being asked to
modify each element in the array, this option is not available, since
foreach works on a copy of the array and would therefore result in
added overhead. Although a while loop or a do…while loop might work,
because the array is sequentially indexed a for statement is best
suited for the task, making Answer A correct.</p>
</blockquote>
<p>I still think foreach is the best. And as long as I use it with key I can modify values.</p>
<pre><code><?php
foreach($myarray as $k=>$v){
$myarray[$k] = "Modified ".$v;
}
?>
</code></pre>
<p>Do I miss something?</p>
| php | [2] |
2,403,377 | 2,403,378 | PHP- Date function confusion in tamil format | <p>I want like this in PHP date format</p>
<p><code>$date1= 2012-02-22 15:31:01;</code> is to </p>
<p>புதன்கிழமை, 22 பெப்ரவரி 2012, 07:55.53 மு.ப GMT</p>
| php | [2] |
2,556,391 | 2,556,392 | Error Message 'class::function' : illegal call of non-static member function | <p>i was trying to call a static function of class using scope resolution operator, the way to access static function but still generating error. what are the possibilities.</p>
| c++ | [6] |
5,217,268 | 5,217,269 | google analytics how does it save data? | <p>I understand that google analytics uses first party cookie tracking, so it sets the cookie from the domain being visited with javascript (rather than setting the cookie from google-analytics.com)</p>
<p>I am wondering how the ga.js google analytics script saves the cookie data to the database to be reported on by google analytics?</p>
<p>I cant see any reference to a script or url where the data is being saved to a db e.g. in here <a href="http://google-analytics.com/ga.js" rel="nofollow">http://google-analytics.com/ga.js</a></p>
<p>Any ideas?</p>
<p>Cheers Ke</p>
| javascript | [3] |
2,309,773 | 2,309,774 | Send file to user | <p>How to send a file to the user so they can choose directory and file name. The code below let the user download the file but it does not allow for directory selection in Firefox. How can I fix it?</p>
<pre><code>// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
</code></pre>
| php | [2] |
1,743,309 | 1,743,310 | How to split the array values and store in a string in android? | <p>I am getting the values from arraylist <strong>arr</strong> and storing those values in a string with comma separator. But for the last value also comma is adding. How can I remove that? Please help me...</p>
<p>My Code:</p>
<pre><code>ArrayList<String> arr;
String str;
for (int i = 0; i < arr.size(); i++) {
int kk = arr.size();
System.out.println("splitting test" + arr.get(i));
str += arr.get(i) + ",";
System.out.println("result" + str);
}
</code></pre>
| android | [4] |
3,519,805 | 3,519,806 | How to store binary data in PHP | <p>People know all about storing binary data in database server as BLOBs. How would one accomplish the same thing in PHP? </p>
<p>In other words, how do i store blobs in a php variable?</p>
| php | [2] |
2,662,564 | 2,662,565 | If you grow a div and shrink a div in the same column of divs simultaneously, how can you keep the vertical position stable? | <p>Say I have a column of DIV siblings. A click on DIV 3 causes DIV 1 to "unexpand" and DIV 3 to expand (grow longer). This is usually okay if DIV 1 and DIV 3 are about the same height when expanded and unexpanded. But if DIV 1 and DIV 3 are very different heights, then the the browser viewport shifts the mouse pointer away from DIV 3, which the user just clicked on. </p>
<p>I'm not sure if I'm explaining this clearly, but I think Google reader gets around this problem somehow when you expand a feed item and then expand another one that's below that one.</p>
<p>The question, again, is how do you keep the mouse pointer in the same position relative to the div that it just clicked on when the divs around it change in size?</p>
<p>I'm using jQuery.</p>
| jquery | [5] |
1,358,826 | 1,358,827 | crashes Application class | <p>I sit with the problem. Here's the thing.
I am writing an application to display pdf files.</p>
<p>The process of rendering files, runs parallel to the main stream. For very frequent turns the screen comes a time when all the objects in my class application become null.</p>
<p>how do I disable screen rotation and wait for the completion of rendering the page?</p>
<p>I tried used </p>
<blockquote>
<p>setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
setActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);</p>
</blockquote>
<p>but in setting the screen SCREEN_ORIENTATION_SENSOR, the screen orientation is changed several times</p>
| android | [4] |
718,588 | 718,589 | In ASP.net Page life cycle on which state Controls is accessible? | <p>In an ASP.net page life cycle, on which state are controls accessible?
According to me it is after Initialize, is that correct?</p>
| asp.net | [9] |
4,267,631 | 4,267,632 | Issues with creating a new profile for an existing application | <p>I have a working android application. And I am using ant to build the code. I give the following command for building the code.</p>
<p>ant compile -Dbuild.scope=XXX -Dbuild.mode=debug -Dbuild.profile=ABC</p>
<p>now the scope here is referring to what all applications I need to build for that product and profile refers to the Hardware profile for which the code will be built.</p>
<p>I wanna port my application on emulator, my device and a tablet. I will be able to achieve this by just changing the parameters of the command that I use to build the code. Like the scope will be the same, but the profile will change as per the output device. I wanna do it for a tablet this time.</p>
<p>Problem:
What should be the content of my tablet.profile in order to build the code successfully.</p>
| android | [4] |
3,841,268 | 3,841,269 | Isolating picture attachment from email with php | <p>I'm using the following php script to receive and process emails, putting the various pieces into variables to handle later on.</p>
<pre><code>#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
// handle email
$lines = explode("\n", $email);
// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;
for ($i=0; $i < count($lines); $i++) {
if ($splittingheaders) {
// this is a header
$headers .= $lines[$i]."\n";
// look out for special headers
if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
$subject = $matches[1];
}
if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
$from = $matches[1];
}
} else {
// not a header, but message
$message .= $lines[$i]."\n";
}
if (trim($lines[$i])=="") {
// empty line, header section has ended
$splittingheaders = false;
}
}
</code></pre>
<p>Im wondering where would i start in order to accept a picture attachment and isolate that into a variable so i can process it however i needed to.</p>
| php | [2] |
463,449 | 463,450 | how to replace (update) text in a file line by line | <p>I am trying to replace text in a text file by reading each line, testing it, then writing if it needs to be updated. I DO NOT want to save as a new file, as my script already backs up the files first and operates on the backups.</p>
<p>Here is what I have so far... I get fpath from os.walk() and I guarantee that the pathmatch var returns correctly:</p>
<pre><code>fpath = os.path.join(thisdir, filename)
with open(fpath, 'r+') as f:
for line in f.readlines():
if '<a href="' in line:
for test in filelist:
pathmatch = file_match(line, test)
if pathmatch is not None:
repstring = filelist[test] + pathmatch
print 'old line:', line
line = line.replace(test, repstring)
print 'new line:', line
f.write(line)
</code></pre>
<p>But what ends up happening is that I only get a few lines (updated correctly, mind you, but repeated from earlier in the file) corrected. I think this is a scoping issue, afaict.</p>
<p>*Also: I would like to know how to only replace the text upon the first instance of the match, for ex., I don't want to match the display text, only the underlying href.</p>
| python | [7] |
4,350,063 | 4,350,064 | what are the mathematical formulas/concepts used in implementing Chart API (bar chart, pie chart etc.,) | <p>Trying to implement chart API in Java. But I am unsure of the mathematical formulas/concepts used in drawing each of the chart type. Can someone specify the mathematical concepts to be known for drawing each sort of the chart.</p>
| java | [1] |
4,516,425 | 4,516,426 | Java concurrency lock and condition usage | <p>I can use <code>object.wait</code> ,<code>object.notify</code> and <code>synchronized blocks</code> to solve the producer consumer type of problems. At the same time I can use <code>locks</code> and <code>conditions</code> from <code>java.util.concurrent</code> package. I am sure I am not able to understand why we need conditions when we can use <code>object.wait</code> and <code>notify</code> to make threads waiting on some condition like queue is empty or full. Is there any other benefit we are getting if we use <code>java.util.concurrent.locks.Condition</code> ?</p>
| java | [1] |
5,296,355 | 5,296,356 | need to understand Java SE before delving into Java EE? | <p>i want to learn coding web apps with java using glassfish.</p>
<p>i have bought a book "Beginning JAVA EE 6 Platform with Glassfish 3 - From Novice to Professional". I wonder if I can jump to this book directly or do I need to read a book about JAVA SE first?</p>
<p>I just want to develop web apps and not desktop applications nor browser java applets.</p>
<p>Thanks in advance.</p>
| java | [1] |
4,812,603 | 4,812,604 | Dual or triple (or even multiple) comparison in JavaScript | <p>Almighty Gurus,
Please tell me, I want to know can comparison sm. set of variables in row, like this:</p>
<pre><code>x < y >= z
</code></pre>
<p>or i need to do it in two steps?</p>
<pre><code>(x < y) && (y >= z)
</code></pre>
| javascript | [3] |
2,340,497 | 2,340,498 | Cannot Import Counter is encountered in python 2.7.3 on CSH | <p>I am using UNIX's cShell in my Windows 7 OS.<br>
When I am executing a prog. it shows an error every time :<code>can not import name Counter</code>.<br>
though I have mentioned in the script <code>from collections import Counter</code>.<br>
I am using <code>Python 2.7.3</code>, then why this problem is persisting.</p>
| python | [7] |
5,282,348 | 5,282,349 | DOM running slow on jQuery click function | <p>I have a small issue with the DOM taking up to 30 seconds to recognize that a click has been made. When I click back and forth between "A" and "C" the menu that shows up takes more and more clicks to show up. The DOM sometimes takes up to 30 seconds to recognize the change has been made and I usually end up having to double-click after a while to get the click recognized.</p>
<p>Is there a proper way to handle adding/removing classes using jQuery that doesn't throttle the DOM?</p>
<p>The code is here: <a href="http://jsfiddle.net/chrisabrams/F7nQ4/6/" rel="nofollow">http://jsfiddle.net/chrisabrams/F7nQ4/6/</a></p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.