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 |
|---|---|---|---|---|---|
202,889 | 202,890 | How to delete only the phone number in an android phone programatically | <p>i have a Phone.Lookupkey and Phone.CONTACT_ID and i want to delete only the phone number that it points to, i dont want to delete all the contact information.</p>
<p>How do i put empty value?
just update it to ""?</p>
<p>Thanks, </p>
| android | [4] |
3,138,855 | 3,138,856 | How to a turn a list of strings into complex numbers in python? | <p>I'm trying to write code which imports and exports lists of complex numbers in Python. So far I'm attempting this using the csv module. I've exported the data to a file using:</p>
<pre><code>spamWriter = csv.writer(open('data.csv', 'wb')
spamWriter.writerow(complex_data)
</code></pre>
<p>Where complexe data is a list numbers generated by the complex(re,im) funtion. Ex:</p>
<pre><code>print complex_data
[(37470-880j),(35093-791j),(33920-981j),(28579-789j),(48002-574j),(46607-2317j),(42353-1557j),(45166-2520j),(45594-232j),(41149+561j)]
</code></pre>
<p>To then import this at a later time, I try the following:</p>
<pre><code>mycsv = csv.reader(open('data.csv', 'rb'))
out = list(mycsv)
print out
[['(37470-880j)','(35093-791j)','(33920-981j)','(28579-789j)','(48002-574j)','(46607-2317j)','(42353-1557j)','(45166-2520j)','(45594-232j)','(41149+561j)']]
</code></pre>
<p>(Note that this is a list of lists, I just happened to use only one row for the example.)</p>
<p>I now need to turn this into complexe numbers rather than strings. I think there should be a way to do this with mapping as in <a href="http://stackoverflow.com/questions/642154/how-to-convert-strings-into-integers-in-python">this question</a>, but I couldn't figure out how to make it work. Any help would be appreciated!</p>
<p>Alternatively, if there's any easier way to import/export complex-valued data that I don't know of, I'd be happy to try something else entirely. </p>
| python | [7] |
2,824,697 | 2,824,698 | Passing a variable from one page to another using PHP | <p>Does anyone know what's wrong with the code below that prevents me from printing in <code>File2.php</code> the variable <code>$myusername</code> from <code>File1.php</code>.</p>
<p>I simply wanna print the variable <code>$myusername</code>, or if you know any other way of how to pass that variable that would be very helpful for me.</p>
<p>Here is my example:</p>
<p><strong>File1.php</strong></p>
<pre><code><?php
$myusername=$_POST['myusername'];
function getusername()
{
return $myusername;
}
?>
</code></pre>
<p><strong>File2.php</strong></p>
<pre><code><?php
require_once('File1.php');
getusername();
?>
</code></pre>
| php | [2] |
458,238 | 458,239 | Page Response Error | <p>I working on iphone Application Development.
I created a sampleTest button and whenever i click on it the following function invoking.
But unable to return any response. Its showing empty alert message.
(hostName and portNo are dynamic inputs) </p>
<pre><code>sampleTestBtn.addEventListener('click', function()
{
var regDetails = '{"user_login": {"email": "sample@sample.com", "password": "password"}}';
var client = Titanium.Network.createHTTPClient({timeout: 10000});
client.cache = false;
client.open("POST", "http://"+hostName+":"+portNo+"/AccountCreate");
client.setRequestHeader("Content-Type", "application/json");
client.send(regDetails);
alert(JSON.parse(this.responseText));
});
can any one please.
</code></pre>
| iphone | [8] |
3,096,851 | 3,096,852 | Set minimal time for ProgressDialog , maximum not need | <p>I need to display user info while app processing some data. I use ProgressDialog like </p>
<pre><code>pd = ProgressDialog.show(MainActivity.this,
"", "Processing",
true, false);
</code></pre>
<p>Processing takes while connect to network and download data, but when network is not available it returns immediately and my progress dialog just flash very quick. Is there maybe more elegant solution then to put in catch Thread to sleep for some time :</p>
<pre><code>try{
//connecting and calculating
}
catch(Exception exc){
Thread.sleep(400);
handler.sendEmptyMessage(0);
}
</code></pre>
<p>I need to set minimal time for my ProgressDialog regardless of success or failure ? Does anybody know how to achieve that ? </p>
| android | [4] |
4,115,086 | 4,115,087 | Wait for function to finish before ajax call starts | <p>I'm pretty sure I'm being stupid here as it's approaching the end of the day. But when I submit my form (generated dynamically) how would I first complete the close function before I try and open my new lightbox with ajax. At the moment they happen simultaniously so my close function is closing the lighbox I'm trying to open.</p>
<pre><code>// Submit form
$(":submit").live('click', function() {
// Prevent default
event.preventDefault();
// Close previous lightbox
lb.close();
// Open new lightbox
$.ajax({
// Blah blah blah
});
});
</code></pre>
<p>Thanks</p>
| jquery | [5] |
3,400,081 | 3,400,082 | A neat way of extending a class attribute in subclasses | <p>Let's say I have the following class</p>
<pre><code>class Parent(object):
Options = {
'option1': 'value1',
'option2': 'value2'
}
</code></pre>
<p>And a subclass called Child</p>
<pre><code>class Child(Parent):
Options = Parent.Options.copy()
Options.update({
'option2': 'value2',
'option3': 'value3'
})
</code></pre>
<p>I want to be able to override or add options in the child class. The solution I'm using works. But I'm sure there is a better way of doing it.</p>
<p><hr /></p>
<p><strong>EDIT</strong></p>
<p>I don't want to add options as class attributes because I have other class attributes that aren't options and I prefer to keep all options in one place. This is just a simple example, the actual code is more complicated than that. </p>
| python | [7] |
4,676,184 | 4,676,185 | Radeditor error using image manager in IE9 | <p>I am using RadEditor inside Update Panel.
On using image manager in i got error in IE9</p>
<p>Microsoft JScript runtime error: DOM Exception: INVALID_CHARACTER_ERR (5)</p>
<p>whereas image manager works in IE8</p>
<p>inside update panel i have</p>
<p>< telerik:RadEditor ID="RadEditor1" ExternalDialogsPath="~/EditorDialogs" runat="server"
Width="500px" Height="250px" EditModes="Design" ToolsFile="~/ToolsFile.xml" >
< ImageManager ViewPaths="~/myPics" UploadPaths="~/myPics" /> </p>
<p>on code behind i used</p>
<p>Telerik.Web.UI.RadFileExplorer rfe = (Telerik.Web.UI.RadFileExplorer)this.FindRadControl(this.Page);
if (rfe != null)
{
rfe.Upload.EnableFileInputSkinning = false;
}<br>
private Control FindRadControl(Control parent)
{
foreach (Control c in parent.Controls)
{</p>
<pre><code> if (c is Telerik.Web.UI.RadFileExplorer) return c;
if (c.Controls.Count > 0)
{
Control sub = FindRadControl(c);
if (sub != null) return sub;
}
}
return null;
}
</code></pre>
<p>Please help.</p>
| c# | [0] |
5,726,498 | 5,726,499 | single checkbox updates state of muliple checkboxes | <p>I have a group of checkboxes, one of them has a label of 'None'.
When This is ticked, I'd like the others to be disabled. If the 'None' checkbox is unchecked, then the checkboxes that were disabled, are enabled again.</p>
<p>I have the following code:</p>
<pre><code> $(document).ready(function(){
$("#select_none").click(function()
{
$('#select_blue').attr('disabled', true);
$('#select_green').attr('disabled', true);
$('#select_red').attr('disabled', true);
$('#select_black').attr('disabled', true);
$('#select_white').attr('disabled', true);
$('#select_yellow').attr('disabled', true);
$('#select_pink).attr('disabled', true);
});
});
</code></pre>
<p>This simply just disables if the checkbox has been clicked on, it doesn't toggle.</p>
<p>Could someone help me with the toggle functionality?</p>
| jquery | [5] |
4,463,462 | 4,463,463 | How to assign the value of AutoCompleteTextView from Dropdown selected value to another String | <p>Friend's
I need help on setting the data content showing from DropDownlist of auto complete text box to another string,when i click the particular content from dropdown list.
Help me.</p>
<p>thanks in advance.</p>
| android | [4] |
1,661,912 | 1,661,913 | Any way to force an activity to destroy right away but also remain on the stack? | <p>I have a preference activity that allows the user to modify skinning options. If the user modifies the skinning options, I need to reload the activity (call startActivity() with the current intent followed by finish() ) so that the drawables are properly reloaded.</p>
<p>It would be much easier, and much more reliable, if I could force the current activity to get destroyed rather than paused whenever the preference activity starts.</p>
<p>Any ideas how I can achieve this?</p>
<p>Update for clarity:</p>
<p>CURRENT BEHAVIOR:
<code><pre>
1. Activity A starts
2. User selects Settings command
3. Preference Activity starts
4. Activity A is paused
5. User changes preferences
6. Preference Activity is paused and destroyed
7. Activity A is unpaused
8. Activity A must check if preferences were changed
- If yes, call startActivity() to start itself
again and call finish(). This will reload everything
correctly
</code></pre></p>
<p>DESIRED BEHAVIOR (diff in <strong>BOLD</strong>):
<code><pre>
1. Activity A starts
2. User selects Settings command
3. Preference Activity starts
4. Activity A is paused <strong>AND DESTROYED</strong>
5. User changes preferences
6. Preference Activity is paused and destroyed
7. Activity A <strong>STARTS AGAIN FRESH</strong>
</code></pre></p>
<p>Cheers,
swine</p>
| android | [4] |
289,352 | 289,353 | python checking presence of a list element | <p>I am trying to solve a more generic problem similar to the following. In the following, I get vow_array, which indicates the presence of a subset of vowels in some text, say, sent to my program. I need to print each vowel's presence as 0 or 1. </p>
<pre><code>ch_a = 0
ch_e = 0
ch_i = 0
ch_o = 0
ch_u = 0
# vow_array is generated at runtime; here is an example
vow_array = ['a', 'o', 'u']
if 'a' in vow_array:
ch_a = ch_a + 1
if 'e' in vow_array:
ch_e = ch_e + 1
if 'i' in vow_array:
ch_i = ch_i + 1
if 'o' in vow_array:
ch_o = ch_o + 1
if 'u' in vow_array:
ch_u = ch_u + 1
print ch_a, ch_e, ch_i, ch_o, ch_u
</code></pre>
<p>I think this code is too long and prone to errors. Is there a more compact way of writing this? Also, say if I had to do this for all 'letters' in the alphabet I don't want to have to repeat the code.</p>
| python | [7] |
3,905,366 | 3,905,367 | Math.Pow taking an integer value | <p>From <a href="http://msdn.microsoft.com/en-us/library/system.math.pow.aspx">http://msdn.microsoft.com/en-us/library/system.math.pow.aspx</a></p>
<pre><code> int value = 2;
for (int power = 0; power <= 32; power++)
Console.WriteLine("{0}^{1} = {2:N0}",
value, power, (long) Math.Pow(value, power));
</code></pre>
<p>Math.Pow takes doubles as arguments, yet here we are passing in ints.</p>
<p>Question: Is there any danger of floating point rounding errors if there is an implicit conversion to double happening?</p>
<p>If yes, it is better to use something like:</p>
<pre><code> public static int IntPow(int x, uint pow)
{
int ret = 1;
while (pow != 0)
{
if ((pow & 1) == 1)
ret *= x;
x *= x;
pow >>= 1;
}
return ret;
}
</code></pre>
| c# | [0] |
2,727,492 | 2,727,493 | when does a change in php.ini take place in php-core? | <p>If i make changes in php-ini:</p>
<p>when does php react?</p>
<p>is it possible, that I get other data in phpinfo()
than php realy uses?</p>
| php | [2] |
3,234,256 | 3,234,257 | Back button doesn't switch to previous activity, but it exits the Android app | <p>I have an app that contains 2 activities: A1 and A2. When I run the app it opens A1 activity. Then it opens A2 by pressing the button (I use startActivityForResult(intent, 0)). Then if I pressing Back it returns to A1. Everything is ok.</p>
<p>But if I am in A2 activity and <strong>switching to another application</strong> and then returning back to my app, then I'm pressing Back and the application exits instead of switching to A1 activity.
What can I do to prevent such situation?</p>
<p>The code that calls A2 from A1:</p>
<pre><code>@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), A2.class);
startActivityForResult(intent, 0);
}
</code></pre>
<p>Declaration in AndroidManifest.xml:</p>
<pre><code><activity
android:name="A1"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name="A2"
android:launchMode="singleInstance"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
</code></pre>
| android | [4] |
2,813,164 | 2,813,165 | How to check id name if contains some pattern? | <p>I am using jquery and I am looping like:</p>
<pre><code>$("span").each(function (index) {
var idname = $(this).attr('id');
$("#" + idname).click(function () {
window.location.href = "http://" + $(this).attr('id') + "lin.gw";
});
}); //end for click attachment to button
</code></pre>
<p>I would like to loop over the elements where <code>id</code> contains <code>*raid*</code>. What is the syntax for it?</p>
| jquery | [5] |
1,591,760 | 1,591,761 | Use value from array as property | <p>So I have a dictionary-like object and an array:</p>
<pre><code>var colors = {"b":color(0, 0, 0)};
var ar=[["b","0","0"],["b","b","0"],["b","b","b"]];
</code></pre>
<p>Now, I would like to get the value from the dictionary using the array like so:</p>
<pre><code>colors.ar[0][0]
</code></pre>
<p>Which should give me the color black. However, this gives me an error:</p>
<pre><code>Cannot read property '0' of undefined
</code></pre>
<p>I believe this is because it's trying to access colors."b" instead of colors.b .</p>
<p>So how can I get the property from the dictionary by using a value from the array?</p>
<p>Thanks!</p>
| javascript | [3] |
312,584 | 312,585 | Switching between GPS_PROVIDER and NETWORK_PROVIDER in android | <p>I am developing an application in which I need to find the GPS location of the place.</p>
<p>The <code>NETWORK_PROVIDER</code> is not accurate and <code>GPS_PROVIDER</code> works only when I am outside the building.</p>
<p>Can anyone tell me, how I can switch between these two providers. </p>
<p>If possible please attach code.</p>
<p>Thanks</p>
| android | [4] |
3,144,468 | 3,144,469 | Block a user from a website in ASP.NET | <p>Beside IP blocking and probably using a cookie (if the user changes the IP but doesn't remove the cookie, the new IP is added to the banned list, so the IP has to be changed and the cookie has to be removed together to access the site), is there any tricks one can use to block an annoying user from a website, I know that nothing will work with a savvy user but I'm trying to make it harder for the less savvy ones, any suggestions?</p>
<p>Edit: I already have registration in my website, the point is that this is useless to stop determined users (they can simply create other accounts).</p>
<p>@rifferte,
Actually I'm already building a moderation section where moderators can remove posts and suspend members, also members can report abuse and spam, I'm not trying to make this impossible, simply there's no way to do this, I'm just trying to get rid of the less savvy ones (the majority), and not forever, I'm planning to block them for a certain period of time (probably a couple of days or something like that).</p>
| asp.net | [9] |
151,385 | 151,386 | How to write some command on a batch file through C++ program? | <p>I need some help regarding my C++ program. A batch file named <code>abc.bat</code> is located somewhere in my hardisk. I know that in C++ I can use this line of code to execute that <code>abc.bat</code> file:</p>
<p><code>system ("file path here\\abc.bat");</code></p>
<p>I want to send some commands to that batch file so that after executing that <code>abc.bat</code> file my C++ program should write commands to its console and execute them. How can I do that?</p>
| c++ | [6] |
2,078,403 | 2,078,404 | Python: expand list to function arguments | <p>Ok, stupid python question: Is there syntax that allows you to expand a list into the arguments of a function call?</p>
<p>Example:</p>
<pre><code># trivial example function, not meant to do anything useful.
def foo(x,y,z):
return "%d, %d, %d" %(x,y,z)
# List of values that I want to pass into foo
values = [1,2,3]
#I want to do something like this, and get the result "1, 2, 3":
foo( values.howDoYouExpandMe() )
</code></pre>
| python | [7] |
3,385,324 | 3,385,325 | two conditions in if statement with php | <p>is that possible to do that?</p>
<pre><code><?php if($limit != "0" && $num_down < $limit || $limit == "0") {
//stuff
}
?>
</code></pre>
<p>i need to check if limit equals to 0 or if it is not, if $num_down is under limit.</p>
<p>Thank you </p>
| php | [2] |
3,951,261 | 3,951,262 | How to disable network connectivity dynamically for a process? | <p>My app is data intensive and I want to provide users the comfort of turning on/off WIFI only data usage.</p>
<p>My application makes use of the network connectivity all over and also the ads do too. How can I globally for the app process limit the data connectivity type to only WIFI?</p>
| android | [4] |
695,375 | 695,376 | User based string template | <p>I have a string template that the user chooses, I need to take that template and fill in the requested information.</p>
<pre><code>string templateString = "%author% - %title% (%year%)";
</code></pre>
<p>I could do .Contains() and .Replace(), however the template could have a large amount of inputs or a small amount such as:</p>
<pre><code>string templateString = "%author% - %publisher% - %isbn% - %asin% - %title% (%year%)";
</code></pre>
<p>So to do .Contains() and .Replace() for every option that the user can choose seems inefficient, what I am hoping to do is find a better way of populating the templateString with the requested information. Any help would be greatly appreciated. This would be used on thousands of items.</p>
<p>The program itself takes however many files the user inputs (ebooks, some of us have thousands of them), and it renames every ebook based off the individual user's template, filling the information with metadata scraped from the ebook.</p>
| c# | [0] |
4,488,935 | 4,488,936 | expression evaluation in if elif statements | <p>Given code like this:</p>
<pre><code>if f(a) == 1:
# do sth A
elif f(a) == 2:
# do sth B
elif f(a) == 3:
# do sth C
else:
# do sth D
</code></pre>
<p>Does the expression <code>f(a)</code> get executed/evaluated only once? Or does it get executed/evaluated for every case of <code>if</code> or <code>elif</code>? In addition, do compound statements make any difference: e.g.</p>
<pre><code>if f(a) == 1:
# do sth A
elif f(a) == 2 and a > 0:
# do sth B
elif f(a) == 3 and a < 0:
# do sth C
else:
# do sth D
</code></pre>
<p>In this case, how does <code>f(a)</code> get evaluated? Once for all or individually for each case?</p>
| python | [7] |
2,355,925 | 2,355,926 | disable rating on RatingBar | <p>I'am using a ratingbar und a OnRatingBarChangeListener in my Code.
The user can rate once and after this I set
<code>ratingBar.setEnabled(false)</code> .
I want to show the user an advice why he can't rate anymore.
How can I achieve to set a Toast after the user touch the disabled ratingbar?</p>
<p>Anybody an idea?</p>
<p>greetings </p>
| android | [4] |
4,152,513 | 4,152,514 | How to convert byte array into Human readable format? | <p>I am using "Blowfish" algorithm to encrypt and decrypt the contents of the text. I am embedding the encrypted contents in the image but while extracting I am getting the byte array which I am passing it to method <strong>update</strong> of class <strong>Cipher</strong>. </p>
<p>But the method returns me byte array which I want to convert back into Human readable form.<br>
When I use <strong>write</strong> method of <strong>FileOutputStream</strong> it is working fine when a filename is provided.<br>
But now I want to print it on the console in the human readable format. How to get through this? I have tried for ByteArrayOutputStream too. But didn't work well. </p>
<p>Thank you.</p>
| java | [1] |
415,393 | 415,394 | Inner function cannot access outer functions variable | <p>I have created the following jsfiddle which highlights my problem.
<a href="http://jsfiddle.net/UTG7U/" rel="nofollow">http://jsfiddle.net/UTG7U/</a></p>
<pre><code>var ExampleObject = function() {
var myArray = new Array();
this.example = function() {
alert(this.myArray);
};
}
var exampleObj = new ExampleObject();
exampleObj.example();
</code></pre>
<p>I am new to JavaScript and trying to create an object, field and a method.
I can't get my method to access my field variable.</p>
| javascript | [3] |
1,347,350 | 1,347,351 | error when running git command inside Popen | <p>Disclaimer: I'm extremely new at Python programming so I could be doing things very wrong here</p>
<p>All I want to do is run a git command from an open file. Here is the call that I am making</p>
<pre><code>subprocess.Popen( 'git status', cwd = os.path.dirname( path ), shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
</code></pre>
<p>and the error message I am receiving is this: /bin/sh: git: command not found</p>
<p>I have verified that it is pointing to the correct directory by doing a list of the files. Also if I open a file that is under subversion control and do an svn info command everything works perfectly. I'm at a total loss as to what I'm missing here.</p>
| python | [7] |
4,410,776 | 4,410,777 | Creating a Java flipping Dominoes Game | <p>I am creating a java dominoes game.
<br>
This is how a gameboard will look:</p>
<pre><code>SEEEEEEE
DDDDEEEE
EEEDEEEE
EEEDEEEE
EEEDEEEE
EEECEEEE
</code></pre>
<p>Each letter is an object.
S is a switch, it is the only value that can be touched.
D is a Domino, its state is either down or up.
C is where the game is won if a Domino hits C.</p>
<p>Each Object has coordinates, and will be initialized with coordinates.
ex.) S is in (0,0),
and S is initialized as Switch S = new Switch(0,0);</p>
<p>My Questions are:</p>
<p>1.) When S is pressed how would I go about checking each side, to see if there are
Dominoes? What if there are on multiple sides(N,S,E,W).</p>
<p>Once Dominoes are found next to the switch their state must change to Down, and then we must check for more dominoes next to the Dominoes with the Down state, until all connected dominoes are down.</p>
<p>2.) How can I efficiently create different levels containing different orders
of these objects.
I will be using a dual array since level sizes are static, 8 x 6.</p>
<p>3.) In the future I would like to make a gameboard with images, rather than text.
How can I go about doing this?
I'm thing give objects of a certain type a picture property and then display the pictures on the board. Each object will be the same size.</p>
<p>Thank you,
<br>
Fernando Diaz</p>
| java | [1] |
4,667,633 | 4,667,634 | What does a !! in JavaScript mean? | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/3772552/myvar-someothervar">myVar = !!someOtherVar</a><br>
<a href="http://stackoverflow.com/questions/1406604/what-does-the-operator-double-exclamation-point-mean-in-javascript">What does the !! operator (double exclamation point) mean in JavaScript?</a> </p>
</blockquote>
<p>Came across this line of code</p>
<pre><code>strict = !!argStrict
</code></pre>
<p>... <a href="http://github.com/kvz/phpjs/raw/master/functions/array/in_array.js" rel="nofollow">here</a> and wondered what effect the <code>!!</code> has on the line? Pretty new to JS!</p>
| javascript | [3] |
3,392,311 | 3,392,312 | Javascript Reload Page | <p>In order to reload the page without fully reloading everything I'm using:</p>
<pre><code>window.top.location=window.top.location;
</code></pre>
<p>However, this doesn't work for some reason when there is anchor text. It appears to do nothing in this case, but more likely it refreshes the anchor.</p>
<p>Any fix for this that will reload the page (as above) without reloading the cached images and scripts?</p>
| javascript | [3] |
3,838,004 | 3,838,005 | Showing safari browsing webpages history animation in iphone | <p>i need to show the images from left to right on my view controller like we scroll web pages in safari browser...has anyone developed this thing...
Thanks,</p>
| iphone | [8] |
4,549,685 | 4,549,686 | start intent form BroadcastReceiver class | <p>My application receives sms and change to activity to display alert dialog box in my
app Toast is working well but it will not change the activity.onReceive() receive take
sms that contains email depending upon that email id my app search the contact number
associated to that email id and send the contact number as reply message</p>
<pre><code>public void onReceive( Context context, Intent intent )
{
// Get SMS map from Intent
Bundle extras = intent.getExtras();
String messages = "";
if ( extras != null )
{
// Get received SMS array
Object[] smsExtra = (Object[]) extras.get( "pdus" );
// Get ContentResolver object for pushing encrypted SMS to incoming folder
//ContentResolver contentResolver = context.getContentResolver();
for ( int i = 0; i < smsExtra.length; ++i )
{
SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
String body = sms.getMessageBody().toString();
String address = sms.getOriginatingAddress();
messages += "SMS from " + address + " :\n";
messages += body + "\n";
// Here you can add any your code to work with incoming SMS
// I added encrypting of all received SMS
}
// Display SMS message
Toast.makeText( context, messages, Toast.LENGTH_SHORT ).show();
Intent i=new Intent(context,AlertActivity.class);
// context.startActivity(i);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
</code></pre>
| android | [4] |
2,862,448 | 2,862,449 | Using an object's string variable in a switch statement | <p>I'm trying to figure out why I'm getting this error:</p>
<pre><code> switch (token.type.GetName())
{
case PascalTokenType.BEGIN.name: // ERROR: A CONSTANT VALUE IS EXPECTED
{
CompoundStatementParser compoundParser = new CompoundStatementParser(this);
statementNode = compoundParser.parse(token);
break;
}
}
</code></pre>
<p><code>GetName()</code> and <code>name</code> both return strings. This is what the object looks like:</p>
<pre><code> public static readonly PascalTokenType BEGIN = new PascalTokenType("BEGIN");
</code></pre>
<p>I know I could get around this problem by changing it to an <code>if</code> statement but when this is complete I'm going to have at least 20 conditions so I'd rather not. I'm supposing it's because <code>BEGIN.name</code> isn't assigned until runtime?</p>
| c# | [0] |
1,614,288 | 1,614,289 | Get Class and Apply another class | <p>I have some HTML:</p>
<pre><code><div id="tagCloud">
<a class="5" title="1 records" href="tags=Battleship">Battleship</a>
<a class="4" title="1 records" href="tags=Cabbage">Cabbage</a>
etc...
</code></pre>
<p>I want to take the class value, and convert it to a word.</p>
<p>So if class = 5 append class five?</p>
| jquery | [5] |
4,423,570 | 4,423,571 | substr in c++ problem | <p>When I try to execute the program, the output is coming as expected for the first iteration. but for second iteration, out is not coming as expected...</p>
<pre><code>int main(){
string insertBuffer;
string valSep;
valSep = ":";
string configParamSep = "\r\n";
int configParamSepSize = 2;
string configParam;
string::size_type mCPos = 0;
string::size_type mCBeginPos = 0;
int finished = 0;
string one = "hai: yes";
string two = "tension: no";
insertBuffer = one + "\r\n" + two + "\r\n";
cout<<"OUTPUT:"<<"\n";
while (!finished){
if( !(mCBeginPos >= insertBuffer.length()) && ((mCPos = insertBuffer.find(valSep,mCBeginPos)) != string::npos)){
configParam = insertBuffer.substr(mCBeginPos,mCPos);
}else{
finished = 1;
break;
}
cout<<configParam<<"\n";
mCBeginPos = mCBeginPos + insertBuffer.find(configParamSep,mCBeginPos) + configParamSepSize;
}
return 0;
}
</code></pre>
<p>OUTPUT:</p>
<pre><code>hai
tension: no
</code></pre>
<p>But expected outpu is:-</p>
<pre><code>hai
tension
</code></pre>
<p>Any clue why this is happening?</p>
| c++ | [6] |
2,105,793 | 2,105,794 | Using Javascript, I would like to pick up any content in a form field if a user clicks a non-form element | <p>I have a login form on an application that we cannot change the back-end of (vendor supplied), but we can change the template (ie: the html and javascript). It has a "forgot password" link below it. Almost all users will just click the link, but some put in their username, try a few iterations and then hit the "forgot password" link.</p>
<p>What I would like to do is use javascript to take a look at the username field and, if it has any content, change the URL of the "forgot password" link to point to the next step in the password recovery.</p>
<p>So, when the user clicks on the link with no value in the username field, the link goes to: <a href="http://example.com/system/lookup.html" rel="nofollow">http://example.com/system/lookup.html</a></p>
<p>If there is a value in the username field, I'd like the link to resolve to:
<a href="http://example.com/system/lookup.html?id=" rel="nofollow">http://example.com/system/lookup.html?id=</a>{username}</p>
<p>Easy to do?</p>
| javascript | [3] |
2,165,803 | 2,165,804 | Array of Char = Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException | <p>This is my method</p>
<pre><code>private char[] listFindChar;
public void setlistFindChar(char letter){
int pos;
if (listFindChar !=null)
{
pos = listFindChar.length;
pos ++;
listFindChar[pos]=letter;
}
else{
listFindChar[0] = letter; (cause problem)
}
</code></pre>
<p>Why the char is not add in the array of chars at the position[0]??</p>
<p>Thanks for helping me!!</p>
<p>Frank</p>
| java | [1] |
8,696 | 8,697 | is java an open source programming language? | <p>i know about python, ruby, perl etc.. but is java a really open source programming language?
because i searched on google too but didnt get proper answer. so asking here</p>
| java | [1] |
24,849 | 24,850 | Lottery random.randint help in python | <p>Heres my program so far</p>
<pre><code>import random
def lottery(lottoNumber1,lottoNumber2,lottoNumber3):
for count in range(1):
lottoNumber1 = random.randint(1,50)
print(lottoNumber1)
for count in range(1):
lottoNumber2 = random.randint(1,50)
print(lottoNumber2)
for count in range(1):
lottoNumber3 = random.randint(1,50)
print(lottoNumber3)
return lottoNumber1,lottoNumber2,lottoNumber3
def main():
userChoice1 = int(input('Chose a number between 1 and 50: '))
userChoice2 = int(input('Chose a number between 1 and 50: '))
userChoice3 = int(input('Chose a number between 1 and 50: '))
if userChoice1 == lottoNumber1:
lottoNumber1 = lottery(lottoNumber1,lottoNumber2,lottoNumber3)
print('You win $1,000')
else:
print('You effing suck')
main()
</code></pre>
<p>I'm getting a message error saying that lottoNumber1 is reference before the assignment in the main function. I'm not to sure what that means. Anyone know what I could do to make this code smoother. I want to make it so the user has to chose 3 numbers and if he gets them equal to the 3 lotto numbers he wins 10000</p>
<p>Thanks guys. </p>
| python | [7] |
4,016,019 | 4,016,020 | One javascript file kills all the others. Ways to avoid this? | <p>I will not add any code in here. Just working on a project and not only this time, but frequently one javascript file kills the others, so I ussually in this situation looked for similar solution (lets say a different slider and etc.)</p>
<p>But are there any more ways to wrap up some how a javascript file that it wont interfere with the others?</p>
| javascript | [3] |
2,230,076 | 2,230,077 | how to avoid delay playing wav file in JS | <p>I have programmed my site so that a sound plays when the user clicks on an image. I did this with JS. But there is a problem. There is a long delay of about 5 seconds before the sound plays that is after you click on the image. What can I do to make the sound play without delay? The sound is a wav file.</p>
| javascript | [3] |
5,778,130 | 5,778,131 | Directory is not empty error in c# | <p>In my example I am trying to delete the folders under a particular folder. My folder structure like this... <code>C:\Export\MyDir1\MyDir2\MyDir3\MyDir4\MyDir5</code> This structure will come on the fly. Next time when I run my application it should check for <code>C:\Export\MyDir1</code> directory and delete if exists. I written like this</p>
<pre><code>private static string getExportPath(string exportTargetPath, string parentIssue)
{
string exportPath = Path.Combine(exportTargetPath, parentIssue);
if (Directory.Exists(exportPath))
{
string[] files = Directory.GetFiles(exportPath);
string[] dirs = Directory.GetDirectories(exportTargetPath);
File.SetAttributes(exportTargetPath, FileAttributes.Normal);
Directory.Delete(exportTargetPath,false);
}
return exportPath;
}
</code></pre>
<p>I checked with the issue posted in this sit <a href="http://stackoverflow.com/questions/329355/cannot-delete-directory-with-directory-deletepath-true">Issue</a> I tried with this one but can't get solution. As per the suggested answer for this question, when i try to iterate through the directories then it is going to infinite loop. Where I done the mistake? Could any one help me?</p>
| c# | [0] |
2,259,118 | 2,259,119 | onRowCommand gets fired again on refreshing the page | <p>In my web page i have a gridview which contains link to download file and link to open another web site in separate page.When i click on link gridview onRowCommand gets executed and website opens in separate window.After this when i refresh the web page, gridview onRowCommand get executed again and opens web site in separate window again which i dont want.I want that when i click on link to navigate to another web site then only it should go.I mean on page refresh, gridview onRowCommand should not get executed. </p>
<p>I am using Page.RegisterStartupScript to open another web site in separate window.</p>
<p>ASP.net 2.0</p>
<p>thanks</p>
<p>-------------------------------------------code----------------</p>
<p>protected void grdDisplayView_onRowCommand(object sender, GridViewCommandEventArgs e)
{
string path = e.CommandArgument.ToString();</p>
<pre><code> if (path.Contains("http"))
{
StringBuilder sbString = new StringBuilder("<script language='javascript'>");
sbString.Append("window.open('");
sbString.Append("http://www.yahoo.com','', 'status=no,width=600,height=500,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,titlebar=yes,top=198,left=305');");
sbString.Append("</script>");
if ((!Page.ClientScript.IsStartupScriptRegistered("clientScriptExportView")))
{
Page.RegisterStartupScript("clientScriptExportView",sbString.ToString());
}
}
else
{
//download file which is locally
path = Server.MapPath(path);
System.IO.FileInfo file = new System.IO.FileInfo(path);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
HttpContext.Current.Response.AddHeader("Content-Length", file.Length.ToString());
HttpContext.Current.Response.ContentType = "Application/octet-stream";
HttpContext.Current.Response.WriteFile(file.FullName);
HttpContext.Current.Response.End();
}
}
</code></pre>
| asp.net | [9] |
3,022,123 | 3,022,124 | What is the shortest way to create post form and submit it using jQuery? | <p>I have a button with attributes <code>data-url</code> and <code>data-parameter</code> and need to post that to controller. Thing is, that controller will return a redirect, so <code>$.post</code> not really helpful here, I'm thinking about creating form on the fly and submitting it.<br>
I think that is quite common task, but I couldn't find any shortcut on jQuery to do this, what would be the shortest/best way to do it?</p>
| jquery | [5] |
1,905,946 | 1,905,947 | How do i know if my alarm manager timer is on? | <p>I'm using this code (from my activity) to start a periodic timer in the application:</p>
<pre><code>Intent intent = new Intent(this, MyBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 234324243, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),(i * 1000), pendingIntent);
Toast.makeText(this, "Alarm set in " + i + " seconds",
Toast.LENGTH_SHORT).show();
</code></pre>
<p>I want to know how can i know (from a different activity) is the timer is running?</p>
| android | [4] |
689,060 | 689,061 | Android Menu Icon with Title : Title doesn't display | <p>Here is my XML</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/refresh" android:title="Home"
android:icon="@drawable/menu_home" />
<item android:id="@+id/search" android:title="Search"
android:icon="@drawable/menu_search" />
<item android:id="@+id/help" android:title="Help" android:icon="@drawable/menu_help" />
</menu>
</code></pre>
<p>Icon is getting displayed but title doesn't. Please advise.</p>
| android | [4] |
66,227 | 66,228 | List directory filenames by file word count | <p>I'd like to, </p>
<ol>
<li>Check the word count for a folder full of text files. </li>
<li>Output a list of the files arranged by word count in the format - FILENAME is WORDCOUNT</li>
</ol>
<p>I know str_word_count is used to get individual wordcounts for files but I'm not sure how to rearrange the output.</p>
<p>Thanks in advance.</p>
| php | [2] |
3,039,282 | 3,039,283 | javascript: add script that will be evaluated before body scripts? | <p>I have a script foo.js that is included in <code><head></code>. Inside body I have an inline script. Inside it, I want to add to the document another script for bar.js that will be loaded and evaluated before the inline script.</p>
<pre><code><html>
<head>
<script src="foo.js" type="text/javascript"/>
</head>
<body>
<script type="text/javascript">
bar()
</script>
</body>
</html>
</code></pre>
<p>In foo.js I want to add a script pointing to bar.js</p>
<p>bar.js:</p>
<pre><code>function bar() {
alert('hi');
}
</code></pre>
<p>What should be the code of foo.js?</p>
<p>NOTE: I know I can use onload in this trivial example. But in my real case, bar.js contains a function that is called several times and I want to be able to inline these calls in the right sections of the page (for code locality)</p>
| javascript | [3] |
939,924 | 939,925 | how to get the name of the currently connected device to computer? | <p>When I connect my phone to the computer and visit Google play store in google chrome, it seams like the page knows that the device is connected, like this picture:</p>
<p><img src="http://i.stack.imgur.com/G4AHA.png" alt="DeviceName"></p>
<p>How can I do it using JavaScript?</p>
| javascript | [3] |
5,643,346 | 5,643,347 | Why does unboxing cast to the concrete class rather than Number | <p>For example unboxing Integer results in a cast to Integer followed by a call to intValue(). Why not simply cast to Number followed by the necessary intValue() to get the primitive ? Naturally the question extends to unboxing all the other wrappers.</p>
| java | [1] |
3,202,695 | 3,202,696 | Detect in page_load event "webpage dialog" in asp.net | <p>Can and how do you detect in page_load event that the page is "webpage dialog" in asp.net?</p>
| asp.net | [9] |
2,883,264 | 2,883,265 | jquery shake on mouse over? | <p>is it possible to shake a table row if mouse over? and if so how? =)</p>
<p>I have done it before when calling a div, but I havent as yet use the mouse over function, any help appreciated</p>
<p>Thanks =)</p>
| jquery | [5] |
5,638,263 | 5,638,264 | Object doesn't support method | <p>I'm trying to run the following code, but get an error in the gameLoop function saying: JavaScript runtime error: Object doesn't support property or method 'update'.</p>
<p>I'm a beginning JavaScript programmer. Can you spot what is wrong with this code?</p>
<pre><code>function Core(context) {
this.context = context;
this.fps = 500;
this.sprite = new Sprite();
}
Core.prototype.run = function() {
setInterval(this.gameLoop, this.fps); // <<<< PROBLEM
}
Core.prototype.gameLoop = function () {
this.update();
this.draw();
}
Core.prototype.update = function () {
this.sprite.x += 50;
this.sprite.y += 50;
}
Core.prototype.draw = function () {
this.context.clearRect(0, 0, 300, 300);
this.context.fillRect(this.sprite.x, this.sprite.y, 50, 50);
this.context.fillText('x: ' + this.sprite.x + ' y: ' + this.sprite.y, 10, 250);
}
</code></pre>
| javascript | [3] |
5,001,828 | 5,001,829 | jQuery list hide/show based on current class | <p>I want to display the entire ul li struct that has a class <code>current</code> somewhere in it</p>
<p>Every other ul li I want to hide. EXCEPT The top level.</p>
<p>My jQuery is not doing what I want, any suggestions?</p>
<pre><code>$("ul li").find("ul").hide();
$("ul:has(li.current)").parents().show();
$("ul:has(li.current)").children().show();
</code></pre>
<p>For example:</p>
<pre><code><ul>
<li>Entire struct is displayed
<ul>
<li>1.1
<ul>
<li class="current">1.1.1</li>
</ul>
</li>
<li>1.2</li>
</ul>
</li>
<li>Only this li is shown
<ul>
<li>2.1</li>
<li>2.2</li>
</ul>
</li>
</ul>
</code></pre>
<p>Displays as:
<ul>
<li>Entire struct is displayed
<ul>
<li>1.1
<ul>
<li>1.1.1</li>
</ul>
</li>
<li>1.2</li>
</ul>
</li>
<li>Only this li is shown</li>
</ul></p>
<p>EDIT: added children to jQuery, but still not working as desired.</p>
| jquery | [5] |
3,539,054 | 3,539,055 | How to replace last character of the string using c#? | <pre><code>string str = "Student_123_";
</code></pre>
<p>I need to replace the last character "_" with ",". I did it like this. </p>
<pre><code>str.Remove(str.Length -1, 1);
str = str + ",";
</code></pre>
<p>However, is it possible to achieve it more efficiently. may be one line of code.??
BTW, last character can be any character. So Replace wont work here.</p>
| c# | [0] |
4,083,150 | 4,083,151 | Assertion error | <p>I have written(shown below) a method getCelsius to convert from Fahrenheit to Celsius but when I run the program it shows me an assertion error.</p>
<p>Code:</p>
<p>Method in class Temperature:</p>
<pre><code>public double getCelsius() {
double c = 0;
c = ((this.temp_value - 32) * (5 / 9));
return c;
}
</code></pre>
<p>and here is the method call in class TestTemperature, which gives me an assertion error:</p>
<pre><code>Temperature t = new Temperature(212.0, "F");
assert t.getCelsius() == 100.0; // < error in this line
</code></pre>
<p>Help!</p>
| java | [1] |
4,169,603 | 4,169,604 | How do you use jQuery .data() to store html? | <p>when I look up the syntax for .data(), it gives examples like this:</p>
<pre><code>$('body').data('foo', 52);
</code></pre>
<p>I am doing AJAX loads and I was wondering if it is possible to store the incoming html using .data() so once the content is loaded, I would not need to do another AJAX load if the same link is clicked again - I would check to see if the .data key is empty.</p>
<p>Would something like this work?:</p>
<p>To load the contents of a #ajaxdiv into storage:</p>
<pre><code>$('body').data('storage', div#ajaxdiv.html());
</code></pre>
<p>To test if the data has already been loaded:</p>
<pre><code>if $('body').data('storage') != '' {
div#ajaxdiv.html($('body').data('storage'));
}
</code></pre>
<p>Thanks in advance!!</p>
<p>Al</p>
| jquery | [5] |
5,076,350 | 5,076,351 | How to parse JSON obtained from HttpClient connection? | <p>I have successfully established a connection using Httpclient <code>GET</code> method. Now I want to parse the data using JSON Parser. Please help me.</p>
| android | [4] |
647,696 | 647,697 | E-Book publishinng for android | <p>which is best sutible format for e-Book publishing</p>
| android | [4] |
2,376,942 | 2,376,943 | jQuery: Adding up multiple dynamic values | <p><strong>What I'm trying to achieve is this:</strong></p>
<p>I have multiple <em>td's</em> with the same class but different values.</p>
<pre><code><td class="goals_238"> 3 </td>
<td class="goals_311"> 0 </td>
<td class="goals_128"> 1 </td>
<td class="goals_238"> 4 </td>
<td class="goals_238"> 3 </td>
</code></pre>
<p>I want to get the values of "goals_238" and add them up.</p>
<p>The end result for "goals_238" would be = 10</p>
<p>This whole thing is for a sports results table, hence "goals" classes.</p>
<p>I can get to print how many times "goals_238" appears, but doing the math is whole other level for me.</p>
<pre><code>var gamesPlayed = ( $('.goals_238').length );
$('p#goals_238').html(gamesPlayed);
</code></pre>
<p>Any clues on how would I go about this? </p>
| jquery | [5] |
5,585,910 | 5,585,911 | Can't access $_POST variables when using multipart/form-data | <p><strong>What is the problem?</strong></p>
<p>When I add a file using my form the $_POST variables are undefined. When I don't add a file the $_POST variables are defined.</p>
<p><strong>What errors do you receive?</strong></p>
<pre><code>Notice: Undefined index: bbmpin in C:\...\addpin.php on line 6
Notice: Undefined index: usermsg in C:\...\addpin.php on line 7
</code></pre>
<p><strong>Source Code</strong></p>
<p>index.html</p>
<pre><code><form method="POST" action="addpin.php" enctype="multipart/form-data">
<div>
<label for="bbmpin">Your BBM Pin</label>
<input type="text" name="bbmpin" placeholder="Enter Your BBM Pin">
</div>
<div>
<label for="usermsg">Message</label>
<input type="text" name="usermsg" placeholder="(optional) Add a short message" maxlength="255">
</div>
<div>
<label for="image">Upload Image <small>(optional)</small></label>
<input type="file" name="image">
</div>
<button type="submit">Submit</button>
</form>
</code></pre>
<p>addpin.php</p>
<pre><code><?php
session_start();
require_once('config/config.php');
$pin = $_POST['bbmpin'];
$msg = $_POST['usermsg'];
$ip = $_SERVER['REMOTE_ADDR'];
print_r($_POST);
print_r($_FILES);
exit;
...
?>
</code></pre>
| php | [2] |
1,566,845 | 1,566,846 | Getting the full path of current active file (not a Java application, e.g. pdf) in Java | <p>(Active - the file whose window is in the foreground.)</p>
<p>I am working on a problem which is to extract the text in the current active pdf (.pdf), word (.doc, .docx), or notepad (.txt) file in real time. I have tried JNA, and got the active file name (e.g., a.pdf) and exe name, but not the file path (e.g., C:/Desktop/.../a.pdf.) I need the full file path here, because I can read the corresponding file and extract the text in it once I know its path. (I do not need the exe path, e.g., C:/Program Files/adobe.exe.)</p>
<p>I have checked the doc of JNA, but not found a method which can provide the path of current active file (not a Java application). </p>
<p>Alternatively, I think maybe some package can provide the full path of the current file/icon in focus (e.g., I click a.pdf before I open it and my mouse will focus on a.pdf.) I tried JNI, but still not found such a method.</p>
<p>Could you please provide some suggestions about how to get the path of the current active file (not a Java application) using Java or how to get the path of the current file/icon in mouse focus?</p>
<p>Thanks a lot!</p>
| java | [1] |
1,883,623 | 1,883,624 | Is there any LIBrary available in PHP to convert PDF file to HTML? | <p>I Have a system. I which I need to edit the PDF in every specific evcent, for that I googled a lot and reached to conclusion that it can be achieved by first converting PDF to HTML, editting the HTML and then again converting the same HTML to PDF file.</p>
<p>Is there any Library available in PHP to convert PDF file to HTML?</p>
<p>And if anyone available with other way to achieve my task, please let me know, </p>
<p><strong>NOTE: PLEASE DO NOT SUGGEST ZEND FRAMEWORK USE.</strong> </p>
| php | [2] |
834,137 | 834,138 | How do I write good/correct __init__.py files | <p>My package have the following structure:</p>
<pre><code>mobilescouter/
__init__.py #1
mapper/
__init__.py #2
lxml/
__init__.py #3
vehiclemapper.py
vehiclefeaturemapper.py
vehiclefeaturesetmapper.py
...
basemapper.py
vehicle/
__init__.py #4
vehicle.py
vehiclefeature.py
vehiclefeaturemapper.py
...
</code></pre>
<p>I'm always not sure how the <code>__init__.py</code> files are written good and correctly.<br/> The <code>__init__.py #1</code> looks like:</p>
<pre><code>__all__ = ['mapper', 'vehicle']
import mapper
import vehicle
</code></pre>
<p>But how should for example <code>__init__.py #2</code> look like? Mine is:</p>
<pre><code>__all__ = ['basemapper', 'lxml']
from basemaper import *
import lxml
</code></pre>
<p>Is it recommend to use <code>__all__</code>? </p>
| python | [7] |
1,396,150 | 1,396,151 | WebView can not open this url, please help | <p>android 2.2, javascript enabled.<br>
my application with WebView can not open the url <a href="http://map.baidu.com/mobile/#l=18&fr=zhangbai&s=s%26wd%3d%E7%99%BE%E5%BA%A6%E5%A4%A7%E5%8E%A6%E5%9C%B0%E5%9D%80" rel="nofollow">http://map.baidu.com/mobile/#l=18&fr=zhangbai&s=s%26wd%3d%E7%99%BE%E5%BA%A6%E5%A4%A7%E5%8E%A6%E5%9C%B0%E5%9D%80</a>.</p>
<p>but the android system browser can open it.</p>
<p>on android 1.6 can open it too.</p>
<p>anyone can help?</p>
<p>thank you.</p>
| android | [4] |
2,272,490 | 2,272,491 | Difference between namedtuple and a frozen dict | <p>I know there is no frozen dict data type but If there was one how would it be different from namedtuple. It seems to me that namedtuple performs the required operations but obviously it does not. So what are the differences?</p>
| python | [7] |
4,004,923 | 4,004,924 | Enum value to string | <p>Does anyone know how to get enum values to string?</p>
<p>example:</p>
<pre><code>private static void PullReviews(string action, HttpContext context)
{
switch (action)
{
case ProductReviewType.Good.ToString():
PullGoodReviews(context);
break;
case ProductReviewType.Bad.ToString():
PullBadReviews(context);
break;
}
}
</code></pre>
<p>Edit:</p>
<p>When trying to use ToString(); the compiler complains because the case statement is expecting a constant. I also know that ToString() is is striked out with a line in intellisense</p>
| c# | [0] |
3,668,107 | 3,668,108 | Can i Delete Few HTML Tags in JQuery? | <p>In my HTML code i want to check the following HTML code and automatically delete it on page load, how do i do it in JQuery ?</p>
<p>First Code that needs to be deleted</p>
<pre><code><table cellspacing="0" cellpadding="0" width="100%"><tbody><tr class="yellow"><td width="64%" valign="top">
</code></pre>
<p>Second Code that needs to be deleted</p>
<pre><code></td></tr></tbody></table>
</code></pre>
| jquery | [5] |
2,250,765 | 2,250,766 | error when I include iomanip | <p>I was just starting writing a program, when I noticed something I do not understand.
I have defined a structure called "time".
When I try to define a structure variable called "time1", it send out an error: "expected an ';'".
But when I remove the header file "iomanip" the error disappears! And when I include it again the error comes back. Why does this happen?</p>
| c++ | [6] |
4,596,515 | 4,596,516 | Is it good practice to pass scoped_ptr by reference (from one method to another inside a class)? | <p>Or if i need to do that, then i should just use shared_ptr?</p>
<p>I know i have many questions regarding smart pointer - i still don't quite understand when to use which smart pointer.</p>
| c++ | [6] |
5,776,626 | 5,776,627 | Typing only non null fields? | <pre><code>string[] lines = { textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text };
Random RandString = new Random();
string text = lines[RandString.Next(0, lines.Length)];
SendKeys.SendWait(text);
</code></pre>
<p>How can I select textBox's with text inside of them? I was trying to sort the data <code>string[] lines</code> into a new <code>string[] hasText</code> but I'm unsure how to go about checking if the textBox has text inside of it.</p>
<p>If the textBox field is null it will still process through RandString and SendKeys will try to type it out. How can I fix this?</p>
<p>Thanks.</p>
| c# | [0] |
156,571 | 156,572 | How provide several options (not just one) after initialization? | <p>Can several options (after init) be provided at once? </p>
<pre><code>$('<p>Dialog</p>').dialog().parent().draggable( "option", "containment", false );
</code></pre>
<p>If I also want <code>scroll: false</code>, how do I do it?</p>
| jquery | [5] |
573,276 | 573,277 | Can I test if my thread looper finished its messages? | <p>I want to test if my Looper finished its work because I want to execute code after all elements of my activity are on screen. I want to trigger an event after Looper finishes its work. Can I do that or is there any another way to execute my code after all elements in the UI appears on screen?</p>
| android | [4] |
1,686,880 | 1,686,881 | PHP trim problem | <p>I <a href="http://stackoverflow.com/questions/3440635/php-how-to-remove-extra-characters-at-the-end-and-beginning-of-a-string">asked earlier</a> how can I get rid of extra hyphens and whitespace added at the end and beginning of user submitted text for example, <code>-ruby-on-rails-</code> should be <code>ruby-on-rails</code> you guys suggested <code>trim()</code> which worked fine by itself but when I added it to my code it did not work at all it actually did some funky things to my code. </p>
<p>I tried placing the <code>trim()</code> code every where in my code but nothing worked can someone help me to get rid of extra hyphens and whitespace added at the end and beginning of user submitted text?</p>
<p>Here is my PHP code.</p>
<pre><code>$tags = preg_split('/,/', strip_tags($_POST['tag']), -1, PREG_SPLIT_NO_EMPTY);
$tags = str_replace(' ', '-', $tags);
</code></pre>
| php | [2] |
5,066,093 | 5,066,094 | unable to write manifest.Configuration System failed to initialize in c# | <p>I am getting error: -</p>
<pre><code>Unable to write manifest.Configuration System failed to initialize in c# while building application .
</code></pre>
<p>How to solve this?</p>
| c# | [0] |
1,698,970 | 1,698,971 | Two basic C++ questions about string literals and dynamic allocation | <p>Are these two equivalent?</p>
<p>char * aString = "This is a string.";</p>
<p>char aString[] = "This is a string.";</p>
<p>From my understanding, C++ stores strings by their addresses, so the pointer is getting a valid address. I assume the strings are also stored as type char? But how does it know how much memory to allocate for the string? Normally, char arrays need their array size preset. I believe the [] type arrays are counted by the compiler before compilation. Is this what happens for the string literal pointer as well?</p>
<p>On to my second question, what is the difference between these two:</p>
<p>int someNumber;</p>
<p>int * someNumber = new int;</p>
<p>The second is supposed to be dynamic allocation. If I understand the concept right, it allocates the memory as soon as it reads the declaration. But what happens in the standard declaration? Basically, I need to understand how dynamic allocation is advantageous over standard declarations.</p>
| c++ | [6] |
306,812 | 306,813 | How to add zeros onto a number | <p>I have a number that is being returned from my database and I'd like to have trailing zeros after the decimal place. I've tried round but that doesn't work.</p>
<p>$18.0 should be $18.00. What function would I use for this?</p>
| php | [2] |
1,751,482 | 1,751,483 | How to change speed at which text is printed (python) | <p>What I am trying to accomplish is first text appears after 1 second. then 2, ect. till 10. then when time equals 10, the time decreases, so the text appears after 9 seconds, then 8 etc.</p>
<p>How could I fix this code so that it works properly?</p>
<p>The error:</p>
<pre><code>Traceback (most recent call last):
File "C:/Users/Eric/Dropbox/time.py", line 13, in <module>
time.sleep(time)
AttributeError: 'int' object has no attribute 'sleep'
</code></pre>
<p>The code :</p>
<pre><code>import time
x = 1
t = 1
time = t + 1
while x == 1:
print time
if time >=10:
time = t - 1
elif time <= 0:
time = t + 1
time.sleep(time)
</code></pre>
<hr>
<p>Edit:</p>
<pre><code>import time
x = 1
t = 1
time1 = 0
while x == 1:
if time1 == 10:
time1 = time1 - 1
elif time1 == 0:
time1 = time1 + 1
else :
time1 = time1 + 1
print time1
time.sleep(time1)
</code></pre>
<p>So I changed the program around abit, so I almost works correctly. What it does is count to 10, then 9 then back to 10.
ex. 1,2,3,4,5,6,7,8,9,10,9,10,9,10
how can I set it so that the program increases time to ten then decreases to zero then increases again?</p>
| python | [7] |
2,365,757 | 2,365,758 | AutoPointer with objects not allocated on heap | <p>Auto pointer internally calls delete on the object that it points to once it goes out of scope. This works fine if we assign an object that is created on the heap. But if i try to assign an object that's not created on heap it crashes as delete is called twice. First by the auto_ptr itself and second as the object goes out of scope its destructor is called again.
As shown below,</p>
<pre><code>#include <iostream>
#include <memory>
using namespace std;
class sample
{
public:
sample() { puts("sample"); }
~sample() { puts("~sample"); }
};
int main()
{
sample sObj;
auto_ptr<sample> samplePtr(&sObj);
}
</code></pre>
<p>Does that mean we can use auto_ptr to hold only the objects that are created on the heap?</p>
| c++ | [6] |
801,073 | 801,074 | Accessing Array of stdClass Objects | <p>New to PHP....I am trying to access a value in an array that comes from a decoded json file. I printed my variable to the screen, and this was returned...</p>
<pre><code>Array (
[0] => stdClass Object (
[period] => 0
[title] => Sunday
[fcttext] => Mostly cloudy with a chance of ...
[pop] => 50 )
[1] => stdClass Object (
[period] => 1
[title] => Sunday Night
[fcttext] => Partly cloudy. Low of 64F. Win....
[pop] => 10 )
[2] => stdClass Object (
[period] => 2
[title] => Monday
[fcttext] => Partly cloudy. High of 90F. Winds less than 5 mph.
[pop] => 10 )
[3] => stdClass Object (
[period] => 3
...
)
)
</code></pre>
<p>How do I access, for instance, the fcttext from period 1?</p>
<p>Thanks!</p>
| php | [2] |
1,871,941 | 1,871,942 | Python list help q = { 1: [[1]] } | <p>can someone please explain to me what this line does ? </p>
<pre><code>q = { 1: [[1]] }
</code></pre>
<p>Thank you.</p>
| python | [7] |
373,900 | 373,901 | Sort dictionary by value of other dictionary in Python | <p>How to sort this <strong>dictionary</strong> by <code>'votes'</code> in Python?</p>
<pre><code>{
1 : {
'votes' : 2,
'id' : 10
},
2 : {
'votes' : 10,
'id' : 12
},
3 : {
'votes' : 98,
'id' : 14
}
}
</code></pre>
<p>To results in:</p>
<pre><code>{
3 : {
'votes' : 98,
'id' : 14
},
2 : {
'votes' : 10,
'id' : 12
},
1 : {
'votes' : 2,
'id' : 10
}
}
</code></pre>
| python | [7] |
5,428,578 | 5,428,579 | checkbox return only false even it is checked in Jquery | <p>I submit the form while change dropdown option.After submit the form i redirect in to same page.
I submit the form Using below function:</p>
<pre><code>function submitform(){
//Below variables are checkbox value
var addresscheck = $('#addressmatchedCheck').is(':checked');
var rcnumbercheck = $('#rcnumbermatched').is(':checked');
var phonenumbercheck = $('#phonenumbercheck').is(':checked');
var idproofcheck = $('#idproofcheck').is(':checked');
var guarantoraddresscheck = $('#guarantoraddressmatchedCheck').is(':checked');
var guarantoridcheck = $('#guarantoridproofcheck').is(':checked');
var guarantorrelationcheck = $('#guarantorrelationshipCheck').is(':checked');
if( addresscheck & rcnumbercheck & phonenumbercheck & idproofcheck & guarantoraddresscheck & guarantoridcheck & guarantorrelationcheck) {
$('#statusid').val(1);
alert($('#statusid').val() + "if");
}
else{
$('#statusid').val(2);
alert($('#statusid').val() + "else");
}
$('#fieldVerificationFormID').attr('method', 'POST');
$('#fieldVerificationFormID').attr('action', '/mfi/api/1.0/client/ci/groups/member/fieldverification/insert');
$('#fieldVerificationFormID').submit();
}
</code></pre>
<p>My problem is checkbox return only false even it is checked?
First time i.e before form submit it works exactly.Issue is after form submission.
can anyone sove my issue?</p>
| jquery | [5] |
518,372 | 518,373 | numeric sort a mixed types values array by sort() php function | <p>i have a mixed array like this:</p>
<pre><code>$fruits = array("lemon","Lemon", 20, "banana", "apple","121",40,50);
</code></pre>
<p>and then apply sort() function to it as follows:</p>
<pre><code>sort($fruits,SORT_NUMERIC);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "\n";
}
</code></pre>
<p>now, i do not understand the output that is :</p>
<pre><code>fruits[0] = apple
fruits[1] = lemon
fruits[2] = banana
fruits[3] = Lemon
fruits[4] = 20
fruits[5] = 40
fruits[6] = 50
fruits[7] = 121
</code></pre>
<p>please explain the way that is sorted</p>
| php | [2] |
3,441,726 | 3,441,727 | how can i set mTextView to show on button click | <p>i have a UITextView object which i have created in interface builder with it's hidden property unmarked.Now i want this textView to be invisible when my application launches and first view appears.Further i want it to be displayed when a particular method is called.Now this is what i have written in view did load</p>
<pre><code>[mTextView setHidden:YES];
self.mTextView=[[UITextView alloc] init];
</code></pre>
<p>it hides the textView ats the first view appears but when my desired method is called and i write</p>
<p>[mTextView setHidden:NO];
it does not show it again..
Is it like we cant change the appearance of a textView once it is assigned because after assigning memory as</p>
<p>self.mTextView=[[UITextView alloc] init];
and then writing</p>
<p>[mTextView setHidden:YES];</p>
<p>it does not hide textView in viwDidLoad either.....</p>
| iphone | [8] |
3,322,551 | 3,322,552 | Sorting Images | <p>lets start from begining I need images to be sorted by folders. like drawable/Photos, drawable/items, drawable/photos. and put each folder to the registry or at least find way to get them out of there. all I want is something close to php like "../img/photos/photo0.jpg". is there way to do something like this. and folder with Imges must contain in apk file.</p>
<p>possible solutions is make link in the R file but I didn't find how to do it, other solution is find comand with logic like I will show you here :</p>
<pre><code>ImageView img = (ImageView)CloningTable.findViewById(R.id.img);
String ImgPath = "com.test.test/img/img0.jpg";
img.setImageDrawable(Drawable.createFromPath(ImgPath));
</code></pre>
<p>OR</p>
<pre><code>ImageView img= (ImageView)CloningTable.findViewById(R.id.img);
String ImgPath = "com.test.test/img/img0.jpg";
img.setImageResource(ImgPath);
</code></pre>
<p>please say me the best way to handle it. AND specify if it contain path how I can know path the file lies in.</p>
<pre><code> File ImgFile = new File("test/test.jpg");
TextView testtext= (TextView)CloningTable.findViewById(R.id.testtext);
if (ImgFile.exists()) {
test.setImageBitmap(BitmapFactory.decodeFile(ImgFile.getPath()));
testtext.setText("asdasuidjasdk");
}
</code></pre>
<p>can any one say Why programm can't find file and file exist 100% = /?</p>
<p>filepath: Project> assets/test/test.jpg</p>
<p>found solution <a href="http://stackoverflow.com/questions/3691295/android-show-image-by-path">Android Show image by path</a></p>
| android | [4] |
5,464,330 | 5,464,331 | Android: Why is my soft keyboard hiding after these key events? | <p>I have a WebView in my Android Application that is giving me a problem. At first was not handling the keyDown event correctly for the arrow keys, and I had to catch the keyDown and use Javascript like this to process them correctly:</p>
<pre><code> @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.v(TAG, "KeyCode: " + keyCode + " KeyEvent: " + event);
switch(keyCode) {
case 19: /* Up */
this.loadUrl("javascript:editor.setCursor(editor.getCursor().line - 1, editor.getCursor().ch);");
case 20: /* Down */
this.loadUrl("javascript:editor.setCursor(editor.getCursor().line + 1, editor.getCursor().ch);");
case 21: /* Left */
this.loadUrl("javascript:editor.setCursor(editor.getCursor().line, editor.getCursor().ch - 1);");
case 22: /* Right */
this.loadUrl("javascript:editor.setCursor(editor.getCursor().line, editor.getCursor().ch + 1);");
}
return super.onKeyDown(keyCode, event);
}
</code></pre>
<p>But now I am getting an issue that every time I use one of the arrow keys the soft keyboard is hiding. </p>
<p>I found one other question here on Stackoverflow that seems to be the exact same issue, but nobody answered him:</p>
<p><a href="http://stackoverflow.com/questions/8016430/prevent-buttons-from-hiding-soft-keyboard-on-android">Prevent Buttons From Hiding Soft Keyboard On Android</a></p>
<p>Is there some way I can prevent the softkeyboard from hiding on me?</p>
| android | [4] |
5,240,808 | 5,240,809 | replace first occurrence from right and left side of string | <p>I tried to replace first occurance of a json string <code>{</code> from right side, and left side <code>}</code> . </p>
<pre><code>$json_data = preg_replace( '/\{/' , '', $json_data ,1 );
$json_data = rtrim( $json_data ,'}' ); // here is issue
</code></pre>
<p>but string like this <code>{"chart":"c12","series":{"name":"Test","data":[]}}</code> replaced into </p>
<pre><code>"chart":"c12","series":{"name":"Test","data":[]
</code></pre>
<p>The rtrim replaced '}}' . how to replace the first occurance of <code>}</code> from the right side of string ?</p>
| php | [2] |
837,446 | 837,447 | How to call .exe within WPF application | <p>How to run one WPF exe (which is in 3.5 framework) from another WPF application (4.0 application).</p>
<p>Reason of the above is:<br>
I'm using some third party which only support 3.5 framework and my existing application is on 4.0. I can't change my current application target type b'coz it has around 200 projects that I need to change then. </p>
<p>I'm stuck with this problem, also I need to pass string as an argument in that.</p>
<p>Below was code that I tried, but didn't get any luck with that: </p>
<pre><code>var processInfo = new ProcessStartInfo(path, param);
Process.Start(processInfo);
</code></pre>
<p>EDIT:
I changed the path and it works for me. But now the problem is I'm not able to get the Command-line argument in the .exe application. Like Currently I'm passing the "param" (it is a string type of array) as an argument to my .exe. But can anyone please help me that how to get this parameter in the .exe file. Means in the window.Loaded handler I want to get this parameter and based on that I want to perform some action.</p>
| c# | [0] |
596,693 | 596,694 | Inheritance - initialization problem | <p>I have a c++ class derived from a base class in a framework. </p>
<p>The derived class doesn't have any data members because I need it to be freely convertible into a base class and back - the framework is responsible for loading and saving the objects and I can't change it. My derived class just has functions for accessing the data.</p>
<p>But there are a couple of places where I need to store some temporary local variables to speed up access to data in the base class.</p>
<pre><code>mydata* MyClass::getData() {
if ( !m_mydata ) { // set to NULL in the constructor
m_mydata = some_long_and complex_operation_to_get_the_data_in_the_base()
}
return m_mydata;
}
</code></pre>
<p>The problem is if I just access the object by casting the base class pointer returned from the framework to MyClass* the ctor for MyClass is never called and m_mydata is junk.<br>
Is there a way of only initializing the m_mydata pointer once?</p>
| c++ | [6] |
5,883,067 | 5,883,068 | Changing a GridView item's font weight | <p>I have a gridview that contains one linkbutton within itemtemplate.
I bind this gridview with a table from my database that displays different items.
When the gridview displays records and when the user clicks on an item of gridview then how can i change that item's fontweight to bold and change that same item's color.</p>
| asp.net | [9] |
2,087,358 | 2,087,359 | How to add submit event to dynamically generated form? | <p>Here is the PHP code that generates the form:
form.php </p>
<pre><code> <?php
echo '
<form action="/wall/comment.php" method="post" id="submit-comment-form" name="'.$postid.'">
<div class="write-comment-profile-pic">
<img src= "'.$myprofilepic.'" width="30" height="30""/>
</div>
<div class="write-comment-textbox-wrap">
<input type="text" class="textbox4" id="write-comment-textbox" value="Write a comment..." name="comment" style="width:65%;" />
</div>
</form>
';
?>
</code></pre>
<p>Jquery code which gets the form.php</p>
<pre><code>$('#images img').click(function() {
$.get('form.php', function(data) {
$('#image-pop-up').html(data);
});
});
</code></pre>
<p>AND here is the jquery code to needs to submit the form:</p>
<pre><code>$('#image-pop-up').on('submit', '#submit-comment-form', function() {
evt.preventDefault();
});
</code></pre>
<p>in index.html image-pop-up div is an empty one
just </p>
<p><code><div id="image-pop-up"></code></p>
<pre><code></div>
</code></pre>
<p>this isn't working... what's wrong? how to fix it?</p>
| jquery | [5] |
4,607,449 | 4,607,450 | ProgressDialog covers whole screen | <p>I'd like to show a ProgressDialog which covers whole screen. I mean when the dialog is showing, the UI shouldn't be touched or clicked or interacted. How to create a dialog like that?</p>
| android | [4] |
1,493,352 | 1,493,353 | how do i convert this piece of code into javascript function? | <p>i have a form where it has the default value prompting user to enter data.</p>
<p>here is my form.</p>
<pre><code><input type="text" id="name" name="name" class="input-text" value="Enter Name..." onfocus="if(this.value == 'Enter Name...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter Name...';}" />
<input type="text" id="email" name="email" class="input-text" value="Enter Email Address..." onfocus="if(this.value == 'Enter Email Address...') { this.value = '';}" onblur="if(this.value == '') { this.value ='Enter Email Address...';}"/>
<textarea name="message" id="message" class="input-textarea" onfocus="if(this.value == 'Enter your Message...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter your Message...';}">Enter your Message...</textarea>
</code></pre>
<p>there are lots of code repeatation here. i want to convert the below code into the javascript function.</p>
<pre><code>onfocus="if(this.value == 'Enter Name...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter Name...';}"
</code></pre>
<p>how do i do that?</p>
| javascript | [3] |
3,551,462 | 3,551,463 | What is the best approach to parse a String type to other numeric types available in Java? | <p>Let's consider the following code snippet in Java. There are some of possible approaches (that I know) to parse a String value to other numeric types (Let's say for the sake of simplicity, it is an Integer, a wrapper type in Java).</p>
<pre><code>package parsing;
final public class Parsing
{
public static void main(String[] args)
{
String s="100";
Integer temp=new Integer(s);
System.out.print("\ntemp = "+temp);
temp=Integer.parseInt(s);
System.out.print("\ntemp = "+temp);
temp=Integer.valueOf(s).intValue();
System.out.print("\ntemp = "+temp);
temp=Integer.getInteger(s);
System.out.print("\ntemp = "+temp);
}
}
</code></pre>
<hr>
<p>In all the cases except the last one, returns the value 100 after converting it into an Integer. Which one is the best approach to parse a String value to other numeric types available in Java? The last case returns NULL even if the String object <strong>s</strong> already contains a parsable value. Why?</p>
| java | [1] |
3,052,193 | 3,052,194 | Will the Java 7 JRE be pushed out as an automatic update to people running the Java 6 JRE? | <p>I believe a precedent for this must exist... when the Java 6 JRE was released, were users of the Java 5 JRE automatically updated to Java 6 JRE?</p>
<p>Or to put it another way, are automatic update capable of moving you from one major version to another (e.g. from JRE 5 --> JRE 6), or do they just update the "maintenance" releases within a version (e.g. JRE 1.6.0_25 --> 1.6.0_26)?</p>
| java | [1] |
2,745,809 | 2,745,810 | structure of double vectors | <p>I am trying to create a structure of double vectors in C++.</p>
<pre><code>struct distance{
vector<double> x(10000);
vector<double> y(10000);
vector<double> z(10000);
};
distance distance_old, distance_new;
</code></pre>
<p>In the definition it throws an error saying:</p>
<pre><code>error: expected identifier before numeric constant
error: expected ‘,’ or ‘...’ before numeric constant
</code></pre>
<p>Where am I going wrong?</p>
<p>I saw this post <a href="http://stackoverflow.com/questions/6290540/structure-of-vectors-c">Structure of vectors C++</a>
but it doesn't seem to be working for me.</p>
| c++ | [6] |
3,500,598 | 3,500,599 | finding a line that contains… etc | <p>Ok, well i'm basically trying to find a certain line withing "Users.txt"</p>
<p>Heres my code so far.</p>
<pre><code>if (ok == "b" || ok == "B")
{
using (StreamWriter w = File.AppendText("Users.txt"))
{
//Test
Out.WriteLine("Please state the username");
string user = Console.ReadLine();
Out.WriteLine("Checking..");
if (w.Equals(user))
{
Out.WriteLine("Username is taken");
}
Thread.Sleep(pause);
Out.WriteLine("Please state the password for the user");
string pass = Console.ReadLine();
Logger(user, pass, w);
// Close the writer and underlying file.
w.Close();
Out.WriteLine("Checking..");
Out.WriteBlank();
Thread.Sleep(pause);
Out.WriteLine("Anything else Mr." + Environment.UserName + " ?");
}
string choice = Console.ReadLine();
if (choice == "no")
{
Boot();
}
if (choice == "yes")
{
Console.Clear();
Console.Title = "Administrator Panel";
Panel();
}
}
</code></pre>
<p>want it to see if the "user" is taken, then stop them from executing the process.</p>
<p>Thanks for the help.</p>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.