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
589,967
589,968
How can i construct a variable name in code from a string?
<p>I have a number of variables named test1....test10 they are all declared as a string.</p> <p>what I want to do is access them from inside a loop using the loop counter something like this:</p> <pre><code>string test1; //... string test10; for (int i = 1; i &lt; 10; i++) { test + i.ToString() = "some text"; } </code></pre> <p>any idea how I could do this? this is a WPF .net 4 windows App.</p>
c#
[0]
621,295
621,296
can we add data for sql database within the application
<p>Can i add the data with in the application like as enclosed below. </p> <p>public long createEntry(String lat, String log, String name, String value, String light){</p> <pre><code> ContentValues cv = new ContentValues(); cv.put(KEY_LAT, 30); cv.put(KEY_LOG, 40); cv.put(KEY_NAME, raj); cv.put(KEY_VALUE, 40); cv.put(KEY_LIGHT, A); DATABASE_NAME.insert(DATABASE_TABLE,KEY_ROWID, cv); cv.put(KEY_LAT, 40); cv.put(KEY_LOG, 50); cv.put(KEY_NAME, ken); cv.put(KEY_VALUE, 70); cv.put(KEY_LIGHT, B); DATABASE_NAME.insert(DATABASE_TABLE,KEY_ROWID, cv); cv.put(KEY_LAT, 60); cv.put(KEY_LOG, 40); cv.put(KEY_NAME, lee); cv.put(KEY_VALUE, 80); cv.put(KEY_LIGHT, A); DATABASE_NAME.insert(DATABASE_TABLE,KEY_ROWID, cv); </code></pre> <p>}</p>
android
[4]
4,154,260
4,154,261
Not able to put ArrayList into Bundle in onSaveInstanceState
<p>Is any way to put this into Bundle during <code>onSaveInstanceState</code>?</p> <pre><code>public static ArrayList&lt;StringProArrayList&gt; splnenoNa1 = new ArrayList&lt;StringProArrayList&gt;(); </code></pre> <p>The method <code>putStringArrayList</code> don't work.</p>
android
[4]
2,036,826
2,036,827
Does making an apk take two hours?
<p>I have asked someone to make me an app. I want to test it and asked him if he can email me the apk twice every day with the changes he made that day.</p> <p>He told me it takes too long to set up that apk twice every day, that it takes a couple of hours. Is that true?</p>
android
[4]
4,616,769
4,616,770
How to detect whether a keyboard is present or not
<p>How does android detects whether a keyboard is present or not? Which file I should modify if I need to change the way android detects the keyboard.</p>
android
[4]
381,498
381,499
What kind of User data I can collect
<p>I was wondering if I ever need to collect any kind of user data (like their location, which I don't think I should collect now, their IMEI, their google account, app usage time etc), then how much of it I can collect without doing so illegally.</p> <p>I know there will be issues with all of them, but since I couldn't find any document or question on SO, addressing this topic, telling me what kind of data I can collect, I am here with a question.</p> <p>Hope to get nice answers.</p> <p>Wish to mark it as a community wiki.</p>
android
[4]
3,712,774
3,712,775
Jquery best practice, checking for the existence of button/link before attaching an event
<p>I have a web page with buttons and links that may or may not exist. I have jQuery that runs and assigns <code>click</code> events to these buttons and links.</p> <p>Is it bad practice <em>not</em> to check for the existence of the buttons or links before I try to attach <code>click</code> or any other events? What are the repercussions?</p> <p>If I should check for the button and link existence, what technique is best practice? Checking the length like so - <code>$('myButton').length != 0</code> or some other manner?</p>
jquery
[5]
932,335
932,336
how to set margin between TableRow android
<p>I found a lot of solutions about TableRow margin, but when I tried the rows dont margin at all. </p> <p>This is my code:</p> <pre><code> TableLayout table = (TableLayout)findViewById(R.id.myTableLayout); for (int i = 0; i &lt; 3; i++) { TableRow tr = new TableRow(this); LayoutParams layoutParams = new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); int leftMargin=110; int topMargin=100; int rightMargin=100; int bottomMargin=100; layoutParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin); tr.setLayoutParams(layoutParams); tr.setBackgroundResource(R.drawable.shelf_bar); table.addView(tr, new TableLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); } </code></pre> <p>This is my expected result :</p> <p><img src="http://i.stack.imgur.com/eLrMd.jpg" alt="enter image description here"></p> <p>Please anyone point my mistake out. Thanks</p>
android
[4]
2,937,431
2,937,432
Assigning a name to a pattern-matched item in Python
<p>I'm trying to do the following:</p> <pre><code>def f( a=(b,c,d) ): pass </code></pre> <p>But the interpreter complains that b is not defined when I do this. Is there a "Pythonic" way of getting the intended result? I know that I could do something like the following: </p> <pre><code>def f( (b,c,d) ): a = (b,c,d) pass </code></pre> <p>But I'd rather a solution that didn't require me to repeat myself. Any ideas?</p> <p><strong>Edit for clarification</strong>: What I am trying to do is have a function that can be called as follows:</p> <pre><code>f( (1,2,3) ) </code></pre> <p>Then, within the body of the function, the following names are assigned:</p> <pre><code>a = (1,2,3) b = 1 c = 2 d = 3 </code></pre>
python
[7]
2,685,502
2,685,503
Using threadpool and func objects
<p>When using a thread pool and its queuecallbackitem, can I not pass in a func object (from the method parameter)? </p> <p>I don't see a func which takes one parameter but returns nothing. There is<code> func&lt;T, TResult&gt;</code> but how can I set TResult to be null (want to indicate "this method returns void")?</p> <p>Also, how could I use the threadpool for methods which return and take all sorts of paremeters? Could I not store Func objects in a generic collection and also an int to indicate priority, then execute those funcs?</p> <p>Finally, in a static object (such as collection), what synchronisation in a global application would it need?</p>
c#
[0]
5,378,451
5,378,452
Ignore if there is URL
<p>This question is continuation of: <a href="http://stackoverflow.com/questions/14880551/garbage-values-coming-on-pulling-data-from-wordpress">Garbage values coming on pulling data from wordpress</a></p> <p>I have dealt with the garbage value by using following piece of code:</p> <pre><code> htmlentities($entry-&gt;title, ENT_QUOTES | ENT_IGNORE, 'UTF-8') </code></pre> <p>The problem with above piece of code is that if there is any url in the data then instead of showing that url it breaks the url to something like following:</p> <p><code>&amp;#8230; &lt;a href="http://abc.com/blog/"&gt;Continue reading &lt;span class="meta-nav"&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;</code></p> <p>Kindly let me know how to ignore if there is url.</p>
php
[2]
2,799,292
2,799,293
System.DirectoryServices.AccountManagement.PrincipalOperationException Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
<p>I'm having a hard time figuring this one out.</p> <p>I have an application that reads active directory. This application is installed on 6 machines. I have one machine that produces this error every time it's ran.</p> <p>The call to active directory is wrapped in an Impersonator class that uses an domain administrator account. </p> <p>This machine being used is Windows 7 with .Net 4.0 installed. Any help would be awesome, below is the code. This is a winform application.</p> <pre><code> List&lt;string&gt; User_Collection = new List&lt;string&gt;(); using (new Tools.Impersonator("ad", "domain", "11")) { PrincipalContext yourOU = new PrincipalContext(ContextType.Domain, "dc1", "OU=Ty,OU=Cal,OU=me,DC=domain,DC=net"); GroupPrincipal findAllGroups = new GroupPrincipal(yourOU, "*"); PrincipalSearcher ps = new PrincipalSearcher(findAllGroups); foreach (var group in ps.FindAll()) { if (group.ToString().ToLower().Contains("global")) { } else if (group.ToString().ToLower().Contains("vendor")) { } else if (group.ToString().ToLower().Contains("user")) { User_Collection.Add(group.ToString()); } } User_Collection.Sort(); foreach (string au in User_Collection) { comboBox1.Items.Add(au); } } </code></pre>
c#
[0]
835,378
835,379
Question about C++ inner class
<p>HI,</p> <p>In C++ inner class,</p> <pre><code>class A { public: void f1(); private: void f2(); class B { private void f3(); }; } </code></pre> <p>Does an inner class (B) has a pointer to its parent class (A)? (like it does in Java). And can B calls its parent class public/private method (like it does in Java).</p> <p>Thank you.</p>
c++
[6]
863,872
863,873
Can I prevent the screen from turning on for an incoming phone call?
<p>I have seen questions that are somewhat similar to this, but none that answer this question. If I wanted to be able to prevent the screen from turning on at all when receiving an incoming call, is this possible? I know it may sound bizarre, but it would only act this way exactly when the user would want it to, particularly at night, and they would be well aware of this behavior.</p> <p>I'd still want it to turn on if they pressed the unlock button of course, just not when receiving an incoming call.</p> <p>I've experimented with Screen Brightness and Screen Timeout, but it still turns on the screen while the call is ringing. I would like it to act similarly to when you receive a notification message, where you see the blinking indicator, but the screen never turns on.</p> <p>Thanks a lot in advance for the help, I appreciate it! Paul</p>
android
[4]
4,068,473
4,068,474
Using SetTimeout and .each Jquery
<p>I want to use settimeout() function with .each function.Basically iwant to show each image for 5 seconds and then next but i am only able to see last image.The .each executes and do not stop for 3 seconds.How can i do this?This is how i am doing.</p> <pre><code> &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $('#Images').find('li').each(function () { var img = this; setTimeout(function () { Start(img); }, 3000); }); }); function Start(img) { $('#slideshow').html(img); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div id="slideshow"&gt; &lt;/div&gt; &lt;div style="display:none;"&gt; &lt;ul id="Images"&gt; &lt;li&gt;&lt;img src="images/ajax-loader.gif" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="images/Ajax Loader White.gif" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="images/fancybox_sprite.png" /&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p> </p>
jquery
[5]
541,295
541,296
How to obtain the possible duration of idle time of phone based on its current battery level
<p>I am new to the android programming environment. I am currently working on a project which deals with the user's phone battery level.I am showing the current battery level left on the phone.now i want to display the amount of duration of "idle time, talk time, video playback, audio playback and web surfing" that can be done based on the current battery level.Please help me.What kind of approach shall i follow.(or) What available API shall i use to get those.</p> <p>Thanking You</p>
android
[4]
4,093,417
4,093,418
Global declaration in iOS
<p>i have this code for storing information about username,password,costomerkey etc etc in .h file</p> <pre><code>extern NSString * const consumerKey; extern NSString * const consumerSecret; extern NSString * const userStoreUri; extern NSString * const noteStoreUriBase; extern NSString * const shardId; extern NSString * const username; extern NSString * const password; </code></pre> <p>in .m file </p> <pre><code> NSString * const consumerKey = @"mynote"; NSString * const consumerSecret = @"45fv66gtt"; NSString * const username = @"john55";// need to be dynamic instead of john55 textfiledusername.text; NSString * const password = @"sjo555"; NSString * const userStoreUri = @"https://www.evernote.com/edam/user"; NSString * const noteStoreUriBase = @"https://www.evernote.com/edam/note/"; @implementation evernoteloginpage </code></pre> <p>but here all the values are sttcaly cretae,i want the username and password toy be dynamic,by using text filed .when the login button is clicked it needs to set the text filed values to the string username and password like this.<code>textfiledusername.text = username</code> in button click,for the dynamic creation of username and password. but i put <code>NSString * const username = textusername.text;</code> i got errors because i put this before implementation method.how t mke this possible? please help me to do this.</p>
iphone
[8]
1,192,297
1,192,298
SharedPreferences
<p>I'm creating a <code>SharedPreferences</code> and it's working only if I start Activity like this:</p> <pre><code>myIntent.putExtra("prefName", MYPREFS); startActivity(myIntent); </code></pre> <p>But my SharedPreferences is not working after I save it and hit back a few times, to go at menu page and go to the page where I want to get my preferences.</p> <p>Anyone can help me with that?</p> <p>Code below: </p> <p>This is where I save my preferences:</p> <pre><code>String MYPREFS = "MyPref"; SharedPreferences mySharedPreferences; SharedPreferences.Editor myEditor; </code></pre> <p>Inside onCreate:</p> <pre><code>mySharedPreferences = getSharedPreferences(MYPREFS,0); myEditor = mySharedPreferences.edit(); </code></pre> <p>Inside button onClickListener:</p> <pre><code> myEditor.putString("address", AddressET.getText().toString()); myEditor.putString("contact", ContactET.getText().toString()); myEditor.commit(); Intent myIntent = new Intent(myContext, nok_individual_particular.class); myIntent.putExtra("prefName", MYPREFS); startActivity(myIntent); </code></pre> <hr> <p>This is the activity I pass to:</p> <pre><code>SharedPreferences mySharedPreferences; </code></pre> <p>Inside onCreate:</p> <pre><code>Intent myReceivingIntent = getIntent(); String myPREFName = myReceivingIntent.getStringExtra("prefName"); mySharedPreferences = getSharedPreferences(myPREFName, 0); applySavedPreferences(); </code></pre> <p>In the applySavedPreferences method:</p> <pre><code> String addressValue = mySharedPreferences.getString("address", "Jack Smith"); String contactValue = mySharedPreferences.getString("contact", "Jack Smith"); addressTV.setText(addressValue); contactTV.setText(contactValue); </code></pre>
android
[4]
305,895
305,896
Private storage folder to store paid app specific content in Android?
<p>I'm developing an app that would have an In-app purchase and download Videos from my server and store them on the device. The problem is, the Videos are paid videos and are to be maintained in a highly secure place <strong>inside the app itself.</strong></p> <p>What are the possibilities of doing it? I had a look at setting <code>android:exported="false"</code>, but it just restricts other apps to access my app's data. But how do I store the videos in a place which are restricted to be viewed by default even when connecting the device to a PC? </p> <p>Are the apps allowed to store data in the device's <code>\data</code> folder? If so, please tell me how!</p>
android
[4]
5,536,326
5,536,327
Is eventKit supported in IOS 3.0
<p>Is eventKit is not supported on 3.0 - it's giving me this message below on my 3.0 iPhone</p> <blockquote> <p>dyld: Library not loaded: /System/Library/Frameworks/EventKit.framework/EventKit</p> <p>Referenced from: /var/mobile/Applications/B50DB029-19WE-481A-9090-3748EC4DD415/abc.app/abc</p> <p>Reason: image not found</p> <p>Data Formatters temporarily unavailable, will re-try after a 'continue'. (No memory available to program now: unsafe to call malloc)</p> </blockquote> <p>Please let me know how to resolve this.</p> <p>Appreciate it</p>
iphone
[8]
1,954,159
1,954,160
Error Installing Android SDK Platform Tools
<p>I have downloaded eclipse, the android SDK starter package, and installed the "Developer Tools." Following the guide on developer.android.com exactly. After the developer tools have installed, and eclipse restarts I get two error messages: </p> <p>1: <code>"SDK Platform Tools component is missing! Please use the SDK Manager to install it."</code></p> <p>So, I go in eclipse under Windows > Android SDK Manager and while trying to fetch the files it brings up the sdk manager log with the following:</p> <pre><code> Fetching https://dl-ssl.google.com/android/repository/addons_list-1.xml Failed to fetch URL https://dl-ssl.google.com/android/repository/addons_list-1.xml, reason: Invalid argument: connect Fetched Add-ons List successfully Fetching URL: https://dl-ssl.google.com/android/repository/repository-5.xml Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-5.xml, reason: Invalid argument: connect Done loading packages. </code></pre> <p>Because of this error I cannot use the SDK Manager to install it. Any ideas on how to fix this?</p> <p>2: "Failed to initialize Monitor Thread: Unable to establish loopback connection." No idea what this one means.</p> <p>Any help would be greatly appreciated. I have spent a few hours googling trying to find fixes but nothing seems to work, or the fixes refer to a non-existent "settings" window. </p>
android
[4]
412,337
412,338
What are the pros and cons of the various Python implementations?
<p>I am relatively new to Python, and I have always used the standard cpython (v2.5) implementation. </p> <p>I've been wondering about the other implementations though, particularly Jython and IronPython. What makes them better? What makes them worse? What other implementations are there?</p> <p>I guess what I'm looking for is a summary and list of pros and cons for each implementation.</p>
python
[7]
930,950
930,951
How to get method parameter in an array?
<p>Imagine in a class you got this Method:</p> <pre><code>float Do(int a_,string b_){} </code></pre> <p>I'm trying to do something like this:</p> <pre><code>float Do(int a_, string b_) { var params = GetParamsListOfCurrentMethod(); //params is an array that contains (a_ and b_) } </code></pre> <p>Can someone help ?</p> <p>Why should I want to do thet ?</p> <p>Imagine you got an Interface:</p> <pre><code>public Interface ITrucMuch { float Do(int a_,string b_); // And much more fct } </code></pre> <p>And a lot of classes implementing that interface</p> <p>And a special class that also implement interface:</p> <pre><code>public class MasterTrucMuch : ITrucMuch { public floatDo(int a_, string b_) { ITrucMuch tm = Factory.GetOptimizedTrucMuch(); // This'll return an optimized trucMuch based on some state if(tm != null) { return tm.Do(a_,b_); } else { logSomeInfo(...); } //do the fallback method } </code></pre> <p>As the interface constains a lot of method and as the first lien of all method are always the same (checking if there is a better interface that the current instance and if so call the same method on the instance) I try to make a method of it. </p> <p>Thx</p>
c#
[0]
1,553,587
1,553,588
android app unable run in Motorola droid
<p>Hi i am new to android. i developed an android app using 2.1 version in eclipse Ganymede. i used SQLite data base to store data and it will show the stored values when loading page My app is running perfectly in Sony Ericsson Xperia but it was not working in motorola droid which is having os Android 2.1 i dont know what is the cause. is there need to give any special permissions in manifest file to run app in droid or other mobile comapanies or any other issue occured by using the SQLite database?</p> <p>Please respond for my request</p>
android
[4]
2,013,321
2,013,322
c++ while loop repeats
<p>I have the following code. When something like <code>jackpot</code> is inputted, it prints out the cout 8 times, once for each character. Why is it doing this? Information is a structure and number is an integer. </p> <pre><code>do { cout &lt;&lt;"Please input a valid number."&lt;&lt; endl; cin&gt;&gt;information.number; if (!cin) { cin.clear(); cin.ignore(); } } while(information.number&gt; 12 || information.number&lt; 1); </code></pre>
c++
[6]
3,317,936
3,317,937
upload data to server memory
<p>I'm using PHP</p> <p>I understand that its possible to upload value to the server memory</p> <p>Lets says that every user have table of permissions for the website</p> <p>I don't want to do query for permission every time user load some page. I s it possible to load all permission in advanced to the server memory and pull them every time he slide to a new page?</p> <p>Thank you in advance, Roi.</p>
php
[2]
656,904
656,905
Adding elements to a page dynamically and then removing them
<p>I set up a jQuery control that adds a table containing textboxes to a page dynamically.</p> <p>The adding part works fine, but the remove function at the end fires no matter where I click in the table...I just want it to remove the table when I click on the remove button.</p> <p>Is there a better way to set this up?</p> <p>Thanks</p> <pre><code> var linkCounter = 1; $("#btnAddLink").click(function () { if (linkCounter &gt; 10) { alert("Only 10 learning objectives allowed per page."); return false; } var newTextBoxDiv = $(document.createElement('div')).attr("id", 'link' + linkCounter); newTextBoxDiv.after().html( '&lt;table&gt;' + '&lt;tr&gt;&lt;td&gt;' + '&lt;label&gt;URL: &lt;/label&gt;' + '&lt;/td&gt;&lt;td&gt;' + '&lt;input type="text" name="tbLinkUrl" style="width: 300px;"' + '" id="tbLinkUrl' + counter + '" value="" &gt;' + '&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;' + '&lt;label&gt;Label: &lt;/label&gt;' + '&lt;/td&gt;&lt;td&gt;' + '&lt;input type="text" name="tbLinkLabel" style="width: 300px;"' + '" id="tbLinkLabel' + counter + '" value="" &gt;' + '&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'); newTextBoxDiv.Append.Html( '&amp;nbsp;&amp;nbsp;&lt;input type="button" value="Remove" class="removeLink"&gt;').click(function () { $(this).remove(); linkCounter--; }); newTextBoxDiv.appendTo("#linksGroup"); linkCounter++; }); </code></pre>
jquery
[5]
4,917,569
4,917,570
implement seek bar in media player on android
<p>in my app i am storing all song file name,path from sdcard into data base and play one by one with seek bar. my problem is i get null pointer exception println needs a message. the file name is exist and valid one.</p> <p>my code:</p> <pre><code> playsong(filename); // line no 92 .... private void playsong(String filename2) { try{ Log.e("sdcard",filename2); mediaPlayer.setDataSource(filename2); // line no 192 seek.setMax(mediaPlayer.getDuration()); mediaPlayer.prepare(); mediaPlayer.start(); myHandler.post(runn); isPlaying = true; mediaPlayer.setOnCompletionListener(this); } catch(Exception ex){ Log.e("sdcard-err2:",ex.getMessage()); // line no 204 } } </code></pre> <p>my logcat</p> <pre><code> 05-16 17:46:41.648: ERROR/AndroidRuntime(5641): Uncaught handler: thread main exiting due to uncaught exception 05-16 17:46:41.711: ERROR/AndroidRuntime(5641): java.lang.NullPointerException: println needs a message 05-16 17:46:41.711: ERROR/AndroidRuntime(5641): at android.util.Log.println(Native Method) 05-16 17:46:41.711: ERROR/AndroidRuntime(5641): at android.util.Log.e(Log.java:208) 05-16 17:46:41.711: ERROR/AndroidRuntime(5641): at com.seek.bar.main.playsong(main.java:204) 05-16 17:46:41.711: ERROR/AndroidRuntime(5641): at com.seek.bar.main.access$0(main.java:192) 05-16 17:46:41.711: ERROR/AndroidRuntime(5641): at com.seek.bar.main$2.onClick(main.java:92) ... </code></pre> <p>please help me.</p>
android
[4]
2,797,395
2,797,396
To show an alert when application just enter into background
<p>I just want to show an alert when user just quit the application before application entering the background, how can I do that??</p> <p>If I show the alert in <code>applicationDidEnterBackground:(UIApplication *)application</code> method then this alert will be shown when we again resume the application, but I need to show the alert before the application enters the background.</p>
iphone
[8]
3,813,665
3,813,666
Base64 encodeBytes - out of memory exception
<p>I ma trying to upload a picture from android to remote server. Everything is working is fine except for large photos. I am getting "memory out of exception" at Base64.encodeBytes() methos. Here is the code.</p> <pre><code>ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want. byte [] byte_arr = stream.toByteArray(); String image_str = Base64.encodeBytes(byte_arr); </code></pre> <p>Can you guys please help me solving this issue ? I have tried to solve this issue by insampling the bitmap before, and it works but it scales down the bitmap and i always want to upload pictures in its original size.</p> <p>Thanks.</p>
android
[4]
3,505,628
3,505,629
Not displaying added two months (PHP)
<p>I have a problem in my codes. Obviously, I'm beginning to program in PHP and know nothing about its advanced concepts. So I'm asking of your help. I'd like to add 2 months to the end date the user input. I tried this code below:</p> <pre><code>protected function inputEndDate() { $value = $this-&gt;endDate; $html = ""; $html .= '&lt;label for="enddate"&gt;End Date:&lt;/label&gt;' . PHP_EOL; $html .= '&lt;input type="text" readonly name="enddate" id="enddate" value="'.$value.'"&gt;'; $html .= '&lt;input type="button" id="enddatebutton" onclick="getEndDate()"&gt;' . PHP_EOL; return $html; } protected function inputExpiryDate() { $value = $this-&gt;endDate; $date = date('Y/m/d', strtotime("$value +2 month")); $html = ""; $html .= '&lt;label for="expirydate"&gt;Expiry Date:&lt;/label&gt;'; $html .= '&lt;input type="text" readonly name="expirydate" id="expirydate" value="'.$date.'"&gt;'; $html .= '&lt;input type="button" id="expirydatebutton" onclick="getExpiryDate()"&gt;' . PHP_EOL; return $html; } </code></pre> <p>But when I run the program, it's not displaying the correct value; however it's displaying the added two months of its start date. Please help. Thanks.</p>
php
[2]
2,468,622
2,468,623
Need to get the value of a variable which is sent as a string?
<p>I'm sending a string as parameter to a function, but i already have a global variable in that name, i want to get the value of that variable but its sending as undefined..</p> <p>My example code</p> <p>i have a array as reg[0][0],reg[0][1],reg[1][0],reg[1][0],reg[2][0],reg[2][1]</p> <p>and i have some global variables as tick1, tick2, tick3...</p> <p>it will either have the values as 0,1 or 2</p> <p>and in a function i called </p> <pre><code>calc_score(id) //id will return as either tick1,tick2,tick3 { alert(eval("reg[id][1]")); // it should return the value of reg[0][1] if id is 0 } </code></pre> <p>But its not working.</p> <p>The id wont be a numeral it will be string .. So how can i do this?</p>
javascript
[3]
1,379,865
1,379,866
How to change speed at which text is printed (python)
<p>What I am trying to accomplish is first text appears after 1 second. then 2, ect. till 10. then when time equals 10, the time decreases, so the text appears after 9 seconds, then 8 etc.</p> <p>How could I fix this code so that it works properly?</p> <p>The error:</p> <pre><code>Traceback (most recent call last): File "C:/Users/Eric/Dropbox/time.py", line 13, in &lt;module&gt; time.sleep(time) AttributeError: 'int' object has no attribute 'sleep' </code></pre> <p>The code :</p> <pre><code>import time x = 1 t = 1 time = t + 1 while x == 1: print time if time &gt;=10: time = t - 1 elif time &lt;= 0: time = t + 1 time.sleep(time) </code></pre> <hr> <p>Edit:</p> <pre><code>import time x = 1 t = 1 time1 = 0 while x == 1: if time1 == 10: time1 = time1 - 1 elif time1 == 0: time1 = time1 + 1 else : time1 = time1 + 1 print time1 time.sleep(time1) </code></pre> <p>So I changed the program around abit, so I almost works correctly. What it does is count to 10, then 9 then back to 10. ex. 1,2,3,4,5,6,7,8,9,10,9,10,9,10 how can I set it so that the program increases time to ten then decreases to zero then increases again?</p>
python
[7]
4,991,771
4,991,772
Put imports at the top? Or where they get used?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/477096/python-import-coding-style">Python import coding style</a> </p> </blockquote> <p>When I write some code that requires an import, and the import is only introduced by the bit of code I'm currently writing, should I:</p> <p>Stick the import at the top of the file where it is made clear that to make this module work it needs these imports, yet the import is detached from the usage and should the need be removed later the module may still import stuff it doesn't ever actually use, or</p> <p>Keep the import with the code that uses it immediately thereafter so it is obvious what the import is used to do and whence it can be safely removed, but risk importing the same libs multiple times and make it hard to work out what libs are required to make the module work.</p> <p>Best practice?</p> <p>Put the import at the top? Or put it where it gets used?</p>
python
[7]
1,811,928
1,811,929
How to show an image that is hidden using jQuery
<p>I'm having issues showing an image that is hidden using jQuery. </p> <p>I have hidden the an image with the class 'img.zoom' using jQuery. I want to be able to hover over the list item that the image is within and show the image that is hidden. I am able to do this but it affects every list item with that image in. I only want it to affect that particular list item.</p> <p>Please help.</p> <p>My code:</p> <pre><code> &lt;ul class="portfolio"&gt; &lt;li&gt; &lt;img src="images/example.jpg" width="200" height="200" alt="Example" /&gt; &lt;img src="images/row.png" width="11" height="11" class="zoom" /&gt; &lt;/li&gt; &lt;li&gt;&lt;img src="images/example.jpg" width="200" height="200" alt="Example" /&gt;&lt;img src="images/row.png" width="11" height="11" class="zoom" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="images/example.jpg" width="200" height="200" alt="Example" /&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="images/example.jpg" width="200" height="200" alt="Example" /&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>my js:</p> <pre><code>// hide zoom button $("img.zoom").hide(); // show zoom button on hover $("ul li").hover(function () { $('img.zoom').show(); }); </code></pre> <p>Many thanks in advance.</p> <p>Craig</p> <p>UPDATE</p> <p>I have managed to work this out by adjusting the code like so</p> <pre><code>$('img.zoom', this).toggle(); </code></pre> <p>But is there away to fadeToggle this in and out?</p>
jquery
[5]
5,728,650
5,728,651
Testing FPS using Android plugin for Eclipse?
<p>Ive no doubt this question may have been addressed before but how can I turn on a framerate monitor to use when I run my programs using the android emulator so I can see exactly what my android game is achieving at a given time?</p>
android
[4]
290,124
290,125
How to open two popup window on a button click?
<p>I need to open two pdf files as popup window on click ona button in asp.net C#,but now its opening only the first popup?Can anybody help me ,to open the both windows at the same time?</p> <p>This is my code:</p> <pre><code>string PDFPath = folderpath + filename; string PopupName = "popUp"; string PopupSettings = "height=900,width=1000,top=100,left=100,scrollbars=no,resizable=no,toolbar=no,menubar=no,location=no,status=yes"; string NewPath = "var popup=window.open('../PopupForReport.aspx?pdfPath=" + PDFPath.Replace("\\", "/") + "','" + PopupName + "','" + PopupSettings + "')"; ScriptManager.RegisterStartupScript(updatePanel1, updatePanel1.GetType(), "popupOpener", NewPath, true); string PDFPath1 = folderpath + filename1; string PopupName = "popUp"; string PopupSettings = "height=900,width=1000,top=100,left=100,scrollbars=no,resizable=no,toolbar=no,menubar=no,location=no,status=yes"; string NewPath1 = "var popup=window.open('../PopupForReport.aspx?pdfPath=" + PDFPath1.Replace("\\", "/") + "','" + PopupName + "','" + PopupSettings + "')"; ScriptManager.RegisterStartupScript(updatePanel1, updatePanel1.GetType(), "popupOpener", NewPath1, true); </code></pre>
c#
[0]
6,026,050
6,026,051
Convert iPhone GPS to address
<p>I have been researching a few different apps lately for my company which are all able to convert your current GPS location to an address. I have been googling and searching through the stack but I can't seem to find any helpful information on the net to tell me how to achieve this. So my question is this; how do you:</p> <p>a) get your current GPS coordinates and then<br> b) transform them into a real address i.e. street number/name, city, country</p>
iphone
[8]
2,246,214
2,246,215
Searching for '\' using javascript
<p>I have written a following code to get just the file name without extension and path.I m running it in browser. </p> <pre><code>&lt;script type="text/javascript"&gt; var str=new String("C:\Documents and Settings\prajakta\Desktop\substr.html"); document.write(str); var beg=str.lastIndexOf("\");// **HERE IS THE PROBLEM IT DOESNT GIVE ME THE INDEX OF '\'** alert(beg); var end=str.lastIndexOf ("."); alert(end); document.write("&lt;br&gt;"+str.slice(beg+1,end)); &lt;/script&gt; </code></pre> <p>but the same code code works if i replace'\' by another character ex.('p'); i m initializing var str just for ex but in my application it is not always fixed.As i m new to Javascript can any body plz tell me what is the problem?n how to solve it?</p>
javascript
[3]
1,255,679
1,255,680
comparing two ExtendedProperty's
<p>I am working in C#, so I have a define list of ExtendedProperty's, then I pull another list of ExtendedProperty's. </p> <p>So ExtendedProperty myprop &amp; ExtendedProperty pulledList</p> <p>Now I would like to compare both ExtendedProperty's. However both extendedProperty list are not in the same order. How could i itterate though both list and compare the fields to see if they match. </p> <p>I was thinking like the defind list myProps, and check the first prop against all from the pulled list and see if they match, then move on to the second one and compare against the pulled list, and so on and so forth.</p> <p>I think i have the logic down, but I don't know how to go about coding this.</p> <p>Anyhelp would be appreciated on how to code this would be apprecaited.</p>
c#
[0]
928,117
928,118
xml parsed result pass through Geopoint() ,problem in number format
<p>I have done xml parsing and store result as latitude and longitude in an StringArray and using <code>for loop</code> I store result of lat and longitude in a string named "lat" and "longi" I want to pass these points through GeoPoint() for showing in a map,now the problem is now that i have 43 items in array: "sitesList.getLatitude().size()" when i use in our for loop it force close it is showing only 20 items show when i hard coated it then it is showing all lat long in map so now my qus is how to show all 43 position in mymap???</p> <pre><code> **if i use this then force close and gives number format exceptions...** **// for (int i = 0; i &lt; sitesList.getLatitude().size(); i++)** for(int i=0;i&lt;20;i++) { name = sitesList.getLatitude().get(i); name1 = sitesList.getLongitude().get(i); Log.i("array_spinner" + i, name); Log.i("longitiitude"+i,name1); point = new GeoPoint((int) (Double.parseDouble(name) * 1E6), (int) (Double.parseDouble(name1) * 1E6)); OverlayItem overlayItem = new OverlayItem(point, "Tomorrow ", "(M gives Bond his mission in Daimler car)"); itemizedOverlay.addOverlay(overlayItem); } </code></pre>
android
[4]
2,698,244
2,698,245
development of php oop based project
<p>I want to develop my php project using oop concepts.I read many tutorials.But i can't understand how to implement those are in my project. Plz help me.</p> <p>Thanks in advance Bhavyasri</p>
php
[2]
1,863,463
1,863,464
Can I create a non-explicit constructor for a Java class?
<p>By default, C++ will do "auto promotion" in assignment if appropriate constructors exist (and are not declared <code>explicit</code>).</p> <p>In Java, this behavior doesn't happen by default. If I want automatic promotion, is there a way to declare my constructors as implicit?</p> <p>For example, here is some C++ code that has the effect that I want:</p> <pre><code>class Foo { public: Foo(string) { /* ... */ } /* Foo's methods and stuff */ }; void DoSomethingWithAFoo(Foo foo) { /* ... */ } int main() { string s = "I am a happy string, I swear!"; DoSomethingWithAFoo(s); return 0; } </code></pre> <p>Generally, in C++ this is allowed, and the <code>string s</code> will be automatically promoted (by constructing a temporary <code>Foo</code> from <code>s</code>).<br> Since the <code>Foo(string)</code> constructor is not marked explicit, I don't even need a typecast.</p> <p>Is there a way to do this in Java?</p> <p>I ask because I am trying to create a specific type that represents any one of a specific variety of other types. For example, imagine a <code>class Primitive</code> that was representing either a single boolean, integer, character, or double (that's not my specific example, but it is related). </p> <p>Methods in my system that expect a Primitive should also accept any of the "real types" that the Primitive might represent (by auto-promotion to an anonymous object of type Primitive through a constructor call). </p> <p>In my actual work (as opposed to this example), my equivalent to the <code>Primitive</code> class has constructors both from a few primitive types as well as several object types (each constructor taking only the one parameter). Ideally I would want auto promotion for all of them.</p>
java
[1]
5,337,154
5,337,155
Android:click effect in a linearlayout
<p>I am a beginner in android programing and just started to play around with android.</p> <p>I have a linearlayout which contains 2 textviews. When i click on the linearlayout, the textcolor in one textview and background in the other textview must change for a small peroid of time. It should return to its orginal textcolor and background after the click.</p> <p>The problem is that the <code>setOnClickListener()</code> must be implemented on the linearlayout.</p> <p>This is the code</p> <pre><code> &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/linearlayout_logout" android:orientation="horizontal"&gt; &lt;TextView android:gravity="center" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@drawable/logout_home_icon" /&gt; &lt;TextView android:id="@+id/text_logout" android:layout_height="match_parent" android:layout_width="wrap_content" android:textColor="@color/white" android:text="Log Out" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Here the logout_home_icon is an image(.png)..plsss help.</p>
android
[4]
2,663,385
2,663,386
overriding a method from a class with a private variable
<p>If I have a class that can't be changed (inside a jar), Ex. </p> <pre><code>public class AA implements A{ private String s = "foo"; public String getValue() { return s; } } </code></pre> <p>what would be a good way to override that getValue() method? My way has been recopying the class. Ex.</p> <pre><code>public class AB implements A{ private String s = "foo"; public String getValue() { return s + "bar"; } } </code></pre> <p>Thanks!</p>
java
[1]
303,542
303,543
How add new hidden input fields to the form on submit
<p>I'm doing some conditional checks and want to pass certain hidden variables to a request.</p> <p>For example I want to pass these if this condition passes:</p> <pre><code> &lt;script type="text/javascript"&gt; function checkClosureLevel() { var openLevel = document.getElementById('openLevel'); var phyCompLevel = document.getElementById('phyCompLevel'); var finCompLevel = document.getElementById('finCompLevel'); if(openLevel.checked){ //PASS HIDDEN FORM VARIBALES HERE AND SUBMIT FORM } } &lt;/script&gt; &lt;form action="process.det_details" method="post" name="detParameterForm"&gt; &lt;fieldset class="det"&gt; &lt;legend&gt;Closure Level&lt;/legend&gt; &lt;input type="checkbox" name="openLevel" &gt;Open&lt;/input&gt;&lt;br/&gt; &lt;input type="checkbox" name="phyCompLevel" &gt;Physically Complete&lt;/input&gt;&lt;br/&gt; &lt;input type="checkbox" name="finCompLevel" &gt;Financially Complete&lt;/input&gt; &lt;/fieldset&gt; </code></pre>
javascript
[3]
2,816,160
2,816,161
how do you implement System.Net.IPAddress.HostToNetworkOder and NetworkToHostOrder
<p>The <code>HostToNetworkOrder</code> method converts multibyte integer values stored on the host system from the byte order used by the host to the byte order used by the network, and the <code>NetworkToHostOrder</code> does the reverse.</p> <p>Question is how to implement these methods in C#, assuming that it is not available in the system library.</p>
c#
[0]
1,150,000
1,150,001
converting char to unsigned char
<p>How the conversion works ? For example: Scope of char[-128, 127], scope of unsigned char[0, 255]</p> <pre><code>char x = -128; unsigned char y = static_cast&lt;unsigned char&gt;(x); cout&lt;&lt;y; //128 </code></pre> <p>Why not 0 ?</p>
c++
[6]
889,847
889,848
where to store user credentials
<p>at the android developer site <a href="http://developer.android.com/guide/practices/security.html" rel="nofollow">http://developer.android.com/guide/practices/security.html</a> i read that user password should not be stored in device.</p> <p>Then how should i handle this. I mean how to store user credentials on clouds and access that when needed. What problems could be there if I store user credentials in device.</p> <p>what other things one should keep in mind (for security) while developing app.</p>
android
[4]
3,724,158
3,724,159
Why does this `auto` not automatically turn into "`const`"
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/14008893/auto-reference-in-c11">auto reference in c++11</a> </p> </blockquote> <p>The more I learn C++, the more I have come to realize that so far (almost; see below) everything in it basically just makes sense. I find that I don't really have to learn any rules by heart because everything behaves as expected. So the main thing becomes to actually understand the concepts, and then the rest takes care of itself.</p> <p>For instance:</p> <pre><code>const int ci = 0; auto &amp;a = ci; //automatically made const (const int &amp;) </code></pre> <p>This works and makes sense. Anything else for the type of <code>a</code> would just be absurd.</p> <p>But take these now:</p> <pre><code>auto &amp;b = 42; //error -- does not automatically become const (const int) const auto &amp;c = 42; //fine, but we have to manually type const </code></pre> <p>Why is the first an error? Why doesn't the compiler automatically detect this? Why does the <code>const</code> have to be typed out manually? I want to really understand why, on a fundamental level so that things make sense, without having to learn any rigid rules by heart (see above).</p>
c++
[6]
5,463,502
5,463,503
Arbitrary precision type
<p>Is there such a type\implementation in C#?</p> <p>It is needed to calculate figures up to 10<sup>10,000</sup> magnitude.</p>
c#
[0]
1,830,921
1,830,922
How can I tell if a ManualResetEvent is signaled or non-signaled?
<p>I want to check to see if an instance of ManualResetEvent is signaled before starting a thread. How can I do this?</p>
c#
[0]
4,126,318
4,126,319
get every 4th hour
<p>I have a time string from 0 to 24. like this</p> <pre><code>0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 </code></pre> <p>Now if it is 2 oclock, I want to select every 4th hour. so from above it will be</p> <pre><code>2, 6, 10, 14, 18, 22 </code></pre> <p>I am trying to wrap my head around it to get this going thanks</p> <p>I have tried this</p> <pre><code>if(range($hour, 23, 4)){ print_r($hour);echo '&lt;br /&gt;'; } </code></pre> <p>but it still prints all the hours in that array</p> <p><strong>EDIT</strong> here is the code </p> <p><code>$hourlyData-&gt;hour</code> is just an hour digit, like 0 or 1 or 2 etc upto 23</p> <pre><code>foreach($jason-&gt;hours as $hourlyData){ if(range($hourlyData-&gt;hour, 23, 3)){ // print here to check if the correct time is used print_r($hourlyData-&gt;hour);echo '&lt;br /&gt;'; } } </code></pre>
php
[2]
4,709
4,710
Why can't I have an object initializer within another object initializer in Javascript?
<p>I have the following code and was wondering why I am not allowed to create another object within another.</p> <p><strong>CODE</strong></p> <pre><code>//Object initializer var shoe = { size: 10, make: var maketype = { this.brand: "rebook" }, availability: "now" } </code></pre>
javascript
[3]
883,403
883,404
how to pass parameter programtically in objectdatasource
<p>i want to pass 3 parameters for SelectMethod and 1 parameters for SelectCountMethod of ObjectDataSource.</p> <p>How can i pass these?? And how ObjectDataSource can distinguish which parameters for which methods.??</p> <p>Thanks &amp; Regards</p>
asp.net
[9]
5,310,122
5,310,123
Replace a value if null or undefined in JavaScript
<p>I have a requiremnt to apply the ?? C# operator to JavaScript world and don't know how. Consider this in C#:</p> <pre><code>int i?=null; int j=i ?? 10;//j is now 10 </code></pre> <p>Now I have this set up in JavaScript:</p> <pre><code>var options={ filters:{ firstName:'abc' } }; var filter=options.filters[0]||'';//should get 'abc' here, it doesn't happen var filter2=options.filters[1]||'';//should get empty string here, because there is only one filter </code></pre> <p>How do I do it correctly?</p> <p>Thanks.</p> <p>EDIT: I spotted half of the problem: I can't use the 'indexer' notation to objects (my_object[0]). Is there a way to bypass it? (I don't know the names of the filters properties beforehand and don't want to itereate over them).</p>
javascript
[3]
5,299,456
5,299,457
save files with specific name from site to disk drive
<p>here is my code is not working perfectly so what is the problem </p> <pre><code>$urls = file('list.txt', FILE_IGNORE_NEW_LINES); foreach($urls as $url) { copy(trim($url),"c:/data/$url"); echo "$url is done"; ob_flush(); flush(); } </code></pre> <p>some urls does not exist </p> <p>i want that each file from url will be saved with the name of the url </p> <p>url look like : <a href="http://site.com/index.htm" rel="nofollow">http://site.com/index.htm</a></p>
php
[2]
31,098
31,099
subscribe and unsubscribe a function that contains calls to other functions
<p>I have a function that I want to subscribe it to a event queue. When it executes this function I need it to unsubscribe from the queue.</p> <p><code>functionToExecute</code> is the function I want to execute.</p> <p><code>onDOMReady</code> subscribes the <code>attachDOMHandler</code> function which in turn executes <code>functionToExecute</code> and unsubscribes itself. I have:</p> <pre><code>onDOMReady : function(functionToExecute){ subscribe(this.attachDOMHandler(functionToExecute)); }, attachDOMHandler : function(functionToExecute) { unsubscribe(this.attachDOMHandler(functionToExecute)); functionToExecute(); } </code></pre> <p>Everything works fine when I have the following:</p> <pre><code>onDOMReady : function(functionToExecute){ subscribe(functionToExecute, this, true); }, </code></pre> <p>However I need the function to unsubscribe after it is executed. My plan was to use the <code>attachDOMHandler</code> function which executes the function and has the unsubscribe behaviour. When I run the former I get a <code>"Uncaught RangeError: Maximum call stack size exceeded"</code> in the Chrome console. It looks like it gets stuck in an infinite loop which makes sense since I keep running <code>attachDOMHandler</code> in the unsubscribe which gets caught in a loop. I basically need to subscribe a function that I specify by parameter passing. When the function is executed it unsubscribes. Hope I have explained this ok.</p>
javascript
[3]
4,423,516
4,423,517
Submitting with jquery
<p>I would like to learn how these websites are validating data with PHP. For instance you go to facebooks page and view the source code there is no form action supplied. Ok I understand they are using Javascript in some manner to post data towards PHP but can I do something similar with jquery? Are the submit() and Post() functions that I should learn in depth to achieve the results. Could some one shed some light how these websites are doing all this or is it just Ajax? Thanks help is much appreciated and if there is some tutorial you would recommend please do tell!</p>
jquery
[5]
4,542,415
4,542,416
hashcode uniqueness
<p>Is it possible for two instances of Object to have the same hashcode ? </p> <p>In theory an object's hashcode is derived from its memory address, so all hashcodes should be unique, but what if objects are moved around during GC ?</p>
java
[1]
5,357,092
5,357,093
Crash due to SIGABRT on Linux C++ PowerPC
<p>My program crashes in string assign. I cannot corner down the exact cause of it. Multiple threads execute the same code.</p> <p>This is my code.</p> <pre><code> char* cTemp = new char[5]; memset(cTemp,'\0', 5); snprintf(cTemp , 5 , "%04x" , iParameter); string sVar1 = cTemp; delete[] cTemp; if(sVar1 == "0") sVar1 = "0000"; pSharedLib-&gt;setVar1(sVar1); </code></pre> <p>The set Function(in shared library)</p> <pre><code> bool A::setVar1(CString&amp; temp) { m_sVar1= temp; return true; } </code></pre> <p>The crash bt shows the error as </p> <pre><code>#0 0x48194444 in raise () from /lib/libc.so.6 #0 0x48194444 in raise () from /lib/libc.so.6 No symbol table info available. #1 0x48199694 in abort () from /lib/libc.so.6 No symbol table info available. #2 0x481d4ecc in ?? () from /lib/libc.so.6 No symbol table info available. #3 0x481e14d4 in ?? () from /lib/libc.so.6 No symbol table info available. #4 0x481e32b0 in free () from /lib/libc.so.6 No symbol table info available. #5 0x480df8b8 in operator delete(void*) () from /usr/lib/libstdc++.so.6 No symbol table info available. #6 0x480b136c in std::string::_Rep::_M_destroy(std::allocator&lt;char&gt; const&amp;) () from /usr/lib/libstdc++.so.6 No symbol table info available. #7 0x480b35f4 in std::string::assign(std::string const&amp;) () from /usr/lib/libstdc++.so.6 No symbol table info available. </code></pre>
c++
[6]
3,849,421
3,849,422
Using evaluated variable values instead of the actual type
<pre><code>var foo; console.log(typeof foo); //"undefined" if(typeof foo === 'undefined') console.log(1); if(!foo) console.log(2); </code></pre> <p>In my example above, the console will log both "1" and "2", since <code>undefined</code> evaluates as <code>false</code>. The same thing will happen for <code>null</code>, <code>NaN</code>, <code>""</code> (empty string) etc.</p> <p>Is it more common to use the <code>typeof</code> operator and compare the string value, rather than using the evaluated boolean value? Is there any difference besides readability? Any pros and cons?</p>
javascript
[3]
4,187,259
4,187,260
Launch App from Notification with data
<p>I'm trying to use C2DM to trigger a push notification on my android phone, and have the user click the notification and launch a certain activity in the app. How can I pass this information along? </p> <p>Currently I'm doing the following:</p> <pre><code> String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.notification23; Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_AUTO_CANCEL; Context appContext = getApplicationContext(); Intent notificationIntent = new Intent(this, RequestDialogActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); notificationIntent.putExtra(LocationHandler.KEY_ORIGINATOR, number); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(appContext, contentTitle, contentText, contentIntent); final int id = 1; mNotificationManager.notify(id, notification); </code></pre> <p>I'm trying to store state by calling <code>putExtra</code> on the notificationIntent, but the new activity always has a null savedInstanceState Bundle. How can I pass information along?</p>
android
[4]
4,700,368
4,700,369
How to call a method in another class using the arraylist index in java?
<p>Currently I have two classes. A Classroom class and a School class. </p> <p><code>public void addTeacherToClassRoom(Classroom myClassRoom, String TeacherName)</code></p> <p>I would like my method addTeacherToClassRoom to use the Classroom Arraylist index number to setTeacherName</p> <p>e.g. int 0 = maths int 1 = science</p> <p>I would like to setTeacherName "Daniel" in int 1 science.</p> <p>many, thanks</p> <pre><code> public class Classroom { private String classRoomName; private String teacherName; public void setClassRoomName(String newClassRoomName) { classRoomName = newClassRoomName; } public String returnClassRoomName() { return classRoomName; } public void setTeacherName(String newTeacherName) { teacherName = newTeacherName; } public String returnTeacherName() { return teacherName; } } import java.util.ArrayList; public class School { private ArrayList&lt;Classroom&gt; classrooms; private String classRoomName; private String teacherName; public School() { classrooms = new ArrayList&lt;Classroom&gt;(); } public void addClassRoom(Classroom newClassRoom, String theClassRoomName) { classrooms.add(newClassRoom); classRoomName = theClassRoomName; } public void addTeacherToClassRoom(Classroom myClassRoom, String TeacherName) { myClassRoom.setTeacherName(TeacherName); } } </code></pre>
java
[1]
3,689,993
3,689,994
file_put_content in loop
<p>I want to replace "uggg" word inside of the index.php with different values (I have values in array) and make new files for each replaced string and save it with the name of string. I wrote this but it only create one file for the last value in the array.</p> <pre><code>foreach($info_array as $rp) { $data = file_get_contents("index.php"); $data = str_replace("uggg", "$rp", $data); file_put_contents($rp.".php", $data); } </code></pre> <p>Here is the error when I execute this code</p> <blockquote> <p>Warning: file_put_contents(john c .php) [function.file-put-contents]: failed to open stream: Invalid argument in C:\wamp\www\n\cfile.php on line 357</p> </blockquote> <p>line 357 is:</p> <pre><code>file_put_contents($rp.".php", $data); </code></pre> <p>what is wrong ?</p>
php
[2]
669,555
669,556
How do I read one number at a time and store duplicates into an array?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11819532/how-do-i-read-one-number-at-a-time-and-store-it-in-an-array-skipping-duplicates">How do I read one number at a time and store it in an array, skipping duplicates?</a> </p> </blockquote> <p>I'm trying to read numbers from a file into an array, storing any duplicates. For instance, say the following numbers are in a file:</p> <pre><code>41 254 14 145 244 220 254 34 135 14 34 25 </code></pre> <p>Though the number 34 occurs twice in the file, I would only like to store it once in the array. How would I do this?</p>
c++
[6]
948,028
948,029
what is the difference between [[],[]] and [[]] * 2
<pre><code>t0 = [[]] * 2 t1 = [[], []] t0[0].append('hello') print t0 t1[0].append('hello') print t1 </code></pre> <p>The result is</p> <pre><code>[['hello'], ['hello']] [['hello'], []] </code></pre> <p>But I can't tell their difference.</p>
python
[7]
3,958,315
3,958,316
How to decode eval( gzinflate( base64_decode(
<p>I have this code injected in my site. How can I decode the trailing string? I need to know what happened and what is the code behind it.</p>
php
[2]
1,656,107
1,656,108
How do I write my script for each link I want to redirect
<p>So I'm trying to redirect users from html links and element id tags, to other pages with javascript. I've figured out how to do one singular redirect but having trouble writing the code for multiple links heres what I have so far:</p> <p>HTML: </p> <pre><code>&lt;head&gt; &lt;script type = "text/javascript" src="script2.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="nickname.html" id="redirect1"&gt;NickName&lt;/a&gt; &lt;a href="salestax.html" id="redirect"&gt;Salestax&lt;/a&gt; &lt;a href="http://www.w3schools.com" id="redirect2"&gt;W 3 Schools&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My external script so far for just one link:</p> <pre><code>window.onload = initAll; function initAll() { document.getElementById("redirect").onclick = initRedirect; } function initRedirect() { confirm("Go to Salestax page?"); window.location="salestax.html"; return false; { </code></pre> <p>Do I just crank out more functions and change the location value, getElementById value and the onclick value?</p>
javascript
[3]
5,377,473
5,377,474
getNodeById does not work
<p>I have a ext treepanel with json.</p> <pre><code>var tree = new Ext.tree.TreePanel({ renderTo:'tree-container', title: 'Category', height: 300, width: 400, useArrows:true, autoScroll:true, animate:true, enableDD:true, containerScroll: true, rootVisible: false, frame: true, root: { text: 'Category', draggable: false, id: '0' }, // auto create TreeLoader dataUrl: $("#web").val() + "/category/index/get-nodes", listeners: { 'checkchange': function(node, checked){ if(checked){ categoryManager.add(node.id); //node.getUI().addClass('complete'); }else{ categoryManager.remove(node.id); // node.getUI().removeClass('complete'); } } } </code></pre> <p>});</p> <p>dataUrl loads the following json code</p> <pre><code>[{"text":"Code Snippet","id":"1","cls":"folder","checked":false,"children":[{"text":"PHP","id":"3","cls":"file","checked":false,"children":[]},{"text":"Javascript","id":"4","cls":"file","checked":false,"children":[]}]}] </code></pre> <p>when I try to find a node by console.log( tree.getNodeByid(3) ), it shows that it is undefined.</p> <p>Do I have a problem with my code?</p>
javascript
[3]
447,920
447,921
What does $foo="file.php" mean?
<p>I have trouble understanding some code. There is a part where the code reads:</p> <pre><code>$GA_PIXEL = "ga.php"; </code></pre> <p>Is this like an include? In which situations would this be useful? This code was taken from the server side implementation of google analytics. </p>
php
[2]
1,713,109
1,713,110
While statement help (PHP)
<p>My database contains both questions and answers. The questions have an ID (intQAID) and the responses have an ID (intResponseID). The intRespondID is the same as the intQAID ID that it is responding to. Each entry into the database has its own ID, which is intPostID.</p> <p>What's i'm trying to do is write a query that will grab all this information and post it to a website using a while statement. However, the structure needs to be Question and underneath be the answer, until the while loop ends.</p> <p>I can get the questions to post:</p> <pre><code>$question = mysql_query("SELECT *, (SELECT cUsername FROM tblUsers tblU WHERE Q2.intPosterID = tblU.intUserID) AS username, (SELECT DATE_FORMAT(dPostDateTime, '%b %e %Y %H:%i')) AS post_time FROM tblQA Q2 WHERE intResponseID = 0 ORDER BY Q2.dSortDateTime DESC, Q2.intQAID DESC LIMIT 40"); while($row = mysql_fetch_array($question)) { echo "&lt;tr class='forum'&gt;"; echo "&lt;td class='forum'&gt;" . substr($row['cBody'], 0, 150) . "&lt;/td&gt;"; echo "&lt;td class='forum'&gt;" . $row['cCategory'] . "&lt;/td&gt;"; echo "&lt;td class='forum'&gt;" . $row['username'] . "&lt;/td&gt;"; echo "&lt;td class='forum'&gt;" . $row['post_time'] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } </code></pre> <p>But how can I get it to post the answer in the same while statement?</p> <p>Should output like so:</p> <pre><code>Question 1: Answer 1: Question 2: Answer 2: Question 3: Answer 3: etc.... </code></pre>
php
[2]
1,281,213
1,281,214
Toggling image border color on click
<p>Referencing this Fiddle ( <a href="http://jsfiddle.net/j5uGN" rel="nofollow">http://jsfiddle.net/j5uGN</a> ), how can I toggle a clicked image's border color between <code>#efefef</code> and <code>#3f96cf</code> so that it is <code>#efefef</code> when the image appears to be unchecked (aka has a class of "nocheck")? I already have a click event firing on img.check, so how do I go about chaining commands together to change a different element?</p> <p>Is my question clear?</p> <p>Thanks</p>
jquery
[5]
1,245,096
1,245,097
how to Design the exported excel in asp.net?
<p>I am exporting gridview data to excel but that excel file add the some lable text and textbox values and format also taken , pls give how to design the excel code in asp.net. I am writing like this </p> <ul> <li><p>All gridview data taken dataset ds -pls give me textbox values and some label or normal text designed code in excel</p> <p>GridView GridView1 = new GridView(); GridView1.AllowPaging = false; GridView1.DataSource = ds; GridView1.DataBind();</p> <pre><code> Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=DataTable.xls"); Response.Charset = string.Empty; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); for (int i = 0; i &lt; GridView1.Rows.Count; i++) { ////Apply text style to each Row GridView1.Rows[i].Cells[4].Attributes.Add("class", "textmode"); } GridView1.RenderControl(hw); //style to format numbers to string string style = @"&lt;style&gt; .textmode { mso-number-format:'\#,\#\#0\.00';} .textmode1(mso-number-format:'\@';} .SSNmode{mso-number-format:'000-00-000';} &lt;/style&gt;"; Response.Write(style); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); </code></pre></li> </ul>
asp.net
[9]
4,525,435
4,525,436
Android How to get my MapView's Screen coord? (the visible rect)
<p>How can I get the my MapView's Screen coord to save? (visible rect left-top, and zoomlevel) I'd like to reload that coords after a while. How can I do that?</p> <p>Thanks, Leslie</p>
android
[4]
3,190,296
3,190,297
Passing data without using cookies in Javascript
<p>Is there a way to pass data between pages without using cookies and a server-side language in javascript? every way I found incorporates cookies or a server-side language (PHP session vars).</p>
javascript
[3]
1,323,128
1,323,129
getting all child nodes' values of the current node
<p>I am trying to retrieve all of the values in the div. For example:</p> <pre><code>&lt;div&gt;xyz &lt;span&gt; abc &lt;/span&gt; def&lt;/div&gt; </code></pre> <p>This is the code</p> <pre><code>the_page="&lt;div&gt;xyz &lt;span&gt; abc &lt;/span&gt; def&lt;/div&gt;" doc = libxml2dom.parseString(the_page, html=1) divs=doc.getElementsByTagName("div") print divs[0].firstChild.nodeValue </code></pre> <p>This only prints "xyz". I tried to just do print divs[0].nodeValue, but that gives me an error. I want all of the text. How would I get around this?</p>
python
[7]
4,338,181
4,338,182
PHP developer looking for 2nd language (I want out of web development)
<p>I've been working with PHP for over a year now, and although I've learnt and worked with a lot of cool things I'm grateful for (OOP, working with a framework, learning some design patterns, theming and developing for Drupal/WP),...I've already made up my mind and I know I don't want to do web development forever. I really enjoy the programming, but I don't like having to deal with some "web-dev-related" things forever. I'm a freelancer, so 95% the jobs I get are websites. Designing websites and making them <em>pretty</em> is cool and rewarding... but the type of client that asks you for a website... well, let's just say they usually make me mad, I guess it would be easier if I just worked for a company, but since I'm currently traveling a lot, I actually <strong>need</strong> to be able to freelance. </p> <p>I tried learning C for a while, just as a hobbie, and I did enjoy my experience with it, but back then...didn't have the time to learn it (and I'm definitely going to go back to it when I'm actually settled somewhere)... So, what do you guys think? With my kind of background, and considering what I want and need at the moment is learning a language that's not gonna tie me to web development,...where should I start looking (python looks like a lot of fun, and I've played with it in the past, but languages like JAVA and Objective-C seem to be in higher demand)?</p>
php
[2]
697,913
697,914
How to get out of Recursive function?
<p>I wrote this function to find a particular element in a table :</p> <pre><code> function LoopThroughChildElements(parantEle,flag) { for (var i = 0; i &lt; parantEle.childNodes.length; i++) { if (parantEle.childNodes[i].childNodes.length &gt; 0) { LoopThroughChildElements(parantEle.childNodes[i]); } } else { if (parantEle.childNodes[i].id.indexOf("chkSelect") &gt; 0) { alert("Found"); return parantEle.childNodes[i]; } } } return null; } </code></pre> <p>When executing this: </p> <pre><code> var checkBox = LoopThroughChildElements(col); alert(checkBox); </code></pre> <p>I get an alert of <code>"Found"</code>, but the result stays null all time ..</p> <p>Why does this happen? How to break the recursion loop when I get my result?</p>
javascript
[3]
787,221
787,222
Object Creation Differences
<p>What is the Difference in between 2 statements </p> <pre><code>int main() { A a = new A(); A a; } </code></pre> <p>Please explain this two object creation statements.</p>
c#
[0]
2,794,163
2,794,164
What to read to understand how Java works?
<p>Knowing how Java works in initializing objects and how it bind methods and fields to an object , abstract , final methods to an object and some other issues take a lot of time to guess myself , and i needed to ensure that every guess i made was correct by asking here and there . I need some recommendations to read or watch (books-tutorials-articles-videos) , thanks in advance </p>
java
[1]
4,547,379
4,547,380
checkpointing library for C#
<p>Am looking for checkpointing library for C#. Any ideas ?</p> <p>see <a href="http://en.wikipedia.org/wiki/Application_checkpointing" rel="nofollow">http://en.wikipedia.org/wiki/Application_checkpointing</a></p>
c#
[0]
5,706,896
5,706,897
how to pass value to pop up window using javascript function?
<p>I want to open new window from existing form.When I am clicking on new window in form then new form should open with results of value entered,but new window form is opening with main page,not able to get text box value from parent form.</p> <p>How to call textfield input value in popup window from parent window using javascript?</p> <pre><code>//currently I'm using following code: &lt;script type="text/javascript"&gt; function pop_up5() { var l_url=window.opener.document.getElementById("name").value; window.open(l_url,'''','scrollbars=yes,resizable=no,width=550,height=400'); } &lt;/script&gt; </code></pre>
javascript
[3]
2,601,714
2,601,715
Make an android activity method thread safe
<p>I have a method updateFoo() of an activity called both from a Handler thread every 5 seconds and from a button when user want to press it... updateFoo update the interface of my activity... to make this method thread safe I declared it "synchronized" ... Is that the right way???</p> <p>Thanks in advance for any help..</p> <p>.4S.</p>
android
[4]
1,719,302
1,719,303
How to select closest hidden div in jquery?
<p>I'm trying to perform a keypress event the divs inside the bus_lines div.</p> <pre><code>$('#bus_lines').keypress(function(e){ var box = $(this).closest("div:hidden").attr("id"); console.log(box); }); </code></pre> <p>Here's what it looks like in firebug:</p> <p><img src="http://i.stack.imgur.com/w2t2V.png" alt="enter image description here"></p> <p>It only works on the parent div which is the one with the bus_lines id. If I try to perform keypress events inside of fs_buslines or fs_bustax its not working. I need to know the closest div where the keypress is performed. Basically I'm trying to perform button click events using keyboard shortcuts.</p>
jquery
[5]
621,983
621,984
Bypass the .submit() handler
<p>I have an event handler for a form submittal that needs to do some work. That work includes making an ajax call to perform some very specific validations. Because of the asynchronous nature, my intent was to <code>preventDefault</code> at the top of the event handler and, if everything went well, submit the form "manually" by triggering the <code>submit()</code> method.</p> <p>Of course, that drops me into a loop. If I submit and all goes well, then the submit event handler is called when I resubmit. Is there any way to bypass the handler when I trigger the submit manually?</p> <p>I should add that my geek karma is on empty today so I may be making this much harder than it has to be. If there's a dead simple solution for what I'm trying to do, I'd love to hear it.</p> <p>I should add that I've put a working solution in place by simply making the jQuery <code>$.ajax</code> call synchronous, but I can't help feeling like there's a more effective way of getting this done that I'm just not seeing today.</p> <p>Thanks.</p>
jquery
[5]
1,784,261
1,784,262
How to cache html file like browser but on server depending on header file
<p>Is there a special function that does this or does one needs to parse the header ?</p>
java
[1]
5,371,216
5,371,217
android:windowBackground="@null" to improve app speed
<p>I just read a <a href="http://www.curious-creature.org/2009/03/04/speed-up-your-android-ui/" rel="nofollow">blogpost by Romain Guy</a> on how to speed up an app UI. He basically says that if your app uses opaque views you can set the background to <code>@null</code> in your <code>Activity</code>'s style using:</p> <pre><code>&lt;item name="android:windowBackground"&gt;@null&lt;/item&gt; </code></pre> <p>Does this work? I was willing to test this using FPS as he did but I didn't find a clear way of getting that info.</p> <p>I have read some <a href="http://groups.google.com/group/android-developers/browse_thread/thread/52bb5927f8f5cac3" rel="nofollow">threads</a> saying you need to do it yourself. I am about to add a custom view that draws the FPS in the <code>onDraw()</code> method and calls <code>invalidate()</code> to get call all the time.</p> <p>Although this works, I would like to know if there is a better way to analyse FPS in an application.</p>
android
[4]
5,708,685
5,708,686
problematic python function returns
<p>I have a function similar to the following:</p> <pre><code>def getCost(list): cost = 0 for item in list: cost += item return cost </code></pre> <p>and I call it as so:</p> <pre><code>cost = getCost([1, 2, 3, 4]) </code></pre> <p>This is GREATLY simplified but it illustrates what is going on. No matter what I do, cost always ends up == 0. If I change the value of cost in the function to say 12, then 12 is returned. If I debug and look at the value of cost prior to the return, cost == 10</p> <p>It looks like it is always returning the defined number for cost, and completely disregarding any modifications to it. Can anyone tell me what would cause this?</p>
python
[7]
1,102,692
1,102,693
in php i need one line if condition for time compare
<p>i have to value</p> <pre><code> $mo=strtotime($input_array['MondayOpen']); $mc=strtotime($input_array['MondayClose']); </code></pre> <p>now i need a if condition to display an error on below conditions</p> <ol> <li>if one of them($mo or $mc) are empty, null or blank.</li> <li>if close time($mc) is less than open time($mo)</li> </ol> <p>means if both are empty(null) or $mc>$mo then go further</p> <p>please suggest optimized one line if condition for this</p> <p>i know it seems very basic question, but i m facing problem when both are null either i was using simple</p> <pre><code>if(($mo==NULL &amp;&amp; $mc!=NULL) || ( $mo&gt;=$mc &amp;&amp; ($mo!=NULL &amp;&amp; $mc!=NULL)) ) </code></pre>
php
[2]
4,169,883
4,169,884
Add image from database after building jar
<p>So, I have a java program which reads a MySQL database. It reads lots of things from there and, one of them, is the path for images.</p> <p>Is there a way I can add an image path in this database and make a built jar show it without rebuilding?</p>
java
[1]
30,795
30,796
Limiting number of checkable radios in a page
<p>Evening all,</p> <p>Been trying to do this for a day now but can't figure it out.</p> <p>I've got a page filled with 5 groups of radio selects, with 3 selects in each group.</p> <pre><code>GROUP 1 | GROUP 2 | GROUP 3 | GROUP 4 | GROUP 5 radio 1-1 | radio 1-1 | radio 3-1 | radio 4-1 | radio 5-1 radio 1-2 | radio 2-2 | radio 3-2 | radio 4-2 | radio 5-2 radio 1-3 | radio 2-3 | radio 3-3 | radio 4-3 | radio 5-3 </code></pre> <p>Of course, user is limited to selecting only one radio within each group, but I want to be able to limit the total number of radios on the whole page a user can select ... to, say, 3 ... then all the other radios would be deselected.</p> <p>Would also like to display what radios are currently selected in a separate area ... but I can't figure out how to make jquery work with multiple radio groups! With checkboxes it's simply :checked ... but since checking a radio deselects other radio in same group, don't know how to emulate that.</p> <p>Any help is much appreciated.</p>
jquery
[5]
2,779,086
2,779,087
How to embed different languages in android apps?
<p>I have made an app.(base version Gingerbread 2.3) and now I want to embed different languages to it so that the user can use the app. in different languages. But the process of embedding different languages is not clear to me(I'm a new to android programming), somebody please explain it in details with code.</p>
android
[4]
5,017,265
5,017,266
How to maintain and clear Browser history in android 2.2
<p>How to maintain and clear Browser history in android 2.2 I know <code>Browser.clearSearches(getContentResolver());</code> used for default browser but I want to create custom one.</p>
android
[4]
1,955,203
1,955,204
How to upload a file to a folder without 777 permission?
<p>I want to upload a file to a folder which has not 777 permission. How can i do this using php?</p>
php
[2]
3,338,765
3,338,766
Rendering HTML to PNG / JPEG
<p>I am looking for a php library or an unix shell tool to render a HTML page into a single png/jpg image.</p> <p>Is there any?</p>
php
[2]
2,073,531
2,073,532
Automatic Slide show?
<p>HI,</p> <p>Want to implement automatic slideshow in my application, the images should change automatically with some time. Should look like a flash type changing screens, Please help?</p>
android
[4]
3,879,570
3,879,571
How can i see a combo in al window forms in c#
<p>Hy. I want to use the combo selected item from form1 in form 2 and i don't know how in c#.</p> <p>Please help!</p>
c#
[0]
5,328,226
5,328,227
Execute PHP without being redirected to the action linked file?
<p>If I have a submit button that will execute a PHP script, can I execute it without actually going to that page, i.e.: process.php? I'm used to JavaScript being able to do this.</p> <p>(For the record, I'm talking about without AJAX, without redirecting once on that other page, and no, I'm not very hopeful.)</p>
php
[2]
5,340,084
5,340,085
Copying an array to a list
<p>Hey guys I am wondering if there's a one-line way of copying an array to a list than the following:</p> <pre><code>String array[] = new String[]{"1", "2", "3", "4" } ; List list = new ArrayList(); for (int i=0; i&lt; array.length; i++){ list.add(array[i] ); } </code></pre> <p>Edit: thanks for both informative answers, very helpful :)</p>
java
[1]