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 |
|---|---|---|---|---|---|
3,692,254 | 3,692,255 | traversing an object tree | <p>I'm trying to find information on different ways to traverse an object tree in python.
I don't know much about the language in general yet, so any suggestions/techniques would be welcome.</p>
<p>Thanks so much
jml</p>
| python | [7] |
4,612,528 | 4,612,529 | asp:RequiredFieldValidator | <h2>This is my first question in stackoverflow.com. I am working on a school project which I have to validate the input from the user. Everytime the page load, it give the server error message. Please see the codes, and the error message after.</h2>
<pre><code><div>
<table>
<td>
<asp:RadioButton ID="RadioButton1" runat="server"></asp:RadioButton>
<asp:RequiredFieldValidator ID="validateCheck" runat="server" ControlToValidate="RadioButton1" ErrorMessage="Please Enter" Display="Dynamic"></asp:RequiredFieldValidator>
</td>
</table>
</div>
</code></pre>
<hr>
<pre><code>Server Error in '/' Application.
Control 'RadioButton1' referenced by the ControlToValidate property of 'validateCheck' cannot be validated.
</code></pre>
| asp.net | [9] |
2,248,878 | 2,248,879 | Getting all startup items? | <p>Ok, I guess I'm having a brain fart here and cant find my way out of it. What I'm trying to accomplish is to list all startup items (applications, processes, etc) and display them on a form (like what you get with msconfig.exe). I thought this code would do it:</p>
<pre><code>private List<StartupItems> getStartupItems()
{
try
{
ManagementClass cls = new ManagementClass("Win32_StartupCommand");
ManagementObjectCollection coll = cls.GetInstances();
List<StartupItems> items = new List<StartupItems>();
foreach (ManagementObject obj in coll)
{
items.Add(
new StartupItems
{
Command = obj["Command"].ToString(),
Description = obj["Description"].ToString(),
Name = obj["Name"].ToString(),
Location = obj["Location"].ToString(),
User = obj["User"].ToString()
});
}
return items;
}
catch (Exception ex)
{
_message = ex.ToString();
_status = false;
return null;
}
</code></pre>
<p>But all that gets are the enabled ones with my username. What I'm trying to get is all items, either my username or system, all the enabled ones and all the disabled ones as well (just like msconfig). I've done tons of searching and cannot find anything really any different than what I'm using.</p>
| c# | [0] |
5,235,312 | 5,235,313 | Is that possible to call finish() after some time of application's invisible state? | <p>Is that possible to set a timer which would work on background and triggered on <code>onStop()</code>, i.e. when application goes off the user's screen? I need to "kill" the application so it will start from scratch after some time being invisible to the user.</p>
| android | [4] |
3,291,620 | 3,291,621 | jQuery - create an array containing images located in a server folder | <p>I'm pretty new to jQuery and I am trying to achieve the following solution. </p>
<p>I am using a nice image carousel/slider that requires me to have a div on the page containing the images that I want the carousel to use. I want the flexibility to put images in a folder instead of hard coding them, and the images then be displayed, so:</p>
<ul>
<li>a folder (img) on my server containing any number of images</li>
<li>some solution to create a list (array) of the images (their paths)</li>
<li>the list or array to be used with the carousel, whether it just generates the HTML or not I guess is half the problem! </li>
</ul>
<p>I appreciate the help!</p>
<p>@RobW - as I said I am learning.. </p>
<p>/--- edit: I found a solution using jQuery templates. It may not be the smartest, but here it is:</p>
<p>I created a div that I want the images placed in:</p>
<pre><code><div id="imageContainer"></div>
<!-- Create template -->
<script id="imageTemplate" type="text/x-jquery-tmpl">
<img id="imageItem" src='../PublishingImages/${Name}' alt="${Desc}" />
</script>
<!-- Get data -->
<script type="text/javascript">
$(document).ready(function () {
$.getJSON(
'../_vti_bin/ListData.svc/Images',
function(data) {
$('#imageTemplate') //select the template
.tmpl(data.d.results) //bind it to the data
.appendTo('#imageContainer'); //render the output
});
});
</script>
</code></pre>
| jquery | [5] |
3,065,628 | 3,065,629 | Creating a dynamic embed code | <p>I'm having issues creating a dynamic embed. I basically need it to change dynamically (e.g index.php?channel=randomname), but I want it so when they input the name it changes the name in the embed to what they put. </p>
<pre><code><object type="application/x-shockwave-flash"
data="http://www.justin.tv/widgets/live_embed_player.swf?channel={$id}"
id="live_embed_player_flash"
height="300"
width="400"
bgcolor="#000000">
<param name="allowFullScreen" value="true"/>
<param name="allowScriptAccess" value="always" />
<param name="allowNetworking" value="all" />
<param name="movie" value="http://www.justin.tv/widgets/live_embed_player.swf" />
<param name="flashvars" value="hostname=www.justin.tv&channel={$id}&auto_play=false&start_volume=25" />
</object>
</code></pre>
<p>But at the same time I'd like a default video when it's index.php or an invalid link. How can I do this?</p>
| php | [2] |
3,129,649 | 3,129,650 | Can one programmatically generate the focused image for an ImageButton? | <p>I'm porting an application from iPhone to Android. The iPhone app has artwork for some dozen or more buttons in their normal and pressed state. That translated over just fine to Android. However, we of course currently don't have any images for the "focused" state.</p>
<p>Besides the work involved in creating all these focused button images, we're not sure exactly what color to set the focus too. Selection color varies from phone to phone, etc. We'd have to come up with some neutral "white glow" of some sort I suppose. Then the idea struck -- could we programmatically render a focus images for the buttons based on the current selection color? Have folks been doing anything like this in the Android dev community? Can you point me to some examples. A net search didn't turn up anything too useful, though perhaps I searched on the wrong keywords.</p>
<p>Thank you!</p>
<p>The Xdog.</p>
| android | [4] |
2,894,517 | 2,894,518 | i want to compare names in two different tables and then equal get details | <p>i have two different tables.I want to compare the names in two tables,if both the names are equal then i want to get the details.how can i do that? please help me.</p>
<p>Here is the code: </p>
<pre><code>Cursor cr=mDbManager.fetchnewcustomerdata();
Cursor cr1 = mDbManager.fetchinvoicecustomerdata();
cr1.moveToFirst();
//String address;
while (!(cr1.isAfterLast())) {
String name = cr1.getString(cr1.getColumnIndex("icstname"));
if(name.equals(cr.getString(cr.getColumnIndex("cname"))))
{
Toast.makeText(this,"equal",1000).show();
}
String address = cr1.getString(cr1.getColumnIndex("caddress"));
map.put(name, address);
nameAList.add(cr1.getString(cr1.getColumnIndex("icstname")));
cr1.moveToNext();
}
mDbManager.close();
}
</code></pre>
| android | [4] |
5,061,932 | 5,061,933 | question about inline keyword | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3212571/usefulness-of-the-inline-feature">Usefulness of the “inline” feature</a> </p>
</blockquote>
<p>why is used inline keyword in c++?</p>
| c++ | [6] |
1,783,503 | 1,783,504 | Is there a reversed function for mysql_escape_string? | <p>So that I can change string like <code>I\'ll go</code> back to <code>I'll go</code></p>
| php | [2] |
4,938,109 | 4,938,110 | What tools do you use to look up in android reference? | <p>Currently, i am using a chrome plugin called "Android SDK Reference Search". But it can only search class. I want to search certain method in a class. <br>
For example, i want to search <code>onCreate</code> method in <code>android.app.Activity</code>. After i input something like <code>Activity#onCreate</code> then the browser will jump to the method. Does this tool exist?</p>
| android | [4] |
4,803,907 | 4,803,908 | Jquery - How list id elements contained from a div | <p>If I have a div like this:</p>
<pre><code><div id="box">
<div class="but" id="1">Text 1</div>
<div class="but" id="2">Text 2</div>
</div>
</code></pre>
<p>How can I create an array of all IDs of the <code>.but</code> elements contained in the <code>#box</code> div?</p>
<p>In the example will be <code>[1, 2]</code>.</p>
| jquery | [5] |
1,764,352 | 1,764,353 | Return numeric value and addClass | <p>I need to find the numeric value inside a div and add a class accordingly. How do I find the numeric value? This seems to only return class of 'medium' so far.</p>
<pre><code><h4 class="days">Over <span class="filterUrgency">71</span> Days</h4>
$('.days').addClass(function() {
if ($('.filterUrgency').val() >100) {
return 'urgent';
} else {
return 'medium';
}
});
</code></pre>
<p>or</p>
<pre><code>$('.days').addClass(function() {
var number = parseInt($('.filterUrgency').text());
if (number >100) {
return 'urgent';
} else {
return 'medium';
}
});
</code></pre>
| jquery | [5] |
154,159 | 154,160 | Access Tableview Cell in some other methods | <p>How to access a table view cell in some other user defined methods other than those predefined methods for tableview???</p>
<p>Plz help...
Thanx in advance...</p>
| iphone | [8] |
538,845 | 538,846 | Trouble centering simple jquery sideshow with nav under | <p>Im currently recoding my site. Keeping it very minimal. But I am having trouble getting the links nav to behave properly. I want them to sit underneath the images about 50px's. Currently on the nav div I have a margin-top value of around 550px. But once you get it on a different size screen it obviously will be higher or lower depending on screen size. I'm obviously very new and would appreciate the help greatly!</p>
<p>You can view my site here:
<a href="http://www.twentyfivethree.com" rel="nofollow">www.twentyfivethree.com</a></p>
| jquery | [5] |
3,940,172 | 3,940,173 | Physical constness of a class | <p>I'm studying "The C++ Programming Language" from Bjarne Stroustrup and he talks about logical and physical constness of a class. </p>
<p>The example of logical constness is something like:</p>
<pre><code>class A {
int m;
void func() const { m++; } //forbidden
}
</code></pre>
<p>It's possible to bypass this with a cast, like:</p>
<pre><code>class A {
int m;
void func() const { (A*) this)->m++; } //allowed
}
</code></pre>
<p>In his words, logical constness is </p>
<blockquote>
<p>"an object that appears constant to its users."</p>
</blockquote>
<p>and physical constness is</p>
<blockquote>
<p>"stored in read-only memory"</p>
</blockquote>
<p>As a note he says that </p>
<blockquote>
<p>physical constness may be enforced by placement of an object in read-only memory only for classes without constructors</p>
</blockquote>
<p>I didn't quite understand this statement. Could someone provide an explanation on how to enforce physical constness and why it does not work if the class has a constructor?</p>
| c++ | [6] |
5,390,080 | 5,390,081 | SIGXFSZ on ideone.com? | <p>I want to print repeated characters in a string in ascending order. This code compiles but gives a <code>SIGXFSZ</code> runtime error with no output on online c++ compilers... any suggestions?</p>
<pre><code>#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
int main()
{
unsigned int i;
char str[26];
int a[26];
for(i=0;i<26;i++)
a[i]=0;
A:
i=0;
cout<<"Enter the string:";
cin>>str[i];
while(str[i]!=13)
{
if(isalpha(str[i]))
i++;
else{
cout<<"Invalid string";
goto A;
}
}
cout<<"You Enterd:"<<str;
for(i=0;i<strlen(str);i++)
++a[str[i]-97];
cout<<"\nLetters Frequency:";
for(i=0;i<26;i++)
cout<<a[i]<<" ";
cout<<"\nDuplicates in sorted order:";
for(i=0;i<26;i++)
{
if(a[i]>1)
cout<<char(i+97);
}
return 0;
}
</code></pre>
| c++ | [6] |
2,121,479 | 2,121,480 | How to clear the search bar history | <p>I am working on google quick search bar; I know it is easy to clear the history if I extend the class <code>SearchRecentSuggestionsProvider</code>. </p>
<p>However, are there any way that I can save and clear the history without extending the class SearchRecentSuggestionsProvider?</p>
| android | [4] |
3,463,046 | 3,463,047 | Panel not displaying when it should be | <p>So in my very small program I am generating a random percentage and based off that percentage it should display one of two panels. However, it is only ever displaying one.</p>
<p>Here is my code:</p>
<pre><code>Random random = new Random();
private void button1_Click(object sender, EventArgs e)
{
bool button1Clicked = true;
if (button1Clicked == true) { ITIpanel.Visible = true; }
}
private void ITIpanel_Paint(object sender, PaintEventArgs e)
{
ITItimer.Enabled = true;
}
private void ITItimer_Tick(object sender, EventArgs e)
{
double rand = random.NextDouble();
if (rand <= .50) { bluestimPanel.Visible = true; }
if (rand >= .50) { redstimPanel.Visible = true; }
ITItimer.Enabled = false;
}
private void bluestimPanel_Paint(object sender, PaintEventArgs e)
{
Trialtimer.Enabled = true;
}
private void redstimPanel_Paint(object sender, PaintEventArgs e)
{
Trialtimer.Enabled = true;
}
private void Trialtimer_Tick(object sender, EventArgs e)
{
bluestimPanel.Visible = false;
redstimPanel.Visible = false;
Trialtimer.Enabled = false;
ITIpanel.Visible = true;
}
</code></pre>
| c# | [0] |
1,877,803 | 1,877,804 | ImageView - draw translucent color on top for its focused state? | <p>I have an ImageView, I'd like a selector such that when the user clicks or otherwise has focus, a translucent color is drawn on top of the ImageView content. I'm not sure if this is possible with selectors (which I've been defining ok in the past with static drawables). </p>
<p>But basically I have a listview with imageview instances in each row, and wanted to do something like:</p>
<pre><code>ImageView iv = ...;
iv.setBitmapDrawable(bitmapLoadedFromInternets()); // dynamic content
iv.setClickStateOverlayColor(0x33ff0000); // ?
</code></pre>
<p>Usually ImageView only takes a single drawable via setBitmapDrawable(), but a selector (1) swaps out the drawable for the different click states, whereas I just want a color overlay drawn, and (2) the off state is a dynamic bitmap, so I can't reference that from a selector definition.</p>
<p>Thanks</p>
| android | [4] |
4,702,876 | 4,702,877 | Storing and retrieving user files on a different server / sub domain | <p>I'm looking for some quick info about best practices on storing user's uploaded files on different servers or sub domains...</p>
<p>For example, photos on facebook of course arent on facebook.com/files/users/453485 etc...
but rather on photos.ak.fbcdn.net or whatever...</p>
<p>I'm wondering how with php i can upload to a different server whilst maintaining a mysql connection to my original... is it possible?</p>
| php | [2] |
3,474,719 | 3,474,720 | How to get the names of applications seen on home screen in android? | <p>I want to create a list of applications seen on the home screen in android. </p>
<p>Presently i am using the following code : </p>
<pre><code> List<ApplicationInfo> packs = pm.getInstalledApplications(0);
</code></pre>
<p>But this returns all the installed applications but i require only the applications having icons on the home screen.</p>
<p>How can this be done?</p>
<p>Any help appreciated.</p>
| android | [4] |
4,123,662 | 4,123,663 | complie error: X does not exist in the current context | <p>The name 'MenuItems_Click' does not exist in the current context. should i named it anywhere in ContextMenuStrip?thanks</p>
<pre><code>private void icnNotify_Click(object sender, EventArgs e)
{
// Create a new instance of the Favorites class
Favorite.Favorites objFavorites =
new Favorite.Favorites();
// Scan the Favorites folder
objFavorites.ScanFavorites();
// Clear current menu items
FavoritesMenu.Items.Clear();
// Process each objWebFavorite object
// in the Favorites collection
foreach (Favorite.WebFavorite objWebFavorite
in objFavorites.FavoriteCollection)
{
// Declare a ToolStripMenuItem object
ToolStripMenuItem objMenuItem =
new ToolStripMenuItem();
// Set the properties of ToolStripMenuItem object
objMenuItem.Text = objWebFavorite.Name;
objMenuItem.Tag = objWebFavorite.Url;
// Add a handler to Click event of new menu item
objMenuItem.Click +=
new EventHandler(MenuItems_Click);
// Add the ToolStripMenuItem object
// to the ContextMenu
FavoritesMenu.Items.Add(objMenuItem);
}
private void MenuItems_Click(object sender,
System.EventArgs e)
{
// Create a ToolStripMenuItem
// and fill it with sender parameter
ToolStripMenuItem s = (ToolStripMenuItem)sender;
// Open the internet explorer to view selected
// favorite
System.Diagnostics.Process.Start(s.Tag.ToString());
}
private void ExitMenuItem_Click(object sender,
System.EventArgs e)
{
Application.Exit();
}
</code></pre>
| c# | [0] |
442,554 | 442,555 | c++ operator= method for const references | <p>I am writing class with a const reference like this:</p>
<pre><code>class B;
class foo {
const B& b;
foo(const B& newb): b(newb) { }
void operator=(const foo & foo2) {
// This does not work
foo.b = foo2.b;
}
};
</code></pre>
<p>I am trying to define a working operator= Obviously = does not work since I am not allowd to change a const reference. This there a way to let a reference point to another object?</p>
<p>If b is not const c++ will provide me with a working operator=. If I define one member as const cl will spit out:</p>
<p>warning C4512: 'foo' : assignment operator could not be generated</p>
| c++ | [6] |
1,348,257 | 1,348,258 | Exporting data programmatically from an application | <p>In my iPhone application,i have a registration screen contains user name, address,Phone number etc. Now i need to export this data and mail it. How can i export the data programmatically from my screen.Any help?</p>
<p>Thanks in Advance.</p>
| iphone | [8] |
4,326,393 | 4,326,394 | Is there any possibility to convert a varbinary image to its file path in C#? | <p>I want to retrieve the image from the database on edit.</p>
<p>But I want it to appear as its file path (which was uploaded previously).</p>
<p>My idea is to convert varbinary to byte[], byte[] to image using MemoryStream and Image to its file path..</p>
<p>Is it possible and can anyone help me with it</p>
| c# | [0] |
1,791,502 | 1,791,503 | Python Parallel Threading | <p>so basicly I created this program that adds values to redis. So far I get this for time:</p>
<pre><code>real 0m27.759s
user 0m18.129s
sys 0m5.580s
</code></pre>
<p>however when I tried to run multiple threads:</p>
<pre><code>if __name__ == '__main__':
try:
for x in range(0,NUM_THREADS):
Thread(None,startProgram,None,
(NUM_HOSTS/NUM_THREADS*x+1,NUM_HOSTS/NUM_THREADS*(x+1))
).start()
except Exception as errtxt:
print errtxt
</code></pre>
<p>I get this with <code>NUM_THREADS=10</code>:</p>
<pre><code>real 0m32.642s
user 0m22.953s
sys 0m11.473s
</code></pre>
<p>Why is my program running <em>slower</em> with <em>more</em> threads?</p>
<p>Im running linux Ubuntu 11.04 and Python 2.7.1</p>
| python | [7] |
209,061 | 209,062 | Unusual problem with multiple return in Python | <p>When I call the function "<code>G()</code>" which returns two values: <code>p_T</code> and <code>q_T</code> twice (see below) but using the same style, that's, <code>P_T, neg = G(); U, Ign = G()</code> and print sums of <code>P_T</code> and <code>U</code>, I get two different answers! Another thing is that both answers are incorrect!</p>
<p>I have only included part of the code which can simply aid in explaining the idea. The block of statements within the function <code>G()</code> under the for loop is executed N times as the loop suggests. Is there something being compromised by global variables declaration?</p>
<p>Any suggestion of what is wrong and how to fix it is appreciated!</p>
<pre><code>def G():
global p_T; global q_T
for n in range(N):
p_T = U_T(EvolveU_T(p_T))
q_T = V_T(EvolveV_T(q_T))
return p_T, q_T
P_T, neg = G()
print sum(P_T)
U, Ign = G()
print sum(U)
</code></pre>
| python | [7] |
1,638,028 | 1,638,029 | How to compare elements and merge if condition satisfies within arraylist? | <p>i have list of trades, each trades has some attributes like source now, from the list of trades, i want to get all trades that have same source value and combine them together into one trade, for example </p>
<pre><code>tradeName quote source quantity price
Google GOOG Goldman Sachs 15 610
Microsoft MSFT Barclays 400 28
Google GOOG Goldman Sachs 45 610
Google GOOG Goldman Sachs 40 610
Microsoft MSFT Barclays 1000 28
</code></pre>
<p>now based on source information, i should combine trades, so my updated list of trade would be </p>
<pre><code>tradeName quote source quantity price
Google GOOG Goldman Sachs 100 610
Microsoft MSFT Barclays 1400 28
</code></pre>
<p>I am not sure about comparison part, how to go about solving it? </p>
<hr>
<p>Tried following approach, </p>
<pre><code>for (Trade trade : tradeList)
{
//Not sure how to compare this.trade.source with all sources
//of all trades present in the trade.
//Logic should be if source matches then quantity should be added
//but am not sure how comparison would work.
}
Class Trade
{
private tradeName;
private quote;
private source;
private quantity;
private price;
//Getters and Setters for each of above mentioned attributes.
}
</code></pre>
| java | [1] |
715,666 | 715,667 | To PHP experts: How to master PHP? | <p>How many years of experience is needed (on average) for someone to "master" PHP?
What specific projects does he/she need to accomplish in PHP so he/she can consider himself/herself a good PHP programmer?</p>
| php | [2] |
872,133 | 872,134 | Can we make such a class which is not inherits Object class | <p>Can we make such a class which is not inherits Object class directly or indirectly in java.</p>
| java | [1] |
5,720,148 | 5,720,149 | how does google voice do this | <p>When you select new message, you have the option to go to google voice, this is also present when you look at something in your inbox and hit reply. How do they do that? I'm talking about the google voice android app.</p>
| android | [4] |
5,188,248 | 5,188,249 | For Loop Issue, 'i' does not return to zero | <p>I'm not sure how else I can get a loop going that checks to find the letter, checks if it's capital or not by adding a 'C' (or not), and continues with the rest of the characters in the string. I'm not very good at explaining what's happening here as I'm sort of new with C#. But 'i' in the 'for' loop never gets reset back to 0, making it so that you receive the wrong output.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Encrypt
{
class Program
{
static char[] alphabet = new char[52] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'z' };
static void Main(string[] args)
{
string input = Console.ReadLine();
string output = Decode(input);
Console.WriteLine(output);
Console.ReadLine();
}
static string Decode(string input)
{
string output = "";
foreach (Char c in input)
{
for (int i = 0; i < alphabet.GetLength(0); i++)
{
if (c == alphabet[i])
{
int intoutput = i + 1;
if (intoutput > 26)
{
intoutput = intoutput - 26;
output = "C" + intoutput + " ";
}
else
{
output = intoutput + " ";
}
}
}
}
return output;
}
}
}
</code></pre>
| c# | [0] |
4,692,368 | 4,692,369 | What happens when I pass a totally different argument name in a function? | <p>Let's say I have this function:</p>
<pre><code>def print_a_line(line_count, f):
print line_count, f.readline()
</code></pre>
<p>I call it by:</p>
<pre><code>current_line = 3
print_a_line(current_line, current_file)
</code></pre>
<p>What happens now? line_count = 3 or will it be line_count= current_line = 3?</p>
<p>Also, is it a bad thing if I pass different argument names(like I did here with current_line instead of line_count?)</p>
| python | [7] |
4,093,823 | 4,093,824 | Arithmetic operator return type | <pre><code>int main(int argc, char **argv)
{
unsigned char a = 10, b = 100;
std::cout<<sizeof(a-b)<<endl;
return 1;
}
</code></pre>
<p>Output: <code>4</code></p>
<p>What is the return data type?</p>
| c++ | [6] |
4,435,525 | 4,435,526 | Send Email using MFMailComposeViewController | <p>Currently I have a UITextView field with the CheckBox "Detect Links" checked. The contents of the field will always be an email address.</p>
<p>What I want to do is allow the users to tap the email address and the mail composer open inside of my app. </p>
<p>I have read how you implement sending an email inside of your app using <strong>MFMailComposeViewController</strong> but how do I capture the user touching the email address, in the UITextView, and send it to my mail composer code instead of the default action?</p>
| iphone | [8] |
2,653,335 | 2,653,336 | Launch External Process With Time To Live | <p>I need to launch an external process, that at times, will lock up. I have no control over this process. I'm looking for a way to launch an external process in c#, killing it if it takes over N seconds.</p>
| c# | [0] |
3,828,480 | 3,828,481 | i want get the sum of files size in folder by php | <p>i have an folder 'files' ok
i want know the sum of size of its files</p>
| php | [2] |
2,140,615 | 2,140,616 | Transfer data from Windows7 to Windows Mobile 6.5 via USB Cable | <p>I am using Windows7 operating system and i want to make application for transfer data from Windows7 to Windows Mobile 6.5 via USB Cable. I don't know that how to start coding for that application.
any one have some idea for that pls share with me....</p>
<p>thanks. </p>
| c# | [0] |
1,740,199 | 1,740,200 | Cannot read text file in C++ | <p>I am stumped by this simple problem. I am reading a text file with C++: </p>
<pre><code>std::ifstream stream;
stream.open(filename);
if (!stream)
cout << "Invalid stream" << endl;
</code></pre>
<p>And <code>!stream</code> is true but there seems to be nothing wrong with the text file. Under what circumstances can <code>stream</code> be false? </p>
<p><strong>Note:</strong> is_open returns true </p>
| c++ | [6] |
4,220,388 | 4,220,389 | dumb data object holds all common values c++, is this correct | <p>So I am new to c++ and I'm writing for a scientific application.</p>
<p>Data needs to be read in from a few input text files.</p>
<p>At the moment I am storing these input variables in an object. (lets call it inputObj).</p>
<p>Is it right that I have to pass this "inputObj" around all my objects now. It seems like it has just become a complicated version of global variables. So I think I may be missing the point of OOP.</p>
<p>I have created a g++ compilable small example of my program:</p>
<pre><code>#include<iostream>
class InputObj{
// this is the class that gets all the data
public:
void getInputs() {
a = 1;
b = 2;
};
int a;
int b;
};
class ExtraSolver{
//some of the work may be done in here
public:
void doSomething(InputObj* io) {
eA = io->a;
eB = io->b;
int something2 = eA+eB;
std::cout<<something2<<std::endl;
};
private:
int eA;
int eB;
};
class MainSolver{
// I have most things happening from here
public:
void start() {
//get inputs;
inputObj_ = new InputObj();
inputObj_ -> getInputs();
myA = inputObj_->a;
myB = inputObj_->b;
//do some solve:
int something = myA*myB;
//do some extrasolve
extraSolver_ = new ExtraSolver();
extraSolver_ -> doSomething(inputObj_);
};
private:
InputObj* inputObj_;
ExtraSolver* extraSolver_;
int myA;
int myB;
};
int main() {
MainSolver mainSolver;
mainSolver.start();
}
</code></pre>
<p>Summary of question: A lot of my objects need to use the same variables. Is my implementation the correct way of achieving this.</p>
| c++ | [6] |
1,734,545 | 1,734,546 | rating system without reloading a page | <p>i have a page on which i have some rating function like people who like the post can rate up or who don't can rate down.</p>
<p>on that link im calling a php file with some parameters passed in the anchor tag. Then in that php file im saving that rating with +1 or -1 (whichever is the case) in the database and after doing that im redirecting to that first page from where we have rated.
Now this whole function is reloading my whole page which i dont want.Is there any way with which i can do this rating without reloading the page,i want that when a person clicks on rate then just after click the rating should be shown according to what the user just did(+ or -) and that too without reloading the whole page.Is there any way to do that in php???????</p>
| php | [2] |
3,222,748 | 3,222,749 | Populating One Select Box Based on the Selection in Another Select Box - JQuery? | <p>I am trying to populate one select box based on the selection made in the first select box. I've looked online, and found a lot of helpful information on hard-coded options, but I need my options to come from a query (like cfquery in coldfusion). I know that a cfquery is server-side, so I cannot include it in my jquery, but is there another option?</p>
<p>I was using the following example:</p>
<p>down vote accepted</p>
<p>Code speaks for itself:</p>
<p>HTML:</p>
<pre><code><select id="counties">
<option> </option>
<option> somerset </option>
<option> hertfordshire </option>
</select>
<select id="towns" disabled="true">
</select>
</code></pre>
<p>JS:</p>
<pre><code>var countyTowns = [
["Bath", "Bristol"],
["Letchworth", "Hitchin"]
];
$("#counties").change(function() {
var county = this.selectedIndex - 1;
$("#towns").empty();
if (county === -1) {
$("#towns").attr("disabled", true);
} else {
var towns = countyTowns[county];
for (var i = 0; i < towns.length; i++) {
$("#towns").append($("<option></option>").text(towns[i]));
}
$("#towns").attr("disabled", false);
}
});
</code></pre>
<p>What I would need is for towns to be dynamic, and able to be read from a database. </p>
<p>Any help is greatly appreciated!</p>
<p>Thanks</p>
| jquery | [5] |
5,766,225 | 5,766,226 | How to build Android Custom Firmware Image | <p>I have an Android Tablet that is no use for me, as I have just upgraded to an iPad. Now I am just thinking of learning some internals of Android, for that I decided to start with learning how to build a custom firmware image with my own boot images/animation, applications and logos. But I don't know how to proceed with it...Can anyone guide me ?</p>
| android | [4] |
376,330 | 376,331 | How To Set delivery notification whether mail successfull or failure? | <pre><code>HtmlEmail email = new HtmlEmail();
email.setHostName(ip);
email.addHeader("X-ListMember", to);
email.addTo(to);
email.setFrom(from,fromdisplay);
email.setSubject(subject);
email.setHtmlMsg(message);
email.send();
System.out.println("welcome");
</code></pre>
<p>how to solve</p>
| java | [1] |
171,146 | 171,147 | Getting error while using .Val() in jquery | <p>I am using JQuery and I have got below JQuery Code sample.</p>
<p><strong>JQuery Code:</strong></p>
<pre><code> $.ajax({
type: "POST",
url: "Login.aspx", // Send the login info to this page
data: str,
success: function(result)
{
// Show 'Submit' Button
$('#loginButton').show();
// Hide Gif Spinning Rotator
$('#ajaxloading').hide();
var resLength = (result).val().trim().length;
alert(resLength);
if(resLength!=0)
{
var arr = result.split(",");
var fname = arr[0];
var lname = arr[1];
var activeCardNo = arr[2];
var multipleTier = arr[3];
var activeStatus = arr[4];
var access = arr[5];
}
}
});
</code></pre>
<p>In Above code sample when I am trying to use <strong>.val()</strong> in below line </p>
<pre><code>var resLength = (result).val().trim().length;
</code></pre>
<p>it is giving error <strong>"result.val is not a function"</strong>, If I am using just <strong>result.trim().length</strong> its working fine in firefox, however giving error in IE.</p>
<p>Please suggest!</p>
| jquery | [5] |
2,439,762 | 2,439,763 | PHP: passing Arrays from server to client not working! | <p>The server Contents are server.php:</p>
<pre><code><?php
$err["foo"]="bar";
?>
</code></pre>
<p>The client.php</p>
<pre><code><?php
require 'server.php';
echo "<p> Server says: $err['foo']</p>";
?>
</code></pre>
<p>But,This code works :
The new server Contents are server.php:</p>
<pre><code><?php
$err["foo"]="bar";
$errAssign=$err["foo"];
?>
</code></pre>
<p>The client.php</p>
<pre><code><?php
require 'server.php';
echo "<p> Server says: $errAssign</p>";
?>
</code></pre>
<p>Why am i not able to get the contents of the array from the server ?</p>
<p>Tried the following in the client.php</p>
<pre><code> echo "<p> Server says: $err[\'foo\']</p>";
echo "<p> Server says: $err[\"foo\"]</p>";
echo "<p> Server says: $err[foo]</p>";
</code></pre>
<p>None of which are working!!.. please help !!</p>
| php | [2] |
2,160,489 | 2,160,490 | can anybody tell how to use the traceview tool in android | <p>I want the test performance of my applicaton .I know have to use trace view tool but don't know how to use .can anybody tell how to use traceview tool with example</p>
<p>Thanks</p>
| android | [4] |
1,632,874 | 1,632,875 | how to consult the base class of a class | <p>Recently i am learning something about unicode in python2.7, and i want to know something about the base class of str, unicode, basestring, etc. and the relations of them, but i can't find a proper way to look up the base class of them expect read the source code.</p>
<p>e.g.</p>
<pre><code>class child(A):
pass
</code></pre>
<p>How can i know the base class of child using functions?
The only way is reading the source code?</p>
| python | [7] |
3,817,346 | 3,817,347 | Why is 4 not an instance of Number? | <p>Just curious: </p>
<ul>
<li>4 instanceof Number => false</li>
<li>new Number(4) instanceof Number => true?</li>
</ul>
<p>Why is this? Same with strings: </p>
<ul>
<li><code>'some string' instanceof String</code> returns false</li>
<li><code>new String('some string') instanceof String</code> => true</li>
<li><code>String('some string') instanceof String</code> also returns false</li>
<li><code>('some string').toString instanceof String</code> also returns false</li>
</ul>
<p>For object, array or function types the instanceof operator works as expected. I just don't know how to understand this.</p>
<p>[re-opened to share new insights]</p>
<p>After testing I cooked up this functionality to be able to retrieve the type of <em>any javascript object</em> (be it primitive or not):</p>
<pre><code>Object.prototype.typof = objType;
objType.toString = function(){return 'use [obj].typof()';};
function objType() {
var inp = String(this.constructor),
chkType = arguments[0] || null,
val;
function getT() {
return (inp.split(/\({1}/))[0].replace(/^\n/,'').substr(9);
}
return chkType
? getT().toLowerCase() === chkType.toLowerCase()
: getT();
}
</code></pre>
<p>Now you can check any type like this:</p>
<pre><code>var Newclass = function(){}; //empty Constructor function
(5).typof(); //=> Number
'hello world'.typof(); //=> String
new Newclass().typof(); //=> Newclass
</code></pre>
<p>Or test if an object is of some type:</p>
<pre><code>(5).typof('String'); //=> false
new Newclass().typof('Newclass') //=> true
[].typof('Arrray'); //=> true;
</code></pre>
| javascript | [3] |
4,125,658 | 4,125,659 | Python: Problems mocking an instance | <p>I am having problem mocking an object to test a descriptor.</p>
<p>This is the code of the descriptor:</p>
<pre><code>class Text(object):
def __init__(self, default_value=u'', validators=[]):
self.validators = validators
self._value = default_value
def __set__(self, instance, value):
for validator in self.validators:
validator(value).validate()
</code></pre>
<p>this is the test:</p>
<pre><code>def test_text_validator_raises_exception(self):
validator = Mock()
validator.validate.side_effect = ValidationError()
text = Text(validators=[validator])
self.assertRaises( ValidationError, text__set__, (text, '') )
</code></pre>
<p><strong>Edit:</strong>
The function has () in the code I did a typo when copying the code.</p>
<p>The error I got was that <strong>set</strong>() takes exactly 3 arguments. But I noticed in the answers that I shouldn't pass a tuple as a last argument.</p>
<p>But It also isn't working when I called validator('').validate() inside the test function.</p>
| python | [7] |
1,006,730 | 1,006,731 | How save list of objects onStop/onPause of activity in android | <p>Lately writing some app I've been stopped by one problem.</p>
<p>In this app I have two activities: A and B. In activity A I am downloading list of objects from web each time when GPS coordinates change. To this activity there is connected bound service with GPS and Internet connection call. Those objects are then put into list created from their names and after pressing on any of this I can open the B activity passing this object and in activity B get some more info from this object.</p>
<p>Activity B hasn't got any bound service, it's only taking what is inside object and display it.</p>
<p>Because bound service in activity A is unbound in onStop then when I come back to it using a back arrow it takes a while to download everything again. What is more interesting, the list is still filled, but those are only names, the actual list of objects doesn't exist and pressing just after comeback on any of names will cause OutOfBoundException.</p>
<p>So, my question is, what would you advice to do to save this objects when I am living activity A and retrieve them when come back, before download of the new (or this same) list.</p>
<p>I've tried:</p>
<ul>
<li><code>onRestoreInstanceState()</code> with <code>onSaveInstanceState()</code>, because there you can save parcelable list, but the activity A isn't destroyed so fast, so there is no call for <code>onRestoreInstanceState()</code>;</li>
<li><code>Shared preferences</code>, but it was bad choice, because you can't save list there;</li>
<li><code>ContentValues</code> and <code>content resolvers</code> but also, bad choice, because you can't save list.</li>
</ul>
<p>Do you have any more ideas, how it can be done?</p>
<p>Oh, I've forget to mention, <strong>I've taken assumption that there can be mximum 100 objects in list, and each object have 5 fields.</strong></p>
| android | [4] |
5,069,005 | 5,069,006 | Foreach Loop not passing all values as expected | <p>I am trying to loop through an array comprised of IP addresses collected from a text file. The ultimate goal of this is to retrieve the host name for each IP. My problem is I am only getting results from the last IP in the array. I figured it would be pretty simple, but I am clearly missing something.</p>
<pre><code><?php
$thefile = 'myfile';
$arr = file($thefile.".txt");
foreach ($arr as $data) {
echo $hostname = gethostbyaddr($data);" <br>";
?>
</code></pre>
<p>The text file contains several IP's that I know have associated names, but I get </p>
<p>"Warning: gethostbyaddr() [function.gethostbyaddr]: Address is not a valid IPv4 or IPv6 address in..."<br>
for every instance but the last, which returns the correct results. Thanks for any help.</p>
| php | [2] |
4,369,582 | 4,369,583 | Finding a number in a text file and outputting that line of data | <p>I'm having trouble looping through the content of a text file, searching for a number and then once found, outputting the data on the line which the number exists.</p>
<p>At the moment, no matter what number you specify, it will always output the first line of the text file.</p>
<pre><code>cout << endl << "Please enter a staff members ID: ";
cin >> id;
do
{
inStream.seekg(0, ios::beg);
getline(inStream, line);
if (line.find(id))
{
cout << endl << line;
}
else
{
cout << endl << "Error. Could not find the staff member.\n";
}
} while (id != id);
</code></pre>
| c++ | [6] |
4,980,273 | 4,980,274 | How can I create an interface without parameterless constructor in C++? | <p>How can I hide the default constructor from consumers? I tried to write in private but got compilation issues.</p>
<p>solution is:</p>
<pre><code>class MyInterface
{
public:
MyInterface(SomeController *controller) {}
};
class Inherited : public MyInterface
{
private:
Inherited () {}
public:
Inherited(SomeController *controller)
{
}
};
</code></pre>
| c++ | [6] |
3,190,163 | 3,190,164 | PHP - Replace space between words with something | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6042802/how-to-replace-a-string-contains-space-with">how to replace a string contains space with -</a> </p>
</blockquote>
<p>I want to replace blank space between words with something.</p>
<p><strong>Example, I have:</strong></p>
<pre><code>$title = "An example title";
$separator = "*";
</code></pre>
<p>And I want a function which shows:</p>
<pre><code>An*example*title
</code></pre>
<p>Thanks in advance!</p>
| php | [2] |
4,887,316 | 4,887,317 | Formulating my div objects in such a way that it resembles a sine wave | <p>So the basic idea is that I have an array of 8 div rectangles with a width of 30 px and a random height through Math. rand. Right now I'm trying to arrange them such that they form a sine wave pattern. I know I have to use Math.sin somewhere, but I have no clue as to go about it. Any help with this issue will be greatly appreciated. Here is what I have so far:</p>
<pre><code>var divArr = new Array();
for(i = 0; i < 8; i++){
//var rand_numX = Math.floor((100-19)*Math.random()) + 20;
var rand_numY = Math.floor((100-19)*Math.random()) + 20;
divArr[i] = OS.dom.add_element('div', view, {position: 'absolute', width:'30px', height: rand_numY+'px', 'background-color': '#000000'});
}
</code></pre>
| javascript | [3] |
6,020,674 | 6,020,675 | ASP.net: dynamically load web user control | <p>I have a asp.net web page with place holder control and Menu control when user select an item from the menu. It will dynamically load the control based on menu item's value.</p>
<p>I got the control loaded but if i click on the a link button or anything on the web user control (.ascx) The web user control (.ascx) will disappear. I do not know what is causing this. Can someone take a look at my code and see what i'm missing?</p>
<pre><code>Protected Sub Menu1_Click(ByVal sender As Object, ByVal e As EventArgs)
Select Case Me.Menu1.SelectedValue
Case "CustMasterMain"
Dim ccCustMasterMaint As UserControl = CType(Page.LoadControl("~/Controls/Franchise/CustMasterMaintControl.ascx"), UserControl)
Me.phHolder1.Controls.Add(ccCustMasterMaint)
Case "AcctRecInq"
Dim ccAcctRecInq As UserControl = CType(Page.LoadControl("~/Controls/Franchise/custAccountsReceivableInquiry.ascx"), UserControl)
Me.phHolder1.Controls.Add(ccAcctRecInq)
End Select
End Sub
</code></pre>
| asp.net | [9] |
5,604,032 | 5,604,033 | How to sort a list using my own logic (not alphabetically or numerically) | <p>I've spent the last 30 mins looking through existing answers for what I think is a common question, but nothing quite hits it for me. Apologies if this is a dupe.</p>
<p>I've got a list of objects.</p>
<pre><code>List<Journey> journeys;
</code></pre>
<p>The object has a 'status' property - this is a string.</p>
<pre><code>class Journey
{
public string Name;
public string Status;
}
</code></pre>
<p>I want to sort based on this string, however not alphabetically. The status depicts the object's position through a journey, either "Enroute", "Finished", or "Error". When sorted ascending I want them to appear in the following order: "Error", "Enroute", "Finished". (In practice there are more statuses than this so renaming them to fall in alphabetical order isn't an option)</p>
<p>Aside from creating a class for 'status' with value and sort order properties, and then sorting based on that, how do I do this? Or is that the best method?</p>
| c# | [0] |
3,191,195 | 3,191,196 | How to get next year from the current date in iphone? | <p>I have implemented calendar application in which i want to get next year from the current date.I don't know how it possible.
Please help me for this query.</p>
<p>Thanks in advance.</p>
| iphone | [8] |
4,947,393 | 4,947,394 | What is the best way to implement storage for a hit counter in ASP.NET? | <p>I am creating a hit counter which serves to keep track of how many people accessed a particular page. The table which holds this information contains the page_id, ip_address, and timestamp (when the IP address accessed the page).</p>
<p>The "issue" I'm having is which is the best way to save this information. If I store it every time a user accesses the page it affects the website performance as well as problems may rise in the saving process. I was hoping of maybe using the <code>Application_End</code> in the <code>Global.asax</code> file to add the records in the counter table. But how can I save such records? Do I make use of an <code>Application</code> variable? If yes, how?</p>
| asp.net | [9] |
3,699,923 | 3,699,924 | Need a simple maintainable design pattern for a game in Android | <p>I have a simple game</p>
<p>It displays a list of items that the user selects from with game timer.</p>
<p>I am using native Android widgets in an Activity and a Service to control the game. This has turned out to be cumbersome and my Activity is getting bloated and difficult to maintain.</p>
<ol>
<li>I have a timer (currently I am using a count down timer)</li>
<li>I need to keep track of scores and rounds</li>
<li>I need to restore the state when the game changes orientation</li>
<li>I need to access a database.</li>
<li>I need different states in the game (buttons cannot be pressed, and sometimes they can)</li>
<li>I need to pull as much out of the Activity as I can</li>
</ol>
<p>I don't need a canvas, but can someone suggest the best pattern I could use for this? What are the main classes I would have, do I need a game thread etc.</p>
| android | [4] |
1,030,672 | 1,030,673 | How to select particular field in address book in iPhone | <p>i am working on one app and in that i have to open the address book, i have used ABPeoplePickerNavigationController to open address book and in that have stored phone number and email for all the user, however i didnd't know how to store the value of phone number or email, suppose if user clicks on email field the email address stores in some variable and if clicks on phone number store in another variable.</p>
| iphone | [8] |
307,837 | 307,838 | How to focus away from an EditText? | <p>In my application I need to make something happen when an EditText loses its focus. When editing an EditText I can't make it lose its focus. In windows phone there is the this.Focus(); method but here in android it doesn't seem to be the same. How can I do???</p>
| android | [4] |
2,156,664 | 2,156,665 | Android Audio Control to forward and Reverse | <p>I am creating a custom Audio Player. So far I am able to add features such as Audio streaming, volume control, Duration, Progress bar etc. I have to add feature where user can touch a slider and jump audio to skip some part. Is there any way to do this?</p>
| android | [4] |
2,022,573 | 2,022,574 | How to use different URLs for Simulator and Device | <p>I am building a Web application.</p>
<p>When I am testing it on a simulator, I want to typically use a local loop back URL e.g. localhost because the test may mess up the data on a real server. When I want to test/release on a Device, I want to use a real server.</p>
<p>I can change the value manually, of course, but it is easy to forget to change. I am looking for an automatic solution if it is possible.</p>
<p>E.g. if I am using Debug or just Run, I know that I could use DEBUG flag that is set by the Project settings to produce different codes.</p>
<p>i.e.</p>
<pre><code>#ifdef DEBUG
kURL = @"http://localhost/xyx"
#else
kURL = @"http://realserver/xyz"
#endif
</code></pre>
<p>Since the flag is automatically set by the Xcode (I still choose whether to Run or Debug from the Menu), it relieves me from manually setting the flag in the code myself regarding whether it is run for Debug or Run.</p>
<p>Although this is useful, the DEBUG flag is no use to detect either it is run on a simulator or on a device.</p>
<p>I don't know whether there is any flag defined to identify whether it is running on a simulator or a device (or different versions/names of SDKs, since it seems that they use different SDKs), that I could use to instruct the code to use different URLs. </p>
<p>Any idea?</p>
<p>Thanks.</p>
| iphone | [8] |
4,627,039 | 4,627,040 | Why won't PHP retrieve my $_SESSION variables? | <p>I was making a login system for a site today and had finished up all the code and everything was working fine. I pushed the changes to get and came back a few hours later to start developing again. Everything was working fine and I changed no code, then sessions stopped working. Now even very simple code will not work and I can not figure out why. Sessions were working and then just stopped for no reason. </p>
<p>page1.php:</p>
<pre><code><?
session_start();
$_SESSION['test'] = 'hello world';
print_r($_SESSION);
?>
</code></pre>
<p>output:
Array ( [test] => hello world )</p>
<p>The output is just as expected. However:
page2.php</p>
<pre><code><?
session_start();
print_r($_SESSION);
?>
</code></pre>
<p>output:
Array ( )</p>
<p>I can not figure out what the problem is, no code was changed between the time it worked, no server updates nothing. I use linode so my host did not change anything. Can anyone please tell me what to do here I have been at this for hours no suggestions help. </p>
| php | [2] |
2,448,484 | 2,448,485 | Android: How to get an XML layout from a different contentview | <p>I am in the contentview of seekbarlist.xml and need to get the layout of seekbars.xml.
I need to send the layout to CustomSeekBar constructor. Below, you can see that I tried to set the content view to one layout, grab it, then switch to the other. This will not work b/c I have to extend listactivity and the layout must have an item with the id "list". seekbars.xml does not have a "list" and it would not make sense for it to have it.
How can I get the layout of seekbars?</p>
<pre><code> public class ColorsActivity extends ListActivity {
/** Called when the activity is first created. */
//Array Adapter that will hold our ArrayList and display the items on the ListView
SeekBarAdaptor seekBarAdaptor;
//List that will host our items and allow us to modify that array adapter
ArrayList<CustomSeekBar> seekBarArrayList=null;
// TextView myValueText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seekbars);
LinearLayout myLayout = (LinearLayout)findViewById(R.layout.seekbars);
setContentView(R.layout.seekbarlist);
//Initialize ListView
ListView lstTest= getListView();
//Initialize our ArrayList
seekBarArrayList = new ArrayList<CustomSeekBar>();
//Initialize our array adapter
seekBarAdaptor = new SeekBarAdaptor(ColorsActivity.this, R.layout.seekbars, seekBarArrayList);
CustomSeekBar red = new CustomSeekBar(this, myLayout, "red", 1);
//CustomSeekBar blue = new CustomSeekBar(this, "blue");
//CustomSeekBar green = new CustomSeekBar(this, "green");
//Set the above adapter as the adapter of choice for our list
lstTest.setAdapter(seekBarAdaptor);
seekBarArrayList.add(red);
//seekBarArrayList.add(blue);
//seekBarArrayList.add(green);
Amarino.connect(this, "00:11:11:21:05:53");
}
}
</code></pre>
| android | [4] |
1,446,362 | 1,446,363 | Variable as the property name in a JavaScript object literal? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/695050/how-do-i-add-a-property-to-a-javascript-object-using-a-variable-as-the-name">How do I add a property to a Javascript Object using a variable as the name?</a><br>
<a href="http://stackoverflow.com/questions/7638659/use-variable-for-property-name-in-javascript-literal">Use variable for property name in JavaScript literal?</a> </p>
</blockquote>
<p>Is it possible to add a variable as the property name of an object in JavaScript, like the following:</p>
<pre><code>var myVar = "name";
var object = {
{myVar}: "value"
};
</code></pre>
| javascript | [3] |
2,886,359 | 2,886,360 | What does product() do in python? | <p>what does product do in python?
How can it be replaced?
what are all it's capabilities.
what does the <code>*</code> sign do?
How do you test it without getting the generator warning message thing</p>
<pre><code><itertools.product object at 0x0159BD00>
</code></pre>
| python | [7] |
263,848 | 263,849 | Using UrlConnection Openstream mutiple times in a loop | <p>I have a application on android where I want to read data from a url on the 3g and wifi interface of my phone. I am using the following code</p>
<pre><code>read_data() {
url = new URL("http://0xbadc0ffee.de/plHUGE.txt");
UrlConnection conn = url.openConnection;
reader = new BufferedInputStream(conn.getInputStream());
//Then I write this into a FileOutput stream
reader.close();
}
</code></pre>
<p>This works fine when I run it twice on the 3g and wifi interface. But when I put this in a loop it fails to get the Inputstream. Initially I doubted if the stream was getting closed properly or not, but if it wasnt how would it work the first 2 times on the 2 interfaces? I have been stuck with this for over 2 days now... Any pointers are appreciated..</p>
| android | [4] |
4,289,228 | 4,289,229 | How to create an Android Library Project including Referenced Libraries? | <p>I want to create a common Android Library(jar).So I am create an Android Library project in Eclipse.In this project I am included some other open source Libaries(jar),that is specified under Referenced Library in Android Library Project.The main jar file is generated under the bin option.But when I am using the jar file under the bin option to other android application the referenced library options are not working.The methods in Referenced Library is not included in jar file.How can I create a jar file including Referenced Library in Eclipse Android??</p>
| android | [4] |
1,229,509 | 1,229,510 | connecting my application to wamp server | <p>I am new to android. I want to display my localhost (wampserver) Page on a click of a button.</p>
<p>I have tried using <code>httppost</code> method but it is not displaying anything just a blank mess. If I give a wrong addres then it is throwing error message.</p>
<p>All help is appriciated</p>
| android | [4] |
5,985,513 | 5,985,514 | Meaning of "this" for a struct (C#) | <p>According to MSDN (Section 11.3.6 of the <a href="http://download.microsoft.com/download/3/8/8/388e7205-bc10-4226-b2a8-75351c669b09/CSharp%20Language%20Specification.doc" rel="nofollow">C# spec</a>):</p>
<blockquote>
<p>Within an instance constructor of a
struct, <code>this</code> corresponds to an <code>out</code>
parameter of the struct type, and
within an instance function member of
a struct, <code>this</code> corresponds to a <code>ref</code>
parameter of the struct type. In both
cases, <code>this</code> is classified as a
variable, and it is possible to modify
the entire struct for which the
function member was invoked by
assigning to <code>this</code> or by passing <code>this</code>
as a <code>ref</code> or <code>out</code> parameter.</p>
</blockquote>
<p>I don't get it. How is <code>this</code> different for a struct than for a class? Code examples are appreciated</p>
| c# | [0] |
3,159,563 | 3,159,564 | Updating variables in PHP after declaring them once | <p>Is it possible to update variables in PHP?</p>
<p>Like declare the variable in the head of the file, and then inside a switch case update the variable?</p>
<p>I'm trying to get it so that it changes the page in the title as so [Website] - [Page visiting [Eg. Home/About Us/Contact Us]]</p>
| php | [2] |
4,903,586 | 4,903,587 | Saving images from an associative array | <pre><code>$object = json_decode(file_get_contents('https://api.500px.com/v1/photos/?feature=user&username=nsz&consumer_key=xxx'), true);
</code></pre>
<p>This object have the following structure:</p>
<pre><code>Array
(
[0] => Array
(
[id] => 176621
[name] => ***
[description] =>
[times_viewed] => 1411
[rating] => 47.7
[created_at] => 2010-10-08T14:39:43-04:00
[category] => 11
[privacy] =>
[votes_count] => 65
[favorites_count] => 8
[comments_count] => 7
[nsfw] =>
[store_width] => 643
[store_height] => 915
[image_url] => http://pcdn.500px.net/176621/6f2932b14d545f9664e9472a01ae74596f8d4588/2.jpg
</code></pre>
<p>What i would like to know is: How to make a foreach loop that saves each file from the <code>[image_url]</code> to my server.</p>
<p>This seems to be working, but i dont know how to make the loop:</p>
<pre><code>copy('http://path/to/image.jpg', 'images/flower.jpg');
</code></pre>
<p>Thanks in advance!</p>
| php | [2] |
1,375,530 | 1,375,531 | How to release my view from stack? | <p>In my application I m using following coding convention to open my default screen :--</p>
<pre><code>AppDelegate *ptrDefaultScreen = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[self.navigationController presentModalViewController:ptrDefaultScreen.FrmFlashScreenLink animated:YES];
</code></pre>
<p>but when I move to other screen after default screen ,my default screen is still exists even i used [self dismissModelViewController:YES]; to dimiss default screen from view.</p>
<p>where I m wrong I want my default screen will be completely removed from view.</p>
<p>Is any other way to call default screen before actual application.
Please help me out.Thanks in advance</p>
| iphone | [8] |
3,723,493 | 3,723,494 | Use onBackPressed to save a file | <p>I want to allow users to save a list of favourite items from a list, so I display the full list using a Listview with checkboxes, and the user will check or uncheck items in the list.</p>
<p>When the user presses the back button, I want to be able to save the checked items out to a separate file on the SD card.</p>
<p>I'm using the following method in my Activity:</p>
<pre><code>@Override
public void onBackPressed() {
// TODO Auto-generated method stub
}
</code></pre>
<p>However, the list that I create within my OnCreate method is not available within the onBackPressed method - ie it's out of scope.</p>
<p>If I try and pass the list into the onBackPressed method as follows:</p>
<pre><code>@Override
public void onBackPressed(ArrayList<HashMap<String, Object>> checked_list) {
// TODO Auto-generated method stub
}
</code></pre>
<p>Then I get the error:</p>
<p>"The method onBackPressed(ArrayList>) of type SetFavourites must override or implement a supertype method" and Eclipse prompts to remove the @Override.</p>
<p>But when I do this, then the onBackPressed method never gets called.</p>
<p>How can I pass variables into the onBackPressed method so that I can perform actions on data within my Activity before exiting?</p>
<p>Thanks</p>
| android | [4] |
1,625,356 | 1,625,357 | Browsing local directories and files with php | <p>Instead of the traditional navigation, I am trying to emulate the terminal navigation, or how you navigate with vim.
Example:</p>
<pre><code>..
index
otherfile
</code></pre>
<p>This is my code:</p>
<pre><code>$dir = realpath(dirname(__FILE__));
if(is_dir($dir)){
if($open = opendir($dir)){
while(($file = readdir($open)) !==false){
if(is_dir($file)){
if($file == '.'){ }
else{
echo "<a href=".$file.">".$file."</a><br/>";
}
}
else{
$name = explode('.php',$file);
echo "<a href=".$file.">".$name[0]."</a><br/>";
}
}
}
}
else{
echo $dir." Was not found";
}
}
</code></pre>
<ol>
<li><p>How can I remove the file or folder I am in from the list? For example, if I am on the page index.php, it is still appearing on the list.</p></li>
<li><p>I want to sort files by given them a number example '1file.php' '2anotherfile.php'..
How could I sort them by the number, then remove the number and '.php', and finally print it out?</p></li>
</ol>
<p>If you feel like refactoring something please do so...</p>
<p><img src="http://i.stack.imgur.com/89ToP.png" alt="enter image description here"></p>
| php | [2] |
15,520 | 15,521 | if there any better way to read bb function souce code.i was very faint | <pre><code>in python ,if
a.py
from b import bb
bb()
b.py
from c import cc
def bb():
do someting else
cc()
c.py
from d import dd
def cc():
do someting else
dd()
d.py
from e import ee
def dd():
do someting else
ee()
e.py
from f import ff
def ee():
do someting else
ff()
</code></pre>
<p>to Understood bb function,i must open 5 file,i was very faint .</p>
<p>if there any better way to read bb function.(a tools to read source code better)</p>
<p>thanks</p>
| python | [7] |
1,830,926 | 1,830,927 | Display String and number together in tableview | <p>I am trying to concatenate and display string and number together in a table view cell. Is there any mechanism to convert both of them together to a label string?</p>
| iphone | [8] |
2,351,955 | 2,351,956 | How to extract number and String in java | <p>i want to extract number and add these numbers using Java and String remain same.</p>
<p>String as-</p>
<pre><code>String msg="1,2,hello,world,3,4";
</code></pre>
<p>output should come like- 10,hello,world</p>
<p>Thanks</p>
| java | [1] |
987,485 | 987,486 | Is it possible to initialize a View from different Layout? | <p>I have an <code>Activity</code> and associated with it <code>layout</code>. Also I have another <code>layout</code> with some <code>Views</code>. I want to initialize a variable (<code>TextView</code>) from my <code>Activity</code> using a <code>View</code> from that standalone <code>layout</code>. I always get <code>null</code>. </p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button); // This is OK
// because R.id.button is from R.layout.main layout
tvOne = (TextView) findViewById(R.id.first_item); // This is not OK
// because R.id.first_item is from another layout.
}
</code></pre>
| android | [4] |
2,599,312 | 2,599,313 | how to set the button unusable ,after successful install a apk? | <p>everyone ,i have a peoblem here ,when i install a apk the system wiil show a install Dialog ,one is "open",the other one is "done",how can i set the "open" button unusable
and when user click "done",it will show the activity that i want to show?thanks!</p>
| android | [4] |
1,953,494 | 1,953,495 | Struct implicit vs empty constructor | <p>Considering the following struct :</p>
<pre><code> struct S
{
public string s;
}
</code></pre>
<p>What is the difference between 1 : </p>
<pre><code> S instance = new S();
instance.s = "foo";
</code></pre>
<p>and 2 :</p>
<pre><code> S instance;
instance.s = "foo";
</code></pre>
<p>Both versions compile and run fine.<br>
I am just curious to know what happens behind the scenes.
<br><br><strong>Edit :</strong> <br>
I guess in case 2 S is unassigned until we put a value on its s field;<br>
As this doesn't work :</p>
<pre><code> S instance;
if (inst.s == null)
inst.s = "foo"; //Compiler drops : Use of possibly unassigned field 's'
</code></pre>
<p>while this does :</p>
<pre><code> S instance;
inst.s = "foo";
if (inst.s == null)
inst.s = "bar"; //Compiler drops : Use of possibly unassigned field 's'
</code></pre>
<p>and this also works : </p>
<pre><code> S inst = new S();
if (inst.s == null)
inst.s = "foo";
</code></pre>
<p>I welcome any deeper explanations about this behavior </p>
<p><strong>Update</strong><br>
I found those 2 posts, completing Marc's answer : <br>
<a href="http://stackoverflow.com/questions/441309/why-are-mutable-structs-evil">why are mutable structs evil</a><br>
<a href="http://stackoverflow.com/questions/521298/when-to-use-struct-in-c/6973171#6973171">when to use struct in c#</a><br></p>
| c# | [0] |
2,638,235 | 2,638,236 | iphone+Webservice whihc gives shorten url in responce | <p>I want the webservice in json OR in xml which gives the shorten url in response.
I have to implement the webserivce in iPhone application..
The webserivce
Example
If i give <strong>HTTP://WWW.GOOGLE..COM</strong> in request</p>
<p>Then it give <strong>http://goo.gl/fbsS</strong> in response.
Please do provide me any webserivce which do the following.</p>
<p>I found this:-
<a href="https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS" rel="nofollow">https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/fbsS</a></p>
<p>But this is actually the reverse of what i want.In htis i have to pass the shorten url and it gives the long url in response</p>
<p>Like this:-</p>
<p>{
"kind": "urlshortener#url",
"id": "http://goo.gl/fbsS",
"longUrl": "http://www.google.com/",
"status": "OK"
}</p>
<p>Please help me.</p>
| iphone | [8] |
5,642,654 | 5,642,655 | simple asp.net webforms ul li menu with selected class | <p>I have a simple unordered list with links in it.</p>
<pre><code><body>
<div id="topMenu">
<ul>
<li><a class="selected" href="../Default.aspx">Start</a></li>
<li><a href="../Category/ShowAll.aspx">Categories</a></li>
<li><a href="../Elements/ShowAll.aspx">Elements</a></li>
<li><a href="../Articles/ShowAll.aspx">Articles</a></li>
</ul>
</div>
<asp:ContentPlaceHolder ID="MainContentPlaceholder" runat="server">
</asp:ContentPlaceHolder>
</body>
</code></pre>
<p>I want to change the class of the link i click to the "selected" class, which is the easiest way to do this. I thought about making it into linkbuttons and saving the info in the session, but that seems overkill, there has to be an easier approach?</p>
| asp.net | [9] |
4,992,239 | 4,992,240 | What should I do when the android activity is interrupted? | <p>I currently have a program where a user fills information out and sends it to a server. It then downloads a one to two MB file to device. I have it setup so the phone does not sleep when it is downloading the file, but it is interrupted when the user manually presses the sleep button or a text comes in to the phone. What would be the best solution to this? Should I create a service or is there someway to tell the activity to keep downloading in the onPause method?</p>
| android | [4] |
802,761 | 802,762 | How can I use corertelephony framework in iPhone | <p>I need to include coretelephony framework in my App. I am using jailbreak phone. Is there any sample code available for it.</p>
<p>Please healp
Thanks
SD</p>
| iphone | [8] |
5,801,349 | 5,801,350 | How to use the value of one variable when checking the existence of another | <p>I want to be able to check the existence of up to, but often less than, 6 consecutively named variables using a FOR loop thus:</p>
<pre><code>for ($i = 0; $i <= 5; $i++) {
$vartocheck = "$var_".$i;
if ($vartocheck) {
echo $vartocheck." exists!";
}
}
</code></pre>
<p>Now I know the above doesn't work but I can't figure out how to reference and check the existence of $var_0 through to $var_5 by using the value of $i.</p>
<p>I have tried isset and call_user_func to construct and return the variable name I am after but I have had no success thus far.</p>
<p>I am trying to avoid an eval statement.</p>
| php | [2] |
2,703,299 | 2,703,300 | Insert selected text on the page into textarea (jQuery) | <p>Need to insert selected text on the page into textarea. There must be some button to do it.</p>
| jquery | [5] |
704,714 | 704,715 | Php "Parse error: syntax error, unexpected T_STRING" | <p>hi there i am setting up a simple html php form.
the php is:</p>
<pre><code><?php
$name = $_POST["name"];
$email = $_POST["email"];
$devices = $_POST["devices"];
$games = $_POST["games"];
$apps =$_POST["apps"];
$beta = $_POST["beta"];
$stuff = array();
//($stuff, "<html>", "name=", $name, "<br />",
array_push($stuff, "<html>", $name, "<br />", $email, "<br />", $devices, "<br />", $games, "<br />", $apps , "<br />", $beta, "</ html>);
mail ( "apps@nicholasparry.geek.nz", "Add me to the mailing listt!!!", $stuff);
</code></pre>
<p>and i get </p>
<pre><code>Parse error: syntax error, unexpected T_STRING in /home/nickp/public_html/email/form.php on line 12
</code></pre>
<p>any ideas?</p>
| php | [2] |
3,840,168 | 3,840,169 | PHP is_writable() returns true but file_put_contents() returns false | <p>I'm having trouble writing to a file even though <code>is_writable()</code> returns true. Of course, the file exists and is apparently readable. Here is the code:</p>
<pre><code>$file = "data";
echo file_get_contents($file)."<br>";
echo is_writable($file) ? "is writable<br>" : "not writable<br>";
if (file_put_contents($file, "ghijkl", FILE_APPEND) === FALSE) echo "failed<br>";
echo file_get_contents($file)."<br>";
</code></pre>
<p>And here is the output:</p>
<pre><code>abcdef
is writable
failed
abcdef
</code></pre>
| php | [2] |
3,266,259 | 3,266,260 | easier way to create grid than creating 900 controls c#.net | <p>I'm trying to write a program that creates a 30x30 grid of 20px x 20px boxes. When you click on a box in the grid it changes the color of the box and stores the RGB value of it and the x,y coordinates (hidden in the box). So basically I'm making a simple paint program. The purpose of it is to assist me in programming LED RGB animations for a 30x30 pixel grid. So once I draw something I export the X,Y,R,G,B of each pixel in the image. </p>
<p>So my question is, is there an easy way to do this. With out creating 900 buttons and putting them together? I've got something sorta working :</p>
<pre><code> Panel BU = new Panel();
BU.AutoSize = false;
BU.Location = new System.Drawing.Point(xpos, ypos);
BU.BackColor = System.Drawing.Color.Transparent;
BU.Font = new System.Drawing.Font("Microsoft Sans Serif", 5, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
BU.Name = row_num + " x " + col_num;
BU.Size = new System.Drawing.Size(20, 20);
BU.MouseDown +=new MouseEventHandler(BU_MouseDown);
BU.MouseEnter +=new EventHandler(BU_MouseEnter);
this.Controls.Add(BU);
xpos = xpos + 20;
px_num++;
col_num++;
if (col_num == 30) { col_num = 0; ypos = ypos + 20; row_num++; xpos = 0; };
</code></pre>
<p>But it takes WAAAAAY to long to load.</p>
| c# | [0] |
5,776,562 | 5,776,563 | JavaScript - Check if absolute coordinates (left, top, right, bottom) are going to be visible on the current viewport | <p>Hey guys I have an absolute position for an element that will be created in the future. I want to check if the element is going to be entirely visible on the current viewport. I know I could use <code>getBoundingClientRect</code> if the element was rendered on the page, however it's not and it couldn't not be. Is there a way that I can detect if given absolute coordinates (left, top, bottom, right) are going to be visible on the current viewport? Thanks in advance.</p>
<p>Edit:</p>
<p>My solution so far - insert an element with <code>visibility: hidden</code> and use <code>getBoundingClientRect</code>, I was just wondering if there is a better way.</p>
| javascript | [3] |
2,527,473 | 2,527,474 | jquery .on('change' IE issues | <p>I have read a few posts mentioning an issue with jquery .on('change' see below.</p>
<p><a href="http://stackoverflow.com/questions/208471/getting-jquery-to-recognise-change-in-ie/1080243">Getting jQuery to recognise .change() in IE</a></p>
<p><a href="http://stackoverflow.com/questions/9328598/jquery-on-change-in-ie8">jQuery on() change in IE8</a></p>
<p>But the issue I am experiencing seems to be slightly different than this.</p>
<p>When I view <a href="http://jsfiddle.net/VNSam/19/" rel="nofollow">http://jsfiddle.net/VNSam/19/</a> in ie9 and select choose salesman nothing happens (it is fine in all other major browsers the table gets manipulated).</p>
<p>However when I hit f12 to open the developer console and choose salesman and select an option the table gets manipulated. Why is this? How can I get this working without having to press f12?</p>
| jquery | [5] |
5,164,756 | 5,164,757 | getting the index of starting and ending 1 of a binary list having a sequence of 0s or 1s | <p>I have a python list with binary information having either a sequence of 1s or a sequence of 0s for example:</p>
<pre><code>event = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1]
</code></pre>
<p>How can I store the index values of the starting 1 and ending 1?</p>
<p>For example:</p>
<p>if <code>event = [0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1]</code> then <code>result = [2,5,8,11]</code></p>
<p><strong>EDIT2</strong> i realised that result should ideally be result_start=[2,8] result_end=[5,11], like lazyr solution, this way we understand where just a single 1 located. eg. event=[0,0,1,1,0,1], would yield a wrong list for the last 1. Thanks for trying all!</p>
<p><strong>EDIT1:</strong> I need the index of the first and the last 1 but first to the last 1.</p>
<p>I tried to code it like the following:</p>
<pre><code>k=False
j=0
result=[]
for i in event:
if i==1:
k=True
result.append(k)
else:
k=False
</code></pre>
| python | [7] |
519,815 | 519,816 | Why does Java allow such strange code using inner class to pass compilation? | <p>Hi I tried below code while learning Java inner class. So surprising it passed compilation but could not work in run-time. My understanding is for inner class it must be instantiated in an instance of the top class. </p>
<p>But why JDK compiler allow such code to pass compilation? I am using JDK 6. </p>
<pre><code>public class Hello
{
public Hello()
{
System.out.println("Simple Hello!");
}
public void test()
{
Test.test();
}
protected int i = 0;
static class B
{
public B()
{
System.out.println("B Hello!");
}
static class C
{
public C()
{
System.out.println("C Hello!");
}
}
}
}
class Test
{
static void test()
{
C c = new C();
}
}
</code></pre>
| java | [1] |
1,830,332 | 1,830,333 | How to get selected values from combobox which is placed in DataGridView | <p>I am tring to get selected values from Combobox which is placed in DataGridView using following code</p>
<pre><code> DataGridViewComboBoxColumn dgvcmb = new DataGridViewComboBoxColumn();
dgvcmb.HeaderText = "Tran_Mode";
for (ni = 0; ni < dTable.Rows.Count; ni++)
{
dgvcmb.Items.Add(dTable.Rows[ni][1].ToString());
}
dgv.Columns.Add(dgvcmb);
dgv.Columns[5].DisplayIndex = 4;
</code></pre>
<p>can any one tell me how i can get the value ?</p>
| c# | [0] |
2,582,864 | 2,582,865 | Python - Sending HTTP request at same time | <p>Hey guys I have looked at the best ways to do this. I want to make sure I understand correctly.</p>
<p>If I want:</p>
<p>http1
http2
http3
http...</p>
<p>To be sent at exactly the same time. I should set these up into a thread and then start the thread? I need to make sure it is exact same time.</p>
<p>I think this can be done in Java but Im not familiar with it. Thanks guys for any help you can give!</p>
<p>After reading up more on the process I dont think this was super clear. Will the async processing send these packets at the same time so they arrive at the destination at the same time? From reading different articles it seems like the async is just that. </p>
<p>I believe for what Im looking for, I would need to use a synchronous method like multiprocessing. </p>
<p>Thoughts? </p>
| python | [7] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.