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
2,436,992
2,436,993
Layout priority in Android
<p>My program had two layout: layout1 and layout2. I make the layout2 visible while layout1 is touched by OnTouchListener(). I want layout2 on the top of layot1. On the contrary, layout2 is overridden by layout1. Any one can help me to resolve the problem? My code as:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:visibility="invisible"&gt; &lt;ImageButton android:id="@+id/video_playback_pause" android:layout_width="wrap_content" android:layout_height="wrap_content"/&gt; &lt;/RelativeLayout&gt; &lt;VideoView android:id="@+id/videoView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerInParent="true"/&gt; android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" android:layout_below="@id/relativeLayout2"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>I want relativeLayout2 to override videoView1.</p>
android
[4]
5,917,608
5,917,609
Javascript not acquiring dropdown value
<p>I have a list of 2 values in dropdown list as...</p> <pre><code> &lt;select id="prop"&gt; &lt;option value="Caa:123"&gt;Ca&lt;/option&gt; &lt;option value="Cb:745"&gt;Cb&lt;/option&gt; &lt;/select&gt; </code></pre> <p>...and in javascript i used...</p> <pre><code> var p = document.getElementById('prop'); var q = p.options[p.selectedIndex].value; alert(q); </code></pre> <p>...but I am not getting no alert and an error "Index or size is negative or greater than the allowed amount" code: "1 " Kindly help I trapped in this problem</p>
javascript
[3]
2,565,332
2,565,333
Slide up element on hover
<p>Take a look at <a href="http://www.shopvcf.com/blog/?page_id=56" rel="nofollow">http://www.shopvcf.com/blog/?page_id=56</a></p> <p>I need the area with the red heart to slide up which I have done with this code. </p> <pre><code>$(document).ready(function () { $('div.bottomwrap').on({ 'mouseenter': function () { $(this).animate({ bottom: 20 }); }, 'mouseleave': function () { $(this).animate({ bottom: 0 }); } }); }); </code></pre> <p>Issue is I would like it to slide up when entering into the box with the content, not just the bottomwrap.</p> <p>I would also like to hide the at the same time which will show the image in the background.</p> <p>Any help would be great. Thanks!</p>
jquery
[5]
2,301,779
2,301,780
Difference between document.body.contentEditable='true'; and document.designMode='on';
<p>It seems both allow to edit the document, so what's the difference?</p>
javascript
[3]
202,906
202,907
android: how to upload the images from the card
<p>hi to all i my application i want to upload the images from the sd card with restricting the user to upload only less than 2mb. thanx in advanse.</p>
android
[4]
3,708,164
3,708,165
.show table rows is scrolling to the top on first show
<p>When I show a table row for the first time, the page always scrolls to the top in both IE and Firefox. Subsequet shows do not do this.</p> <p>I have traced it to the first action that jquery takes on a show, where it appends, reads the display value, and removes an element from the body in order to populate elemdisplay[]. I think this is causing these browsers to scroll to the top when this is done for a &lt;tr&gt;.</p> <p>Is there any way around this behavior that anyone has seen?</p>
jquery
[5]
2,193,694
2,193,695
how to force close wifi and data roaming
<p>I want to manually close wifi and data roaming in android. After finishing with processing some data i want to enable it back. How can i do this programatically?</p> <p>I only find this howto but is not working in my android 4.</p> <p><a href="http://stackoverflow.com/questions/11060414/how-do-i-program-android-to-look-for-a-particular-network">How do I program android to look for a particular network?</a></p>
android
[4]
444,789
444,790
Cannot make static reference to a non-static method
<p>I'm getting the <code>Cannot make static reference to a non-static method</code> error but I don't appear to be making a static reference.. my code is something like the following...</p> <pre><code> public void run() { MyClass mc = new MyClass(); mc.method(); } public void MyClass(){ myothermethod(); //error here. } </code></pre> <p>I've create a new instance of my class so the reference wont be static but it's still giving me the same error.</p>
java
[1]
1,678,463
1,678,464
Remove Delegate from event - cause Sync issues?
<p>I have an event </p> <pre><code>this._sequencer.Completed </code></pre> <hr> <p>Two delegates are subscribed to this</p> <pre><code>this._sequencer.Completed += OnActivityFinished; this._sequencer.Completed += OnCarrierReLoaded; </code></pre> <hr> <p>The delegates implemnetation is as given below</p> <pre><code>void OnActivityFinished(object sender, EventArgs e) { // Do some activity this._sequencer.Completed -= OnActivityFinished } void OnCarrierReLoaded(object sender, EventArgs e) { // Do some activity this._sequencer.Completed -= OnCarrierReLoaded } </code></pre> <hr> <p>The delegates in the event are invoked asynchronosly as given below.<strong>Will it cause a synchroniztion issue if the delegate is removed from the event as given above? Please help me</strong></p> <pre><code>void EventHelper::FireAndForget(Delegate^ d, ... array&lt;Object^&gt;^ args) { try { if (d != nullptr) { array&lt;Delegate^&gt;^ delegates = d-&gt;GetInvocationList(); for each(Delegate^ delegateMethod in delegates) { try { DynamicInvokeAsyncProc^ evtDelegate = gcnew DynamicInvokeAsyncProc(this, &amp;EventHelper::OnTriggerEvent); evtDelegate-&gt;BeginInvoke(delegateMethod, args, _dynamicAsyncResult, nullptr); //FIX_DEC_09 Handle Leak } catch (Exception^ ex) { } } } else { } } catch (Exception^ e) { } } void EventHelper::OnTriggerEvent(Delegate^ delegateMethod, array&lt;Object^&gt;^ args) { try { // Dynamically invokes (late-bound) the method represented by the current delegate. delegateMethod-&gt;DynamicInvoke(args); } catch (Exception^ ex) { Log(LogMessageType::Error, "EventHelper.OnTriggerEvent", ex-&gt;ToString()); } } </code></pre>
c#
[0]
1,473,499
1,473,500
role of parentheses in javascript
<p>I'd like to know the difference between the following and the role of the parentheses:</p> <pre><code>foo.bar.replace(a,b) </code></pre> <p>and</p> <pre><code>(foo.bar).replace(a,b) </code></pre> <p>do the parentheses require the contained expression to be evaluated first before moving on to the replace method? I have seen this in code I am maintaining and am curious as to why it would be neccessary? E.G.</p> <pre><code>location.hash.replace(a,b) </code></pre> <p>and</p> <pre><code>(location.hash).replace(a,b) </code></pre>
javascript
[3]
5,893,291
5,893,292
Add/delete controls on button click
<p>I am new to android development. I am working on a sample application. I need to add a button with context menu, edit text and delete button for each click of a button. and delete all when I click on delete button for adding contact. I have searched a lot and still didn't get any idea. Please help me.</p>
android
[4]
2,384,728
2,384,729
File.Move error in C#
<p>I am trying a simple move as shown below and get the following error: "The process cannot access the file because it is being used by another process." How do I fix this? Thanks.</p> <pre><code>FileInfo file1 = new FileInfo(srcFile); if (file1.Exists) { FileInfo file2 = new FileInfo(destFile); if (!file2.Exists) { try { File.Move(srcFile, destFile); } catch (System.IO.IOException e) { Console.WriteLine(e.Message); } } } </code></pre>
c#
[0]
288,993
288,994
page onload alerts
<p>i want to show an alerts when a page loads .but i wat it to show only once in a session so that the users does not get disturbed. please help me with some javascript codes.</p> <p>in hope robin .</p>
javascript
[3]
274,158
274,159
What is the rule for declaration before use in C++?
<p>My course notes say "C++ requires declaration before use in a block and among types but not within a type."</p> <p>Is this what it means?</p> <pre><code>int f() { if (i) return i; int i = 1; //allowed? return 0; } //not allowed? int g() { if (i) return i; return 0; } int i = 1; </code></pre>
c++
[6]
1,605,656
1,605,657
Remove a line with specific characters in a variable before putting into CSV
<p>I would like to ask what is the efficient way to achieve this.</p> <p>I have a variable that holds the data below which is to be pass into a CSV file.</p> <pre><code>"Name","Address","Email","Comment" ", &lt;=, ",", &lt;=, ",", &lt;=, ",", &lt;=, " "John Smith","USA","john@john.net","No Comment" </code></pre> <p>What I want to achieve is to remove the second line so that before I push the data into the CSV those characters already remove.</p> <pre><code>", &lt;=, ",", &lt;=, ",", &lt;=, ",", &lt;=, " </code></pre> <p>The only thing that I can do right now is to save the data into a file then manipulate it then use it for CSV but I am sure there is a faster way to manipulate.</p>
php
[2]
2,505,838
2,505,839
Will decimal be supported one day with Math.Pow in .NET?
<p>I saw this dated in 2004:</p> <p><a href="http://connect.microsoft.com/VisualStudio/feedback/details/94548/math-pow-method-should-have-an-overload-for-decimal" rel="nofollow">http://connect.microsoft.com/VisualStudio/feedback/details/94548/math-pow-method-should-have-an-overload-for-decimal</a></p> <p>Math.Pow() method should have an overload for decimal</p> <p>Since has anything changed ? Cause I try it doesn't seem Pow supports decimal.</p>
c#
[0]
4,843,953
4,843,954
Trying to get a number within an array that is twice the average
<p>I have been assigned to set up an array with points. I am told to get the maximum value, average, and within this same array, if any point in the array is twice the average, I should <code>cout</code> an "outlier." So far I have gotten the average and maximum numbers in the array. but i am unable to set the programme to <code>cout</code> the outlier. Instead it gives me a multiple of the average. here is the programme;</p> <pre><code>int main() { const int max = 10; int ary[max]={4, 32, 9, 7, 14, 12, 13, 17, 19, 18}; int i,maxv; double out,sum=0; double av; maxv= ary[0]; for(i=0; i&lt;max; i++) { if(maxv&lt;ary[i]) maxv= ary[i]; } cout&lt;&lt;"maximum value: "&lt;&lt;maxv&lt;&lt;endl; for(i=0; i&lt;max; i++) { sum = sum + ary[i]; av = sum / max; } cout&lt;&lt;"average: "&lt;&lt;av&lt;&lt;endl; out = av * 2; if(ary[i]&gt;out) { cout&lt;&lt;"outlier: "&lt;&lt;maxv&lt;&lt;endl; } else { cout&lt;&lt;"ok"&lt;&lt;endl; } return 0; } </code></pre>
c++
[6]
3,686,540
3,686,541
datatable sort method not working!
<p>here is my datatable:</p> <pre><code>DataTable dttemp = new DataTable(); dttemp.Columns.Add(new DataColumn("position", typeof(string))); dttemp.Columns.Add(new DataColumn("specimen", typeof(string))); </code></pre> <p>i am sorting like this and then importing every row into a different datatable:</p> <pre><code>view = dttemp.DefaultView; view.Sort = "position"; foreach (DataRow row in dttemp.Rows) dt_final.ImportRow(row); </code></pre> <p>here are the two rows that it is supposed to sort however as you can see it is not sorting</p> <pre><code>D01 PAINCAL4 F01 PAINQC2 A01 PAINCAL1 C01 PAINCAL3 E01 PAINQC1 G01 PAINQC3 H01 PAINQC4 </code></pre> <p>it is supposed to sort on the first column</p> <p>what am i doing wrong?</p>
c#
[0]
5,007,801
5,007,802
what means return { someObject : someObject }
<p>I saw this code, after looking for a while and look for on the internet I still do not get it.</p> <pre><code>var client = function (){ var engine = { ie: 0, gecko: 0, webkit: 0, version: null }; return { engine : engine }; }(); </code></pre> <p>My specific question is about the return statement. I know that:</p> <p><code>client</code> is a function that <code>var engine = { ... }</code> is creating a object engine with some properties inside and a default values, but I do not understand the <code>return</code> and why at the of the function it has <code>()</code>.</p>
javascript
[3]
1,771,097
1,771,098
how do i deserialize the WCF String in C#
<pre><code>&lt;string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"&gt; |date|time|name| &lt;/string&gt; </code></pre> <p>I keep getting invalid character when I try to deserialize the XML</p>
c#
[0]
147,193
147,194
Hiding UIToolBar for child views of UITableViewController
<p>My main controller is a subclass of UITableViewController with a UIToolBar at the bottom and when a row is selected, I'd like to display another view without the toolbar. How can I hide the UIToolBar in the child view? Right now, it's present throughout all child views unless they're created as modal.</p> <p>Toolbar is created in RootController:</p> <pre><code>self.toolbar = [[UIToolbar alloc] init]; // add tool bar items here [self.navigationController.view addSubview:toolbar]; </code></pre> <p>RootController displays its child views as such:</p> <pre><code>UIViewController *controller = [[UIViewController alloc] init...] [self.navigationController pushViewController:controller animated:YES]; </code></pre> <p>RootController is instantiated as such in the app delegate's applicationDidFinishLaunching:</p> <pre><code>RootController *rootcontroller = [[RootController alloc] initWithStyle:UITableViewStyleGrouped]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:rootcontroller]; [rootcontroller release]; [window addSubview:[self.navigationController view]]; </code></pre> <p>If I add the toolbar to [self.view] within RootController instead of navigationController's view, the toolbar disappears alltogether..</p>
iphone
[8]
4,792,774
4,792,775
Find subsequences of strings within strings
<p>I want to make a function which checks a string for occurrences of other strings within them. However, the substrings which are being checked may be interrupted within the main string by other letters.</p> <p>For instance:</p> <pre><code>a = 'abcde' b = 'ace' c = 'acb' </code></pre> <p>The function in question should return as b being in a, but not c.</p> <p>I've tried set(a).intersection(set(b)) already, and my problem with that is that it returns c as being in a.</p>
python
[7]
2,516,044
2,516,045
Getting debug information from your users
<p>If one of your beta testers has problems with your app crashing, how do you usually go about debugging this if it works fine for yourself/other users?</p> <p>Is there a way to have debug information sent to you?</p>
iphone
[8]
727,717
727,718
C# standard class (enumeration?) for Top, Bottom, Left, Right
<p>Is there a standard c# class that defines a notional Left, Right, Top and Bottom? </p> <p>Should I just use my own?</p> <pre><code>enum controlAlignment { left = 1, top, right, bottom, none = 0 } </code></pre>
c#
[0]
3,029,026
3,029,027
Show additional details when you hover over a column in gridview
<p>I want to display additional details when you hover over a row in gridview.The additional information is retreived from a differant table in my database using ado.net</p> <p>Iam sure this might have been done previously and did not find the correct direction to acheive this. Are there any directions or previous links where this has been advised if not need directions please</p> <p>thanks</p>
asp.net
[9]
5,964,931
5,964,932
Problem with using javascript to insert <input> tags in html
<p>I am trying to take text that is in an array (one word per value) and insert it into html. All the code is here: <a href="http://jsfiddle.net/chromedude/r6wVq/3/" rel="nofollow">http://jsfiddle.net/chromedude/r6wVq/3/</a>.</p> <p>Update: My question is what am I doing wrong? It does not do anything which is weird.</p> <p>Just for everybody who was wondering what this code is supposed to help me do is memorize long passages for school.</p>
javascript
[3]
5,885,342
5,885,343
How to display results of a sql query on screen
<p>I am trying to write a simple app just to display on screen the results on a sql query.</p> <pre><code>public class ContactLookup extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Cursor c = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null ); } } </code></pre> <p>How exactly do I print the results of the cursor? Everything I find goes into to way more detail then I need at the moment... I just want to know how to get that variable printed on screen. </p>
android
[4]
2,436,979
2,436,980
Disable all SELECTs with jquery?
<p>I have a post form with a first dropdown for choosing a category and a second for choosing a subcategory. The second one changes according to the first category that was chosen.</p> <p>I have many dropdowns and I show the most correct one depending on the chosen category.</p> <p>I need to disable all dropdowns and enable that one so that I can submit the form correctly.</p> <pre><code>&lt;select name='dropdown'&gt;&lt;/select&gt; &lt;select name='dropdown'&gt;&lt;/select&gt; &lt;select name='dropdown' id='1'&gt;&lt;/select&gt; </code></pre> <p>How can I disable all selects with <code>name = 'dropdown'</code> except the one with id='1'?</p>
jquery
[5]
941,938
941,939
Javascript dragging
<p>i was trying to make a drag able element but i failed... i don't want to use jquery.</p> <p>i got the following html code:</p> <pre><code>&lt;div id='area'&gt; &lt;div id='drag'&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>i want to drag id='drag' inside id='area' and not going out of it.</p> <p>sorry for my bad English and for my newbie question.</p> <p>EDIT:</p> <pre><code>Area.addEventListener("mousemove", function (e) { var X, Y; X = e.offsetX; Y = e.offsetY; Information.innerHTML = 'X:' + X + ' - ' + 'Y:' + Y; }); img.addEventListener("mouseover", function () { this.style.cursor = 'move'; this.addEventListener("mousemove", function (e) { var X, Y; X = e.offsetX; Y = e.offsetY; Information2.innerHTML = 'X:' + X + ' - ' + 'Y:' + Y; }); }); </code></pre> <p>idk how to get the X and Y of the Area to add it to img</p>
javascript
[3]
4,357,228
4,357,229
Getting callable object from the frame
<p>Given the frame object (as returned by <a href="http://docs.python.org/library/sys.html#sys.%5Fgetframe" rel="nofollow">sys._getframe</a>, for instance), can I get the underlying callable object?</p> <p>Code explanation:</p> <pre><code>def foo(): frame = sys._getframe() x = some_magic(frame) # x is foo, now </code></pre> <p>Note that my problem is getting the object out of a frame, not the currently called object. </p> <p>Hope that's possible.</p> <p>Cheers,</p> <p>MH</p> <p><b>EDIT:</b></p> <p>I've somewhat managed to work around this problem. It was heavily inspired by Andreas' and Alexander's replies. Thanks guys for the time invested!</p> <pre><code>def magic(): fr = sys._getframe(1) for o in gc.get_objects(): if inspect.isfunction(o) and o.func_code is fr.f_code: return o class Foo(object): def bar(self): return magic() x = Foo().bar() assert x is Foo.bar.im_func</code></pre> <p>(works in 2.6.2, for py3k replace <code>func_code</code> with <code>__code__</code> and <code>im_func</code> with <code>__func__</code>)</p> <p>Then, I can aggressively traverse globals() or gc.get_objects() and dir() everything in search for the callable with the given function object. </p> <p>Feels a bit unpythonic for me, but works.</p> <p>Thanks, again!</p> <p>MH</p>
python
[7]
1,887,236
1,887,237
Android - A way to trigger onRetainNonConfigurationInstance?
<p>Is there a way to trigger the calling of onRetainNonConfigurationInstance on my activity, so getLastNonConfigurationInstance() returns something the next time the activity is created?</p> <p>I ask because I have a memory leak in my application which only appears/crashes my app after my phone is left idle for hours, so I believe the issue is here.</p> <p>Force Stop in Settings does not cause this. Any help would be greatly appreciated as i've spent days chasing red herrings to catch this bug.</p>
android
[4]
5,647,430
5,647,431
Dynamically adding a custom layout one below other
<p><img src="http://i.stack.imgur.com/nUmAg.png" alt="enter image description here">I have to add a custom layout in a relative layout on a button click. Again on another click add that same layout with another values above the previous inflated layout. and it will continue like this. I don't want to use list view.</p> <p>I can add dynamically my custom layout but how to place it above the previous added.</p> <p>on click of ADD button a new row will be added to my relative layout in xml, like ROW 1, ROW 2, and this will continue with ROW 3, ROW 4 etc.</p>
android
[4]
2,031,331
2,031,332
PHP from symbol to hex
<p>I have a chinese character set as a variable with character encoding as utf-8:</p> <pre><code>$a='列'; </code></pre> <p>From this, how can I get the value '5217' assigned to a string (<code>$b</code>) (possibly using UTF-16? but there might be a better way to do it)? </p> <p>Codes: <a href="http://www.fileformat.info/info/unicode/char/5217/index.htm" rel="nofollow">http://www.fileformat.info/info/unicode/char/5217/index.htm</a></p>
php
[2]
2,278,898
2,278,899
Can the apk file exceed 50mb size in android?
<p>I am working on android applications. <strong>Currently my apk size is 12mb.</strong> I need to keep 40mb size images in my project. So if I keep those images in my drawable folder then my apk size will exceed 50 mb. <strong>So will the apk install in mobile if it exceeds 50 mb?</strong> Please help me regarding this...</p> <p>Thanks in advance</p>
android
[4]
5,725,277
5,725,278
PHP - Is there a simple way to loop between two dates and fill in missing values?
<p>I have 2 dates. Lets say they look like this.</p> <pre><code>$start = 2010/12/24; $end = 2012/01/05; </code></pre> <p>I query the database to look for visits between these two dates. I find some. I then populate an array called stats.</p> <pre><code>$stats['2010/12/25'] = 50; $stats['2010/12/31'] = 25; ... </code></pre> <p>As you can see, there are days missing. <strong>I need to fill the missing dates with a value of zero.</strong> I was thinking something like this. (I have pulled day / month / year from start and end dates.</p> <pre><code>for($y=$start_year; $y &lt;= $end_year; $y++) { for($m=$start_month; $m &lt;=$end_month; $m++) { for($d=$start_day; $d &lt;= $end_day; $d++) { </code></pre> <p>This would work fine for the year however the months and days wouldn't work. If the start day is the 15th. Days 1-14 of each subsequent month would be missed. I could have a solution like this then...</p> <pre><code>for($y=$start_year; $y &lt;= $end_year; $y++) { for($m=1; $m &lt;13; $m++) { $total_days = cal_days_in_month(CAL_GREGORIAN, $m, $y) + 1; for($d=1; $d &lt;= $total_days; $d++) { </code></pre> <p>I would then need a bunch of if statements making sure starting and end months and days are valid.</p> <p>Is there a better way of doing this? Or could this even be done in my mysql query?</p>
php
[2]
5,801,660
5,801,661
iTunes:How to update the binary and upload into Appstore?
<p>I have an application in Appstore. I have fixed few issues and want to update again in Appstore. How to remove the existing app present in Appstore and update with the version what i have? I went and saw in iTunes connect, there is one button called "Add version". I don't want to add any new version for my previous app, i just to want overwride the binary with the latest one. Anyone please hint me on this?</p> <p>Thank you!</p>
iphone
[8]
2,191,060
2,191,061
Not able to display special characters
<p>I am unable to display special characters (polish characters) on screen. I have a requirement where I get the data from database which has some special characters. I get the data in an xml format (The xml is not recognizing it as a string) and pass it to action where I try to display the data. I am trying to get the Uniciode of the special character as <code>&amp;#X142;</code> but when I try to display, this gets converted to <code>&amp;amp;#X142;</code> and so I am unable to display it because it does not take it as a string.</p> <pre><code>String ex1="ł"; System.out.println("ex1...."+ex1); output:: ? </code></pre> <p>I am trying to get the Unicode using the following code::</p> <pre><code> public static String convert (String str) throws UnsupportedEncodingException { String tc = str; String output = ""; char[] ca = tc.toCharArray(); for (int i = 0; i &lt; ca.length; ++i) { char a = ca[i]; if ((int) a &gt; 255) { output += "&amp;"+"#X"+ Integer.toHexString((int) a) + ";"; } else { output += a; } } return output; } </code></pre> <p>The output is: If input is given as <code>str="ł"</code> then <code>output=&amp;#X142;</code></p>
java
[1]
5,036,816
5,036,817
How do I save data from a DataGridView to an XML file using the SaveFileDialog?
<p>How do I save data from a <code>DataGridView</code> to an XML file using the <code>SaveFileDialog</code>?</p> <pre><code>saveFileDialog1.Title = "Save File"; saveFileDialog1.InitialDirectory = "C:\\XML\\"; saveFileDialog1.Filter = "XML file (*.xml)|*.xml"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; saveFileDialog1.FileName = ""; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { </code></pre>
c#
[0]
1,167,430
1,167,431
need to get Posted data as fast as i can
<p>I created a web page to receive some data Posted from third party My code is follows</p> <pre><code> static StreamReader sr; string data = string.Empty; protected void Page_Load(object sender, EventArgs e) { try { if (Request.QueryString["Name"] != null) { data = Request.QueryString["Name"].ToString(); ProcessData(data); } else if (Page.Request.InputStream.Length &gt; 0) { sr = new StreamReader(Page.Request.InputStream); data = Server.UrlDecode(sr.ReadToEnd()); sr.Close(); ProcessData(data); } } catch (Exception ex) { Logger(ex.ToString() + " StackTrace: " + Convert.ToString(ex.StackTrace)); } } </code></pre> <p>I need to get the posted data and response within 1000 milliseconds. But it is sometime more than 3 seconds and sometime less than a second. Please tell what are the chances. And how can i reduce this time taken. Please someone help...</p>
c#
[0]
3,776,157
3,776,158
Android Display a list using ListView
<p>I am trying to display a list after clicking a button on Android.</p> <p>This is my code:</p> <pre><code>//Button after clicking should display a list final Button button4 = (Button) findViewById(R.id.widget30); button4.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(v.getContext(), TestListActivities.class); startActivity(myIntent); } public class TestListActivities extends Activity { String[] listItems = {"Game1", "Game2", "Game3", "Game4"}; public ListView la; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); la=(ListView)findViewById(R.id.widget50); la.setAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.main2, listItems)); } } </code></pre> <p>My XML file is:</p> <pre><code>?xml version="1.0" encoding="utf-8"? AbsoluteLayout android:id="@+id/widget28" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" ListView android:id="@+id/widget50" android:layout_width="wrap_content" android:layout_height="wrap_content" AbsoluteLayoute </code></pre> <p>But when I click the button, the application is forced to close and it crashes.</p> <p>Manifest file </p> <pre><code>&lt;application android:icon="@drawable/icon" android:label="BAM! Pong" android:debuggable="true"&gt; &lt;activity android:name=".GUI" android:label="@string/app_name" android:screenOrientation="portrait"&gt;&lt;intent-filter&gt;&lt;action android:name="android.intent.action.MAIN"&gt;&lt;/action&gt; </code></pre> <p> </p> <p> </p> <p> </p>
android
[4]
1,994,432
1,994,433
Volume Control in android application
<p>I'd like to know how to control my application's volume from the volume keys (contrary to my belief , I've read they control only the ringer volume). Should I overwrite the onKey Down/Up? </p> <p>Or is there other way to accomplish this? I'm asking because if I overwrite the upper mentioned function for an activity, then the functions will receive the event only if a view associated with the this activity has the focus, and I'm looking for something "Globaly" ( to work no matter what activity is running now)</p>
android
[4]
3,953,580
3,953,581
How to round currency (decimals) to Millions? (C#)
<p>I have decimal currency amounts (from SQl2k* tables as 32,8) and I would like to round them to Millions with 2 decimal places.</p> <p>The system will be displaying 1000s of rows with multiple amounts in them, and I need to summarise the totals for various categories into a "quick view".</p> <p>e.g.</p> <pre><code>123,456,789.12345678 goes to 123.46 6,655,443,332.2110099 goes to 6,655.44 </code></pre> <p>etc</p> <p>I know there are issues with rounding and decimal/floating point math:</p> <pre><code>45,454,454.454545 goes to 45.46 OR 45.45 ? </code></pre> <p>so also any advice on what's best to use would also be very much appreciated.</p> <hr> <p>Two more examples (of what I'd EXPECT...not what might actually be mathematically correct!)</p> <pre><code>555444444.444444 =&gt; 555.44 555444444.444445 =&gt; 555.45 </code></pre> <p>I would expect the final "5" of the second example to cascade up to the decimal place?</p>
c#
[0]
887,507
887,508
Getting a list of specific index items from a list of dictionaries in python (list comprehension)
<p>I have a list of dictionaries like so:</p> <pre><code>listDict = [{'id':1,'other':2},{'id':3,'other':4},{'id':5,'other':6}] </code></pre> <p>I want a list of all the ids from the dictionaries. So, from the given list I would get the list:</p> <pre><code>[1,3,5] </code></pre> <p>It should be one line. I know I've done this before, I've just forgotten the syntax...Thanks</p>
python
[7]
5,123,813
5,123,814
flvFPW1() - What does it do?
<p>I've been tasked with rewriting the Javascript engine currently powering my customer's internal website. While reviewing the code I've come across this function <em>flvFPW1</em> which I do not recognize, nor can I decipher the code(my Javascript knowledge is modest at best). A Google search gives me a few hits, but most if not all page hits are from the Javascript used on that particular page. In other words, I cannot find a description for this function, even though it is obviously used by others. </p> <p>Can someone here enlighten me?</p> <p>Thanks / Fredrik</p>
javascript
[3]
2,752,309
2,752,310
extended GCD algorithm
<p>i have wrote following algorith for extended GCD algorithm,just dont know how to return triple and could anybody help me?</p> <pre><code>#include&lt;iostream&gt; #include&lt;math.h&gt; using namespace std; int gcd(int a,int b) { return (b==0 ?a:gcd(b,a%b));} long long gcd(long a,long b) { return (b==0 ?a:gcd(b,a%b));} template&lt;class Int&gt; Int gcd(Int a,Int b) { return (b==0 ?a:gcd(b,a%b));} template&lt;class Int&gt; struct Triple { Int d,x,y; Triple(Int q,Int w,Int e) :d(q),x(w),y(e)) {} }; //extended GCD /* computes d=gcd(a,b) also x and y such that d=a*x+y*b and return tripls (d,x,y) */ template&lt;class Int&gt; Triple &lt;Int&gt; egcd(Int a,Int b) { if(!b) return Triple&lt;Int&gt;(a,Int(1),Int(0)); Triple&lt;int&gt;q=egcd(b,a%b); return Triple&lt;Int&gt;(q.d,q.y,q.x-a/b*q.y); } int main(){ int a=35; int b=13; return 0; } </code></pre> <p>how to finish it using my triple struct constructor?please help me</p>
c++
[6]
2,304,576
2,304,577
Passing all data from database into arrays as the application starts
<p>My question is not "how?" but "should I?".</p> <p>I got the app that uses access to database very often. It's money manager basically. It uses data to make calculations, draw a charts and stuff. </p> <p>I was wondering if the accessing database every ocasion I need some data is efficent way, especially when database grows larger.</p> <p>Is it a good idea of making class that would read all the database tables into multidimensional arrays for further use of the application? I would read it in a thread with some progress bar if necessary, and then I would have much more efficient way of accesiing datas from arrays right?</p> <p>Please be gentle with me, as I could be totally wrong here.</p>
android
[4]
5,133,994
5,133,995
Session State (Server-side)
<p>Ok I'm sure this is pretty obvious. But when you say session state is persisted on the "server" in memory, are we talking about IIS or what? When I think of Server-side session State, I think memory in terms of IIS app pools and such. Am I off base or missing anything here? </p> <p><a href="http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx</a></p> <p>the term "server" could mean many things. Sure it's "server-side" but what specific process / memory / area / app on the server are we talking about (IIS only? other?)</p> <p>I wish MS would have explained what they mean because that's pretty relative.</p> <p>Specifically this, "store on server"</p> <pre><code>Storing Data on the Server (in memory) • Session state • Application state • Profile Properties </code></pre> <p>so "on the server" where in memory and what process/app is handling each of these?</p>
asp.net
[9]
5,563,039
5,563,040
How to parse a string in javascript?
<p>I'm just curious how I go about splitting a variable into a few other variables.</p> <p>For example, say I have the following javascript:</p> <pre><code>var coolVar = '123-abc-itchy-knee'; </code></pre> <p>And I wanted to split that into 4 variables, how does one do that?</p> <p>To wind up with an array where</p> <pre><code>array[0] == 123 and array[1] == abc </code></pre> <p>etc would be cool.</p> <p>Or (a variable for each part of the string)</p> <pre><code>var1 == 123 and var2 == abc </code></pre> <p>Could work... either way. How do you split a javascript string? </p>
javascript
[3]
194,497
194,498
Difference between perform selector in backgorund and detachNewThread
<p>I want to know what is difference between perform selector in backgorund and detachNewThread</p>
iphone
[8]
3,615,754
3,615,755
How do these JS code snippets work?
<p>I'm reading about closures, and I had difficulty understanding the difference between these 2 code snippets:</p> <pre><code>var myElements = [ /* DOM Collection */ ]; for (var i = 0; i &lt; 100; ++i) { myElements[i].onclick = function() { alert( 'You clicked on: ' + i ); }; } </code></pre> <p>The above code should only display <code>i</code> as 99 for every onclick</p> <pre><code>function getHandler(n) { return function() { alert( 'You clicked on: ' + n ); }; } for (var i = 0; i &lt; 100; ++i) { myElements[i].onclick = getHandler(i); } </code></pre> <p>And this code above displays the correct value of 'i' for every element click event!</p> <p>I can't understand why the 1st one doesn't display the correct value of <code>i</code>. And if not, why does the 2nd one display the correct value??</p> <p>They were taken from <a href="http://james.padolsey.com/javascript/closures-in-javascript/" rel="nofollow">this link</a></p>
javascript
[3]
5,838,957
5,838,958
How to support Bluetooth for both Android 1.x and 2.x at the same time?
<p>I can access the Android bluetooth api via reflection in Android 1.x and I can also access bluetooth api 2.x using the build in Android class but I can't support both at the same time in my App. Like having the reflection to use the old bluetooth api to support 1.x and at the sametime using the new api for 2.0+ with a 2.0 Android build.</p>
android
[4]
1,841,609
1,841,610
increment the i
<pre><code>for(var i=1;i&lt;=($("input:regex(id,[0-9]+)").length);i++) { array.push($("#i").val()); } </code></pre> <p>Hey, I am tying to store the input value in the array. Each of the input has distinct id associated with it, in this case, 1,2,3,4 and so on. How can I change the i in </p> <pre><code>array.push($("#i").val()); </code></pre> <p>accordingly with the counter i in the for loop, which would fetch the value from inputs. like if I got two inputs fields, whose ids are 1 and 2. After this codes execution, the array has two elements that are from the inputs. Thank you </p>
javascript
[3]
4,411,942
4,411,943
jQuery: same filename, wont load issue
<p>in html i got this:</p> <pre><code>&lt;div id="userPhoto"&gt; &lt;a href="profil.php?id=&lt;?php echo $sid; ?&gt;"&gt; &lt;img src="images/profilePhoto/thumbs/&lt;?php if($vP["photo"]){ echo $vP["photo_thumb"]; }else{ echo "noPhoto_thumb.jpg"; } ?&gt;" style="float: left; border: 2px solid #CCC; margin-right: 5px; margin-left: 15px; margin-bottom: 2px; width: 44px; height: 48px;"&gt; &lt;/a&gt; &lt;/div&gt; </code></pre> <p>on my ajax success i have this:</p> <pre><code>$('#userPhoto').find('img').attr('src', ['/your/path/', newFilename].join('')); </code></pre> <p>Now my case is that all users only have 1 image, called userid.jpg. (e.g 1.jpg)</p> <p>Now i wish to load it/refresh the image, after you inserted a new profileimage (on success), but it doesnt load because the line above, newFilename var contains the same imagename as before. (e.g 1.jpg)</p> <p>How can i fix this, so it load/refreshes new even if its the same name?</p>
jquery
[5]
2,508,073
2,508,074
how to update variables, passed to a method?
<p>when i pass variables to my method they are not updated in the main code, but only passed to the method. how to do that once passed variable would update in main code? Thanks!</p> <pre><code>//////////// here is main code: public static class MyCoding extends MainScreen{ static int mee=1; public static void myCode(){ Status.show("mee="+mee, 2000); // shows me=1 Moo.moo(mee); Status.show("mee="+mee, 2000);// should be mee=76547545 but still shows mee=1 ! } } //////////// here is my method: public static class Moo extends MainScreen{ public static void moo(int bee){ mee=76547545; return; } } </code></pre> <p>What to do? Thanks!</p>
java
[1]
5,275,432
5,275,433
why the output is not good in some cases?
<p>i feel stupid and don't know why the output is not good in some cases. here is the output (at the end) it sould find the first sub string in given string for example: sim('banan','na') -> 'na'</p> <pre><code> def rev (str): rev_str='' i = len(str)-1; while (i &gt;= 0): rev_str += str[i]; i = i-1; return rev_str; ###################################### def sim (str,sub): sub_len = len (sub); start = str.index(sub); rev_str = rev(str) rev_sub = rev(sub) if (start ==0): start =1; end = start + rev_str.index(rev_sub,start-1); ret_val = '' print start , end for n in range (start,end): ret_val += str[n]; return ret_val; print sim('abcdef', 'abc') print sim('abcdef', 'bc') print sim('banana', 'na') the output : 1 4 bcd 1 4 bcd 2 4 na </code></pre>
python
[7]
1,845,890
1,845,891
Executing JavaScript after Ajax-call
<p>I want to execute javascript for creating calendar using "calendarDateInput.js". Is it possible to execute javascript after an ajax call page using ajax tabs ?</p> <p>I am not using any of the ajax libraries, only direct ajax call.</p> <p>Here I want to call the function in an ajax returned page like DateInput("smsDate",true, "YYYY-MM-DD");</p>
javascript
[3]
5,349,258
5,349,259
How to change UIImageView's subview's frame
<p>I have UIImageView with subviews. How can I change frames of subviews after rotation UIImageView? I need your help)</p>
iphone
[8]
3,646,467
3,646,468
About Python MatchObject
<p>I'm learning Python regular expressions and I have a question: all books and Python documents I have read tell me that <code>re.search</code> returns a <code>MatchObject</code> or <code>None</code>.</p> <p>My question is where is the definition of <code>MatchObject</code>? What class does <code>MatchObject</code> belongs to? When I use <code>help(matchObj)</code>, it prints <code>&lt;'_sre.SRE_Match'&gt;</code>. What is this?</p>
python
[7]
3,811,171
3,811,172
Maximum file upload limit in php.ini have no effect on wordpress
<p>I have changed the upload limits in php.ini</p> <blockquote> <p>sudo sublime-text /etc/php5/apache2/php.ini</p> </blockquote> <p>upload limit, post limit and something else, I restarted apache2</p> <p>the phpinfo shows me both upload and post limit as 100M for master and local value inside the index file where I have setup wordpress multisite.</p> <p>So my question is why the hell is WordPress still show me </p> <blockquote> <p>Maximum size: 1.46484375MB</p> </blockquote> <p>I know there are 3 ways to do this with php.ini, .htaccess and inside a php file. But isn't it supposed to take effect when I change it in the very root level? In other words I don't want to set this for every site I setup in my server. I want to set this ip globally once and for all. What is maybe overwriting this?</p> <p>I read on some wordpress setting in "options", I cant find anything to change under "settings". No "options" menu is there under my wp-admin.</p> <p><strong>Got it, the thing was that I had to setup this for all subsites on the root multisite admin. The option is only available there.</strong></p>
php
[2]
3,618,036
3,618,037
How to control log output in Android
<p>I found in my cpp source code, if I define LOG_NDEBUG marco to 0, the log can output correctly, else the output cannot print. Who can I tell me why, or how to find the reason. Thank you very much.</p>
android
[4]
2,394,113
2,394,114
jQuery - call the element this into another function
<p>I have this jQuery function :</p> <pre><code>$('a[name=pmRead]').click(function(e) { e.preventDefault(); $(this).parents(".pmMain").find(".pmMain5").toggle(); $.ajax({ type: 'POST', cache: false, url: 'pm/pm_ajax.php', data: 'pm_id='+$(this).attr('id')+'&amp;id=pm_read', dataType: 'json', success: function(data) { $('#pmCouter').html(data[0]); //HOW CAN I CALL THIS HERE? I'D like to do $(this).parents(".pmMain").find(".pmMain5").append('ciao'); } }); }); </code></pre> <p>As you can see in the code, I'd like to recall <strong>this</strong> into the <em>$.ajax</em> function. How can I do it?</p>
jquery
[5]
633,176
633,177
Buttons and Layout bot loaded when I call ListActivity from Activity
<p>I have problem when I call ListActivity from Activity. It gives me an error when I call just following drawing strong Code part from activity it works and gives me an List but I have a layout which consist of buttons and List. Error case is that when I call ListView all of block codes. It gives me an error.</p> <pre><code> super.onCreate(savedInstanceState); **setListAdapter(new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, COUNTRIES)); getListView().setTextFilterEnabled(true);** setContentView(R.layout.activity_your_budget_categories); //Main Sayfasına geri Gider Button btn_ur_udget=(Button)findViewById(R.id.btnYourBudget); btn_ur_udget.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); Button bntAddCat= (Button)findViewById(R.id.btnAddCategory); bntAddCat.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(YourBudgetCategory.this, YourBudgetNewCategory.class); YourBudgetCategory.this.startActivity(myIntent); } }); </code></pre>
android
[4]
5,293,998
5,293,999
how to loop through php object and replace a string in each property ( variable )
<p>I need to remove these ' &amp; ' characters from each property of a php object</p> <p>I tried the code below but it's not working...what am I missing?</p> <p>thanks dudes</p> <pre><code>foreach($query_item as $key =&gt; $value) { $key = str_replace(' &amp; ',' &amp;amp; ',$value); } </code></pre>
php
[2]
723,747
723,748
Set value of a scoped variable in callback / closure
<p>I have a very large JS script with many functions, callbacks and so on... one of my first actions is to obtain a value from an Ajax call. This value I then set to a global variable defined at the start of my script so I can reference the value again and again... the value with determine the user language for instance.</p> <pre><code>// define my global var at the top of my script.. var globalOpCo = ""; // I then try to give this a value in the next function I call... $.ajax({ url:"getURL", type:"POST", dataType:"json", success:function(data){ if(data === null){ // do something... }else{ // set the current language... globalOpCo = data.Opco.toLowerCase(); console.log(globalOpCo); // this is the value I want it to be from data.Opco.toLowerCase() // now do something.... } }, error:function(xhr, ajaxOptions, thrownError){ console.log(xhr.status); console.log(xhr.statusText); console.log(thrownError); } }); </code></pre> <p>Now later in my script I wish to pass the <code>globalOpCo</code> to another function like so...</p> <pre><code> $("#aButton").on("click", function(){ anotherFunction(globalOpCo); // I want to pass the globalOpCo as an arguement but its value isn't get updated above? }); </code></pre> <p>however the value of <code>globalOpCo</code> is an empty string! The #aButton cannot be clicked before or until the ajax call above is run. Can someone help?</p>
javascript
[3]
3,447,819
3,447,820
Python getattr() member or function?
<p>I'm trying to use Python's getattr() to extract data out of a number of objects that I got from various APIs that I do not control. My idea was to go through a list of hetrogenous objects and try to getattr() on them until I pull out everything that I need.</p> <p>So I'm doing one of these:</p> <pre><code>if hasattr(o, required_field): value = getattr(o, required_field) result.append([required_field, value]) print 'found field', field, 'for value', value </code></pre> <p>My problem is sometimes the objects I'm dealing with have object.data() and sometiems object.data to pull stuff out. Sometimes these objects are actually generators.</p> <p>So once in a while I'd get something like this:</p> <pre><code>found field ValueOfRisk for value CellBM:&lt;Instrument:/limbo/WLA_YdgjTdK1XA2qOlm8cQ==&gt;.ValueOfRisk&gt; </code></pre> <p>Question: is there a way that I can say 'access the data member when it's a data member, or call a function when it's a function' to take the value out of these things? Seems like this should be easy with Python but I can't find it.</p>
python
[7]
4,471,526
4,471,527
Crossplatform way to check admin rights in python script?
<p>Is it any cross-platform way to check that my python script is executed under admin rights? Unfortunately, os.getuid() is UNIX-only and is not available under windows :(.</p>
python
[7]
91,572
91,573
How to append an element with jQuery unless it exists already?
<p>I have this jQuery function that appends a <code>span</code> labelled "optional" to a label if no option is set in the select box.</p> <pre><code>function setLabel() { var label=$('label[for=person_address]'); if ($('select#person_organisation_id').val().length != 0) { label.append(' &lt;span&gt;— optional&lt;/span&gt;'); } else { label.children().remove(); } } </code></pre> <p>Right now this adds a new span to the label every time I select a new option. How can I check if a span already exists and only add a span if there is none already?</p> <p>Thanks for any help...</p>
jquery
[5]
4,484,426
4,484,427
Update multiple row by get value from check box in php
<p>Could you help me: I have three table :there are <code>:users(userid,uername,password,groupid),group(groupid,groupname),menus(menuid,menuname),permissions(menuid,gorupid):</code> I would like update to table:permission here my coding:</p> <pre><code>&lt;?php require_once("includes/session.php"); $post = (!empty($_POST)) ? true : false; if ($post) { require_once("includes/connection.php"); require_once("includes/functions.php"); //GET value from page user submited $groupname = mysql_prep($_POST['groupname']); $desc = mysql_prep($_POST['desc']); $st_val = mysql_prep($_POST['valstore']);//store as array ex:(1,2,3,4,5,); $store_del_exp = explode("," ,$st_val); $store_del_exp_count=count($store_del_exp); for($j=0; $j&lt;$store_del_exp_count;$j++) { $t_id = trim($store_del_exp[$j]); $groupid = mysql_prep($_POST['groupid']); if($t_id&gt;0){ $sql = "UPDATE permissions SET menus_menuid ='$t_id' WHERE groups_groupid ='".(int)$groupid."'"; $result = dbQuery($sql); } } if(mysql_affected_rows){ echo "Successfully"; } } ?&gt; </code></pre>
php
[2]
5,305,814
5,305,815
Newbie having trouble with Javascript
<p>I'm trying to tokenize the string below, but execution terminates at the if statement... What am I missing? The my_tokens.length is OK on the alert, but fails on the if...</p> <pre><code> var my_value = '1 1 0'; var my_tokens = my_value.split(' '); alert('my_tokens=' + my_tokens); /* prints 1,1,0 as expected */ alert('my_tokens length=' + my_tokens.length); /* prints 3 as expected */ /* execution terminates at this if statement, and neither branch runs??? */ if (my_tokens.length != 3) {alert('bad master record');} else {alert('decoded master record=');} </code></pre>
javascript
[3]
2,975,095
2,975,096
is it possible to have a virtual class declaration in a class?
<p>I'm setting a up an interface for various components of a framework in a personal project, and i've suddenly thought of something that i figured might be useful with an interface. My question is whether this is possible or not:</p> <pre><code>class a { public: virtual class test = 0; }; class b : public a { public: class test { public: int imember; }; }; class c : public a { public: class test { public: char cmember; // just a different version of the class. within this class }; }; </code></pre> <p>sort of declaring a virtual class or pure virtual class, that is required to be defined within the derived object, so that you might be able to do something like this:</p> <pre><code>int main() { a * meh = new b(); a * teh = new c(); /* these would be two different objects, but have the same name, and still be able to be referred to by an interface pointer in the same way.*/ meh::test object1; teh::test object2; delete meh; delete teh; return 0; } </code></pre> <p>msvc++ throws me a bunch of syntax errors, so is there a way to do this, and i'm just not writing it right?</p>
c++
[6]
210,504
210,505
How can I use localstorage to remember a selection list choice?
<p>I have a selection list that I would like to remember what was chosen when a visitor returns to the page. The selection list is used to set a value used in another function. I understand there is something call DOM storage that can use localstorage to save a value like a cookie but, I don't know how. :(</p> <p>Can someone tell me how to do it with the below selection list?</p> <pre><code>&lt;SELECT class="FJselect" name="numberconsumables" style="width: 54px" id="FJsconsumables" onchange="ConsumableNUM=this.options[selectedIndex].value;&gt; &lt;OPTION class="FJoptionBG1" value="1"&gt;1&lt;/OPTION&gt; &lt;OPTION class="FJoptionBG2" value="2"&gt;2&lt;/OPTION&gt; &lt;OPTION class="FJoptionBG1" value="3"&gt;3&lt;/OPTION&gt; &lt;OPTION class="FJoptionBG2" value="4"&gt;4&lt;/OPTION&gt; &lt;OPTION class="FJoptionBG1" value="5"&gt;5&lt;/OPTION&gt; &lt;/SELECT&gt; </code></pre>
javascript
[3]
5,810,870
5,810,871
Alternative C++ Compilers?
<p>I want to start learning C++, so I downloaded Microsoft Visual Studio 2010 Express, and the entire application freezes and crashes every time I try to compile (debug and release build) something (I have tried running it in Admin Mode). Is there a good alternative compiler that I could still use VS 2010 as the IDE?</p>
c++
[6]
3,565,945
3,565,946
Save file from web?
<p>how do i save file from a website for example an image?</p>
android
[4]
5,437,603
5,437,604
How to get coordinates by tapping google map
<p>I'm developing an Location based reminder for android using gps. I want to obtain the co-ordinates of a particular location by tapping a map. i am unable to find a fitting solution to this problem. Can anybody pls help? Thank you in advance..</p>
android
[4]
917,747
917,748
Manually need to synchronize access to synchronized list/map/set etc
<p>Collection class provides various methods to get thread safe collections . Then why is it necessary to manually synchronize access while iterating ?</p>
java
[1]
178,113
178,114
Build a Database with 7 values already inserted
<p>In my application, after the user presses the appropriate button, an activity starts that creates a database with one table with two columns. The thing I can't seem to get is: I would like one of the columns to automatically fill with the days of the week so that when I return a cursor over the database for the listActivity, the days are shown. I can get the database to build but I can't seem to get the column to fill with the days. I tried this</p> <pre><code>public void installDays() { String[] day = new String[7];; ContentValues initialValues = new ContentValues(); day[0] = "Monday"; day[1] = "Tuesday"; day[2] = "Wednesday"; day[3] = "Thursday"; day[4] = "Friday"; day[5] = "Saturday"; day[6] = "Sunday"; for(int i = 0; i &lt; 7; i++) { initialValues.put(KEY_DAY, day[i]); } menuDb.insert(DATABASE_TABLE, null, initialValues); } </code></pre> <p>but that didn't work. Then I tried this:</p> <pre><code>if(rowId == 0) { menuDbHelper.createMenu("Monday", "", "", ""); menuDbHelper.createMenu("Tuesday", "", "", ""); menuDbHelper.createMenu("Wednesday", "", "", ""); menuDbHelper.createMenu("Thursday", "", "", ""); menuDbHelper.createMenu("Friday", "", "", ""); menuDbHelper.createMenu("Saturday", "", "", ""); menuDbHelper.createMenu("Sunday", "", "", ""); //menuDbHelper.installDays(); rowId = 1; } </code></pre> <p>That works but its no good, if you hit the back button and come back to that activity it just adds them all over again and then I have fourteen days. What am I doing wrong here? I am new to Java so take it easy on me.</p>
android
[4]
1,385,959
1,385,960
Auto set input values
<p>Somewhat a simple question, but i can't get it working.</p> <p>I want to make a simple checkup to see if the browser supports the placeholder attribute. If they don't i want to set the values if the input fields with jquery.</p> <p>I'm testing it on firefox now, but can't get it working. I don't get any alert field..</p> <p>This is what i got and what doesn't work...</p> <pre><code> jQuery.each(jQuery.browser, function(i, val){ if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9"){ $("input").each(function() { alert(this.id); }); } }); </code></pre> <p>Tried this as well without a result</p> <pre><code> jQuery.each(jQuery.browser, function(i, val){ if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.9"){ var $inputs = $("form :input"); $inputs.each(function(el) { alert(el.id); }); } }); </code></pre>
jquery
[5]
4,111,870
4,111,871
Ajax Requests Chaining/Nesting?
<p>I'm writing a script that uses Ajax. The script will call an API, and then use that data to call the API again, and then based on that a final request to the API a third time.</p> <p>Currently the Ajax requests are chained, so if response status is 200, it will perform the other Ajax request and if that one is 200 it will do another. So basically nested requests.</p> <p>They are asynchronous requests. Is this the correct way to do this? I cant help but think its a little messy, and wrong.</p>
javascript
[3]
4,670,284
4,670,285
Providing expansion content to Android apps
<p>I plan on providing a free app in the Android Market with some sample content from various "expansion" content packages that I intend to sell separately. These expansions would contain no executable code, just additional static data like sounds and images. </p> <p>I've researched this a bit trying to see how this could be done. I've come up with a few different possibilities:</p> <p>1) <strong>Separate stand-alone app per expansion</strong>: Each stand-alone app would contain that expansion's content and would require nothing else to be installed. Though this would work for some applications, I'm not really considering this as a solution because I ultimately want an app where if the user has purchased multiple expansion packs, they can browse through all of them in-app.</p> <p>2) <strong>Selling a "data only" app</strong>: I've seen a few apps actually do this. You purchase and install an expansion "app" from the Android Market that installs no application at all (i.e. - it's not displayed on your Application list). Somehow the actual app finds the expansion data and uses it. I'd like to find an example of how to do this exactly.</p> <p>3) <strong>In-app Purchase</strong>: I know that Android provides an In-app Purchase API, but I'm not sure exactly how this would work. I assume that if I went this route I would have to provide the content myself on my own web server or something. This seems both very cool and a big pain to do.</p> <p>So, my question is, what is the best way to do this? Are there any pros/cons of each method that I've missed? Are there any other methods that I've missed completely?</p>
android
[4]
4,419,106
4,419,107
Android App development what is better browser based or pure java based
<p>I have an app that has requirements for various hardware needs on the adroid platform, such as the gps, camera, storage, etc. But this app is also going to communicate constantly while in use with a web based service. Its an extension of that service kinda like how facebook has an app for its services, well I have a similar requirement. </p> <p>My problem is I am unfamiliar with Android development other than its based on the SDK and JAVA. So I am wondering are apps like the facebook app a browser-esk based application where some of the buttons controlling the app are for connecting to the hardware, or is the app a purely java based rendition of the web counter part?</p>
android
[4]
5,168,240
5,168,241
Hide/show elements in plain JavaScript
<p>I wrote a few lines of jQuery code, but don't know how to realize this in plain JavaScript. That output:</p> <pre><code>echo "&lt;tr id='perf_row' class='table_header_tr' name='tr_$row_fio_perf[0]'&gt; &lt;td class='table_header_td' name='td_$i'&gt; $i &lt;/td&gt; &lt;tr&gt;"; </code></pre> <p>search input. When user inputs chars, table rows (output higher) must hide and show only what matches the search word.</p> <pre><code>&lt;input type="text" onkeyup="showPerformers();" id="ShowSearchPerformers"&gt; function showPerformers(){ var search_login = $('#ShowSearchPerformers').val(); search_login = search_login.toLowerCase(); $('tr[name^=tr_]').hide(); var search = 'tr[name*=' + search_login+']'; $(search).show(); } </code></pre> <p>How to write this function in JavaScript, not jQuery?</p>
javascript
[3]
293,673
293,674
Adding script tag to document IE7 issue
<p>My page throws an error in IE7 when I appending an script tag the body.</p> <p>The error occurs on the line that is commented:</p> <pre><code>&lt;script type="text/javascript"&gt; cmSetClientID("90065468", false,"www9.blah.com","blah.com"); //--&gt; &lt;/script&gt; </code></pre> <p>This is how I append the script:</p> <pre><code>var scriptHolder = document.createElement('script'), body = window.parent.document.getElementsByTagName('body')[0], fn = "function doMyFn(){//dosomething}"; scriptHolder.text = fn; body.appendChild(scriptHolder); window.parent.doMyFn(); </code></pre>
javascript
[3]
2,912,835
2,912,836
How to access String resource from another application
<p>I have a application 'A' and application 'B'. </p> <p>Say, I have a string resource in the application 'A'</p> <pre><code>&lt;\string name="abc"&gt;ABCDEF&lt;\/string&gt; </code></pre> <p>How do I access the value of abc from the Activity in 'B'.</p> <p>I tried the following method.</p> <pre><code>try { PackageManager pm = getPackageManager(); ComponentName component = new ComponentName( "com.android.myhome", "com.android.myhome.WebPortalActivity"); ActivityInfo activityInfo = pm.getActivityInfo(component, 0); Resources res = pm.getResourcesForApplication(activityInfo.applicationInfo); int resId = res.getIdentifier("abc", "string", null); } catch(NameNotFoundException e){ } </code></pre> <p>Always resId is returned 0 always.. Can anyone please let me know if I could access string abc from the application 'B'</p> <p>Regards, SANAT</p>
android
[4]
1,678,231
1,678,232
Works inSimulator 6.1, but not on iPhone iOS 6.1
<p>I am using the iPhone 6.1 Simulator and it works. However, when I go to my iPhone [iOS 6.1] I get an error "Error while updating. not an error". HELP!!!!</p> <pre><code> NSString *filePath = [[[NSBundle mainBundle] resourcePath ]stringByAppendingPathComponent:@"myDatabase.sqlite"]; NSString* str2 = SeqNo1.text; sqlite3 *database; sqlite3_stmt *updateStmt=NULL; if(sqlite3_open([filePath UTF8String], &amp;database) == SQLITE_OK) { NSString* sql= [NSString stringWithFormat:@"UPDATE MyTable Set MyField2 = \"%@\" WHERE MyField1 = \"%@\"", @"Y", str2]; if(sqlite3_prepare(db, [sql cStringUsingEncoding:NSASCIIStringEncoding], -1, &amp;updateStmt, NULL) != SQLITE_OK) NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(database)); } if(sqlite3_open([filePath UTF8String], &amp;database) == SQLITE_OK) { int step = sqlite3_step(updateStmt); if(step != SQLITE_DONE) NSLog(@"Error while updating. %s", sqlite3_errmsg(database)); // THIS WHERE THE ERROR IS OCCURRING sqlite3_finalize(updateStmt); sqlite3_close(database); } else{ NSLog(@"Error while Opening Databse. %s", sqlite3_errmsg(database)); } </code></pre>
iphone
[8]
5,509,121
5,509,122
Use resource font directly in Java
<p>How to use resource font directly in Java?</p>
java
[1]
2,604,977
2,604,978
how to delete all check file using for loop?
<p>This is my code which deletes only the first checked file. </p> <p>I want to delete all checked files, what changed do I need to make?</p> <p>How do I collect all values in CheckArr[i]? </p> <p>The code only deletes the first checked file in grid. I want to first collect all checked values which are true then make database call(s).</p> <pre><code>boolean CheckArr[]; File[] currentFiles; unhide.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { for (int i = 0; i &lt; CheckArr.length; i++) { if (CheckArr[i] == true) { db = new DataBase(getBaseContext()); try { db.createDataBase(); } catch (IOException e1) { e1.printStackTrace(); } Cursor DataC = db .selectQuery("SELECT path FROM Photos where name ='" + currentFiles[i].getName() + "'"); if (DataC.getCount() &gt; 0) { Bitmap bitmap = decodeFile.decodeFile(new File(root + "/" + currentFiles[i].getName())); try { FileOutputStream outputStream = new FileOutputStream( new File(DataC.getString(DataC .getColumnIndex("path")))); outputStream.write(decodeFile.getBitmapAsByteArray(bitmap)); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } File file = new File(root + "/" + currentFiles[i].getName()); file.delete(); inflateListView(currentFiles); } DataC.close(); db.close(); } } </code></pre>
android
[4]
5,718,973
5,718,974
how to select a dynamic string from a sentence
<p>How can I select the first number from these example sentences</p> <pre><code>" 1 SAMPLE SAMPLE 1" " 20 SAMPLE SAMPLE 2" </code></pre> <p>I want to isolate the first number from those lines.</p> <p>I tried a few string functions that come with javascript but can't seem to make them work. I don't want the spaces, I need the number only.</p>
javascript
[3]
685,695
685,696
How to check if string contains anything but QWERY/1234
<p>I'm trying to make sure a string I'm posting only has alphabetical and numberical letters/numbers + ,.; etc. However all checks I seem to do still bring back à è ò as valid?</p> <p>Anyone know a solution for this?</p> <p>Thanks</p>
php
[2]
4,298,649
4,298,650
Dynamically display data from csv file into drop down list
<p>I have a csv file that contains a bunch of states in one column of its table. I need to take those states and populate a drop down list with them <em>with no repeats</em></p> <p>My code for this is</p> <pre><code>//make unique array for ($i=0; $i&lt;count($array); $i++) { $state_array[$i]=$array[$i][1]; } //display in drop down list $state_array=array_unique($state_array); $state_array=array_values($state_array); for ($i=0; $i&lt;count($state_array); $i++) { echo "&lt;option value='".$state_array[$i]."'&gt;".$state_array[$i]."&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <p>The csv file is outputted to a multidimensional array and the index for the states is $array[$i][1]</p> <p>There's something wrong with my code as the select box remains blank. Can anyone spot what's wrong please? Any help is appreciated.</p> <p><strong>Note:</strong> If it counts, I'll just mention that I can't use SQL, Java, etcetc. Only php.</p>
php
[2]
1,906,765
1,906,766
Integer prototype
<p>how can you make an prototype on an Integer?</p> <pre><code>Integer.prototype.num = function(dec){ return number_format(this.toString(), dec); } </code></pre>
javascript
[3]
4,927,152
4,927,153
my simple window.open function in jquery it's not working
<p>i am trying to open two links when i click the readmore text but here same link opened two times my html is:</p> <pre><code>&lt;html&gt;&lt;body&gt; &lt;p&gt; &lt;a style="font-family: Verdana;color:#478718;font-weight:bold;text-decoration:none;cursor: pointer;cursor: hand;" href="http://www.scribd.com/doc/76022697/Manthan-Awards-Digital-innovations-for-the-larger-good-2" target="_blank"&gt;Manthan Awards 2011 - Rang De wins Manthan Award for e-Inclusion&lt;/a&gt;&lt;br /&gt;Winners of the Manthan Award, South Asia, which seeks to encourage start-ups using information and communication technology (ICT) for social development, were announced on Friday. This year, the competition received 510 nominations from India and neighbours such as Afghanistan, Nepal, Bangladesh and Sri Lanka. Of these, 110 projects were selected to compete in categories such as governance, health, education and learning, inclusion, infrastructure, travel and tourism, environment, community broadcasting, entertainment, agriculture and livelihood, localization, news and media, science and business and enterprise. ... &lt;a id="readmorelink" title="No Cookie Cutters Need Apply"&gt;Read More&lt;/a&gt; &lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>my script is:</p> <pre><code> $(document).ready(function(){ $('#readmorelink').click(function(){ window.open('http://www.scribd.com/doc/76022697/Manthan-Awards-2011-Digital-innovations-for-the-larger-good-1'); window.open('http://www.scribd.com/doc/76022697/Manthan-Awards-2011-Digital-innovations-for-the-larger-good-2'); }); }); </code></pre> <p><a href="http://jsfiddle.net/sureshpattu/zNTNK/1/" rel="nofollow">my jsfiddle</a></p>
jquery
[5]
1,507,898
1,507,899
need help regarding $_POST in PHP
<p>i am new to stack overflow :)</p> <p>i have problem with my piece of code , kindly let me know where exactly i go wrong.i am sending an email to my account and the error i get is ... that i get only half of the information.to get a clear idea of wat i am asking i am attaching the code below ...please review and let me know .. thank yu for yur time :) </p> <pre><code> &lt;?php $first_name = $_POST["name_t"] ; $last_name = $_POST["lname_t"] ; $contact=$_POST["contact"] ; $email = $_POST["email"] ; $adults =$_POST["no_adults_t"] ; $children = $_POST["no_children"] ; $address = $_POST["address"] ; $date = $_POST["date_t"] ; $message = "First Name : ".$first_name."\n\nLast Name : ".$last_name."\n\nContact Number : ".$contact."\n\nAddress :".$address."\n\nE mail :".$email."\n\n Number Of Adults : ".$adults."\n\nNumber Of children : ".$children."\n\nReservation Date : ".$date; $headers = "From:" . $email; @mail( "someone@someone.com", "some subject ",$message,$headers); echo "&lt;pre&gt;".print_r($_REQUEST, 1)."&lt;/pre&gt;"; print $first_name; print $last_name; print $contact; print $email; print $adults; print $children; print $address; print $date; print "&lt;body style="."background-color:gray"."&gt;&lt;/body&gt; &lt;h2 style="."color:maroon;"."&gt;Thank You.Your information has been submitted.Our Representative would be contacting you shortly&lt;/h2&gt; &lt;h4 style="."color:blue"."&gt;&lt;a href="."index.html"."&gt;Click Here To Go Back to Main Page.&lt;/a&gt;&lt;/h4&gt;" ?&gt; </code></pre> <p>waiting for yur answer</p>
php
[2]
78,150
78,151
How to download audio clip and play in media player in android?
<p>I need help with download audio clip from server and play default android media player with in same screen,How can i download audio clip and invoke media player.How can it possible this.please help me friends </p> <p>Thanks Friends..</p>
android
[4]
5,413,898
5,413,899
main function - what is the point of a return value?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/204476/what-should-main-return-in-c-c">What should main() return in C/C++?</a><br> <a href="http://stackoverflow.com/questions/3309042/what-does-main-return">What does main return?</a> </p> </blockquote> <p>I've been wondering this for a while: what is the purpose of a <code>return 0;</code> statement at the end of the main() function? </p> <p>I know that a return statement at the end most functions returns a value to the function which called it. However, as I understand it, the main function is the starting and ending point of the program, so I'm a little confused as to why it has a return type at all?</p> <pre><code>main() { //code goes here return 0; // &lt;-- what is the point of this return statement? } </code></pre> <p>edit: I'm pretty new to programming (first year computer science student) and after looking at some of the answers it sounds like the return statement is used to tell the caller of the function if it has completed successfully. Other than the OS and command line, is there anything else that can call a main function? thanks for the quick answers =)</p>
c++
[6]
2,458,656
2,458,657
How to simulate a click event in jQuery
<p>note: all this is on chrome</p> <p>I am trying to test something that responds to a click a checkbox. I realize jQuery.click() exists, but it seems to be different from a "native" click in that during the click handler, the state of the checkbox isn't updated yet (so checkbox is unchecked, you call .click(), in the handler, checkbox is still unchecked. If you actually click the box, in the handler the state is checked).</p> <p>I apologize for the confusing question, here is a fiddle <a href="http://jsfiddle.net/XBhWy/" rel="nofollow">http://jsfiddle.net/XBhWy/</a></p> <p>Click the foo button, notice that button handler says it has been checked, but the checkbox handler says it has not been checked (even though the ui shows a checkmark). Now, click the checkbox itself. Notice the click event handler is reporting what you would expect it to report.</p> <p>My question is how to simulate the same thing that happens when you actually click the box.</p> <p>Now, I took a stab at a better simulated event like this</p> <pre><code>$.fn.check = function() { if ($(this).is(':checked')) { $(this).attr('checked', 'checked'); } else { $(this).removeAttr('checked'); } $(this).click(); } </code></pre> <p>Unfortunately (and somewhat confusingly), it didn't work.</p> <p>Anyone run into this before? Can it be accomplished?</p> <p>Note that I'm not looking for the <code>click</code> method.</p>
jquery
[5]
2,368,866
2,368,867
How can I simplify that part of code?
<p>I have a code:</p> <pre><code> byte[][][] file = GetConfigData(); if (file == null) return; int pages = 0; for (i = 0; i &lt; file.Length; i++) { if (file[i] != null) { for (j = 0; j &lt; file[i].Length; j++) { if (file[i][j] != null) { pages++; } } } } </code></pre> <p>How can I simplify it ?</p> <p>Please, provide 2 versions:</p> <ol> <li>for .net 2.0</li> <li>for .net 3.5 (linq)</li> </ol>
c#
[0]
3,940,571
3,940,572
Making a "folder" in Android app - sqlite or other method?
<p>So I'm making a task management app in Android and have thus far made an implementation that just displays a list of tasks which are store in an SQLite database.</p> <p>I want to be able to add categories or folders that the tasks can be sorted in to, and planned to do it using a one to many relationship with SQLite but from what I've read SQLite isn't great with foreign keys?</p> <p>I would appreciate any input or thoughts regarding the best method for doing such a thing.</p>
android
[4]
2,313,817
2,313,818
retrieve an image from server with a rest web service
<p>Sorry for my english. I want to retrieve image from a server via a rest web service to android.Can someone explain me the architecture which i'll follow to do this? thanks</p>
android
[4]
825,981
825,982
PHP array copying error
<p>when I'm trying to copy an array's element to another using php</p> <pre><code>$new=array(); for($i=0;$i&lt;$num;$i+3){ $new[] = $old[$i]; } </code></pre> <p>it is throwing an error <code>Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes)</code></p> <p>I need to copy <code>old</code>'s element into <code>new</code> by skipping two elements in between (I need 1st, 4th, 7th elements .. skipping 2nd&amp;3rd, 5th&amp;6th, 8th&amp;9th) <br><br></p> <p>suggest me how </p> <p><strong>update:solved---sry its typo error...</strong> its silly but i starred @ my code for 15min and not found my typo error...am copying the code, how i rectified </p> <pre><code>$new=array(); for($i=0;$i&lt;$num;$i+=3){ $new[] = $vdo[$i]; } </code></pre>
php
[2]
4,870,754
4,870,755
How to get articles from a custom field to display to a specific post
<p>Hy im building a cinema site..</p> <p><a href="http://cinema.trancelevel.com/amazing-spider-man-2012/" rel="nofollow">http://cinema.trancelevel.com/amazing-spider-man-2012/</a></p> <p>How can i get the news that contain the movie title...</p> <p>How can i get the news by tag.</p> <p>i have this code : link <a href="http://wordpress.org/support/topic/how-to-get-articles-from-a-custom-field-to-display-to-a-specific-post?replies=1" rel="nofollow">http://wordpress.org/support/topic/how-to-get-articles-from-a-custom-field-to-display-to-a-specific-post?replies=1</a></p> <p>For example: if i have a news and have tag the Amaizing Spiderman....i want to apear in the right in sidebar.</p> <p>For Movies - i use POST For Stiri - i use post_type</p> <p>If ennybody knows please post... or how can i get the news other way... custom field... etc... </p>
php
[2]