Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
5,820,366
5,820,367
Python path help
<p>how can i run my program using test files on my desktop without typing in the specific pathname. I just want to be able to type the file name and continue on with my program. Since i want to be able to send it to a friend and not needing for him to change the path rather just read the exact same file that he has on his desktop.</p>
python
[7]
4,370,468
4,370,469
how to split the String using comma,but with out any in {...}'s commas
<pre><code>String filterPath="aa.bb.cc{k1:v1,k2:{s1:s2}},bb.cc,ee.dd"; String[] result=filterPath.split(","); for(String r:result){ System.out.println(r); } </code></pre> <p>I want split the String <code>filterPath</code> ,but with out any in { ... }'s commas:</p> <pre><code>aa.bb.cc{k1:v1,k2:{s1:s2}} bb.cc ee.dd </code></pre> <p>thanks for help.</p>
java
[1]
2,627,826
2,627,827
Setting up new iPhone Dev Environment for existing app
<p>This might be a weird question, but I'll try anyway.</p> <p>I set up my dev environment with certificates etc on an old MBP, built an app and released it on the App Store. I've since upgraded to a new MacBook Pro, but didn't move over any certificates, so can no longer build my application.</p> <p>Have I completely screwed things up? How can I install the right certificates on my new MBP? Note: I do not own the old MBP any longer so cannot transfer anything from there...</p> <p>Thanks for any advice!</p>
iphone
[8]
2,432,312
2,432,313
Persistence navigation bar on top of all activities
<p>I'm about to start on an Android project. This app needs to have a (navigation) bar that will be always on top and always visible, also when you switch between activities. The bar must be 10 dp from the bottom and the active activity in the background must be visible above and below to the bar. Is there any component to do this with? </p> <p><em>its lifecycle must remain while switching between activities so it won't slide out of the screen, like the activities do</em></p> <p>Already tried: Fragments: Only available for > 3.0 Widgets: View is removed when switching between activities ActivityGroup: Seems to be a bad way</p> <p><a href="http://stackoverflow.com/questions/6788198/how-to-create-fixed-navigation-bar-for-all-activities-in-an-android-application">How To Create Fixed Navigation Bar For All Activities In An Android Application</a> This seems to be the same question, but no correct answer given.</p>
android
[4]
489,989
489,990
php $_SERVER['DOCUMENT_ROOT'] too far down the tree
<p>I have multiple sub-domains within the document_root. And multiple folders/classes within those sub-domain folders. I need something that will help me with my include_once paths, but $_SERVER[DOCUMENT_ROOT] goes too far down. And if I were to use this, and transfer the website folder later, all my include_once paths will/might break.</p> <p>Hope my question is clear... Any recommendations?</p> <p>Essentially, what I'm trying to do is, access classes, that are located in different folders, from different files. When it works for some files, it'll break in others, because of the way I'm writing the include statements.</p> <p>Ie. class test{include_once '../Data/employee.php';} A file that will include the class test, will work. But say another file, from a different directory, includes the class test. It'll break. Because the other file can be 3 folders deep, instead of just one.</p>
php
[2]
5,783,614
5,783,615
How to get a list of top 5 links from a google search?
<p>I need a list of top 5 links obtained from a user query about a partiuclar subject.Is there any way by which I can do this ? How can I fetch top 5 links of a google search ? Is there any API available for it ?Some demo examples will be helpful. </p> <p>Thanks in advance.</p>
java
[1]
2,256,547
2,256,548
C# AJAX or Java response HTML scraping
<p>Is there a way in C# to get the output of AJAX or Java? What i'm trying to do is grab the specifics of items on a webpage, however the webpage does not load it into the original source. Does anybody have a good tutorial or a good place to start?</p> <p>For example, i would want to get all the car listings from <a href="http://www.madisonhonda.com/Preowned-Inventory.aspx#layout=layout1" rel="nofollow">http://www.madisonhonda.com/Preowned-Inventory.aspx#layout=layout1</a></p>
c#
[0]
3,304,021
3,304,022
Android using back button
<p>i wanna use the back button on the mobile itself to make a dialog box appear to ask me whether am sure i wanna exit or not?</p> <pre><code> public void onBackPressed() { // TODO Auto-generated method stub AlertDialog.Builder dialog=new AlertDialog.Builder(MainActivity.this); dialog.setTitle("Confirm"); dialog.setMessage("Are you sure you want to exit?"); return; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); EditText text=(EditText)findViewById(R.id.Text); TextWatcher watch=new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub onBackPressed(); } }; text.addTextChangedListener(watch); } </code></pre>
android
[4]
1,939,593
1,939,594
Use more than one font to drawstring
<p>I want to use drawString to print a sentance but some parts of it has to be bold. What is the best way to do this? Yes, I have considered using two drawString. But is there a intelligent way of using two drawStrings if we have to.</p> <p>We cannot make any assumtion about the length of the sentance. However it is prepared in a format.</p> <p>eg: </p> <p>Say hello to <strong>name</strong>. Good afternoon <strong>name</strong>. </p> <p>Thanks</p>
c#
[0]
4,265,231
4,265,232
Can I do addView in onDraw of MyLayout?
<p>I am new for android. I want to add image button in onDraw. I wonder if I can do like this. I don't have compile error. But simulator says, "Unfortunately MyApp has stopped." My second question is how can I add button at x, y location in screen? There is no location parameters in addView.</p> <pre><code>protected class MyLayout extends LinearLayout { ImageButton button; public MyLayout(Context context) { super(context); setWillNotDraw(false); button = new ImageButton(context); button.setImageBitmap(buttonBitmap); // buttonBitmap is loaded in onCreate } public void onDraw(Canvas canvas) { addView(button); } } </code></pre>
android
[4]
5,532,715
5,532,716
Time Duration problem for 12 hrs format
<p>I am getting the time duration correctly for 24 hrs format but for 12 hrs format I am getting error if i give 11:00 am to 1:00 pm. If I give 10:00 am to 11:00 am it will correctl and if I give 6:00 pm to 7:00 pm it will give correctly only in am to pm i m facing problem.</p> <pre><code>function autoChangeDuration() { var diff1 = "00:00"; var start = document.getElementById("startTime").value; var end = document.getElementById("endTime").value; if (start &gt; end) { document.getElementById("duration").value = diff1; } else { var space1 = start.split(' '); var space2 = end.split(' '); s = space1[0].split(':'); e = space2[0].split(':'); var diff; min = e[1] - s[1]; hour_carry = 0; if (min &lt; 0) { min += 60; hour_carry += 1; } hour = e[0] - s[0] - hour_carry; diff = hour + ":" + min; document.getElementById("duration").value = diff; } </code></pre>
javascript
[3]
94,385
94,386
is there a way to call this javascript function in this way?
<p>I'd like be able to call a function like item_edit.say hello passed as a string on the window object (like the last line of the following):</p> <pre><code>var arc={ view: { item_edit: {} } }; arc.view.item_edit={ say_hello: function(){ alert('hello there'); } } var f_name='say_hello'; var g_name='item_edit.say_hello'; var str=window.arc.view.item_edit[f_name](); // &lt;- this works var str2=window.arc.view[g_name](); // &lt;- this is what I'm interested in; curently doesn't work </code></pre> <p>any ideas on how to get this to work?</p> <p>thx in advance</p> <p><strong>edit #1</strong> I guess I should add that probably don't want to be doing eval although the more I look at it, that might be what makes sense (and is in fact what eval was made to do).</p>
javascript
[3]
1,657,060
1,657,061
Should I always check if a variable was changed, or just change it regardless?
<p>I have the following code (Javascript):</p> <pre><code>var boolA = false; var boolB = Math.random()*2 ? true : false; </code></pre> <p>I don't know if boolB will be true or false, but I need to update boolA with it anyway every tick. Should I just update it or check if it was changed?</p> <p>Which is fastest?</p> <pre><code>boolA = boolB; </code></pre> <p>or</p> <pre><code>if ( boolB != boolA ) boolA = boolB; </code></pre> <p>What about integers, strings and other objects? </p> <p>Thank you in advance!</p>
javascript
[3]
4,466,117
4,466,118
How many days until next year?
<p>Could somebody tell me how to get the days until next year in C++? </p> <p>I've been searching for a solution, but haven't had any luck. The only ones I found are using boost library, but I would like to do it without it.</p>
c++
[6]
4,335,182
4,335,183
how to validate numeric strings in PHP
<p>I'm looking for a method that would allow me to check for valid IDs in my system. </p> <p>They're by definition:</p> <ul> <li>positive, not 0,</li> <li>a whole number, but might be bigger than integer size</li> <li>come as either string or number</li> </ul> <p>I'd like to know what you think is the most elegant way of validating this. Candidates that fail are: - <code>is_int()</code>, because it's valid for negative numbers, AND because of the integer size limit - <code>is_numeric()</code>, because it'd valid for float, or, say, having an exponential part like this +0123.45e6 - <code>ctype-digit()</code> with casting the input to string, because this would be valid: "0000"</p> <p>I've so far settled with this:</p> <pre><code>preg_match('/^[1-9][0-9]*$/',(string)$id); </code></pre> <p>Can anyone come up with an alternative?</p>
php
[2]
5,400,120
5,400,121
Thumbnails
<p>Is there an Api for creating a thumbnail from a JPEG</p>
java
[1]
1,592,315
1,592,316
Jquery Address Problem
<p>I can not use in Ajax.html function. Data is again the function of each is installed. Thanks for the solution.</p> <p><strong>index.html;</strong></p> <pre><code>$.address.change(function(event) { $.post('ajax.html',{cmdModule:'test'}, function(data) {$("#middle").html(data);}); }); </code></pre> <p><strong>ajax.html;</strong></p> <pre><code> $.address.internalChange(function(event) {alert("test")}); </code></pre>
jquery
[5]
2,541,409
2,541,410
Show a bulleted list from Strings.xml file in android
<p>I have a problem that I want to show a bulleted list contents which is resided in strings.xml file as an array elements. Then the problem is that how to convert the array elements in Html List format? Can any one suggest any solution regarding the same.</p> <p>Thanks in advance</p>
android
[4]
1,750,142
1,750,143
A question from Morgan Stanley's interview
<p>There is a array filled with char elements, can you suggest a most efficient way to find the max length of continuous white space?</p>
c++
[6]
1,132,682
1,132,683
Programmatically Make Bound Column Invisible
<p>I'm trying to make a data bound column invisible after data binding, because it won't exist before data binding. However, the DataGrid.Columns collection indicates a count of 0, making it seem as if the automatically generated columns don't belong to the collection.</p> <p>How can I make a column that is automatically generated during binding invisible?</p>
asp.net
[9]
4,121,120
4,121,121
integer showing as NaN
<p>I'll begin with posting my javascript.</p> <pre><code> $(document).on('click','.remove-single-inbox-message', function(e){ e.preventDefault(); var messageid = $(this).data('messageid'); var messages = $("#number-messages").html(); var messages = parseInt(messages, 10); messages--; $.ajax({ type: 'POST', url: '?a=profile_message_delete', data: { "messageid" : messageid }, success: function(){ $('.table-row'+messageid).hide(); if(messages == 0){ $("#insert-message-indicator").html(""); } else { $("#insert-message-indicator").html("&lt;strong&gt;&lt;small&gt;"+messages+"&lt;/small&gt;&lt;/strong&gt;&amp;nbsp;&lt;i class='icon-envelope icon-white' rel='tooltip' title='New messages available'&gt;&lt;/i&gt;"); } } }); }); </code></pre> <p>The first decrementation works fine and the new number is displayed but the ones that follows it shows NaN. What am I doing wrong?</p>
jquery
[5]
5,667,184
5,667,185
Can a callback have parameters defined?
<p>I know it's maybe an fairly easy basic knowledge for you, here I need to ask your help to see whether there is a 'hole' behind to improve. Please check the code below, can I set 'response' as callback parameter but not callSvc's? instead of this kinda 'tricky' way? </p> <pre><code>function callSvc(response, callback){ callback(response); } callSvc("I'm a response!",function(param_response){document.write(param_response);}); </code></pre> <p>Thanks.. </p> <p><strong>Update</strong></p> <p>Maybe this is good enough?</p> <pre><code>function callSvc(callback) { callback("response"); } callSvc(function(data) { document.write(arguments[0]); }); </code></pre>
javascript
[3]
5,440,445
5,440,446
Regarding playing mp4 file as splash screen at the start of android application
<p>I am developing an android application in which i have to play a mp4 file in the splash screen.I have written code for splash screen java class.But dont know why it is not picking,can anyone guide me...</p> <p>Below is my java class code </p> <p><a href="http://pastebin.com/teCuDdcp" rel="nofollow">http://pastebin.com/teCuDdcp</a></p> <p>Thanks in advance Tushar</p>
android
[4]
4,498,802
4,498,803
Grouping Elements of a List based on attributes of the elements
<p>I have the following list</p> <pre><code>List=[ ('G1', 'CFS', 'FCL', 'R1'), ('G3', 'LOOSEFREIGHT', 'MIXEDLCL', 'R9'), ('G4', 'CFS', 'FCL', 'R10'), ('G2', 'LOOSEFREIGHT', 'LCL', 'R4'), ('G1', 'CFS', 'FCL', 'R2'), ('G2', 'LOOSEFREIGHT', 'LCL', 'R5'), ] </code></pre> <p>Now I want to group this elements of List first by index [1] (i.e. CFS and LOOSEFREIGHT) together and for those elements which are grouped together for LOOSEFREIGHT, I want to further divide them into different groups based on index[2] (i.e. LCL or MIXEDLCL).</p> <p>So essentially I want them grouped into different lists and my solution should be of the form</p> <pre><code>New_List=[ [ ('G1', 'CFS', 'FCL', 'R1'), ('G1', 'CFS', 'FCL', 'R2'), ('G4', 'CFS', 'FCL', 'R10') ], [ ('G2', 'LOOSEFREIGHT', 'LCL', 'R4'), ('G2', 'LOOSEFREIGHT', 'LCL', 'R5') ], [ ('G3', 'LOOSEFREIGHT', 'MIXEDLCL', 'R9') ], ] </code></pre> <p>How do I do it?</p> <p>I managed to do divide them into different lists based on index [1] however I was not able to further divide them based on index [2]</p> <p>Any help is appreciated.</p>
python
[7]
461,216
461,217
Get the Windows ProductID via registry, in JAVA
<p>How do I get the Windows ProductID via registry in Java? The only way I tried is via:</p> <pre><code> Process p = Runtime.getRuntime().exec("reg query \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\" /v ProductId"); </code></pre> <p>which returns null or error.</p> <p>Thanks in advance.</p>
java
[1]
3,447,759
3,447,760
Ignore 'Object sent -autorelease too many times" warning
<p>When running Analyzer, I receive the "Object sent -autorelease too many times" warning. I know I'm doing something tricky (and am open to alternatives to accomplishing my goal).</p> <p>Essentially, I wanted to keep a stack of specific types of controllers handy for sending messages from a central location. So, considering:</p> <p>From 'ActionBroker' shared object:</p> <pre><code>NSMutableSet *liveActions; liveActions = [NSMutableSet alloc] init]; </code></pre> <p>...</p> <pre><code>CLViewController *action = [[[actionClass alloc] init] autorelease]; if (!action) { return nil; } [self.liveActions addObject: action]; // When adding an object, the retain count is increased. We want the action // to dealloc, so that it might remove itself from the list... [action release]; return action; </code></pre> <p>And the complementary dealloc code:</p> <pre><code>[[CLActionBroker sharedActionBroker] removeAction: self]; [super dealloc]; </code></pre> <p>... and in removeAction:</p> <pre><code>[action retain]; [self.liveActions removeObject:action]; </code></pre> <p>The above code works, I just get the nagging error. And the nagging sensation that I could probably solve the problem a different way.</p> <p>One of the use cases for this code is to pass an 'handleOpenURL' request through a chain of open controllers and returning the first 'YES' response.</p>
iphone
[8]
5,636,142
5,636,143
How to add new items to multiDimensional Array
<p>How do I add new to items to this Array?</p> <pre><code>public static string[,] myArray = new string[,] { { "1", "1a" }, { "2", "2a" } }; public Form1() { InitializeComponent(); myArray.add("3", "3a"); // error for (int i = 0; i &lt; myArray.GetLength(0); i++) { Console.WriteLine(myArray[i, 0] +", "+ myArray[i, 1]); } } </code></pre> <p>thank you.</p>
c#
[0]
1,415,326
1,415,327
Showing / scrolling to top of page in jQuery
<p>I'm developing an app with a <em>kind of</em> multiple part form (step 1, step 2 etc...)</p> <p>What I'm doing, is separating this out in divs, and having the submit button hide the current div, and show the next one.</p> <p>I'd like the page to scroll to the top (as if it were a postback) when hiding/showing the next part:</p> <pre><code>$('#my_submit_button').click(function (){ $('#div_one').hide(); $('#div_two').show(); //now it should scroll to top of window... $(window).scrollTop(100); }); </code></pre> <p>However, this isn't working as expected.</p>
jquery
[5]
147,274
147,275
How do I convert one element (or key) of an array into a string variable?
<p>I have an array like this:</p> <pre><code>array ( [0] =&gt; "string0" [1] =&gt; "string1" ) </code></pre> <p>I want to be able to do something like this:</p> <pre><code>$str = array[0]; print_r ($str); </code></pre> <p>And get a result like this:</p> <pre><code>"string0" </code></pre> <p>Instead I am getting this:</p> <pre><code>str ( [0] =&gt; "string0" ) </code></pre> <p>I want to take one element of an array and turn it into a string.</p>
php
[2]
1,872,710
1,872,711
Block the user to see the result page when not login
<p>I'm using web application, struts and hibernate are the technologies used in that application. When user login, it traverse from login page to result page. My question is, how do i prevent the user when not login, user should not allow to see the result page using the url of the result page directly. i.e means hitting the result page url in browser. For e.g: login page url --> //localhost:8080/Log/login.action</p> <p>result page url --> //localhost:8080/Log/details.action</p> <p>Appreciate your help.</p>
java
[1]
141,606
141,607
What are the virtualkey codes for following shortcut combinations in c#
<p>I need to disable the following keyboard shortcuts like,</p> <p>alt + tab</p> <p>alt + esc </p> <p>ctrl + esc</p> <p>windows key [this is not combination]</p> <p>for which i need to provide the keycodes in my condition to make it disable.</p> <p>I tried the following link <a href="http://msdn.microsoft.com/de-de/ms645540%28en-us,VS.85%29.aspx" rel="nofollow">MSDN Keycodes</a></p> <p>And did my condition like below...</p> <p>if (((lParam.vkCode == 12) &amp;&amp; (lParam.flags == 9)) || // alt + tab</p> <p>((lParam.vkCode == 12) &amp;&amp; (lParam.flags == 1)) || // alt + esc</p> <p>((lParam.vkCode == 11) &amp;&amp; (lParam.flags == 1)) || // ctr + esc</p> <p>((lParam.vkCode == 5) &amp;&amp; (lParam.flags == 0)) || // windows key</p> <p>But it doesent seem to work. Please help me on this. where am i going wrong ??? Thanks.</p> <p>If anyone needs to see my whole code to make the shortcuts disabled, Please see this post in the same site which i posted before. <a href="http://stackoverflow.com/questions/1198161/where-to-get-the-keycode-for-keyboard-hook-in-c">Click here for the code</a></p>
c#
[0]
2,229,973
2,229,974
After asp.net web deployment the users must have net framework installed to view the pages?
<p>If I upload a project(asp.net , net framework 4) to a webhosting service, will the users which are accessing the website need to have net framework 4.0 installed on their own machines in order to view the asp.net website?</p>
asp.net
[9]
3,548,890
3,548,891
Android:How to change the background color of the options menu when selected?
<p>I have created an an options menu in my application. I want to change the background color of the menu item selected. Please help me doing this.</p>
android
[4]
917,839
917,840
python 2.7 iterating index error
<pre><code>import re address1 = [] address2 = [] city = [] state = [] zipCode = [] modifiedShipping_address1 = ( ['#### Example Rd. SE', 'City, OH\xa0#####', 'United States', ''], ['### Street Ct', 'Apt B', 'City, SC\xa0#####', 'United States', '']) for i in modifiedShipping_address1: address1.append(i[0]) if len(i) == 4: address2.append('') cityIndex = str(i[1]).find(',') city.append(i[1][:cityIndex]) state_re = re.compile(', (.*?)\\xa0') state_pat = re.findall(state_re, str(i[1]).strip()) for i in state_pat: state.append(i) zip_re = re.compile('\\xa0(.*?)') zip_pat = re.findall(zip_re, str(i[1]).strip()) for i in zip_pat: zipCode.append(i) else: address2.append(i[1]) cityIndex = str(i[2]).find(',') city.append(i[2][:cityIndex]) state_re = re.compile(', (.*?)\\xa0') state_pat = re.findall(state_re, str(i[2]).strip()) for i in state_pat: state.append(i) zip_re = re.compile('\\xa0(.*?)') # This line throws the exception: zip_pat = re.findall(zip_re, str(i[2]).strip()) for i in zip_pat: zipCode.append(i) state = state[:] zipCode = zipCode[:] print state print zipCode </code></pre> <p>When run, the code produces this output:</p> <pre><code>['OH'] [] Traceback (most recent call last): File "iterating.py", line 37, in &lt;module&gt; zip_pat = re.findall(zip_re, str(i[2]).strip()) IndexError: string index out of range </code></pre> <p>How do I go about fixin this? Thank you. I do not understand where indexError is coming from.</p>
python
[7]
1,705,549
1,705,550
Why the Id value is not append with Id in Jquery?
<p><br/> <a href="http://www.jsfiddle.net/Z4yYf/" rel="nofollow">This is my code</a></p> <p>What I am expecting is <code>&lt;input type="text" name="procedurecode1" id="procedurecode1" value=""&gt;</code> <br/> But the result like below <br/> <code>&lt;input type="text" +idvalue="" name="procedurecode" id="procedurecode" value=""&gt;</code> <br/>I dont know why?Thanks in advance.</p>
jquery
[5]
4,901,570
4,901,571
C# how to get (text?) value from PasswordBox?
<p>I have a passwordBox, how can I get its text value after input is finished?</p>
c#
[0]
5,576,700
5,576,701
Unexpected output
<p>I use the code to return data from a function and display it.</p> <p>consider: <code>i = j = 0; count = 4;</code></p> <p>I do not get <code>4</code> return values from the code.. .which is expected output.</p> <p>But i get the result when i replace the for loop with <code>print_r($EODRow);</code></p> <p>Pls help.</p> <pre><code> $i = 0; $j = 0; $count = getEODCount("A"); for(; $i &lt; $count; $i++) { $EODRow = getEOD("A",$i); print "&lt;tr&gt;"; for(; $j &lt; 12; $j++) { print "&lt;td&gt;$EODRow[$j]&lt;/td&gt;"; } print "&lt;/tr&gt;"; } </code></pre> <p>I return an array of values from the function.</p>
php
[2]
4,216,660
4,216,661
how do I get the viewport position relative to the screen?
<h3>My question</h3> <p>What JavaScript code will tell me where the <strong>viewport</strong> of the <strong>browser</strong> is located relative to the <strong>screen</strong>?</p> <h3>Context</h3> <p>My web application includes an applet that allows taking a snapshot via <em>java.awt.Robot</em> (the applet's jar is of course signed and is privileged to perform this).</p> <p>The problem is that Robot's <em>createScreenCapture</em> works with rectangles relative to the entire screen, whereas I want to capture a rectangle relative to the viewport.</p> <p>A browser can obviously be anywhere on the screen, but even if it is maximized (and therefore begins at the top left of the screen, i.e. {0,0}) I still don't know how much the content is pushed down because of the window header or some toolbars.</p> <h3>My research so far</h3> <p>It seems only IE gives the viewport position through <em>window.screenTop/Left</em>.</p> <p>Chrome supports these, but they hold the browser position.</p> <p>FF doesn't support these, instead it has <em>screenX/Y</em>, but like Chrome they hold the browser position.</p> <h3>Making sure we all use the same terminology</h3> <p><strong>Screen</strong> - AKA the desktop. for example I have a WSXGA+ (1680x1050) display. I use Windows and my taskbar is always shown at the bottom so it consumes about 50 pixels vertically.</p> <p><strong>Browser</strong> - a window that may or may not have various toolbars: address and/or bookmarks bar at the top, status/add-on bars at the bottom, etc.</p> <p><strong>Viewport</strong> - where a URL is actually being rendered.</p>
javascript
[3]
5,582,796
5,582,797
What is wrong with Java's generics?
<p>I have seen several times on this site posts that decry Java's implementation of generics. Now, I can honestly say that I have not had any issues with using them. However, I have not attempted to make a generic class myself. So, what are your issues with Java's generic support?</p>
java
[1]
2,776,627
2,776,628
Writing a configuration file in PHP
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7053947/writing-to-a-php-file">writing to a .php file?</a> </p> </blockquote> <p>So I have a config.php file for a CMS that I created from scratch. This file has the structure shown below:</p> <pre><code>&lt;?php date_default_timezone_set( "America/Phoenix" ); define( "DB_HOST_USER", "mysql:host=localhost;dbname=db_cms" ); define( "DB_USERNAME", "username" ); define( "DB_PASSWORD", "password" ); define( "CMS_TITLE", "Sample Title"); define( "USERNAME", "cms_user"); define( "PASSWORD", "cms_password"); ?&gt; </code></pre> <p>My question is that how can I write into this file and save it to the disk using PHP. Help would be greatly appreciated.</p> <p>Edit: I saw that WordPress uses similar kind of file structure to store user/application configuration as outlined <a href="http://phpxref.com/xref/wordpress/wp-config-sample.php.source.html" rel="nofollow">here</a>. I was just wondering if I can change above file (config.php) and store new setting in there. For instance, I want to set USERNAME to blog_user (<code>define( "USERNAME", "blog_user");</code>). Is it possible to just store this change without rewriting the entire file?</p>
php
[2]
5,750,463
5,750,464
JQuery change new line to line break in TEXTAREA
<p>I've been trying to change the new lines to line breaks in the <code>&lt;TEXTAREA&gt;</code> but I'm failing to do so ...</p> <p>I want to do this cause I take the value and append it to another <code>&lt;TEXTAREA&gt;</code> that is copied later on to the clipboard. When I copy to the clipboard, everything is set to a single line due to the <code>new line</code> in the <code>&lt;textarea&gt;</code></p> <p>Here is my code:</p> <pre><code>if(oInput.get(0).tagName == "TEXTAREA") { temp = oInput.val(); temp = temp.replace(/([^&gt;\r\n]?)(\r\n|\n\r|\r|\n)/g, '&lt;br /&gt;'); oInput.val() = temp.val(); } </code></pre>
jquery
[5]
696,687
696,688
Move constructor, non-const copy constructor, list's emplace in VS2010
<p>I'm new to move constructor and quite confused with VS2010 behavior. I design a move constructor (of class A) which in my knowledge is like this:</p> <pre><code>A(A&amp;&amp; input) {some code} </code></pre> <p>When I use list's emplace and put an instance of class A:</p> <pre><code>mylist.emplace(a); </code></pre> <p>My move constructor is not called, and a non-const copy constructor is called instead:</p> <pre><code>A(A&amp; input) {the same code as move constructor} </code></pre> <p>On the other hand when I do this:</p> <pre><code>mylist.emplace(A(2)); </code></pre> <p>My move constructor is called like it supposed to. So, my question is:</p> <ol> <li>Why is list's emplace call my non-const copy constructor instead of my move constructor?</li> <li>Is the non-const copy constructor is actually an alternative way to define a move constructor?</li> <li>Is this behavior is correct (for a c++0x compiler) or it just VS2010's behavior?</li> </ol> <p>Thanks a bunch in advance.</p>
c++
[6]
4,096,371
4,096,372
how do i pass a variable to a function in this context?(for an onclickevent)
<pre><code>function check(child) { var y = "&lt;span onclick=remove(" + child + ") onmouseover='hove(this)'&gt;x&lt;/span&gt;"; child = child + " " + y; send = '&lt;span class="elements" &gt;' + child + '&lt;/span&gt;' ; } function remove(child) { // some of mycode; } </code></pre> <p>These are the 2 functions I have. OK let me tell you this, child is a variable passed from one function to the check() function and again im trying to pass this child value to remove function, adding to the onclick event of span tag but it does not seem to work. I am unable to get out of this.</p> <p>I want to add onclick event to the span tag and it should pass the child value to remove function. Please help me with this. Any help is greatly appreciated. Thanks</p>
javascript
[3]
3,668,246
3,668,247
This jQuery code only works in IE - how to make it compatible with all browsers?
<p>How do I make this code work in all browsers?</p> <pre><code>&lt;script&gt; var $j = jQuery.noConflict(); $j(document).ready(function(){ if ($j.browser.msie) { $j('.round').append('&lt;div class="tl"&gt;&lt;/div&gt;&lt;div class="tr"&gt;&lt;/div&gt;&lt;div class="bl"&gt;&lt;/div&gt;&lt;div class="br"&gt;&lt;/div&gt;'); } }); &lt;/script&gt; </code></pre>
jquery
[5]
710,124
710,125
Awkward python class behaviour?
<p>I have the following simple code:</p> <pre><code>class Node: pass def make_node(value): n = Node n.value = value return n if __name__ == '__main__': list = range(100) random.shuffle(list) nodes = [] for i in range(len(list)): nodes.append(make_node(list[i])) for n in nodes: print n.value </code></pre> <p>Upon printing the value at each of the nodes, they are all identical. It seems that each "new node" i built simply overwrites the value of all of the previous ones. Why are these not being set completely separately, and how can I fix it?</p>
python
[7]
4,314,199
4,314,200
androidQ:saving a history between edittext and spinner
<p>I wanna save the SET of number in edittext and selected spinner item on limit of 10 line from new one. how to is the most popular way?</p>
android
[4]
4,981,813
4,981,814
WaterMark using c#
<p>I am working on a Kiosk application. There is a Maintenance mode in my application. When my application enters into Maintenance mode, i want to show the user a watermark "Maintenance Mode Commenced".</p> <p>I want this watermark to be shown through out my desktop. No matter what form is in focus. Is this possible ? Any ideas.... </p> <p>Note : This is Windows application using c#</p>
c#
[0]
5,325,965
5,325,966
Sqlite query not working when running on android device
<p>I am using few update queries to update my tables(Sqlite). They are working very well on my emulator. But, when I installed on my phone, they dont return sucess. At the same time,it does not throw any errors also. This is my code:</p> <pre><code> ContentValues msg_values = new ContentValues(); msg_values.put("folder_id", 1); int i=getContentResolver().update(MBContants.CONTENT_URI_SMS, msg_values, "address=" + msg.getAddress(), null); if(i&gt;0) System.out.println("done..!"); else Log.i("--------------------------------------------","not done"); </code></pre> <p>Where, I've created my db and the URI to my table is MBContants.CONTENT_URI_SMS, where MBContants class holds all the URI's.</p> <p>Please help solve this issue. Thanks, Viashnavi</p>
android
[4]
1,494,212
1,494,213
Cmmunication between server and mobile app
<p>Can I recognise server communication to my app without intiating or sending any request from my mobile app? Could anyone tell me any possibilities or ideas related to this? Any help will be greatly appreciated.</p> <p>Thanks in advance. Pratheeja</p>
android
[4]
2,640,403
2,640,404
How to set up VPN connection in our Android Application
<p>I am working an an Android project to set up a PPTP and L2TP VPN connection . I searching on this for almost two days and I understood that,We have to customize the Android SDK to make it functioning. But is it possible ? If possible ...how?</p> <p>If we are customizing the SDK,it will work only that handset. I want a portable app.<br> Is there any other way to make it..... Plz reply any one</p> <p>Thanx in advance</p> <p>heyjii </p>
android
[4]
5,123,392
5,123,393
The largest double value
<p>The question is about how to model infinity in C++ for the double data type. I need it in a header file, so we cannot use functions like numeric_limits. </p> <p>Is there a defined constant that represents the largest value? </p>
c++
[6]
384,961
384,962
Enumerable Range is not working quite right
<p>I have an enumerable range, and what I initially wanted to do with the range was loop through the stored list and get the minStop (minimum stoping point) and maxStart (max tarting pint) But I am only geting the min range and max range in my enumerable range and it is not giving me the values that I need. Please help me figure out what I am doing wrong. PLEASE!</p> <pre><code>List&lt;Grades&gt; ranges = new List &lt;Grades&gt;(); var strGrades = "40-50, 55-62, 65-72, 80-82, 85-92, 95-99, 110-115"; var splitGrades = strGrades.Split(char.Parse(",")); foreach(var item in splitGrades) { var splitAgain = items.Split(char.Parse("-")); var myMax = Math.Max(int.Parse(splitAgain[0]), int.Parse(splitAgain[1])); var myMin = Math.Max(int.Parse(splitAgain[0]), int.Parse(splitAgain[1])); //my enumerable list var erange = Enumerable.Range(int.Parse(myMax), int.Parse(myMax)).ToList() foreach (var maxrange in erange) { for (int q = myMin; q &lt; maxrange; q++) { //custom extension method for Between if (!q.Between((myMin), (myMax), true)) { //Public class Grades{public int Start, get; set } ranges.Add(new Grades() { Start= q, }); } } } } return ranges; } </code></pre> <p>Can anyone please show me how to get my enumerable range to get my minStop value (For example: first set of grades: 40-50, my min stop value would be 50, then get my next set of grade ranges 55-62, my max starting value would be 55, so I am looking to get the range from 50- 55, I need the last value from the each set and the beginning value for the set after that. I hope I am clear. Any help would be greatly appreciated! Thanks</p>
c#
[0]
4,664,258
4,664,259
PHP - IF div clicked/has class or id return code
<p>Some HTML</p> <pre><code>&lt;div class='menu_mcwiki'&gt; &lt;ul&gt; &lt;li&gt; &lt;p&gt; Blocks List &lt;/p&gt;&lt;/li&gt; &lt;li&gt; &lt;p&gt; Item List &lt;/p&gt;&lt;/li&gt; &lt;li&gt; &lt;p&gt; Potions &amp; Food &lt;/p&gt;&lt;/li&gt; &lt;li&gt; &lt;p&gt; NPC Trading &lt;/p&gt;&lt;/li&gt; &lt;li&gt; &lt;p&gt; Crafting &lt;/p&gt;&lt;/li&gt; &lt;li&gt; &lt;p&gt; Enchanting &lt;/p&gt;&lt;/li&gt; &lt;li&gt; &lt;p&gt;Legend:&lt;/p&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I would like to get something like, if you click on <code>&lt;li&gt;</code>, the if statement in php file will show an output.</p> <p>I thought to do it with javascript's <code>.addClass</code> <code>.removeClass</code> for add or remove class from <code>&lt;li&gt;</code>, and add to a php file if statement something like <code>{if has class1}</code> then show output, and if it doesn't exist: show anything.</p> <p>Can someone point me in the right direction? Sorry for my English.</p>
php
[2]
2,617,497
2,617,498
onTouch not working?
<p>Why its not going in onTouch method ? I am using Activity that implements onTouchListener and also I have android:onClick = ObjectClick in my xml where ObjectClick handles the click of the view . I am just using onTouch to get x , y but its not going in to ontouch function</p> <pre><code>public class GamePlayActivity extends Activity implements View.OnTouchListener { int click_Locn_x=1,click_Locn_y=1; // onCreate function is also there ..... public void objectClick(View objectClicked) { Toast msg; int [] locationOfViewInScreen=new int[2]; int Object = objectClicked.getId(); View img= (View)findViewById(Object); img.getLocationOnScreen(locationOfViewInScreen); Log.d("Check:","locn of Image" + locationOfViewInScreen[0]+ " "+ locationOfViewInScreen[1]); Log.d("Check:","locn of click" + click_Locn_x + " "+ click_Locn_y); } @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub Log.d("Check"," I am in onTouch Event "); click_Locn_x = (int)event.getX(); click_Locn_y = (int)event.getY(); return true; } </code></pre>
android
[4]
1,324,005
1,324,006
How to time a jQuery game with php
<p>I'm creating a jQuery game where the player has to complete a task in the quickest time possible. I display a timer so the user knows how long they are taking to complete the task.</p> <p>I've been reading up on cheating/hacking and it seems the only way to prevent it is to keep the important logic server side. My server side language of choice is php. As the important logic for my game is the time taken, I can set a timer when the game starts, and stop the timer with an ajax call when the game ends.</p> <p>I'm just wondering what to do if there is a lag between the ajax call being made and the server receiving the call. Say the user completes the task in 12 seconds but there is a 1 second lag for the ajax caqll to be recieved. The value written to the highscore table will be 13 seconds which will make for an unhappy player!</p> <p>Is the server side timer/ajax call the way to go here? Am I worrying too much about a lag? Is there a better way to go about timing a game?</p> <p>This is my first ever game so I'm unsure about the best way to stop cheating!</p>
jquery
[5]
5,402,927
5,402,928
Calling a particular function when multiple events are bound
<p>I have a site wide JS, which creates listeners for various events, but in certain conditions I need to call a particular function, like in code below, I need to call function <strong>call</strong>, but its not getting called. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; window.onload = function () { var inputs = document.getElementsByTagName("input"); var len = inputs.length; for (var i=0; i &lt; len; i++) { if (inputs[i].getAttribute("type") == "text") { var element = inputs[i]; element.onfocus = function() { var id = element.getAttribute("id"); alert(id); } } } } function call(element) { element.value=""; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" name="myvar1" value="same content" id="noviceid" onfocus="call(this);"&gt; &lt;input type="text" name="myvar2" value="same content" id="noviceid" onfocus="call(this);"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Please suggest. I would like to call both <strong>onfocus</strong>. I am new to javascript.</p>
javascript
[3]
3,693,956
3,693,957
Display multiple images from database using PDO mysql
<p>The situation: I could show only one image at a time.</p> <p>Problem: Show images from the database into a web page.</p>
php
[2]
1,014,852
1,014,853
High Precision Constants for Templated Code
<p>I am writing a template class which takes a floating-point-like type (float, double, decimal, GMP) as a parameter. However, my class requires various numeric constants. Some of these are rational numbers (int/int) while others are irrational and available to 30 or so decimal places.</p> <p>What is the best way to go about initialising these constants, so:</p> <pre><code>T c1 = &lt;constant&gt;; </code></pre> <p>where T is the templated type?</p> <p>While I could always fall-back on doubles (T c1 = 0.1415926535...) and rely on the compiler/implicit initialiser to convert to the appropriate type I would like to retain the extra precision if at all possible.</p> <p>I am interested in both current solutions and those which C++0x (or is it C++1x?) might bring to the table.</p>
c++
[6]
3,561,497
3,561,498
403 error in accessing an URL but works fine in browsers
<pre><code>String url = "http://maps.googleapis.com/maps/api/directions/xml?origin=Chicago,IL&amp;destination=Los+Angeles,CA&amp;waypoints=Joplin,MO|Oklahoma+City,OK&amp;sensor=false"; URL google = new URL(url); HttpURLConnection con = (HttpURLConnection) google.openConnection(); </code></pre> <p>and I use BufferedReader to print the content I get 403 error </p> <p>The same URL works fine in the browser. Could any one suggest. </p>
java
[1]
3,631,756
3,631,757
string variable shows wrong length
<p>So I have a function that gets some string variables from a form (after the form is submitted), then runs a query using those variables and returns lines of results. I have several conditions that work fine, except for one and I can't figure out what's wrong. When I print out the query and run it in phpMyadmin - it works just fine (returns 3 rows for example), but it doesn't run on the page (shows that 0 rwos are returned). One thing that I have noticed is that when I do var_dump it gives the correct type (string) but wrong length. trim doesn't make any difference. So fo example</p> <pre><code>$name2 = "John Doe"; var_dump($name1); var_dump($name2); </code></pre> <p>The name2 returns string(8) But when for name1 it returns string(9), even though name1 is also "John Doe" - I have no idea what that extra character is. That variable is coming from a form, from a select element. Select is populated from a table. I trim resulting POST value before assigning to name1. Character encoding is the same for the table where names in select element are coming from and table on which I run a query. All other variables from the form are passing fine and query runs correctly if I don't add the name. Again, if I print out the query (with name condition included) and copy and paste into phpMyAdmin - it runs just fine. I'm going crazy here.</p>
php
[2]
2,857,347
2,857,348
inheritance from xmlrpclib.ServerProxy in python
<p>Why this code doesn't work ?</p> <pre> #!/usr/bin/python2 from xmlrpclib import ServerProxy class ServerProxy1(ServerProxy): def __str__(self): return str(self.__host) proxy = ServerProxy1("http://workshop:58846/") print proxy </pre> <p>Original_<em>str</em>_:</p> <pre> def __repr__(self): return ( "" % (self.__host, self.__handler) ) __str__ = __repr__ </pre> <p>Result:</p> <pre> File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close raise Fault(**self._stack[0]) xmlrpclib.Fault: :method "_ServerProxy1__host.__str__" is not supported'> </pre>
python
[7]
1,376,755
1,376,756
ASP.NET - Populate a page with input entered from a previous page
<p>on my website I have an "Enroll" page where users submit some basic information, there's some basic validation on that page then the user is taken to an "Enrollment Confirmed" page (which i don't want to display the info from previous page). On the confirmation page there is link to a "Print Enrollment Confirmation" page which, on this page, I want to contain the information entered from the "Enroll" page. So basically, I want the input entered on "Page 1" put into labels on "Page 3". I've seen some examples of transferring information from "Page 1" to "Page 2" but I have an extra page users need to go through before hitting the page with their previously entered data. </p> <p>Can someone give me an explanation on how I could do this without using query strings? Thank you.</p>
asp.net
[9]
2,343,772
2,343,773
modulus operator in C#
<p>Which function we can use to find modulus of floating point value ?</p>
c#
[0]
3,642,422
3,642,423
Cannot get a jquery variable to pass it's declared value
<p>--In the variable line below I declared a variable (xwid) as 690. But when I try the code by using the variable of $xwid, the width never updates. Any ideas?</p> <pre><code>$xwid=690; // my var // my code $('.iframe-link').html( '&lt;iframe src="reasons.html" frameborder="0" width=$xwid height="305" scrolling="auto"&gt; </code></pre>
jquery
[5]
1,683,651
1,683,652
jquery getting value from getJSON
<p>I;m trying to get the value <code>'content'</code> from my json data</p> <p><strong>This is the data:</strong></p> <pre><code>[{"pk": 2, "model": "template", "fields": {"content": "message", "status": "Draft", "user": 16, "name": "test", "created": "2013-05-19T20:59:04Z"}}] </code></pre> <p><strong>This is what I have tried:</strong></p> <pre><code> $.getJSON('/sms/fetch/' + id, function (data) { $('#id_content').val($('#id_content').val() + data.fields.content); }) </code></pre> <p>but this does not seem to get the value, the value is within the call as shown above.</p>
jquery
[5]
2,050,670
2,050,671
button works only once
<p>i have a problem with my jquery code, a have a list of buttons witch changing display from none to block of some div and "save" button witch changing display from block to none, when i'm clicking again on same button from the list of buttons display is not changing, nothing happens, WHY ??</p> <p><a href="http://gidzior.net/svg/pom01.html" rel="nofollow">http://gidzior.net/svg/pom01.html</a> panel on the right is the '#right-panel li' and the red button is the 'div.save'</p> <p>buttons from '#right-panel li' should open a window and button 'div.save' should close it and then '#right-panel li' should open it again but shouldn't close it</p> <pre><code>$('#right-panel li').each(function(e){ var i = $(this).index() + 1; $(this).click(function(){ if(i&lt;10){ i = "0"+i; } $('#pom01par'+i+'WraperAbsolute').css('display', 'block'); $('#pom02par'+i+'WraperAbsolute').css('display', 'block'); $('#pom03par'+i+'WraperAbsolute').css('display', 'block'); $('#pom04par'+i+'WraperAbsolute').css('display', 'block'); $('#pom05par'+i+'WraperAbsolute').css('display', 'block'); $(this).css('background','#adff84'); $('.par'+i+'table').css('background','#adff84'); return false; }); }); $('div.save').click(function(){ $(this).parent().css('display','none'); }); </code></pre> <p><strong>UPDATE</strong></p> <p>well i found an error, when i'm clicking button with number from 1 to 9, script put 0 befor number 1-9 and the index is 01,02,03 ..., when i'm clicking it again the index is 001, 002, 003,... and so on, how do I set the index remained the same all the time ?? 01, 02, 03, 04, 05, 06, 07, 08, 09</p>
jquery
[5]
4,616,953
4,616,954
Returning to the Home Screen and then returning to last activity
<p>Having real issue understanding how to sort my issue out.</p> <p>On the Home screen I have 2 buttons</p> <p>When the user clicks the first button it starts a new Activity. What I am looking for is if the user clicks back the app returns to the home screen. If the user clicks the first button again it starts a new activity.</p> <p>If the user clicks the second button it returns to the activity that was last started by clicking button 1</p> <p>What I am having issue with is how to save the state of the activity when the user clicks back Also how to call that activity when the second button is pressed</p> <p>Thanks for your Time</p> <p>UPDATE</p> <p>I have gone down part of this but still having issues. If I put some of the code I am using perhaps someone can point where I gone wrong.</p> <p>Code for calling the new activity from main menu</p> <pre><code>Intent intent = new Intent(MainMenu.this, NewClass.class); intent.putExtra("value1", value1); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); </code></pre> <p>Within the new class I have added the following :</p> <pre><code> @Override public void onBackPressed() { //super.onBackPressed(); Intent intent = new Intent(RoundScoring.this, MainMenu.class); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent); Toast.makeText(this, "Back Button Pressed", Toast.LENGTH_LONG).show(); } </code></pre> <p>I do not have either a onrestoreinstancestate or onresumne in this class. only a oncreate. Do I have to add something like this to bring back the instance</p> <p>On the second button on the main menu I have added this</p> <pre><code>Intent intentContiune = new Intent(MainMenu.this, NewClass.class); intentContiune.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intentContiune); </code></pre> <p>Thanks</p>
android
[4]
4,210,870
4,210,871
Looping through unknown number of array arguments
<p>I am trying to figure out how to loop through several array arguments passed. For example: [1,2,3,4,5],[3,4,5],[5,6,7] If I pass it to a function, how would I have a function loop inside each argument (any number of arrays can be passed) ? </p> <p>I want to use a for loop here. </p>
javascript
[3]
3,164,152
3,164,153
Question about plentyoffish.com asp.net functionality
<p>One the frontpage of plentyoffish.com, the 'Continue' button (for the form submission) links to register.aspx. From what I can see the system does not use postback. So, my question is, how is the form data posted to register.aspx? What would that code look like?</p>
asp.net
[9]
3,780,132
3,780,133
video capture software for iPhone Simulator
<p>HI All, I m looking for a software/tool, which can lead me to capture my application in simulator.. I saw so many videos of application, which performs their functionality of application and capture it in video.</p> <p>Please suggest me some video capturing tool for my app promotion.</p> <p>Suggestions are always appreciated. regards</p>
iphone
[8]
2,119,024
2,119,025
iphone:significant location update not finding
<p>I am using a significant location, but showing update after a long distance.any clue please share.</p> <p>In <code>didfinishlaunching</code> I am starting significant changes and then storing from <code>didupdatelocation</code> delegate method of <code>locationmanager</code>;</p> <pre><code>id locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey]; if(locationValue) {NSLog(@"location value is%@",locationValue); // create a new manager and start checking for sig changes m_locManager = [[CLLocationManager alloc] init] m_locManager.delegate = self; [m_locManager startMonitoringSignificantLocationChanges]; //[m_locManager startUpdatingLocation]; [self.window addSubview:tabBarController.view]; [self.window makeKeyAndVisible]; [self showSplash]; return YES; </code></pre>
iphone
[8]
2,891,120
2,891,121
Checking for properties' validity in Python classes
<p>Where should I write codes for checking validity of class' properties? (For examples: "amount" should be a positive integer, "email" should be a string with correct e-mail formatting) At the setter methods, At somewhere I use that (using try/catch), or others.</p> <p>If I check validity at setter methods, it may be looked ugly (like type checking). But if I check it when using it, duplicated code may appeared when it is used many times.</p> <p>(Sorry for my poor English.)</p>
python
[7]
5,242,484
5,242,485
PDF opening inside a Current WebView Page
<p>My application current view is In web view..inside which if user clicks on a pdf link.it should get installed on sd card and then available options for viewing must be shown ..if no Viewer available then a message should be shown</p> <pre><code>protected void onStart() { super.onStart(); myWebView.loadUrl("URl"); myWebView.setWebViewClient( new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.endsWith("pdf")) { // do eet return true; } return false; } }); myWebView.getSettings().setJavaScriptEnabled(true); /*WebSettings webSettings = myWebView.getSettings(); \ webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true);*/ } </code></pre>
android
[4]
5,864,105
5,864,106
How can I get the name of the calling function in C#?
<p>I need to get the name of the calling function in C#. I read about stackframe method but everywhere its said its not reliable and hurts the performance.</p> <p>But I need it for production use. I am writing a custom tracer which will be logging the name of the method from which trace was called as well.</p> <p>Could someone please help with a efficient method to get the calling function name? I am using Visual Studio 2010.</p>
c#
[0]
3,497,118
3,497,119
What type to use for integers larger than 2^32?
<p>I have an integer variable, that can get a value larger than 4294967295. What type should I use for it?</p>
c#
[0]
4,796,745
4,796,746
How to access getResources() in non-activity class in Android?
<p>Please, refer the code below</p> <pre><code>ForegroundColorSpan ss = new ForegroundColorSpan(context.getResources().getColor(R.color.red_text)); </code></pre> <p>This is what i'm going to do, but it through an error. </p>
android
[4]
241,516
241,517
PHP simultaneous requests and temporary files
<p>For instance I have a .php that creates a temporary file, and the server receives multiple simultaneous requests for that .php.</p> <p>How the server is going to schedule the requests?<br> Are they going to be executed one after the other uninterrupted, or should I always assign a random name to my temporary files?</p>
php
[2]
4,117,708
4,117,709
I'm stuck trying to write a loop through an array for results in a toString
<pre><code>/** * get a formatted string with information about a competition. * * @return String String with information about a competition. * * The output should be in the following format: * &lt;pre&gt; * Rodent's Information: * Rat RFID 787878787 * Gender: F * Vaccination status: false * * Maze Information: * Start Time: 00:00:00 * End Time: 01:00:05 * Actual Time: 01:00:05 * Contest Time: 00:59:30 * &lt;/pre&gt; * */ public String toString() { // your code here, replace the "X" and -9 with appropriate // references to instance variables or calls to methods String output = "Competition Description: " + this.desc + "\nCompetition Count: " + this.count + "\n"; output += "Competition Results:" + "\n"; // loop through the array from beginning to end of populated elements for (int i = 0; i &lt; this.nextPos; ++i) { this.results[i].getRFID(); this.results[i].getGender(); // get toString() for each result return output; } </code></pre> <p>Hi everyone, I've been stuck on writing this toString for a couple of days now. Can someone please help me figure out how to write a loop for showing all the elements in the array from beginning to end. I just keep coming up stuck. As you can see, I have started writing a loop but now I have no clue if it is started out right. Thanks!</p>
java
[1]
1,619,609
1,619,610
Best site for posting Python code?
<p>Which sites are the best for posting Python code that actually works? To show/share, and get input? I would like to post my code. </p>
python
[7]
1,323,423
1,323,424
problem in scrolling jtable
<p>I'm putting the table in JScrollPane, but my table is not supporting vertical scrollable...if anyone can tell me where I'm going wrong. Here is my code..</p> <pre><code>PreparedStatement pst=c1.prepareStatement("select * from entry where visit_to_person=?"); pst.setString(1,visit_combo.getSelectedItem().toString()); ResultSet rs =pst.executeQuery(); while(rs.next()) { vno= rs.getString(1); vnam=rs.getString(2); vtp=rs.getString(3); pur=rs.getString(4); in=rs.getString(5); dat=rs.getString(6); String s[]={vno,vnam,vtp,pur,in,dat}; Vector coldata=new Vector(Arrays.asList(s)); rowdata.add(coldata); } String[] head={"VISITOR NO","VISITOR NAME","VISIT TO PERSON","PURPOSE","IN TIME","DATE"}; colname=new Vector(Arrays.asList(head)); tableModel =new DefaultTableModel(rowdata, colname); table = new JTable(tableModel); // table.isCellEditable(i, n); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JTableHeader header = table.getTableHeader(); JScrollPane pane = new JScrollPane(table); pane.setAutoscrolls(true); pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); pane.setSize(450,300); pane.setVisible(true); panel.add(pane,BorderLayout.CENTER); JFrame.setDefaultLookAndFeelDecorated(true); } </code></pre> <p><strong>i hope to get a reply soon</strong></p>
java
[1]
4,857,256
4,857,257
Image made through Toolkit returns -1 as width,height
<pre><code>java.awt.Toolkit kit = Toolkit.getDefaultToolkit(); try { java.awt.Image img,ig; img = kit.getImage("/home/aditya/Pictures/tile.png"); ig = javax.imageio.ImageIO.read( new java.io.File("/home/aditya/Pictures/tile.png")); } int w = img.getWidth(null); int wp = ig .getWidth(null); int h = img.getHeight(null); int hp = ig .getHeight(null); System.out.println(wp+" "+hp+" "+w+" "+h); </code></pre> <p>Always gives this output </p> <pre><code>59 64 -1 -1 </code></pre> <p>i.e. width,height of image created through toolkit always returns -1.</p> <p>Any idea ?</p>
java
[1]
3,020,697
3,020,698
can we specfity directory path with the property file while using ResourceBundle class in java
<p>I want to place my properties files in some folder, but i am not able to read them because we can specify only the bundle name in static getBundle method on ResourceBundle object.</p> <p>Suppose bundle is : myFile.properties</p> <p>current path is : src</p> <p>i want to keep my properties file in : src/temp</p> <p>so when i am using : </p> <p>ResourceBundle.getBundle("temp/myfile", currentLocale);</p> <p>it is throwing an exception "can't find bundle".</p> <p>I want some way to specify the path.</p> <p>Please suggest me some way to do this. Thankyou</p>
java
[1]
1,492,522
1,492,523
Cloning an Object in Java
<p>I am trying to clone a DTO. I have taken a DTO Object as shown:</p> <pre><code>public class Employee implements Cloneable { String name; String dept; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDept() { return dept; } public void setDept(String dept) { this.dept = dept; } } </code></pre> <p>But this line is giving me Error :</p> <pre><code>public class Test { public static void main(String args[]) { Employee emp1 = new Employee(); emp1.setDept("10"); emp1.setName("Kiran"); Employee emp2 = (Employee) emp1.clone(); // This Line is giving error . } } </code></pre> <p>My query is that clone method is from <code>Object</code>, so why can't we use it directly like we do the `toString Method?</p>
java
[1]
1,268,071
1,268,072
stream_get_contents gets stuck on persistent (KeepAlive) connection
<p>stream_get_contents doesn't seem to handle persistent (KeepAlive) connections correctly. It waits for the connection to timeout before returning. Apache 2.2 has a KeepAliveTimeout of 5 seconds by default. Is there anything I can do about this? (Aside from disabling KeepAlive on the server, or using protocol_version 1.0)</p> <pre><code>$opts = array('http' =&gt; array( 'method' =&gt; 'GET', 'protocol_version' =&gt; 1.1, ) ); $context = stream_context_create($opts); $stream = fopen('http://google.com', 'r', false, $context); $metadata = stream_get_meta_data($stream); $data = stream_get_contents($stream); fclose($stream); </code></pre> <p>Thanks.</p>
php
[2]
5,990,140
5,990,141
Problem with content page in a different folder than master page
<p>I have put the master page in the main directory and content page in a different folder in the same directory. When I try to debug the page, it does not show me any error but the images on the master page are not visible. The content page works fine if it is in the directory itself without any folders. Can anyone let me know if I am missing something here.</p>
asp.net
[9]
1,717,212
1,717,213
Event handler on specific select value with jquery
<p>I am wondering how to fire an event in jQuery based on a specific select value. So, for example i have a small select and div like so:</p> <pre><code>&lt;select id="sweets"&gt; &lt;option value ="Option1"&gt;Option 1&lt;/option&gt; &lt;option value ="Option2"&gt;Option 2&lt;/option&gt; &lt;option value ="Option3"&gt;Option 3&lt;/option&gt; &lt;/select&gt; &lt;div id='showthis'&gt;You have selected option 2&lt;/div&gt; </code></pre> <p>I want to do something like;</p> <p>if the user select Option 2, </p> <pre><code>$('#showthis').show(); </code></pre> <p>if the user selects any other option,</p> <pre><code>$('#showthis').hide(); </code></pre> <p>I am fairly new to jQuery and i'm not sure how to do a change event based on a specic select value. Any help would be greatly appreciated.</p>
jquery
[5]
3,524,824
3,524,825
Can I have properties hidden from console.log?
<p>Is it possible to have properties of an object <code>a</code> that do not show up when doing <code>console.log(a)</code>?</p>
javascript
[3]
1,927,132
1,927,133
uses-library in AndroidManifest.xml
<p>I currently have this in my AndroidManifest.xml</p> <p><strong>uses-library android:name="com.google.android.maps" android:required = "false"</strong></p> <p>The specified requirement of google map api is not compulsory. (This enables me to install my application on an none-google-api emulator)</p> <p>However, this only works for API level 7, Platform 2.1 <strong>It doesn't work for API level 4, Platform 1.6</strong></p> <p>I am getting an error message when I am compiling - " <strong>No resource identifier found for attribute 'required" in package 'android'</strong></p> <p>But, when I looked at the documentation here: <a href="http://developer.android.com/guide/topics/manifest/uses-feature-element.html" rel="nofollow">http://developer.android.com/guide/topics/manifest/uses-feature-element.html</a></p> <p>The attribute 'required' is introduced since level 4.</p> <p>Could somebody help me out!</p> <hr> <p>Thanks Aillyn</p> <p>I think it impossible to include required attribute in uses-library tag.</p> <p>Is there a way to include uses-library in the java code rather than in the AndroidManifest.xml??</p>
android
[4]
1,839,990
1,839,991
Creating an app that has an option to get location information even when it's not running
<p>What's the best way to create an app that periodically gets location (via the GPS or cell towers, or whatever) even when the app isn't running?</p> <p>The first idea I had is to use the AlarmManager to wake up at a specified interval and check. I'm wondering if there's a more specific API to use.</p>
android
[4]
215,282
215,283
how to remove html tags from string in c#
<p>i have something like </p> <pre><code>&lt;h1&gt; I am Text &lt;/h1&gt; </code></pre> <p>in asp.net mvc</p> <p>if i want to write it by <code>&lt;%: mystring%&gt;</code> that he show the tags who filled by someone.</p> <p>how i can decode it then he show <code>" I am Text "</code></p> <p>i just want to show the source from CKEDITOR to page without HTML tags. if i use regex then the all tags hide even user use to fill the information</p>
c#
[0]
4,563,617
4,563,618
How can I sort the keys of a Map in Java?
<p>This is a very basic question, I'm just not that good with Java. I have a Map and I want to get a list or something of the keys in sorted order so I can iterate over them.</p>
java
[1]
4,068,315
4,068,316
Javascript Call And Apply used together
<p>I know the <strong>call</strong> and <strong>apply</strong> in javascript but how does exactly the difference between javascript Call and Apply..?? and another thing i found some code use this together like this:</p> <pre><code> function doSomething() { return Function.prototype.call.apply(Array.prototype.slice, arguments); } </code></pre> <p>are is the same as..</p> <pre><code>Array.prototype.slice.apply(arguments) </code></pre> <p>Why we want to use call and apply together?</p>
javascript
[3]
2,414,318
2,414,319
getting a string value from object
<p>Hello I have an object which has value "B11" i.e </p> <pre><code>object data = "B11"; </code></pre> <p>i have a variable called string resultCell. How do I get B11 into resultCell. </p> <p>it doesn't seem to work for me in c#. I have tried things like ....</p> <pre><code>resultCell = (string)data; resultCell = Convert.ToString(data); </code></pre> <p><strong>More information</strong></p> <p>I am using excel services to get a value in a cell. the excel services returns a object[]. Its a single element though. I want the value in a string. i.e. B11 in the object as string.</p>
c#
[0]
3,491,966
3,491,967
Is there any sizeof-like method in Java?
<p>Is there any built-in method in Java to find the size of any datatype? Is there any way to find size?</p>
java
[1]
4,256,898
4,256,899
DOM loading using javascript
<p>How can we control the loading of images, text and other elements like <a href="http://www.morsa.in/" rel="nofollow">http://www.morsa.in/</a></p> <p>using javascript</p>
javascript
[3]
591,956
591,957
Javascript How do i call functions from an array of function names
<p>var action = ['function1','function2' etc ]</p> <p>var obj = new objectcreate ();</p> <p>for (functionname in action){</p> <p>obj+'.'+action[variablename]+'()';</p> <p>}</p> <p>the functions are already generated I just wanna go through an array and execute all the functions it on the object i created thanks for your help</p>
javascript
[3]
4,874,344
4,874,345
how to redirect to another page in same window in javascript
<p>i am creating an application in which i am using image transitions slideshow. in image slideshow i used hyperlink to go another page. but page open in new window. i want page open in same window.</p> <pre><code>flashyslideshow.prototype.getSlideHTML=function (index) { var slideHTML= (this.imagearray[index][1])?'&lt;a href= "' + this.imagearray[index][1]+'" target = "'+this.imagearray[index][2]+ "_self" '"&gt;\n' : ''; //hyperlink slide? slideHTML+='&lt;img src="'+this.imagearray[index][0]+'" height="550" width="100%" &gt;'; slideHTML+=(this.imagearray[index][1])? '&lt;/a&gt;&lt;br /&gt;' : '&lt;br /&gt;'; slideHTML+=(this.imagearray[index][3])? '&lt;font face="bookman old style" color="blue" size="3"&gt;' + this.imagearray[index][3] : ''; //text description? return slideHTML; //return HTML for the slide at the specified index } </code></pre>
javascript
[3]
468,596
468,597
How do I split text by "," and get rid of the "," in java?
<p>I want to split and get rid of the comma's in a string like this that are entered into a textfield:</p> <p>1,2,3,4,5,6</p> <p>and then display them in a different textfield like this:</p> <p>123456</p> <p>here is what i have tried.</p> <pre><code> String text = jTextField1.getText(); String[] tokens = text.split(","); jTextField3.setText(tokens.toString()); </code></pre>
java
[1]
496,470
496,471
Cut string obtained with Javascript inside hyperlink
<p>I made a bookmark that users can add and it sends them to my site capturing the referrer. </p> <pre><code>&lt;a href="javascript:location='http://www.chusmix.com/tests/?ref='+escape(location.href);" onclick="alert('Drag it, not click it!');return false;"&gt; Bookmark &lt;/a&gt; </code></pre> <p>My problem is that for some reason the location.href part instead of printing http:// it prints: "http%3A//". I want to remove it and get just the domain.com</p> <p>I have a similar code that maybe could be useful but I'm having a hard time figuring out how to implement it inside HTML.</p> <pre><code>// Function to clean url function cleanURL(url) { if(url.match(/http:\/\//)) { url = url.substring(7); } if(url.match(/^www\./)) { url = url.substring(4); } url = "www.chusmix.com/tests/?ref=www." + url; return url; } &lt;/script&gt; </code></pre> <p>Thanks</p>
javascript
[3]
3,154,488
3,154,489
Why use finally instead of code after catch
<p>Why do this </p> <pre><code>} catch (SQLException sqle) { throw new DAOException(sqle.getMessage(), sqle); } finally { cs.close(); rs.close(); } </code></pre> <p>Instead of this</p> <pre><code>} catch (SQLException sqle) { throw new DAOException(sqle.getMessage(), sqle); } rs.close(); cs.close(); </code></pre>
java
[1]