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,998,886
5,998,887
Difference between __get__ and __getattr__ in Python
<p>I've been trying to figure this out for a while. I see plenty of questions like <a href="http://stackoverflow.com/questions/3278077/difference-between-getattr-vs-getattribute-in-python">this one</a>, asking about the difference between <code>__getattr__</code> and <code>__getattribute__</code>.</p> <p>However, my question is thus: what is the difference between <code>__get__</code> and <code>__getattr__</code> in Python? I come from a PHP background, where there is only <code>__get__</code>. When should I use which function?</p>
python
[7]
708,636
708,637
Strange behaviour of MotionEvent getHistorySize() method
<p>There is a strange behaviour of MotionEvent <code>getHistorySize()</code> method on some devices. For example:</p> <pre><code>@Override public boolean onTouchEvent(MotionEvent ev){ if(ev.getAction() == MotionEvent.ACTION_DOWN) return true; if(ev.getAction() == MotionEvent.ACTION_MODE){ int hsize = ev.getHistorySize(); return true; } if(ev.getAction() == MotionEvent.ACTION_UP) return true; } </code></pre> <p>All methods are become called, there is no problems. But on Samsug GT-P5110 <code>hsize</code> always 0 except one case: if I put a break point at line where <code>hsize</code> is initialized, on the first call it's 0 (and it's normal behaviour) and on the next call it's become 16, 17 or whatever (not 0). For example, on Asus TF101 <code>hsize</code> always have such behaviour (0 and then some value). </p> <p>Is there is problems in my code or what? Or it's something specific to Samsung tablets?</p>
android
[4]
5,911,501
5,911,502
OAuth2 coonection to a server - android
<p>I'm developing an app in which when the user enters the email id and submit, I want to connect to the server using oAuth2 and store the mail id in the list. I have the url, access_token, client id, client secret and post header and body. But I'm not sure how to implement it. Any help is highly appreciated</p>
android
[4]
5,898,412
5,898,413
How to detect if document.write() has taken place in JavaScript?
<p>I want to do something when 2 document.write() statements have successfully occured. I tried the following but it didn't work:</p> <pre><code> function loadFields() { var load1 = document.write("&lt;input type='text' name='StoreLocation' value='"+storeLocation+"' /&gt;"); var load2 = document.write("&lt;input type='text' name='couponType' value='"+couponType+"' /&gt;"); } if (loadFields()) { alert('both items have loaded.'); } </code></pre> <p>I also tried this and again same result:</p> <pre><code> var load1 = document.write("&lt;input type='text' name='StoreLocation' value='"+storeLocation+"' /&gt;"); var load2 = document.write("&lt;input type='text' name='couponType' value='"+couponType+"' /&gt;"); if (load1 &amp;&amp; load2) { alert('both items have loaded.'); } </code></pre>
javascript
[3]
4,716,377
4,716,378
Array dereferencing doesn't work
<p>I have uploaded my project to a free web server and I see this error:</p> <pre><code>Parse error: syntax error, unexpected '[' in /home/a9243209/public_html/index.php on line 28` </code></pre> <p>Line 28:</p> <pre><code>$year = getdate(strtotime($currentDate))['year']; </code></pre> <p><strong>Note</strong></p> <p>The remove server runs PHP 5.2.17. I've tried to upload my project to a server with version 5.3, but the same error shows up! Everything works just fine on my localhost (php version 5.16.0)</p>
php
[2]
3,986,969
3,986,970
ASP.NET: I'm new to n-tier architecture. Can someone give me a high level overview?
<p>can you please describe what an n-tier architecture is. what is a data access layer? what type of code would typically go into this data access layer class? i have basically the same question for the business access layer. what type of code typically goes there? finally, can you also explain, in high level, how these layers interact with each other? thanks.</p>
asp.net
[9]
2,798,335
2,798,336
How to continue video play while orientation change in android
<p>I used videoview for playing a video in android default player. When I change its orientation, it starts playing from beginning. </p> <p>How could I make it to continue from that point, where orientation changed ?</p>
android
[4]
1,833,934
1,833,935
Create a function inside a function into a class?
<p>I'm trying to create some classes and i would like to use this syntax:</p> <pre><code>$my = new My(); $my-&gt;field()-&gt;test('test'); </code></pre> <p>I know how to do a <code>$my-&gt;test('test')</code>, it's easy - but I don't know how to add a <code>field()</code> attribute to make an easier comprehension of my class in my code.</p> <p>I can guess it's something like a class into another class - extends - but i'm not sure about that so if you know how to do something similar.</p> <p>I precise it's only for a better comprehension into my class. I mean the aim is to categorize functions in this <code>My</code> class.</p> <p>Thank you :)</p>
php
[2]
3,407,686
3,407,687
Call a non-static class function from a static function
<p>We have a static class function in our code that houses a fair amount of code. Where this code was originally used, and still is used, no instance of the class can be created hence why it is static. The functionality of this function is now needed elsewhere in our codebase, where an instance of the class is already created.</p> <p>Without making a non-static and static version of the same function is there anyway we can create a non-static function that houses all the code that can be polled using the static function in places where no class instance can be initialized, while allowing it to be called using the actual instance elsewhere.</p> <p>For example</p> <pre><code>#include &lt;iostream&gt; class Test { public: Test(){}; ~Test(){}; void nonStaticFunc(bool calledFromStatic); static void staticFuncCallingNonStaticFunc(); }; void Test::nonStaticFunc(bool calledFromStatic) { std::cout &lt;&lt; "Im a non-static func that will house all the code" &lt;&lt; std::endl; if(calledFromStatic) // do blah else // do blah } void Test::staticFuncCallingNonStaticFunc() { std::cout &lt;&lt; "Im a static func that calls the non static func that will house all `the code" &lt;&lt; std::endl; nonStaticFunc(true); } int main(int argc, char* argv[]) { // In some case this could be called as this Test::staticFuncCallingNonStaticFunc(); // in others it could be called as Test test; test.nonStaticFunc(false); } </code></pre> <p>Depending on if its call statically or not the code may alter slightly within the non static function, so we cant simply use a static function at all times, because sometimes we will need access to non-static members used elsewhere in the code. Most of the code will remain identical however. Cheers</p>
c++
[6]
3,043,087
3,043,088
Function getting called on the load of page
<pre><code>for (var key in obj[i]) { dataDump[key] = textField.value; var callback = function(zeKey){ return function(e){ dataDump[zeKey] = e.source.value; }; }(key); textField.addEventListener('change', callback); } </code></pre> <p>When I load the window, this function gets called automatically, which I don't want and instead I want this to be called only when I do a change.</p> <p>The main point is calling <code>function(zeKey){...}(key)</code>. When you do so, key, which is a string is copied as a parameter (zeKey) to your anonymous function.</p>
javascript
[3]
683,576
683,577
c# parameters question
<p>I am new to c# and need help understanding what going on in the following function</p> <pre><code> public bool parse(String s) { table.Clear(); return parse(s, table, null); } </code></pre> <p>where table is a Dictionary. I can see that is is recursive but how is parse being passed three params when it is defined to take just a string?</p> <p>EDIT: how do I delete a question? parse has been overloaded <em>facepalm</em></p>
c#
[0]
3,240,018
3,240,019
C# Checking if remote desktop is enabled on a windows client
<p>Is there any way I can detect if remote desktop is enabled on windows xp/vista/7. I know that you can access the session information using performance counters but what I really need is a enabled/disabled flag?</p> <pre><code>PerformanceCounter performanceCounter = new PerformanceCounter("Terminal Services", "Active Sessions"); </code></pre> <p>Thanks</p>
c#
[0]
743,705
743,706
Opening the numpad of the device
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8476490/open-a-numeric-keyboard-without-forcing-the-edittext-to-be-numeric-only">Open a numeric keyboard without forcing the EditText to be numeric only</a> </p> </blockquote> <p>In my app i have an EditText field which accepts only integer values. so i thought it would be better to open the numpad automatically instead of the alphabetics when i click on this EditText.</p> <pre><code>How can i achieve this?? </code></pre>
android
[4]
5,239,401
5,239,402
jquery div on top of another div
<p>I have a web page that contains a div element called #order_details that is hidden. When a user clicks on a button, then the #order_details div element appears. It appears that the div element has a z-index of 6500 which I have verified is the highest z-index in the entire site. It is also using jQuery because I see code like:</p> <pre><code>$('#order_details').show(); </code></pre> <p>which I know shows the #order_details div element.</p> <pre><code>&lt;html&gt; ... ... &lt;div id="button"&gt;&lt;/div&gt; &lt;div id="order_details"&gt; &lt;div id="button2launch_SURVEY"&gt;&lt;/div&gt; &lt;div id="survey"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/html&gt; </code></pre> <p>Now I've added a new div element called #survey and when I click on a button in the #order_details div I want the survey to appear on the top.</p> <p>I have set the z-index in the css #survey to be 6599. Then I setup some jQuery to show the div.</p> <pre><code>$('#survey').show(); </code></pre> <p>the #survey div appears, but it is not on top of the #order_details div.</p> <p>My question is:</p> <p>Isn't setting the z-index property of #survey to a higher value supposed to ensure that the #survey div will appear at the top?</p> <p>Any help would be greatly appreciated...</p>
jquery
[5]
2,625,744
2,625,745
Javascript. Calculating a percentage results in 1% difference
<p>I'm having an issue with some javascript where I am calculating a percentage. It always comes in 1% off:</p> <pre><code>pcOff = parseInt((1-(PriceFrom/PriceFromRRP))*100); </code></pre> <p>PriceFrom and PriceFromRRP are captured from a JSON return and in the case of <code>PriceFrom = '40.00'</code> and <code>PriceFromRRP = '50.00'</code> pcOff is being set to 19; it should be of 20. Something funny is going on here. Can anyone shed some light?</p>
javascript
[3]
882,279
882,280
How Do I acces a class from my Main Form?
<p>Hi Im new to C# infact somedays past only.I got a project from universty so I though os using c#.</p> <p>What Im doing in this case is <strong>reading text messages from a cell phone and then putting them in a text file.</strong> I learnt that I have to make a class for writing a File so I did and added that Class to My Form.Now I want to access and send string to that class to write it in a Text File. But I dont know how to.If anyone could help me directly then I can send him my code or If some1 can send me some guide links I will be Happy.</p> <p>Thanks xA</p>
c#
[0]
4,574,321
4,574,322
Inconsistent arguments in ArrayList methods
<p>In ArrayList API <strong>add()</strong> takes an argument of generic parameter type, but <strong>contains()</strong> and <strong>indexOf()</strong> take arguments of type <strong>Object</strong>.</p> <pre><code>public class ArrayList&lt;E&gt; ...{ public boolean add(E e); public boolean contains(Object o); public int indexOf(Object o); .... } </code></pre> <p><a href="http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html" rel="nofollow">Java Doc for ArrayList</a></p> <p>So i am just wondering if its something to do with Generics or it's design in-consistency ?</p> <p>I looked at <strong>Openjdk</strong> implementation but couldn't find any specific reason for this.</p>
java
[1]
4,318,438
4,318,439
Image showing on emulator but not on Android tablet
<p>I am developing an Android app which gets an image encoded in base 64 from a web service, and shows it in an ImageView. </p> <p>My problem is that the image is showing correctly on the emulator, but when running on the tablet (tablet ASUS Transformer with Android 4) the ImageView seems to disappear when loading it with the image.</p> <p>This is the code I am using to load the ImageView:</p> <pre><code>ImageView imageView = (ImageView) this.findViewById(R.id.floor_map_view); Bitmap image = BitmapFactory.decodeByteArray(result, 0, result.length); imageView.setImageBitmap(image); </code></pre> <p>The image is obtained correctly from the web service, as I said it is loading correctly on the emulator and plus I've compared the base 64 string received to that sent from my web service and they match.</p> <p>This is my activity layout:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="#ffffff"&gt; &lt;ImageView android:contentDescription="floorMapView" android:id="@+id/floor_map_view" android:layout_width="match_parent" android:layout_height="match_parent" android:src="#222222" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Any ideas what might be happening?</p> <p>Thank you.</p> <p>edit: using inSampleSize in an BitmapFactory.Options object and using it in the decodeByteArray call makes the image appear, but, as expected, smaller than it should be.</p>
android
[4]
1,445,585
1,445,586
how to get a reference to the defining 'class' inside an inner method in JavaScript?
<p>I have the following JS code:</p> <pre><code>var Item = function () { this.property = ''; this.myfunction = function () { var value = this.property; }; }; </code></pre> <p>however, <code>this</code> does not point to the defining class so value doesn't get anything.</p> <p>how do I access <code>this.property</code> from inside my function?</p>
javascript
[3]
1,205,504
1,205,505
Give me an example for this type of method?
<p>Please show me a simple code with class name as return type in a method? Some of the codings in project as classname as return type for methods? I don't understand What that mean?</p> <p>Can anyone give me a breif explanation and simple example regarding that one?</p> <p>For example</p> <pre><code>public Dataset getEmployees() { ----- ---- ------ } </code></pre> <p>In the above code we are using (<code>Dataset</code>)(It's basically a class) but here we are using as return type for <code>getEmployees</code> method.</p> <p>I want the same as example. Instead of <code>Dataset</code>,user defined class should be as return type. I hope you understand what my doubt is. </p>
c#
[0]
3,258,433
3,258,434
Is there a way to check an object reference to see if it is not set to an instance of an object?
<p>The compiler is always complaining about: "Object reference not set to an instance of an object." So hopefully there is an easy way to check whether this is the case before I try doing something that would cause it... thanks.</p>
c#
[0]
3,422,880
3,422,881
How to add a page adaptor to an ASP.NET project?
<p>I want to try the method of saving the viewstate to the DB as mentioned <a href="http://forums.asp.net/t/1293397.aspx/1?Store%20ViewState%20in%20the%20Database%20instead%20of%20Hidden%20Form%20Field/" rel="nofollow" title="here">here</a> but am confused by the PageAdaptor part. It says I should use app.browser to direct force my Adaptor to be used however, I don't use Visual Studio (using Delphi) so have no App_Browsers folder (if thats where it is) so I do not know how to tell my website that my custom adaptor should be used.</p> <p>I have tried adding a .browser file to my website root but this doesn't help.</p> <p>I appreciate I might be acting dumb here, just not sure :)</p> <p>Thanks.</p>
asp.net
[9]
3,461,590
3,461,591
Android: incomplete soap response?
<p>I make a soap request in my Android app using <code>HttpURLConnection</code> the response is a base64 encoded string holding the data of an image.</p> <p>the problem is that the response always received in complete. so the image can not be constructed correctly.</p> <p>what can be the reason for this ?</p> <p>thanks</p>
android
[4]
4,086,566
4,086,567
run animation then change page - jquery
<p>I am trying to build a script that will prevent a link from changing pages immediately and running an animation first. This is what I have so far:</p> <pre><code>$('a').click(function(event){ event.preventDefault(); $('#nav-bar').animate({ left:'-260' }, 1500, function(){ //want to use callback function to load the page.... $(this).attr('href') what next? } ); </code></pre> <p>I would like to rebuild the default event and fire in the callback function. Is there an easy way to do this? THanks</p>
jquery
[5]
461,356
461,357
how to retain the selcted values in the form even after page refreshing
<p>actually i'm new to php &amp; i'm developing a project SIMILAR TO ONLINE EXAMINTAION. so i'm display questionS RANDOMLY FROM D.B what the thing is. i'm displaying 5 questions ALONG WITH THEIR OPTIONS in a single form. and i selected a radio button from a form &amp; done page refreshing.the selected radio button can visible like unchecked after the page refreshing.so i want to display a radio button as checked which was selected by a user before page refreshing..is it possible. or can u suggest a code to block the browser refresh button...</p>
php
[2]
5,130,912
5,130,913
How to set horizontal scroll menu bar
<p>friend's, I have task to set menus in horizontal scrolling with images at two ends to show availability of menus. I did it by using gallery view, but i need to place an seperator (Vertical Line) between menus,i can't able to get the seperator in between the gallery. How can i get it.</p> <p>i need the view below </p> <pre><code> ---------------------------------------- &lt; menu1 | menu2 | menu3 &gt; ----------------------------------------- </code></pre> <p>just refer CBSNews application if u have.</p> <p>Thanks in advance. </p>
android
[4]
2,995,540
2,995,541
NullPointerException in class
<p>I have a class that contains 2 functions:</p> <pre><code>public class FileHandler extends Activity { public void writeToFile(){ String fileName = "lastDevice.txt"; try { FileOutputStream fos = openFileOutput(fileName, MODE_PRIVATE); //Exception thrown here fos.write("some device id".getBytes()); fos.close(); Toast.makeText(this, "File updated", Toast.LENGTH_SHORT).show(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public String readFromFile(){ try { String fileName = "lastDevice.txt"; FileInputStream fis = openFileInput(fileName); //Exception thrown here InputStreamReader isr = new InputStreamReader(fis); BufferedReader br = new BufferedReader(isr); String sLine = null; String data =""; while ((sLine = br.readLine())!=null) { data+= sLine; } return data; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); return "FileNotFoundException"; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return "IOException"; } catch (NullPointerException e){ // TODO Auto-generated catch block e.printStackTrace(); return "Null Pointer Exception"; } } </code></pre> <p>these functions are called from my main activity as follows:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lvDevices = (ListView)findViewById(R.id.ListViewDevices); lastDeviceTxt = (TextView)findViewById(R.id.lastDeviceTxt); //get last connected device FileHandler fh = new FileHandler(); String last = fh.readFromFile(); lastDeviceTxt.setText(last); } </code></pre> <p>but i keep getting a <code>NullPointerException</code> from both functions.<br> when running the functions from my <code>MainActivity</code> (I copied them to my main activity) they work fine. What am I doing wrong? (please remember that I'm very new to <code>android</code> development).</p>
android
[4]
5,376,665
5,376,666
C# encryption key discussion
<p>I am writing a .net application and want to use a supper strong encryption key by using the unicode characters to make it hard for the hackers to hack the code. The encryption key would be any characters from the <a href="http://www.unicode.org" rel="nofollow">http://www.unicode.org</a>. For example my encryption key could லูᇉޒۻڃxxxxxxxxxxxx + couple hundred characters which is very difficult for the computer to predict my code. I think the unicode has more than 95,000 characters.</p> <p>I am wondering if there is any data corruption because of these complex characters. Of course I have to check the decrypt data to make sure the code can decrypt before I save the information to the database. I have tested my code for more than 10 millions times to see how reliable and it run pretty good.</p> <p>Any thoughts guys?</p>
c#
[0]
2,555,683
2,555,684
How to get Screen metrics outside an Activity?
<p>I have a Generic Pool that i am making here:</p> <pre><code>public class FruitPool extends GenericPool&lt;Sprite&gt; { // =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== private final TextureRegion mTextureRegion; private Scene mScene; // =========================================================== // Constructors // =========================================================== public FruitPool(final TextureRegion pFruitTextureRegion, Scene mScene2) { this.mTextureRegion = pFruitTextureRegion; this.mScene = mScene2; } // =========================================================== // Getter &amp; Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override protected Sprite onAllocatePoolItem() { Random rand = new Random(); //I want to get the Screens Display metrics here... Sprite fruit = new Sprite(0, 0, this.mTextureRegion); mScene.attachChild(fruit); return fruit; } </code></pre> <p>I am trying to get the screens display metrics like this..</p> <pre><code> final Display display = getWindowManager().getDefaultDisplay(); CAMERA_WIDTH = display.getWidth(); CAMERA_HEIGHT = display.getHeight(); </code></pre> <p>The only problem is, is that i cant figure out how to do this outside of an Activity..</p> <p>Is this even possible? Or will i have to use SharedPreference or something?</p>
android
[4]
4,518,605
4,518,606
Star TSP100 is not able to print physically using microsoft point of service
<p>Hi I am stuck with previous 2-3 days for the printing functionality with the Star TSP100 printer. I am developing an application in Visual studio 2010. I have installed driver of the printer. also installed the "POS for .Net v1.12.exe" and connected the printer to the com port. I have written the code for implementing the printer. </p> <pre><code> PosExplorer explorer = null; DeviceInfo device = null; PosPrinter printer = null; explorer = new PosExplorer(); DeviceCollection printers = GetPrinters(); if (printers.Count != 0) printer = (PosPrinter)explorer.CreateInstance(printers[0]); string output = "test to print."; printer.Open(); printer.Claim(5000); printer.DeviceEnabled = true; if (printer.State != ControlState.Idle) throw new Exception("Printer not ready: " + printer.State.ToString()); //printer.CharacterSet = 1250; lineWidth = printer.RecLineWidth - 1; printer.PrintNormal(PrinterStation.Receipt, output.ToString()); for (int i = 0; i &lt; 10; i++) { printer.PrintNormal(PrinterStation.Receipt, "Test "+i + Environment.NewLine); } printer.PrintNormal(PrinterStation.Receipt, output.ToString()); printer.DirectIO(121, 0, null); CutPaper(); printer.Release(); Close(); </code></pre> <p>Although, when i test the printing manually from the same printer, I working fine and printing the same. But, when i am running this code it's opening a window form "Microsoft PosPrinter Simulator" and when sending the print command its printing the same on the form.. What should i do now... Please help me..</p>
c#
[0]
3,000,352
3,000,353
Weird jQuery show() issue - What am I not seeing?
<p>I have a DIV that contains an image with a hotspot. It is set to hidden by default.</p> <p>I have a function I call to show it. </p> <p>In the function, this works:</p> <pre><code>$('#adChart').css("visibility", "visible"); </code></pre> <p>But this does NOT work:</p> <pre><code>$('#adChart').show(); </code></pre> <p>This does not work, either:</p> <pre><code>$('#adChart').fadeIn(1000); </code></pre> <p>(And what I really want to do is fade and slide in from the left. But I can't even get a simple show() to work at this point.)</p> <p>Wrapping with Document-ready doesn't help, either. And I don't believe I need to wrap every function definition in the code with document-ready, do I? There could hundreds.</p> <p>Suggestions?</p>
jquery
[5]
1,431,824
1,431,825
Why are argument modifiers (i.e., 'const' or 'volatile') not considered part of a function's type or signature?
<p>Note that the following two functions have the same type and signature:</p> <pre><code>void foo1(int t) {} // foo1 has type 'void(*)(int)', and signature '(*)(int)' void foo2(const int t) {} // Also type 'void(*)(int)', signature '(*)(int)' </code></pre> <p>(the <code>const</code> is not part of the function type or function signature). Similarly, a modifier (<code>const</code> or <code>volatile</code>) on the return type does not influence the function type or function signature.</p> <p>However, in the function definition itself (not shown), the named variable <code>t</code> does maintain the <code>const</code> qualification in <code>foo2</code>.</p> <p>There are many StackOverflow questions discussing why the <em>return type</em> of the function is not considered as part of the function signature (used for overload resolution).</p> <p>However, I cannot find any StackOverflow question that asks why argument modifiers (<code>const</code> or <code>volatile</code>) are not part of the function's type or signature. Also, I have looked directly in the C++11 standards document and find it difficult to unravel.</p> <p>What is the rationale behind the fact that argument modifiers (i.e., <code>const</code> and <code>volatile</code>) are not part of a function's type or signature?</p> <p><strong>ADDENDUM</strong> For clarity, from R.MartinhoFernandes's answer below, I should clarify that in C++ (I think) the argument modifiers <code>const</code> and <code>volatile</code> are only ignored as part of the function type/signature if they are <strong>top-level</strong> modifiers - see that answer below.</p>
c++
[6]
960,269
960,270
Instantiate variables in class instead of onCreate() wrong?
<p>Is something wrong with this construct in Android?</p> <pre><code>class A extends Activity { private Object myObject = new Object(); @Override protected void onCreate(Bundle savedInstanceState) { //myObject = new Object(); } </code></pre> <p>}</p> <p>Because at some point(s) later I get (sometimes, not reproducible yet) exceptions because myObject is null. I don't know if it's because I have to initialize in onCreate.</p> <p><strong>Edit</strong>: Additional details: </p> <ul> <li><p>The actual class of myObject is <code>List&lt;Object&gt;</code> (Where Object is a domain specific type)</p></li> <li><p>At some point later in the activity <strong>I'm storing myObject as a static field of a "Parameter passer" class and starting other Activity</strong> (because I'm avoiding to implement Parcelable. If this is good or bad practice should not be discussed here, unless that's causing my error). In the other Activity I pick up myObject. There it's (sometimes) null.</p></li> </ul> <p><strong>Edit 2</strong>: I don't understand why this object becomes null if I'm storing a reference to it as static field of my parameter passer class (a standalone, dedicated class). That's how garbage collection works, right, it just removes when the objects are not referenced anymore. So since I have a static reference this object should not be removed. According to this thoughts, if they are correct, the problem should be somewhere else.</p>
android
[4]
2,578,382
2,578,383
MediaStore.EXTRA_OUTPUT How to save image with low Pixe
<pre><code> Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri ); </code></pre> <p>When i use this code, the camera is default to 5M Pixe, but now i want to use the lowest Pixe to save image 1.2M Pixe.<br/></p> <p>how can i do this?</p>
android
[4]
5,450,349
5,450,350
Do in_array have a like function?
<p>I have an array of people that is registered as online in a html file. I am using this so that each can have an image assigned to them. But when checking to see if using name is already in use the in_array function return false and allow the script to continue. </p> <pre><code>$user = "&lt; img src='default.jpg' /&gt;John"; $explode = array("&lt;img src='tress.jpg' /&gt;John"); if(in_array($user, $explode)) { //show login script if user exists } else { //continue to script } </code></pre> <p>Now the reason this is not working is because the john in the array is not identical to the john in $user. Is there anyway of checking that the name exists in the array? When responding please explain.</p>
php
[2]
5,040,029
5,040,030
News Aggregators
<p>I need to create a news aggregator for our application, something similar to reading AP News from Yahoo, or something like <a href="http://popurls.com/" rel="nofollow">http://popurls.com/</a>; the problem is that I don't know how it works. <br /> So, a couple of questions: <br /> 1) How do I determine what news site to aggregate? Do I hard-code the specific site's url into the application? <br /> 2) How do I know the url of the specific news? It's one thing to know the site name, but another to know the url of the specific news. <br /> 3) How do I embed the news content onto our application? <br /> 4) How do I determine (without specifically hard-coding everytime) the category(ies) each news should go? <br /> <br /> Thank you very much for the help.</p>
php
[2]
3,369,505
3,369,506
Trying to make a thai translator in Python, but am unable to write using Thai characters
<p>I am trying to make a thai translator, but am unable to write using Thai characters. I saw somewhere to do this to check what the default encoding is:</p> <pre><code>import sys; print(sys.getdefaultencoding()) </code></pre> <p>I get utf-8 </p> <p>My problem is that I just get ?? when I use Thai characters. Is there a way that I can use them? A different question I am trying to translate a sentence and was wondering how to put a space in between words. As of right now I just get all the words combined in the .txt file. </p> <pre><code>s = shelve.open("THAI.dat") s[entry]=define text_file = open("THAI.txt", "w+") num = int(input("How many words are in sentence")) while num != 0: trys = input("Input english word") if trys in s: print(s[trys]) part = s[trys] text_file.write(part) num -= 1 </code></pre>
python
[7]
718,548
718,549
What does Object.create( Class.prototype ) do in this code?
<p>I'm reading about the <a href="http://addyosmani.com/resources/essentialjsdesignpatterns/book/#mixinpatternjavascript" rel="nofollow">mixin pattern in javascript</a> and I encountered this piece of code that I don't understand:</p> <pre><code>SuperHero.prototype = Object.create( Person.prototype ); </code></pre> <p>There is actually a typo in the original code (the uppercase H). If I downcase it it works. However, if I actually delete the line everything seems to work the same.</p> <p>Here is the full code:</p> <pre><code>var Person = function( firstName , lastName ){ this.firstName = firstName; this.lastName = lastName; this.gender = "male"; }; // a new instance of Person can then easily be created as follows: var clark = new Person( "Clark" , "Kent" ); // Define a subclass constructor for for "Superhero": var Superhero = function( firstName, lastName , powers ){ // Invoke the superclass constructor on the new object // then use .call() to invoke the constructor as a method of // the object to be initialized. Person.call( this, firstName, lastName ); // Finally, store their powers, a new array of traits not found in a normal "Person" this.powers = powers; }; SuperHero.prototype = Object.create( Person.prototype ); var superman = new Superhero( "Clark" ,"Kent" , ["flight","heat-vision"] ); console.log( superman ); // Outputs Person attributes as well as powers </code></pre> <p>What does <code>SuperHero.prototype = Object.create( Person.prototype );</code> do?</p>
javascript
[3]
3,458,151
3,458,152
First 6 ListView elements are continuously being invoked with getView()
<p>When I check my logs, when using ListView, I see, that getView() method of a custom adapter is continuously invoked on first 6 elements, even if I scroll to the very end of the list. Has anyone seen behaviour like this?</p>
android
[4]
4,257,742
4,257,743
How to assign value in the callback function?
<p>I am having issues with a <code>callback</code> function</p> <pre><code>project.prototype.getFolder = function(path){ this.imagePath; var instance = this; function getImage(image, callback) { var it = function(i){ codes..... //I am sure variable image is not null callback(image); codes.... } } // function to get the image getImage(image, function (img) { instance.imagePath = img; }); //it outputs undefined... console.log(this.imagePath ) } </code></pre> <p>I want to assign the value to <code>this.imagePath</code> inside the <code>callback</code> function, but it seems I am getting <code>undefined</code> in my case. I am sure I pass valid <code>image</code> variable but I am still getting nothing. Can anyone provide a tip? Thanks a lot!</p>
javascript
[3]
4,231,103
4,231,104
Weird arithmetical behavior in JavaScript
<p>I'm trying to code my own slide show in JavaScript. What I already have is a skeleton which works in Opera, Safari and Chrome:</p> <pre><code>var slideShow = (function() { var latestGames = document.getElementById('latestGames').getElementsByTagName('li'); var displayedGame = 0; return { init: function() { latestGames[displayedGame].style.display = 'inline'; setInterval(this.update, 3000); }, update: function(gameToDisplay) { console.log("Displayed game: " + displayedGame); latestGames[displayedGame].style.display = 'none'; gameToDisplay = gameToDisplay || (displayedGame === (latestGames.length - 1) ? 0 : ++displayedGame); console.log("Game to display: " + gameToDisplay); console.log('===================='); latestGames[gameToDisplay].style.display = 'inline'; displayedGame = (gameToDisplay == latestGames.length ? 0 : gameToDisplay); } } })(); </code></pre> <p>But in Firefox I only get random numbers when I log the gameToDisplay variable. I can't see where is the error.</p> <p>Thanks beforehand. </p>
javascript
[3]
5,411,731
5,411,732
My ASP.NET site doesn't find files located in different folders
<p>My website has many pages which operate on some data in a database. Since many procedures are the same, I have put all of these "general" functions inside a (public partial) static class and saved it in the App_Code folder as suggested by Visual Studio:</p> <pre><code>Root | +-- App_Code | | | +-- GeneralStuff.cs | | | +-- DataStructure.cs | +-- Default.aspx | +-- Default.aspx.cs | +-- etc </code></pre> <p>The problem is that whenever I try to use something defined inside my GeneralStuff class the page doesn't compile because it can't find that class:</p> <pre><code>Compiler Error Message: CS0103: The name 'GeneralStuff' does not exist in the current context </code></pre> <p>I can't also use the files that are saved in the App_Data folder. Note that everything works fine when running from Visual Studio. </p> <p><strong>Additional details:</strong> Here's the version I'm using:<br> - Microsoft .NET Framework Version:2.0.50727.3625;<br> - ASP.NET Version:2.0.50727.3634; </p> <p>Any hints? </p> <p>Cheers</p>
asp.net
[9]
926,274
926,275
Static dataset in ASP.NET
<p>Will declaring a dataset as STATIC in ASP.net website help in persisting data across post backs?</p> <p>I was looking at an application and somehow a static dataset was able to persist the data even if we closed the application and opened it again.</p>
asp.net
[9]
3,929,303
3,929,304
Uses of .sub() in real life
<p>I stumbled upon the <code>.sub</code> function from browsing the jQuery source. There is a <a href="http://api.jquery.com/jQuery.sub/" rel="nofollow">documentation page</a> but it doesn't show any convincing 'real-life' applications.</p> <p>Do people actually use <code>.sub()</code>? If so, for what?</p>
jquery
[5]
5,757,048
5,757,049
ASP.net: What type of application/website is more suitable to Webform or MVC?
<p>I have read all the post regarding the pro and con of ASP.net webform vs mvc.</p> <p>However, I'm wondering under what circumstance does one use webform or mvc? would it come down to what you or your team is more familiar with?</p>
asp.net
[9]
5,833,057
5,833,058
Can we update an existing plist file of an iphone app?
<p>Can we update the content of an existing plist file of an iphone app such that the older plist file is replaced by the updated one in the app?</p>
iphone
[8]
3,147,617
3,147,618
getApplicaiton return which object among applicaitons
<p>in android there is a base class Application for global application state keeper.</p> <p>i create two or more call extending from Application</p> <p>by getApplicaiton() which object i will get from this method ?</p>
android
[4]
3,755,563
3,755,564
Where the microsoft.office.tools.excel.dll is installed?
<p>I have installed VS2010 SP1 with .NET 4.0 and cannot find where the microsoft.office.tools.excel.dll is located.</p> <p>Question> Where I can find this DLL?</p>
c#
[0]
2,593,296
2,593,297
'undefined' is not a function (evaluating '$(this).calcSubWidth()')
<p>Having an issue with an error related to the navigation menu. When hovering over, a javascript error appears: 'undefined' is not a function (evaluating '$(this).calcSubWidth()'). It is in menu.js. However, even with the erro, the menu works fine.</p> <p>Website: <a href="http://csenew.drdino.coresense.com" rel="nofollow">http://csenew.drdino.coresense.com</a></p> <p>Any help you can give is appreciated.</p>
jquery
[5]
166,816
166,817
Fastest method to detect if there is a tag with attribute [itemtype='http://schema.org/Offer']
<p>I am looking to detect with Javascript the fastest possible way, if there is a HTML tag with attribute <code>[itemtype='http://schema.org/Offer']</code> in the current page.</p>
javascript
[3]
3,479,535
3,479,536
jquery: disable submit button in a form and enable it onChange of any element on the form
<p>I need to disable the disable the submit button on my form and to enable if the onchange event occurs for any other input on the form <br/> so basically I need to:</p> <ul> <li>disable the submit button</li> <li>add a method that enbales the submit button to the onchange event for all the other inputs on the form</li> </ul> <p>anybody knows how to do this ? (especially the second one)</p>
jquery
[5]
3,763,390
3,763,391
How can running CMD from c# with a hidden CMD
<p>How can running CMD from c# without to see the cmd windows? </p>
c#
[0]
1,266,011
1,266,012
need help in Java passing objects
<p>UPDATE: i modified the hashCode, now is a little better. :) but the problem is still there... :(</p> <p>so, and modified my method too:</p> <pre><code>private Node getMinNode() { int min = 9999999; //value Node minNode = new Node(); //key,index for (Node key : this.distances.keySet()) { int minOfNode= this.distances.get(key); System.out.println("Key "+ key +", Value = " + minOfNode); if(minOfNode&lt;min) { min= minOfNode; minNode= key; System.out.println("Key minNode = " + minNode + ", Value minNode = " + minOfNode); } } return minNode; } </code></pre> <p>and there is the output: (the whitespace(, ,) in the lines would be an empty char) and this is not the end... this is only the first few row...</p> <pre><code> Key 66601, 3546492, 3546493, 228, f, Value = 9999999 Key 77393, 3628185, 3628186, 64, t, Value = 9999999 Key 0, 0, 0, 0, , Value = 0 Key minNode = 0, 0, 0, 0, , Value minNode = 0 Key 66601, 3546492, 3546493, 228, f, Value = 9999999 Key 77393, 3628185, 3628186, 64, t, Value = 9999999 </code></pre> <p>(note: the element with 'Key 0, 0, 0, 0, , Value = 0' does exists, this is the startNode) in that constructor the attribs are initialized with the zeros, i know, so my main problem is, why is that happening? they are passed rigth out of the if(), but in the if() they arent i hope it's clearer what is my problem. :)</p>
java
[1]
1,299,626
1,299,627
I am not able to add multiple div controls to a parent div control
<pre><code>protected void lbChatFriend_Click(object sender, EventArgs e) { ChatDivContent.Visible = true; System.Web.UI.HtmlControls.HtmlGenericControl createDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV"); createDiv.ID = "div"; createDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Yellow"); createDiv.Style.Add(HtmlTextWriterStyle.Position, "relative"); createDiv.Style.Add(HtmlTextWriterStyle.Color, "Red"); createDiv.Style.Add(HtmlTextWriterStyle.Height, "50px"); createDiv.Style.Add(HtmlTextWriterStyle.Width, "50px"); createDiv.InnerHtml = " I'm a div "; string chatFriend = ((LinkButton)sender).Text; createDiv.Attributes["title"] = chatFriend; ChatDivContent.Controls.Add(createDiv); } &lt;div id="ChatDivContent"&gt; &lt;DIV id="div" style="background-color:Yellow;position:relative;color:Red;height:50px;width:50px;" title="dinesh"&gt; I'm a div &lt;/DIV&gt;&lt;/div&gt; </code></pre> <p>&lt;----This is my output on every postback</p> <p>Wnat am I doing wrong?</p>
asp.net
[9]
2,812,248
2,812,249
unexpected javascript date behavior
<p>I have the following code:</p> <pre><code>var newDate=new Date('05/22/2012'); var month=newDate.getMonth(); var day=newDate.getDate()+(-2); var year=newDate.getYear(); document.write(month+'/'+day+'/'+year); </code></pre> <p>I expected it to return '05/20/2012' but instead it returns '04/20/2012'</p> <p>This makes no sense to me - can someone help me understand what's going on and how to get the correct response?</p> <p>Thank you for your kind attention!</p>
javascript
[3]
5,715,001
5,715,002
C++ Vector of vectors is messing with me
<p>If I put this code in a .cpp file and run it, it runs just fine:</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;string&gt; using namespace std; typedef vector&lt;int&gt; row; typedef vector&lt;row&gt; myMatrix; void main() { //cout &lt;&lt; endl &lt;&lt; "test" &lt;&lt; endl; myMatrix mat(2,2); mat[0][1] = 2; cout &lt;&lt; endl &lt;&lt; mat[0][1] &lt;&lt; endl; } </code></pre> <p>But, if I make a .h and a .cpp file with the .h file like this, it gives me boatloads of errors.</p> <pre><code>#ifndef _grid_ #define _grid_ #include&lt;iostream&gt; #include&lt;vector&gt; #include&lt;string&gt; using namespace std; typedef vector&lt;int&gt; row; typedef vector&lt;row&gt; myMatrix; class grid { public: grid(); ~grid(); int getElement(unsigned int ri, unsigned int ci); bool setElement(unsigned int ri, unsigned int ci, unsigned int value); private: myMatrix sudoku_(9,9); }; #endif </code></pre> <p>These are some of the errors I get:</p> <pre><code>warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared error C4430: missing type specifier - int assumed. Note: C++ does not support default-int </code></pre>
c++
[6]
3,125,739
3,125,740
Moving widgets in runtime on Android
<p><br> I have a simple demo with two buttons. They are laid out with a RelativeLayout at the top and bottom of the screen.<br> When I click one of them, I want them to switch places. What is the best way to do that?</p> <p>This is my res/layout/main.xml :</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageButton android:id="@+id/android_button_1" android:layout_width="200dip" android:layout_height="wrap_content" android:src="@drawable/icon" android:layout_alignParentTop="true" /&gt; &lt;ImageButton android:id="@+id/android_button_2" android:layout_width="200dip" android:layout_height="wrap_content" android:src="@drawable/icon2" android:layout_alignParentBottom="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And this is my Activity:</p> <pre><code>public class HelloButtons extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageButton button1 = (ImageButton) findViewById(R.id.android_button_1); final ImageButton button2 = (ImageButton) findViewById(R.id.android_button_2); button1.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks Toast.makeText(HelloButtons.this, "Beep Bop", Toast.LENGTH_SHORT).show(); } }); button2.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks Toast.makeText(HelloButtons.this, "Beep Bop", Toast.LENGTH_SHORT).show(); } }); } } </code></pre>
android
[4]
348,329
348,330
Persist a Python class instance across command-line calls (without shelve)?
<p>I have an existing Python class that is used for data capture. It has start() and stop() methods to start and stop the data capture. Right now this class is used in a single Python script, e.g.:</p> <pre><code>dataGrabber = DataGrabber() dataGrabber.start() # do a bunch of stuff... dataGrabber.stop() </code></pre> <p>We want to break out the start and stop functionality and be able to start and stop the data capture from the command line, e.g.:</p> <pre><code>python CaptureData.py start &lt;&lt;&lt; go off and do something else &gt;&gt;&gt; python CaptureData.py stop </code></pre> <p>I need a way for CaptureData.py to create an instance of the DataGrabber class when the script is called with the "start" argument, save that class instance somehow, and have it be accessible when I call the script with the "stop" argument.</p> <p>I tried using shelve, but the DataGrabber class has tons of instance methods, and Python can't pickle instance methods.</p> <p>Any ideas? Is there any way I can do this?</p>
python
[7]
1,301,797
1,301,798
play back song in iPhoneapp
<p>I want to play a song global in iPhone. If I quit the sound application and I dont pause the song then that song play globle in iphone.</p>
iphone
[8]
1,395,298
1,395,299
Emulator stops working in android
<pre><code>Error: </code></pre> <p>ActivityManager:Starting:Intent{act=android.intent.category.LAUNCHER}cmp=com.personal/.PersonalActivity}</p> <p>Activity not started ,its current task has been brought to front</p>
android
[4]
2,190,980
2,190,981
How to remove icon programatically (Android)
<p>By remove the below intent-filter in AndroidManifest.xml, it can remove the icon after install.</p> <pre><code>&lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; </code></pre> <p>But i have try the below when on Boot than remove the Icon, but the icon still remain after reboot. I have add the permission, and this reboot receiver is work. </p> <pre><code>public class BootBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { PackageManager p = context.getApplicationContext().getPackageManager(); ComponentName componentName = new ComponentName("com.example.removeicon","com.example.removeicon.LauncherActivity"); p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } } </code></pre> <p>Or Put the Boot on service and AndroidManifest.xml intent-filter is not remove, the service is run and work.</p> <pre><code>package com.example.removeicon; @Override public int onStartCommand(Intent intent, int flags, int startId) { PackageManager p = getPackageManager(); ComponentName componentName = new ComponentName("com.example.removeicon","com.example.removeicon.LauncherActivity"); p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); startService(); } </code></pre>
android
[4]
4,292,757
4,292,758
MVC Razor: How to mix html helpers and text in same line?
<p>I would like to use multiple html helpers in the same line, but I'm not succeding.</p> <p>The result I search is: <code>Name:&lt;textbox&gt;</code> (note the ":")</p> <pre><code>@Html.LabelFor(x=&gt;x.Name) ":" @Html.EditorFor(x =&gt; x.Name) //doesn't work </code></pre> <p>How can I achive this?</p>
asp.net
[9]
3,498,541
3,498,542
How can I append a .png image into a html file using java?
<p>I generate a html file using log4j WriterAppender file. I also takesnapshots of my screen using webdriver. Now I wish to append them together.</p> <p>Any idea how to do that?</p> <p>Thanks!</p> <p>Apologies for not being clear and daft. My situation is that I have got a html file which is generated dynamically by my logger class and then there are some .png file which are also being created dynamically. Now I want them to appear together in one file. Am I clear now? Please ask for more information if needed </p>
java
[1]
5,285,583
5,285,584
Reverse filter in jQuery
<p>Instead of this...</p> <pre><code>$("#gridContainerAvailable input:checkbox") </code></pre> <p>How do I do this...</p> <pre><code>var parent = $("#gridContainerAvailable"); parent.[insert method here].('input:checkbox') </code></pre> <p>Cheers, Ian.</p>
jquery
[5]
3,860,927
3,860,928
Is onCreate called when an Activity object is created?
<p>Is onCreate called when a class object that extends activity is created? Or is it only called when an activity is <em>started</em>, for example over startActivity(...).</p>
android
[4]
5,086,752
5,086,753
Declaring variable in a FOR one time
<p>I have a simple question in java. I have this piece of code:</p> <pre><code>int i1=0; for(String x: list1) { for(String y: list2) { if(x == y) { log ("Checking "+x+" with "+y+" =&gt; found a match!"); list1.remove(i1); break; } else { log ("Checking "+x+" with "+y+" =&gt; not matching!"); } } i1=i1+1; } </code></pre> <p>As u can see, i'm declaring <strong>"i1"</strong> above, but is there a way to declare it in the first for just once and after the finish of that <strong>FOR</strong> to unset itself?</p> <p>Hope you understand me.</p>
java
[1]
4,903,250
4,903,251
Passing objects in javascript
<p>I want to pass an object in javascript. But i am getting an error <code>javascript:callbackCredits(1,dotsContainer_credits); is undefined</code></p> <p>My code is as follows:</p> <pre><code>var dotSlideCredits = { show : 3, width : 430, functionName : "callbackCredits", title: "title", itemId: "#s_credit" } var test = { data[] } $(document).ready(function(){ dynamicList(dotSlideCredits); } function dynamicList(dotSlide){ var divItems = "dotsContainer_"+dotSlide.title; test.data.push({title: dotSlide.title+[i], callBack: "javascript:"+dotSlide.functionName+"("+i+","+divItems+");"}); } function callbackCredits(current, container){ var prev = $("#previousCredit").val(); slideShow(current, prev, container); $("#previousCredit").attr("value", current); } </code></pre>
javascript
[3]
625,004
625,005
JQuery IE 7 or IE9 dynamically add or remove options in select list not getting updated properly
<p>I’m new to JQuery and I hope some experts can help me with a strange issue I’m facing.</p> <p>I’m building a web application using ASP.NET MVC. In one of the view I’m giving a feature to the end users to add (or) remove a row dynamically to a table using JQuery. The first and second columns of the table will have a drop down list. The third column will have a text box. </p> <p>If the user is selecting a value in Column 1 dropdown list (options) the list of options in Column 2 dropdown list will change dynamically.</p> <p>I built this whole thing by referring so many questions &amp; answers out here in SO, (thanks a ton to all the contributors :-), I learnt a lot on JQuery)</p> <p>This whole feature is working great in Chrome, FF and Safari. However this feature is not working as expected in IE7 and IE8. I’ve not tried it in IE9 so far.</p> <p>In IE8 after adding couple of rows dynamically if I select any value in the select list 1 (for ex: Row number 9th, column 1) the options are not getting reflected properly in (Row number 9th, Column 2).</p> <p>When I inspect the DOM the html is having the correct options which confuses me even more. Any of you have faced this issued in the past by any chance? Or am I doing something stupid? </p> <p>I have been trying various options however I’m not able to get this work :-(</p> <p>I have created a js fiddle hope that may help you in explaining this issue better. <a href="http://jsfiddle.net/msudalai/7dJ6J/" rel="nofollow">http://jsfiddle.net/msudalai/7dJ6J/</a></p> <p>Update: I just found this answer this morning. It worked like a charm <a href="http://stackoverflow.com/a/2040837/1162558">http://stackoverflow.com/a/2040837/1162558</a></p> <p>I'm leaving the question out there and see some one has a workaround with JQuery</p>
jquery
[5]
3,242,005
3,242,006
Freeing Application resources
<p>Usually resources such as threads, services, memory allocation... are allocated and defined per Activity. Hence, resources will be allocated on Activity.onCreate() and freed on Activity.pause(). This is very well defined.</p> <p>But, suppose my resources are allocated per Application (i.e I define a service which is used by several activities, OR, I instantiate a thread in the Native layer using NDK). Allocating these resources is not a problem. It can simply be done when the first Activity starts. The problem is - when should these resources by freed? How do I know when my application ends? According to the documentation: <a href="http://developer.android.com/reference/android/app/Application.html#onTerminate" rel="nofollow">http://developer.android.com/reference/android/app/Application.html#onTerminate</a>() - " <strong>Note: never depend on this method being called; in many cases an unneeded application process will simply be killed by the kernel without executing any application code."</strong></p> <p>Any ideas anyone?</p> <p>Thanks, Eyal </p>
android
[4]
1,191,840
1,191,841
is it possible to access HTML form data POSTed through a WebView?
<p>I've started to write an app which provides the user with an HTML form via a WebView. As the form is not under my control, the data filled in may be sent as either GET or POST request. My app is required to capture the transported form data, that is, get a hold on what was entered into the form fields.</p> <p>Using an adequate callback from WebViewClient such as <code>onPageLoaded()</code>, it is easy to capture form data from a GET request. However, I cannot find any appropriate method to allow the same for POSTed data, i.e., be able to access the HTTP POST message body containing the form data. Am I missing a relevant callback here or is there simply no way to accomplish the specified goal with the given API (even the latest level 8)?</p> <p>Assuming it wasn't possible, I considered overriding and extending parts of android.webkit in order to introduce a new callback hook that is passed the POST body somehow. That way, my app could be shipped with a customized browser/WebViewClient that fulfills the desired feature. However, I couldn't find any good spot to start with in the code and would be glad for any hints in this regards (in case the approach looks promising at all).</p> <p>Thanks in advance!</p>
android
[4]
937,834
937,835
JavaScript private methods, asynchronous access
<p>I'm using a pattern like the one shown below to create a javascript library that has private and public methods. The idea is that the page that includes this library would call MYLIB.login() and provide two functions for when the user clicks OK, or Cancel.</p> <pre><code>var MYLIB = function() { // private data and functions var showForm = function() { // create and show the form }; var onOK = function() { // hide the form, do some internal stuff, then… okFunction(); }; var onCancel = function() { // hide the form, do some internal stuff, then... cancelFunction(); }; var okFunction = null; var cancelFunction = null; // public functions return { login : function(okf, cancelf) { okFunction = okf; calcelFunction = cancelf; showForm(); }, }; }(); </code></pre> <p>My question is about getting the buttons in the form to call the internal functions onOK and onCancel, which are private. The buttons look like this:</p> <pre><code>&lt;button onclick="onOK();"&gt;OK&lt;/button&gt; &lt;button onclick="onCancel();"&gt;Cancel&lt;/button&gt; </code></pre> <p>I can get it to work if I make the functions public, but then I may as well make everything public. How can I do what I want? Coming from a C++/Java background, trying to be a good OO guy. Thanks.</p>
javascript
[3]
1,019,989
1,019,990
Ordering a set of lines so that they follow one from the other
<pre><code>Line# Lat. Lon. 1a 1573313.042320 6180142.720910 .. .. 1z 1569171.442602 6184932.867930 3a 1569171.764930 6184934.045650 .. .. 3z 1570412.815667 6190358.086690 5a 1570605.667770 6190253.392920 .. .. 5z 1570373.562963 6190464.146120 4a 1573503.842910 6189595.286870 .. .. 4z 1570690.065390 6190218.190575 </code></pre> <p>Each pair of lines above (a..z) represents the first and last coordinate pair of a number of points which together define a line. The lines are not listed in sequence because I don't know what the correct sequence is just by looking at the coordinates (unless I look at the lines in a map).</p> <p>Hence my question: how can I find programmatically (in Python) what the correct sequence is, so I can join the lines into one long line, keeping in mind the following problem: - a 'z' point (the last point in a line) may well be the first point if the line is described as proceeding in the opposite direction to other lines. e.g. one line may go from left to right, another from right to left (or top to bottom and viceversa).</p> <p>Thank you in advance...</p>
python
[7]
5,998,811
5,998,812
reinitialize an object with self.__init__(...)
<p>Could anybody explain whether it is safe to reinitialize an object by calling "self.<strong>init</strong>(". as shown in the following simplified example?</p> <p>The reason i'm asking is that i couldn't find this method neither in several python books nor in internet. There are some who suggest to list all attributes and set them to initial value one by one. Basically i want to set my object to initial state after it has finished some tasks.</p> <pre><code>class Book(object): def __init__(self,name,author): self.name = name self.author = author self.copies = 5 def reset(self): self.__init__(self.name,self.author) def incrementCopy(self): self.copies += 1 Kite = Book('kite runner','khaled hosseini') print 'initial number of copies:', Kite.copies Kite.incrementCopy() Kite.incrementCopy() Kite.incrementCopy() print '3 copies are added:', Kite.copies Kite.reset() print 'number of copies are reinitialized', Kite.copies initial number of copies: 5 3 copies are added: 8 number of copies are reinitialized 5 </code></pre>
python
[7]
3,816,476
3,816,477
rest webservice in android
<p>can anybody give example of rest webservice in android</p>
android
[4]
3,569,583
3,569,584
How do I send DTMF tones and pauses using Android ACTION_CALL Intent with commas in the number?
<p>I have an application that calls a number stored by the user. Everything works okay unless the number contains commas or hash signs, in which case the Uri gets truncated after the digits. I have read that you need to encode the hash sign but even doing that, or without a hash sign, the commas never get passed through. However, they do get passed through if you just pick the number from your contacts. I must be doing something wrong. For example:</p> <pre><code>String number = "1234,,,,4#1"; Uri uri = Uri.parse(String.format("tel:%s", number)); try { startActivity(new Intent(callType, uri)); } catch (ActivityNotFoundException e) { ... </code></pre> <p>Only the number '1234' would end up in the dialer.</p>
android
[4]
431,332
431,333
Is there any reason to sanitize user input if the input is not going to be stored anywhere?
<p>I can understand why user input that will be stored in a database needs to be sanitized to prevent sql injection and the like. But for a standalone script that just returns temporary data back to the user based on there original input. Is there a need to sanitize the user's original input in this situation?</p>
php
[2]
2,484,741
2,484,742
hiding an element with javascript, in a modular way
<p>I'm trying to create some functionality akin to .hide in jquery, but just using plain javascript, here's what I have so far:</p> <pre><code>(function() { addLoadEventHandler(function() { getByName = (function(name){ return document.getElementsByTagName(name) }) hide = (function(){ return style.display = 'none' }) }); return { getByName: getByName, hide: hide }; }()); </code></pre> <p>so terribly incomplete, but am I heading along the right track here. Sorry, bit of a noob.</p>
javascript
[3]
2,111,923
2,111,924
inheritance related problem in c#
<p>i learnt that private members are available in sub class in c# but we cant use these then what is the use of those private members n sub class and how can i access those private member in sub class please let me now i am not getting this point.</p>
c#
[0]
3,201,538
3,201,539
how to check if a passcode or screenlock is set in Android?
<p>Hi friend's i am new in Android</p> <blockquote> <p>how to check if a passcode or screenlock is set in Android.</p> </blockquote> <p>Is there any public API to figure this out. MY current application stores some secure data so it's important to know from the business logic of the application.please suggest me something. Thanks in Advance.</p>
android
[4]
439,263
439,264
Need direction on where to begin my programming journey. Non language specific just a foundation..where do I start?
<p>Sorry if this is in the wrong forum but I'm taking the plunge and I want to learn how to program from the ground up. I've been using VB.NET but only by copying/pasting what I could find on the net.</p> <p>I am wanting to start fresh. I'm looking for direction on what types of things I should be researching for a good primer for programming before I even consider a language.</p> <p>Any ideas?</p> <p>Thanks</p>
c#
[0]
5,330,440
5,330,441
Surprising output of Python program
<p>I am just started learning Python am getting bit confused after seeing the output of following program:</p> <pre><code>#!/usr/bin/python # Function definition is here def changeme( mylist ): "This changes a passed list into this function" mylist = [1,2,3,4]; # This would assig new reference in mylist print "Values inside the function: ", mylist return # Now you can call changeme function mylist = [10,20,30]; changeme( mylist ); print "Values outside the function: ", mylist </code></pre> <p>Values inside the function: <code>[1, 2, 3, 4]</code><br/> Values outside the function: <code>[10, 20, 30]</code></p> <p>Why is Values outside the function: <code>[10, 20, 30]</code>, and not <code>[1, 2, 3, 4]</code> since we are passing the argument to the function by reference?</p>
python
[7]
983,257
983,258
read file from assets
<pre><code>public class Utils { public static List&lt;Message&gt; getMesages() { //File file = new File("file:///android_asset/helloworld.txtv"); AssetManager assetManager = getAssets(); InputStream ims assetManager.open("helloworld.txt"); } } </code></pre> <p>I am using this code trying read file from assets. I tried two ways to do this. First when use File I receive fileNotFound exception, when use AssetManager getAssets() method doesn't recognized. Is there any solution here?</p>
android
[4]
1,557,773
1,557,774
Adding setUTCDate() to replace "computers" time
<p>Well, I followed this tutorial <a href="http://tutorialzine.com/2011/12/countdown-jquery/" rel="nofollow">http://tutorialzine.com/2011/12/countdown-jquery/</a> (I have no idea how to do ANYTHING in JavaScript, I've done everything I know so far, and gotten a little budge..) But I wanted to just be able to set a date and have it count down to that date, but even so, it would just base it off my computers time, how can I make it so its standard for everyone, [He mentioned setUTCDate() But Have no idea how to implement it. (new to this whole thing)</p> <p><a href="http://justin.derp.us/assets/js/script.js" rel="nofollow">http://justin.derp.us/assets/js/script.js</a> (I can only post two links, so the site is in the javascript post;))</p>
javascript
[3]
1,554,817
1,554,818
FF keeps spinning after document.write()
<pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" &gt; function fn() { document.write("Hello there!!!"); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button onclick="fn()"&gt;click&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>After clicking the button , FF keeps on spinning (11.0), while as if I directly call the fn() without wiring it to the button , it works fine.Could anyone please look into this ?</p>
javascript
[3]
3,086,312
3,086,313
error : Permission denied to access property 'document'
<p>how can I fix this message in firefox? i am using an Iframe which has an anchor tag? I would like to get a reference to this anchor but i am getting this error when I am trying to access anchor:</p> <pre><code> var frameWindow = document.getElementById('myIframe').contentWindow; var anchor = frameWindow.document.links[0]; //.getElementsByClassName('a'); anchor.onclick.... </code></pre>
javascript
[3]
2,077,281
2,077,282
iPhone: multi-part post using NSURLRequest
<p>I've seen a few articles, forum posts talking about uploading a file using NSURLRequest and NSURLConnection. Some of the ones I've seen are:</p> <ul> <li><a href="http://forums.macrumors.com/showthread.php?t=427513" rel="nofollow">http://forums.macrumors.com/showthread.php?t=427513</a></li> <li><a href="http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone">http://stackoverflow.com/questions/125306/how-can-i-upload-a-photo-to-a-server-with-the-iphone</a></li> <li><a href="http://www.cocoadev.com/index.pl?HTTPFileUploadSample" rel="nofollow">http://www.cocoadev.com/index.pl?HTTPFileUploadSample</a></li> </ul> <p>However, most of them don't include any sort of variables along with the file. Say I wanted to post the following variables (and their values) along with a photo:</p> <pre><code>user_id = 121 caption = this photo is awesome thumbnail_x = 12 thumbnail_y = 0 thumbnail_w = 100 thumbnail_h = 200 photo = [file] </code></pre> <p>Is there a way to do this?</p> <p>Or even better, is there already a class out there that builds on NSURLRequest that I could use?</p>
iphone
[8]
3,383,592
3,383,593
Determine if there is a value in a text field after submitting form
<p>All, I have a contact form on my page. I've got some jQuery things to contorl the form submission and I also have some PHP validation before I send the form. I'm still getting some blank emails. I make the email address and name a required field. I then have the following PHP:</p> <pre><code>&lt;?php $email = $_POST['email']; if($email != ""){ //send email } </code></pre> <p>I'm still getting emails though. Would use the empty function work? I'm just trying to make sure there is actually text in the field for it to send instead of being able to send the blank form. What methods do people use to control this?</p> <p>Thanks in advance!</p>
php
[2]
125,428
125,429
How to have an indefinite number of arguments in a Java method
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2635229/java-variadic-function-parameters">Java variadic function parameters</a> </p> </blockquote> <p>I'm new to Java, so if this is common knowledge, I'm sorry.</p> <p>I would like to be able to have an undefined/indefinite amount of variables being able to be passed to a function. like in <code>System.out.print()</code>, I can have a lot of variables passed to it... like in <code>System.out.print(x+" "+y);</code> I have 3 different values.</p> <p>How would I do this in my own function?</p>
java
[1]
5,793,510
5,793,511
android emulating a reboot
<p>I have coded a BroadcastReceiver to enable the resetting of an alarm if a user has to reboot hid device. Is there any way to test this in the emulator, in other words what sequence of events are required to cause the emulator to kick off the BroadcastReceiver . Ron</p>
android
[4]
3,321,737
3,321,738
how to play m4a sound file in systemsoundid?
<p>I want to play m4a sound file in device.In simulater its playing but not in device.can help me for this problem?</p>
iphone
[8]
3,379,804
3,379,805
Jquery update div after form submit with same form and S_POST data
<p>A have a page with 6 (Jquery) tabs and on each tab there is a form, i want to submit one of the forms without refreshing the whole page. When i submit a form i want to "reload" the same form in that tab, but with the $_POST data so i can use that for PHP scripting (database insert after vallidation).</p> <p>I tried Jquery AJAX, but i have to define al the form ellement again to pass the POST data, is'nt there a way similar like action="" but then only for that one tab and not the whole page?</p>
jquery
[5]
5,563,983
5,563,984
MSSQL Query issue in PHP and querying text data
<p>I'm trying a query in PHP to connect and extract data from a MSSQL EXPRESS (2008 R2) database. But i'm getting an error when i'm pulling ntext based data from the DB.</p> <p>Error is;</p> <blockquote> <p>Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (severity 16) in</p> </blockquote> <p>and my script is</p> <pre><code> $myServer = ".\SQLEXPRESS"; $myUser = "sa"; $myPass = "blablabla"; $myDB = "test"; //connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer"); //select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB"); //declare the SQL statement that will query the database $query = "SELECT * FROM dbo.table WHERE query='2'"; //$query .= "FROM dbo.table "; //$query .= "WHERE query='2'"; //execute the SQL query and return records $result = mssql_query($query); $numRows = mssql_num_rows($result); echo "&lt;h1&gt;" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned &lt;/h1&gt;"; //display the results while($row = mssql_fetch_array($result)) { echo "&lt;li&gt;" . $row["query"]. "&lt;/li&gt;"; } //close the connection mssql_close($dbhandle); </code></pre> <p>any help on this is appreciated ....</p> <p>Thanks ....</p>
php
[2]
393,616
393,617
PHP Patterns - how can I write this code?
<p>I want to make an category-system CMS. Everything is fine, except a big trouble.</p> <p>How can I can handle and generate the mysql query depends by some inputs like:</p> <blockquote> <p>site.com/some-category&amp;sortby=views&amp;from=smt&amp;anotherInput=key</p> </blockquote> <p>For example, for this input my query should be something like</p> <pre><code>SELECT * FROM `articles` WHERE from='smt' AND afield='key' ORDER BY VIEWS </code></pre> <p>But these inputs will be different. How I can write this code? I don't know much things about designs patterns, but, I've heard about Factory pattern, is this a part of my solution? </p> <p>Than </p>
php
[2]
1,164,135
1,164,136
How to assign a new ascii key code value
<p>If the user press <code>enter</code> key, it should behave as he is pressing the <code>esc</code> key.</p> <pre><code>function OnEditorKeyPress(editor, e) { if (e.htmlEvent.keyCode == 13) { e.htmlEvent.keyCode = 27; //treeList.CancelEdit(); } } </code></pre> <p>But the value 13 remains same after <code>e.htmlEvent.keyCode = 27;</code> this statement also. How to assign a new value or any other alternative method is there to do this?</p>
javascript
[3]
870,721
870,722
directorynotfound exception
<p>A DirectoryNotFound exception keeps happening for no apparent reason. The exception is thrown in: </p> <pre><code>public static string[] getKeywords(string filename) { string[] keywords = XElement.Load(filename).Elements("Keyword").Attributes("name").Select(n =&gt; n.Value).ToArray(); return keywords; } </code></pre> <p>BUT it is called in this method: </p> <pre><code>public static void SyntaxHighlight(SyntaxHighlighter.SyntaxRichTextBox textbox, Language language) { switch (language) { case Language.Cmake: textbox.Settings.Comment = "#"; string[] CmakeKeywords = getKeywords("APIs\\cmake.xml"); textbox.Settings.Keywords.AddRange(CmakeKeywords); break; case Language.CSharp: textbox.Settings.Comment = "//"; string[] CSharpKeywords = getKeywords("APIs\\cs.xml"); textbox.Settings.Keywords.AddRange(CSharpKeywords); break; case Language.HTML: textbox.Settings.Comment = "&lt;!"; string[] HTMLKeywords = getKeywords("APIs\\html.xml"); textbox.Settings.Keywords.AddRange(HTMLKeywords); break; case Language.Python: textbox.Settings.Comment = "#"; string[] PythonKeywords = getKeywords("APIs\\python.xml"); textbox.Settings.Keywords.AddRange(PythonKeywords); break; } } </code></pre> <p>UPDATE:<br> I have a folder in my project called APIs. I checked the file names several times. Here is the exception: <code>Could not find a part of the path 'C:\Users\Mohit\Documents\Visual Studio 2010\Projects\Notepad\Notepad\bin\Debug\APIs\cs.xml'.</code> Thats the <b>EXACT</b> path of the file!</p>
c#
[0]
3,153,614
3,153,615
limit textbox to x number of characters
<p>I have a textbox on an aspx page which I have limited to accept 250 characters. This works fine when a user just types data in, but if they paste the textbox will accept way more. Is there a way I can get around this? I dont want to disable pasting in the textbox though.</p> <p>thanks again</p>
asp.net
[9]
3,503,851
3,503,852
How can I return two parameters from a javascript function?
<p>I have the following:</p> <pre><code>function getPk(entity) { var store = window.localStorage; switch (entity) { case "City": if (store.getItem('AccountID')) { // Need to return both of the below pieces of information return store.getItem('AccountID') + "04" + "000"; return "CityTable"; } else { paramOnFailure("Please reselect"); return false; } break; </code></pre> <p>The problem is I need to be able to call this function and return two strings. Here I show two return statements but I know I cannot do that. </p> <p>Is there a clean way I can return two strings to the function that calls my getPk(entity) function?</p> <p>If possible can you give an example also of how I can read what is returned.</p>
javascript
[3]
3,841,848
3,841,849
Greedy match with negative lookahead in a regular expression
<p>I have a regular expression in which I'm trying to extract every group of letters that is not immediately followed by a "(" symbol. For example, the following regular expression operates on a mathematical formula that includes variable names (x, y, and z) and function names (movav and movsum), both of which are composed entirely of letters but where only the function names are followed by an "(". </p> <pre><code>re.findall("[a-zA-Z]+(?!\()", "movav(x/2, 2)*movsum(y, 3)*z") </code></pre> <p>I would like the expression to return the array</p> <pre><code>['x', 'y', 'z'] </code></pre> <p>but it instead returns the array</p> <pre><code>['mova', 'x', 'movsu', 'y', 'z'] </code></pre> <p>I can see in theory why the regular expression would be returning the second result, but is there a way I can modify it to return just the array <code>['x', 'y', 'z']</code>?</p>
python
[7]
367,315
367,316
Time based loop and Frame based loop
<p>Trying to understand the concepts of setting constant speed on game loop. My head hurts. I read the <a href="http://www.koonsolo.com/news/dewitters-gameloop/" rel="nofollow">deWiTTERS page</a>, but I can't see the why/how...when I get it...it slips.</p> <pre><code>while(true) { player-&gt;update() ; player-&gt;draw() ; } </code></pre> <p>This will run as fast as possible depending on how fast a processor is...I get that. </p> <p>To run at the same speed on all computers, the logic is what I don't get. If I am trying to run at 60fps, then it means for every 16ms the objects move by a frame, yeah? What I don't get is how the <code>update()</code> or <code>draw()</code> may be too slow.</p> <p>deWiTTERS example (I used 60):</p> <pre><code>const int FRAMES_PER_SECOND = 60; const int SKIP_TICKS = 1000 / FRAMES_PER_SECOND; DWORD next_game_tick = GetTickCount(); // GetTickCount() returns the current number of milliseconds // that have elapsed since the system was started int sleep_time = 0; bool game_is_running = true; while( game_is_running ) { update_game(); display_game(); next_game_tick += SKIP_TICKS; sleep_time = next_game_tick - GetTickCount(); if( sleep_time &gt;= 0 ) { Sleep( sleep_time ); } else { // Shit, we are running behind! } } </code></pre> <p>I don't understand why he gets the current time before the loop starts. And when he increments by <code>SKIP_TICKS</code> I understand he increments to the next 16ms interval. But I don't understand this part as well:</p> <pre><code>sleep_time = nextgametick - GetTickCount() </code></pre> <p>What does <code>Sleep(sleep_time)</code> mean? The processor leaves the loop and does something else? How does it achieve running 60fps? </p>
c++
[6]
1,794,560
1,794,561
var exists or var gets value syntax?
<p>I came across the following line of code in the underscore.js source:</p> <pre><code>function (obj, iterator, context) { iterator || (iterator = _.identity); ... } </code></pre> <p>Is that syntax equivalent to:</p> <pre><code>if (!iterator) { iterator = _.identity; } </code></pre> <p>Are there any performance benefits to using the former syntax other than reducing the statement to one line?</p>
javascript
[3]