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
1,440,344
1,440,345
How to test if current browser supports a given tagName
<p>I'd like to make a function to the effect of: </p> <pre><code>function supportsElem(tagName) { // returns boolean } </code></pre> <p>where: </p> <pre><code>supportsElem("div") // true supportsElem("randomtext") // false </code></pre> <p>What the easiest way to do that?</p>
javascript
[3]
5,521,716
5,521,717
How to detect the error for the list of tuples
<pre><code>l1 = [[(1,1), (1,2), (1,3)]] for e in l1: for i, c in enumerate(e): n = re.search(r'(\d,\d)', c) if n: num = [int(y) for y in c.split(',')] print "num is ", num e[i] = Sequence_element(num[0], num[1]) if sorted(l1) != l1: raise ValueError, 'l1 is not in sequence' class Sequence_element(object): def __init__(self, first_elem, second_elem): self._first_elem = first_elem self._second_elem = second_elem def first_elem(self): return self._first_elem def second_elem(self): return self._second_elem </code></pre> <p>This code is to ensure that (1,2) comes after (1,1) and (1,3) comes after (1,1) and (1,2)</p> <p>The error which I sorted(l1) gives [(1,3), (1,2), (1,1)] which is wrong because this should give [(1,1), (1,2), (1,3)] that means the error should not be raised whereas the error is raised. </p> <p>Each element of l1 is formed by help of another class which may be the reason that this sorted function doesn't work. What is the possible solution?</p>
python
[7]
266,887
266,888
How to get the uri of the .js file itself
<p>is there a method in JavaScript by which I can find out the path/uri of the executing script.</p> <p>For example:</p> <ol> <li><p><code>index.html</code> includes a JavaScript file <code>stuff.js</code> and since <code>stuff.js</code> file depends on <code>./commons.js</code>, it wants to include it too in the page. Problem is that <code>stuff.js</code> only knows the relative path of <code>./commons.js</code> from itself and has no clue of full url/path.</p></li> <li><p><code>index.html</code> includes <code>stuff.js</code> file as <code>&lt;script src="http://example.net/js/stuff.js?key=value" /&gt;</code> and <code>stuff.js</code> file wants to read the value of <code>key</code>. How to?</p></li> </ol> <p><em>UPDATE</em>: Is there any <strong>standard</strong> method to do this? Even in draft status? (Which I can figure out by answers, that answer is "no". Thanks to all for answering).</p>
javascript
[3]
2,731,183
2,731,184
How to write this JS function in best(smartest) way?
<p>I would like to write the function which takes file size in bytes(7762432) and return value in user readable format (7,762,432 bytes).</p> <pre><code>function(fileSizeBytes){ // mind blowing logic :) return userReadable; } </code></pre> <p>I have done it using old school string split way, but i am just curious if there exist way that can blow my head and make me scream with "O god it can be done this way too !!"</p>
javascript
[3]
5,019,557
5,019,558
Why is undefined == undefined but NaN != NaN?
<p>I am wondering why <code>undefined == undefined</code> but <code>NaN != NaN</code>.</p>
javascript
[3]
3,151,467
3,151,468
Can anyone give me code for list view?
<p>I am a beginner in android and have no idea of creating list view cn anyone plz help me out?</p>
android
[4]
2,589,143
2,589,144
What are the two params in the function and how does this work?
<p>I saw this in an application and it works well but i dont understand how it works.... What is the function(i,text) part doing and what are they for </p> <p>its being used <a href="http://jsfiddle.net/tDr4R/1/" rel="nofollow">here</a></p> <pre><code>$(this).text(function(i,text) { return (text == 'Show') ? 'Hide' : 'Show'; }); </code></pre>
jquery
[5]
4,674,402
4,674,403
jquery event which is called when the readonly value of the text box is changed automatically
<p>Is there any jquery event which is called when the readonly value of the text box is changed automatically</p> <p>I want to call an event (jquery) which should be called when the readonly value of the textbox is changed some how by other jquery events.</p> <p>Early Reply is highly appreciated.</p> <p>Best Regards, Sagar</p>
jquery
[5]
3,974,216
3,974,217
Android Html.fromHtml takes too long
<p>What do I do if <code>tv.setText(Html.fromHtml(text));</code> takes too long, and hangs the UI? If I can do it with a thread, can you provide an example?</p>
android
[4]
3,679,930
3,679,931
Smart Phone ! Iphone | Reading the device phone number HTTP etc
<p>Does anyone know if one of these devices connect to the web whether their phone number can be read from a header or some other means?</p>
iphone
[8]
3,602,999
3,603,000
AlarmManager firing off when not needed
<p>I want AlarmManager to fire every day at 12 o'clock.</p> <pre><code>public void alarm() { AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(this, TimeNotification.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT ); am.cancel(pendingIntent); if ( preferences.getBoolean("showNoti", true) ) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(System.currentTimeMillis()); cal.set(Calendar.HOUR_OF_DAY, 12); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent); am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); } } </code></pre> <p>Yet it also fires every time this method is called. Any ideas what I'm doing wrong?</p> <p>Thanks!</p>
android
[4]
989,975
989,976
How to search a specific array determined by a variable?
<p>Being quite new at JavaScript, I'm assuming the answer to my question is extremely simple and I just don't know what I'm doing, but here goes:</p> <p>How do I write an if statement that checks the value of an array when the array name is determined by a variable.</p> <p>For example, say I've got something like this:</p> <pre><code>$x = 2 arr1 = [1, 1] arr2 = [2, 2] </code></pre> <p>and I want to determine which array I examine based on the value of x. The way I'm trying it is below, but I'm quite certain that isn't right:</p> <pre><code>if (arr$x = 1) alert ('2) </code></pre>
javascript
[3]
971,306
971,307
Trigger function on variable change
<p>Is there a better way to monitor a variable for change and trigger a function at certain value?</p> <p>At the moment I have this - </p> <pre><code>$(window).on('scroll', function() { if(scrolledYet == "ready" &amp;&amp; positionNow &lt; 20){ fadeOutIntro(); scrolledYet = "yes"; } if(scrolledYet != "ready" &amp;&amp; positionNow &lt; 840 &amp;&amp; positionNow &gt; 20 ){ $('.logoBlock,.introScrollIcon, .introText').fadeIn('700') setTimeout(function() { $('#nav').fadeIn('1000');},1000); setTimeout(function() {introOnOff = "on";},100) } }); </code></pre> <p>the positionNow variable is set in another function and stores the current scroll position, is there a better way to structure this script</p>
jquery
[5]
4,231,362
4,231,363
Calling a non static function in a static child class php
<p>I have a singleton class that extends a normal class. (Class1)</p> <p>The normal class has two non-static functions called set() and get(). (Class2)</p> <p>A third class (Class3) which gets the singleton's (Class1's) instance uses the set() and get() through the singleton. It works fine using Class3, but is there any way to use the get() method inside the singleton from the parent class to see what the "third" class set it to? </p> <p>I can't seem to call the get because it's non static. Please let me know if this is confusing. </p> <pre><code>class Class1 { public function doThings(){ $this-&gt;view-&gt;set("css","1234"); } } class Singleton extends Class3 { static public function instance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; } //I want this singleton to call get("css") and have it return the value. } class Class3{ public function get(arg){//implementation } public function set(arg){//implementation } } </code></pre>
php
[2]
1,137,522
1,137,523
Saving videos intented to play using video embedding
<p>In my website the users need to be able to enter the embed code( from youtube) in a textbox and when they click a submit button the videos should be displayed in the webpage. If a user selects an embed code , paste it, then video will be displayed in aparticular block say Block A in webpage. And now again if they want another video to be displayed in same webpage and it should be displayed in a block B, The problem when I load the page , the last video will be displayed in both the blocks A and B. So some sort of saving mechanism may be required? Any help please</p>
php
[2]
1,173,212
1,173,213
jQuery serialize / serializeArray from an element that is not a form
<p>I haven't found a concrete answer as to whether this is possible, but it seems like it should be...</p> <p>I would like to serialize all the input elements contained in a div. I can't use a form, because it would be nested within another form. I would then get the values and post them via ajax.</p> <p>Here is the jsFiddle example I am playing with:</p> <p><a href="http://jsfiddle.net/9uyz5/" rel="nofollow">http://jsfiddle.net/9uyz5/</a></p> <p>If I change the root to a it works as expected.</p> <p>Thanks for your help.</p> <p>I've modified the jsfiddle from this other question:</p> <p><a href="http://stackoverflow.com/a/1186309/25020">http://stackoverflow.com/a/1186309/25020</a></p>
jquery
[5]
4,437,582
4,437,583
Force JavaScript exception/error when reading an undefined object property?
<p>I'm an experienced C++/Java programmer working in Javascript for the first time. I'm using Chrome as the browser.</p> <p>I've created several Javascript classes with fields and methods. When I read an object's field that doesn't exist (due to a typo on my part), the Javascript runtime doesn't throw an error or exception. Apparently such read fields are 'undefined'. For example:</p> <pre><code>var foo = new Foo(); foo.bar = 1; var baz = foo.Bar; // baz is now undefined </code></pre> <p>I know that I can check for equality against 'undefined' as mentioned in "<a href="http://stackoverflow.com/questions/27509/detecting-an-undefined-object-property-in-javascript">Detecting an undefined object property in JavaScript</a>", but that seems tedious since I read from object fields often in my code.</p> <p><strong>Is there any way to force an error or exception to be thrown when I read an undefined property?</strong></p> <p>And why is an exception thrown when I read an undefined variable (as opposed to undefined object property)?</p>
javascript
[3]
883,731
883,732
C++ compiled application
<p>Can someone explain in a "very layman's terms" what a C++ compiled application is? There are network accessible computers which run some type of installed program/applet (for lack of better term) to access it across the network but it does not use http/https. Any assistance is appreciated just looking for an overview because I am not a coder/genius like most of you on here.</p> <p>[from comments] </p> <blockquote> <p>I understand but I am more interested in how compiling works more than anything; someone stated to me that "they are using a c++ compiled app" to me and I did not know exactly what that meant.</p> </blockquote> <p>Thanks</p>
c++
[6]
4,604,748
4,604,749
How do I pass data between activities in Android?
<p>I have a scenario where after logging in through a login page, there will be sign out button on each activity.</p> <p>On clicking signout, I will be passing the session id of the signed in user to signout. Can anyone guide me on how to keep session id available to all activities??</p> <p>Alternatively, are there any other solutions to this problem?</p>
android
[4]
1,471,156
1,471,157
Javascript Code Not showing on External Websites
<p>I have site like 2leep, mgid. When I post widget code on external website, most of time it does not show me the result.</p> <p>This is the widget code doing problem on external sites.</p> <pre><code>&lt;script type='text/javascript'&gt;wID='26';document.write('&lt;div id=mywidgets26&gt;&lt;/div&gt;');document.write('&lt;scr'+'ipt type="text/JavaScript" src="http://www.jugglu.com/widget/bootstrap.js"&gt;&lt;/scr'+'ipt&gt;');&lt;/script&gt; </code></pre>
javascript
[3]
2,127,106
2,127,107
Inserting values into a map
<pre><code> typedef map &lt;int, string&gt; MAP_INT_STRING; MAP_INT_STRING mapIntToString; mapIntToString.insert (MAP_INT_STRING::value_type (3, “Three”)); </code></pre> <p>I have only found examples where the values are inserted into the map through the source code. I would like to know how to allow a user do so as the program is running. I image this would involve some sort of for loop, but I am not certain how to set it up.</p>
c++
[6]
5,130,091
5,130,092
How does the JavaScript instanceOf method execute in this statement?
<pre><code>var a = "words"; a instanceOf String; #=&gt; false </code></pre> <p>I can't understand how this code snippet works.</p> <ul> <li>Is <code>instanceof</code> a method of <code>a</code>, or of <code>this</code> which locates it in the default scope?</li> <li>If <code>String</code> here is a parameter passed to <code>instanceof</code>, how come it doesn't have parentheses?</li> </ul>
javascript
[3]
788,917
788,918
C# Reading a console application in a loop
<p>I need to execute my console app for many files in a loop and update my GUI. When I execute my app for the first time everything is ok, GUI updates are done in realtime. But with every iteration, reading of console output get longer delay. After 3-4 files I get only few updates or no updates at all. Its not a problem with updating GUI, my dataraceivedevent doesn't fire up.</p> <p>I can't understand why, because after every iteration I close and dispose my process.</p> <p>This is the method that I execute in the for-loop.</p> <pre><code>public void execute(string arguments, string path) { Process myProcess = new Process(); myProcess.StartInfo.CreateNoWindow = true; myProcess.StartInfo.FileName = path; myProcess.StartInfo.UseShellExecute = false; myProcess.StartInfo.RedirectStandardOutput = true; myProcess.StartInfo.Arguments = arguments; myProcess.Start(); myProcess.BeginOutputReadLine(); myProcess.OutputDataReceived += new DataReceivedEventHandler(this.updateProgress); myProcess.WaitForExit(); myProcess.CancelOutputRead(); myProcess.OutputDataReceived -= updateProgress; myProcess.Close(); myProcess.Dispose(); if (progressBar1.InvokeRequired) { progressBar1.BeginInvoke(new Action(() =&gt; { progressBar1.PerformStep(); })); } else { progressBar1.PerformStep(); } if (progressBar2.InvokeRequired) { progressBar2.BeginInvoke(new Action(() =&gt; { progressBar2.Value = 100; progressBar2.Refresh(); })); } else { progressBar2.Value = 100; progressBar2.Refresh(); } if (this.InvokeRequired) { this.BeginInvoke(new Action(() =&gt; { this.Text = " "; })); } else { this.Text = " "; } Thread.Sleep(500); } </code></pre>
c#
[0]
4,104,913
4,104,914
Java double and bigdecimal same weird value
<p>I'm making a calculation module about that accepts <code>double</code> or <code>BigDecimal</code> like this but I have this problem.</p> <pre><code>double x = 2.3333333333312398; BigDecimal big = BigDecimal.valueOf(2.3333333333312398); </code></pre> <p>I print their values</p> <pre><code>System.out.println(x); System.out.println(big); </code></pre> <p>and the output</p> <pre><code>2.3333333333312396 2.3333333333312396 </code></pre> <p>I tried to changed the value of <code>x</code> and <code>big</code> variable to <code>2.3333333333312395</code> but the output still the same. I changed it again to <code>2.3333333333312396</code> and prints the same value.</p> <p>If I changed again to <code>2.3333333333312394</code> the displayed again the weird value</p> <p><code>2.3333333333312396</code></p> <p>What's the cause of this problem? Thanks!</p>
java
[1]
44,605
44,606
Python AJAX response string literal
<p>I have an AJAX response that returns a JSON object. One of the dictionary values is supposed to read:</p> <p>"image\/jpeg"</p> <p>But instead in reads:</p> <p>"images\\/jpeg"</p> <p>I've gone through the documentation on string literals and how to ignore escape sequences, and I've tried to prefix the string with 'r', but so far no luck.</p> <p>My JSON encoded dictionary looks like this:</p> <p>response.append({ 'name' : i.pk, 'size' : False, 'type' : 'image/jpeg' })</p> <p>Help would be greatly appreciated!</p>
python
[7]
4,182,606
4,182,607
Changing velocity of object in Java Game
<p>So I'm making a sort of space game in Java. Currently, the spacecraft stays in place if the user isn't doing anything, and moves at a constant velocity in different directions based on the user's key input.</p> <p>I'd like to change it so that when the spacecraft is moving, as the user continues to press the key, the spacecraft's velocity accelerates faster. </p> <p>In my move method, I currently have</p> <pre><code>public void move() { x += dx; y += dy; } </code></pre> <p>I've tried doing such things as </p> <pre><code>public void move() { x *= dx; y *= dy; } </code></pre> <p>But constantly multiplying values makes the spacecraft move way too fast.</p> <p>Is there another approach to doing this? </p> <p>Thanks in advance.</p>
java
[1]
3,651,516
3,651,517
Python any item from a list in another list
<p>What is an elegant way to return a list of T/F for a list if matches a list of items?</p> <p>For example:</p> <pre><code>[1,3,5,4] in [4,3,7,5,8] </code></pre> <p>Returns:</p> <pre><code>[True, True, False, True, False] </code></pre>
python
[7]
3,016,606
3,016,607
storing db contents in array PHP
<p>I am not sure how to do this, but if it can be done can anyone please help me in this. Basically I have 3 columns in my table:</p> <pre><code>ID Set Result Case 1 Set1 PASS 101 2 Set2 FAIL 102 3 Set2 FAIL 101 4 Set1 FAIL 101 5 Set1 PASS 104 $set = $row['Set']; </code></pre> <p>What I am trying to achieve is , foreach of these <code>Set</code>, store its associated <code>Result</code> and <code>Case</code> in an array.</p>
php
[2]
2,148,070
2,148,071
How to safely convert from a double to a decimal in c#
<p>We are storing financial data in a SQL Server database using the decimal data type and we need 6-8 digits of precision in the decimal. When we get this value back through our data access layer into our C# server, it is coming back as the decimal data type.</p> <p>Due to some design constraints that are beyond my control, this needs to be converted. Converting to a string isn't a problem. Converting to a double is as the MS documentation says "[converting from decimal to double] can produce round-off errors because a double-precision floating-point number has fewer significant digits than a decimal."</p> <p>As the double (or string) we can round to 2 decimal places after any calculations are done, so what is the "right" way to do the decimal conversion to ensure that we don't lose any precision before the rounding?</p>
c#
[0]
5,475,124
5,475,125
Android imeOptions and auto-pressing Login button
<p>I have typical login screen. I was able to use imeOptions to allow user "tab" from one field to another and on last field(password) I have actionDone - it just closes soft keyboard. Ideally, I like to click "Login" automatically. Is there anything built-in for that?</p>
android
[4]
5,995,881
5,995,882
jQuery tutorial - code not working?
<p>I am new to jQuery, and I am going through a set of video tutorials. Today was the first one, and I did all that I was told in the video, but it doesn't work. The first tutorial was about to fadeout a simple tag. I wrote the following code with CSS and scripting tags.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Hi&lt;/title&gt; &lt;script src = "http://www.myvirtualhost.lcl:8080/jquery/jquery-1.7.1.min.js" type= "text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;style type = "text/css"&gt; #box { background: red; width: 300px; height: 300px; } &lt;/style&gt; &lt;script type="text/javascript"&gt; $(function(){ $('a').click(function(){ alert("hi"); $('#box').fadeOut(); )}; }); &lt;/script&gt; &lt;body&gt; &lt;div id="box"&gt;&lt;/div&gt; &lt;a href="#"&gt;Click Me !&lt;/a&gt; &lt;/body&gt; </code></pre> <p></p> <p>Can anyone tell me what I am doing wrong, and why it is not working?</p>
jquery
[5]
1,915,094
1,915,095
C# How do you continuously add values to a Label Box so that the number generated keeps on adding to it?
<p>I am working on a dice roller program, we are suppose to have a "Total Money Earned" label box which shows the total amount of money earned when the roller rolls the dice. if you roll a 6 you earn 600 dollars if you earn a 5 you earn 500 dollars etc etc. I can get the dollar value to show up on the label box but when i continue rolling, the number will be replaced by the next value instead of summing to for example roll a 5 then you earn 500 dollar then hit roll again you roll 1 and then it should show $600 = 500 + 100.</p> <p>Please help heres the code im using</p> <pre><code> private void button1_Click(object sender, EventArgs e) { int roll1; Random rand = new Random(); roll1 = rand.Next(6) + 1; int value = 100; int sum = (roll1 * value); totalmoneyLabel.Text = sum.ToString("c"); if (roll1 == 1) { diceBox1.Image = drios1_Project2.Properties.Resources._1Die; } if (roll1 == 2) { diceBox1.Image = drios1_Project2.Properties.Resources._2Die; } if (roll1 == 3) { diceBox1.Image = drios1_Project2.Properties.Resources._3Die; } if (roll1 == 4) { diceBox1.Image = drios1_Project2.Properties.Resources._4Die; } if (roll1 == 5) { diceBox1.Image = drios1_Project2.Properties.Resources._5Die; } if (roll1 == 6) { diceBox1.Image = drios1_Project2.Properties.Resources._6Die; } } </code></pre>
c#
[0]
1,416,948
1,416,949
customize next, previous button in jquery cycle
<p>I want the text in next and previous button in my jquery cycle should show the title from next &amp; previous slide respectively. How can I do it. Please help.</p>
javascript
[3]
420,574
420,575
TableView not displaying parsed data from xml?
<p>i have tabbar controller, first tab is for Tableview controller.but i do xml parsing in appldidfinish method , in the xml parse <code>didEndElement</code>, i calculate items count and i give it into first tab's Tableview controller's <code>numberOfRowsInSection</code>,but after xml parsing finished, the following method wont be called. tableview is empty....?</p> <pre><code>-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [myParser.items count]; } </code></pre> <p>i have declared in view did load method of that table view controller</p> <pre><code>myParser = [[XMLMyParser alloc] init]; </code></pre> <p>any help please.....</p>
iphone
[8]
3,058,791
3,058,792
Why this is not compiling in Java?
<p>If you give</p> <pre><code> public class test { public static void main(String ar[]) { if (true) int i=0; } } </code></pre> <p>It's not compiling but the same code with braces is:</p> <pre><code> public class test { public static void main(String ar[]) { if (true) {int i=0;} } } </code></pre> <p>What is the explanation?</p>
java
[1]
3,827,148
3,827,149
Download the image from the urlencoded or base64encoded string
<p>My application sends urlencoded or base64encoded string via http get request, the string contain image data, that most be download from the php file, but i dont know how php would download image from my string that is either urlencoded or base64encoded, please help me out guys... im lost</p>
php
[2]
3,094,884
3,094,885
Having another programmer take over an existing project
<p>This question is not coming from a programmer. (obviously) I currently have a programmer making a website for me and I am realizing that he isn't going to completely work out. </p> <p>He has already done quite a bit of work and the site is almost there but I need someone who is better to take it the rest of way. The site has been done in asp.net and I am wondering how hard it would be for a more experienced programmer to take over and finish the work he has already done? </p> <p>In general, is it hard for an asp.net programmer to come in towards the end of a project and fix what needs to be fixed?</p> <p>There is five different pages on the site with two overlays for a signup and sign in. (Five pages with many different versions) There is a database and client-side scripting. AJAX was also used. It's a site somewhat similar to SO only not quite as complex and about something completly different. I would say think of something that falls somewhere between Stackoverflow and Craig's List. Thats all I can say now as I don't know the technical words.</p>
asp.net
[9]
287,385
287,386
Will RandomAccessFile use a lot of memory when openning large-size file?
<p>I am wondering if RandomAccessFile uses a lot of memory when openning a large-size file or not?</p>
java
[1]
13,365
13,366
Open an activity without declaring it in the manifest file in ANDROID?
<p>I want to open an activity without declaring it in an manifest file. I don't know if it is possible or not. What I actually want is to dynamically open an activity from my program using intents. Can anyone help me if it is possible.</p>
android
[4]
1,056,619
1,056,620
Extract domain name suffix from any url
<p>I have a url in string format like this : </p> <pre><code>str="http://code.google.com" and some other like str="http://sub.google.co.in" </code></pre> <p>i want to extract google.com from first one, and google.co.in from second string . </p> <p>what i did is : </p> <pre><code>var a, d, i, ind, j, till, total; a = document.createElement('a'); a.href = "http://www.wv.sdf.sdf.sd.ds..google.co.in"; d = ""; if (a.host.substr(0, 4) === "www.") { d = a.host.replace("www.", ""); } else { d = a.host; } till = d.indexOf(".com"); total = 0; for (i in d) { if (i === till) { break; } if (d[i] === ".") { total++; } } j = 1; while (j &lt; total) { ind = d.indexOf("."); d = d.substr(ind + 1, d.length); j++; } alert(d); </code></pre> <p>My code works but it works only for ".com" , it doesnt work for others like ".co.in","co.uk" till i specify them manually , Can anyone tell me the solution for this ? I dont mind even i need to change the full code, but it should work . Thanks </p>
javascript
[3]
2,069,904
2,069,905
Java - Does "new FileInputStream" need to be closed?
<p>In this code:</p> <pre><code>Properties prop = new Properties(); prop.load(new FileInputStream("config.properties")); </code></pre> <p>Some properties are loaded, but does the fileinputstream need to be closed or does it somehow take care of that itself?</p> <p>Do I need to create a variable, new file inputstream, then close the variable?</p> <p>I was also wondering, if I create a variable, say, <code>String a = null</code> and <code>int b</code>; Do they consume memory when they hold nothing?</p> <p>and if I have that inside a method or a loop, does it still consume memory when out of scope?</p> <p>I think someone once said it's loaded into memory but not 'active'?</p>
java
[1]
3,737,771
3,737,772
Invalid conversion from 'int' to 'double*'
<p>I have this line of code:</p> <pre><code>int g = modf(ans*power, 1)*10; </code></pre> <p>And it is giving me the error:</p> <blockquote> <p>Invalid conversion from 'int' to 'double*'.</p> </blockquote> <p>ans is defined as:</p> <pre><code>double ans = 1.0/d; </code></pre> <p>power is defined as:</p> <pre><code>int power = pow(10,x); </code></pre> <p>and the x that power is using is defined as:</p> <pre><code>for(int x = 0; x &lt; 50; x++) { </code></pre> <p>I don't see where I am using a pointer. If you need more code just ask.</p> <p>(I have also tried making the line of code that causes the error: </p> <pre><code>int g = (int)modf(ans*power, 1)*10; </code></pre> <p>but that did not work either).</p>
c++
[6]
3,145,734
3,145,735
In JQuery while swapping divs values in textbox are not getting retained
<p>I am swapping the information on 2 divs using JQuery , i.e. pickup and dropoff informations. But in IE the values added by a user gets swapped but in FireFox only the HTML gets copied and the value doesn't get copied! only the preset value what we give in the html tag gets copied. Please HELP!</p>
jquery
[5]
5,514,769
5,514,770
how to uploading image on pi casa through iPhone sdk
<p>In my project i want to take image from my iPhone camera and upload it on Facebook, twitter and pi-casa. Facebook and twitter uploading portion is done but not with pi-casa. so can any one help me how to upload images on pi-casa through iPhone sdk. if possible give me some source code or demo to make problem easy.</p> <p>Thanks &amp; regards, Priyanka.</p>
iphone
[8]
4,283,366
4,283,367
Getting data out of PlainObject in JQuery
<p>I love JQuery-style argument parsing and want to use it in my own function:</p> <pre><code> foo( { 'name': 'bob', 'age': 21 }); function foo (param){ alert($.isEmptyObject(param)); //shows true //now what? :-) //param.prop('name'); does not work //$param=$(param); $param.prop('name'); still does not work //treating it as an array also does not work } </code></pre> <p>How can I get at the data I passed? </p>
jquery
[5]
2,381,007
2,381,008
how to rotate an imageview (not using animation)
<p>Alright, I am sure this question is asked before and I searched the forum but I couldn't find exactly what I want. In a nutshell, I want to be able to rotate an imageview and still this rotated image is clickable (the new space it occupies)</p> <p>I am creating a card game, and I want the player to be able to see his cards like how pople normally hold their cards in one hand (rainbow style). So currently, I have each card being an imageview and they are just best each other. How can I rotate each imageview by a certain angle? I don't want to use rotate animation as it does not change the x/y positions of the image after rotation which prevent from getting a touch on the corner of the card any help? Thank you</p>
android
[4]
3,403,079
3,403,080
crash happens when NSMutableArray is returned?
<p>I have coded like that(that function will be called again and again), but the returned object gives "BAD ACCESS", the NSLog prints correct string, but toReturn sometimes(i called again and again) gives crashes..any help to alter this code,If i remove the "autorelease" method,it worsks fine</p> <pre><code> - (NSMutableArray *)getAll:(NSString *)type { NSLog(@"Type: %@", type); NSMutableArray *toReturn = [[[NSMutableArray alloc] initWithCapacity:0] autorelease]; rs = [db executeQuery:Query1]; while ([rs next]) { [toReturn addObject:[rs stringForColumn:@"Name"]]; NSLog(@"name: %@", [rs stringForColumn:@"Name"]); } [rs close]; return toReturn; } </code></pre>
iphone
[8]
5,213,939
5,213,940
Android how to get name of contact from phone book
<p>i have a listview where i get phone numbers from phone book in Array, i want to compare these numbers with phone book and get name of contact.</p> <p>please help me with a code example.</p> <p>thank you</p>
android
[4]
4,924,166
4,924,167
Why use a set for list comparisons?
<p>I just read another users question while looking for a way to compute the differences in two lists.</p> <p><a href="http://stackoverflow.com/questions/6486450/python-compute-list-difference">Python, compute list difference</a></p> <p>My question is why would I do</p> <pre><code>def diff(a,b): b = set(b) return [aa for aa in a if aa not in b] </code></pre> <p>rather than doing</p> <pre><code>def diff(a,b): tmp = [] for i in a: if(i not in b): tmp.append(i) return tmp </code></pre> <p>edit: just noticed the second diff function actually returned the similarities. It should be correct now.</p>
python
[7]
3,275,264
3,275,265
Submitting a book app so that it can download and read in iBooks?
<p>Could you please let me know how an app needs to be submitted so that it can be downloaded in iBooks and user can read from the same.</p> <p>Any step by step procedure or Tutorials will be appreciated!!</p>
iphone
[8]
4,988,207
4,988,208
Php passing the same objects on another file
<p>1) Suppose I have 2 php files: <strong>fileA.php</strong>, and <strong>fileB.php</strong> And I have 1 class file: <strong>myClassFile.php</strong></p> <p>in <strong>fileA.php</strong>, I need to instantiate a <code>MyClass</code> class in <strong>myClassFile.php</strong>:</p> <pre><code>... myObject = new MyClass(); ... </code></pre> <p>in <strong>fileB.php</strong>, I need to use the <code>myObject</code> object created in <strong>fileA.php</strong>.</p> <p>How would I do that? Is using sessions the way to go?</p> <pre><code>$_SESSION["my_object"] = myObject; </code></pre> <p>or are there better ways? Specifically, how will it be implemented?</p> <p>2) Suppose I don't use solutions similar to the above.. Will <code>myObject</code> in <strong>fileA.php</strong> be lost (destroyed, or freed) when the user proceeds to <strong>fileB.php</strong>? That is, will there be no more reference to <code>myObject</code> in <strong>fileB.php</strong>? </p>
php
[2]
4,542,462
4,542,463
"viewed" system - once per user
<p>I need to implement "viewed" system. </p> <p>How it can be done, so that pressing F5 would not increase viewed number for more than 1 per user? </p> <p>SO also has such system.</p> <p>Cookies, sessions, db? How it is usually done?</p>
php
[2]
5,695,935
5,695,936
Building iPhone app on linux
<p>Hi all is there way to build iPhone app on linux without using xcode.I want to make use of ant.</p>
iphone
[8]
3,826,928
3,826,929
How to update a specific element from List<T> element collections?
<p>I have a list of custom objects List and I would like to update a specific element say 3rd element from top, How would I do that in C#?</p>
c#
[0]
970,114
970,115
Jquery checking success of ajax post
<p>how do i define the success and failure function of an ajax $.post?</p>
jquery
[5]
2,279,478
2,279,479
How to fetch a select tag value from child page javascript?
<p>I have a parent page where a select tag is there. It has a number of options. Now the user can select one of the options.</p> <p>But the problem is the select tag doesnt have an id instead it has a name which is generated in runtime.</p> <p>Now i want to fetch the selected value from child page javascript. Can anyone please provide me the pointers for this?</p>
javascript
[3]
2,661,662
2,661,663
Will this cause memory leaks?
<p>Will the following code cause a memory leak? Essentially I switch between various layouts in my application using setContentView(), and I have member variables of my activity that maintain references to various views (buttons/textviews...) on the layouts. </p> <p>Am I correct in thinking that if the activity class has a reference to a button and then changes layouts the layout wont be garbage collected because it will still hold a button reference? If this is the case, can I just null the button variable before changing layouts?</p> <p>Thanks.</p> <pre><code>public class MyApp extends Activity { private Button startBtn; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set main layout setContentView(R.layout.main); startBtn = (Button) findViewById(R.id.startBtn); startBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { doStart(); } }); } private void doStart() { // Change to starting screen layout setContentView(R.layout.begin); /// .. Work with more views here and change layouts in a bit .. // } } </code></pre>
android
[4]
1,623,827
1,623,828
Exception in opening a file that is already open
<p>I am building an application in C# in which I have to open a CSV file to read data from it. I get an exception when I try to open the CSV file from C# when that file is already open in Excel. The exception says that the process cannot access the file since it is already open. How can I solve this problem and open the file even if it is opened in other application?</p> <p>Thanks, Rakesh.</p>
c#
[0]
2,146,260
2,146,261
phonelookup always returns empty cursor
<p>I have android 2.3.3 installed. I have a phone number in my call history. And trying to get the id of it programmatically using Phonelookup.</p> <p>But my cursor always has 0 rows. No clue what would be causing this.</p> <blockquote> <p>Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode("666-999-6666"));</p> </blockquote> <pre><code> Cursor c = getContentResolver().query(uri, null, null, null, null); while(c.moveToNext()){ Log.d("", c.getLong(c.getColumnIndex(PhoneLookup._ID))); } </code></pre>
android
[4]
3,860,546
3,860,547
about databases in android
<p>i am new in android database.i downloaded sqlite database browser. can u give me the steps how to use already generated database in android sdk with eclips. give me proper structure where to store database in eclips folder structure</p>
android
[4]
3,262,392
3,262,393
How to fake a touch event in the system
<p>Is it possible to make a 'fake' touch event on android? (if necessary with root access) The app would run in the background and let an other app think there was a 'real' touch event.</p> <p>I want this for an app wich allows the iControlPad (bluetooth controller) to make a touch event by pressing a (hardware) button.</p> <p>Thanks!</p>
android
[4]
5,511,119
5,511,120
How to open a window without toolbars and addressbar?
<p>Is there a way to open ( via javascript ) a new window but without toolbar, addressbar, etc ?</p> <p>I have tested this code:</p> <pre><code>window.open('http://example.it','example','height=300px,width=724px,resizable=1,alwaysRaised=1,location=1,links=0,scrollbars=0,toolbar=0'); </code></pre> <p>but in Opera, it shows the bookmarks bar and the address bar.</p>
javascript
[3]
104,420
104,421
How to remove black shade in the Drawable image in Android?
<p>How to remove black shade in the Drawable image in Android?<img src="http://i.stack.imgur.com/v8o3T.png" alt="enter image description here"></p> <pre><code> Drawable d = new BitmapDrawable(bitmap);mapController.animateTo(geoPoint); mapOverlay = new MapOverlay(d); listOfOverlays = mapView.getOverlays(); // listOfOverlays.clear(); listOfOverlays.add(mapOverlay); overlayitem = new OverlayItem(geoPoint, "", ""); mapOverlay.addOverlay(overlayitem); listOfOverlays.add(mapOverlay); mapView.invalidate(); </code></pre>
android
[4]
1,736,765
1,736,766
Android equivalent to applicationDidBecomeActive and applicationWillResignActive(from iOS)
<p>I hope it exists.</p> <p>I would like to store the time when the application loses focus and then check if it has lost focus for more than n-minutes to bring up a lock.</p> <p>Seeing how an application is composed of activities, I think there will not be a direct equivalent. How would I be able to achieve similar results?</p> <p>EDIT<br> I tried to extend the Application class to <code>registerActivityLifecycleCallbacks()</code> and realized I will not be able to use this approach because it is only available in API Level 14+</p>
android
[4]
794,696
794,697
Exporting Page Data to PDF and Excel in asp.net where data is generated dynamically
<p>For PDF: I have wrote some code for the page content exporting to PDF. And Complete design code is under Content Place Holder in design page. As the data is generated dynamically, it is little tough to handle. After this code im getting following error at htmlworker.Parse(str); as Input string was not in a correct format Can please help on this?</p> <pre><code>protected void btnExpPDF_Click1(object sender, EventArgs e) { //string attachment = "attachment; filename=CFSSurveyPage.pdf"; Response.ClearContent(); // Response.AddHeader("content-disposition", "attachment; filename=" + strFileName + ".xls"); Response.AddHeader("content-disposition", "attachment; filename=" + "CFSSurveyPage" + ".pdf"); Response.ContentType = "application/pdf"; StringWriter stw = new StringWriter(); HtmlTextWriter htextw = new HtmlTextWriter(stw); this.Page.Form.Controls[7].RenderControl(htextw); // (this.Page.Master.Controls[3].Controls[7].Controls[47]).RenderControl(htextw); //div2.RenderControl(htextw); StringReader str = new StringReader(stw.ToString()); Document document = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlworker = new HTMLWorker(document); PdfWriter.GetInstance(document, Response.OutputStream); document.Open(); htmlworker.Parse(str); document.Close(); Response.Write(document); Response.End(); } public override void VerifyRenderingInServerForm(Control control) { } </code></pre>
asp.net
[9]
96,250
96,251
How to slice a string in Python using a dictionary containing character positions?
<p>I have a dictionary containing the character positions of different fields in a string. I'd like to use that information to slice the string. I'm not really sure how to best explain this, but the example should make it clear:</p> <p>input:</p> <pre><code>mappings = {'name': (0,4), 'job': (4,11), 'color': (11, 15)} data = "JohnChemistBlue" </code></pre> <p>desired output:</p> <pre><code>{'name': 'John', 'job': 'Chemist', 'color': 'Blue'} </code></pre> <p>Please disregard the fact that jobs, colors and names obviously vary in character length. I'm parsing fixed-length fields but simplified it here for illustrative purposes.</p>
python
[7]
2,356,653
2,356,654
can the swap be used to clear std::set as vector ?
<p>can swap function be used to free memory as in case of vectors as mentioned below?</p> <pre><code> std::vector&lt;int&gt; v1; // somehow increase capacity std::vector&lt;int&gt;().swap(v1); </code></pre>
c++
[6]
4,689,980
4,689,981
sizeof different program elements in c++
<p>When does memory get allocated to a data type ,class and function at the time of declaration or at the time of definition?Also is there any way to know the sizeof function?</p>
c++
[6]
3,646,161
3,646,162
How can I update a database string value from a TextBox?
<p>I cant update my database through textbox.in the case of numeric value i can update but cant with a string value. my coding is...</p> <pre><code>SqlCommand cmdup= new SqlCommand("UPDATE [port1] SET [prt1]=@prt1 WHERE [no]= 1",cn); cmdup.Parameters.Add("@prt1", TextBox1.Text); cmdup.ExecuteNonQuery(); </code></pre> <p>if any one know the ans: reply me</p>
asp.net
[9]
2,440,807
2,440,808
Add mailto link to static email with JQuery
<p>I'm trying to add a mailto link to static email addresses found within a list of results from a database, using JQuery. I was able to find the following excerpt online which works for the first result, but it does not work for any email addresses after the first one.</p> <p>I'm curious why this is.. and how I can get it to apply the mailto: attribute to every email address found in the results. :-)</p> <p>Current code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ var regEx = /(\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/; $("table td").filter(function() { return $(this).html().match(regEx); }).each(function() { $(this).html($(this).html().replace(regEx, "&lt;a href=\"mailto:$1\"&gt;$1&lt;/a&gt;")); }); }); </code></pre> <p></p> <p>Thanks!</p>
jquery
[5]
3,468,409
3,468,410
what is the VirtualKeyboardLayout mechanism
<p>Recently,I am working at android Input event.I meet a problem I can't understand.The keyboard device always has a *.kl and #.kcm files.They help map the scancode to keycode or char.But I don't know whether virtualKeyboard also has them.Because I saw virtual keyboard has been created in EventHub.cpp and load some map files,But I don't find it on my phone.I want to know whether the virtual keyboard has the same mechanism as physical keyboard input device?or who can tell me the real meaning of VIRTUAL_KEYBOARD on android.I think it seems not to stand for the keyboard on screen we use input char.</p>
android
[4]
376,914
376,915
Android Hello World orients from portrait to landscape but not visa versa
<p>I created the Hello World android application, which is automatically created by the ADT plugin for eclipse. I noticed that when I reorient in the emulator, the hello world application properly automatically reorients from portrait to landscape, but not the other way. How do I fix this?</p>
android
[4]
3,463,732
3,463,733
Accessing <a> inside div id
<p>im trying to color the <code>&lt;a&gt;</code> background color</p> <pre><code>&lt;div id="contact"&gt;&lt;a href="mailto:name@.domain.net&gt;name&lt;/a&gt; </code></pre> <p>with the selector </p> <pre><code>$('#contact a').css("background", "red"); </code></pre> <p>however im not successfull, where is my error?</p>
jquery
[5]
3,130,467
3,130,468
Correct way of anonymously subclassing TimerTask keeping a reference to 'this' inside the run method
<p>I subclassed <code>TimerTask</code> with an anonymous 'concrete' class, this way:</p> <pre><code>public void setTimedTask() { /* Note: 'this' implements an interface called UpdateIndicatorsReceiver */ final UpdateIndicatorsReceiver receiver = this; final TimerTask timerTask = new TimerTask() { @Override public void run() { /* The interface UpdateIndicatorsReceiver has an updateIndicators method */ receiver.updateIndicators(); } }; /* Code to actually set the timer.... */ } </code></pre> <p>Please note the oddity of declaring a local <code>final</code> field named <code>receiver</code> and setting it to <code>this</code>. Is there any cleaner way of getting a non changing reference to <code>this</code>, in order to use it in the <code>run</code> method of the anonymous class?</p>
java
[1]
5,374,955
5,374,956
What is HandlerLeak?
<p>ADT's lint checker says:</p> <blockquote> <p>This Handler class should be static or leaks might occur </p> </blockquote> <p>What's the meaning of the leak handler?</p>
android
[4]
1,005,867
1,005,868
any advice to my leanring direction with python?
<p>According to the course plan of my university,there's no Python courses. And I'll be taking course like Database,Operating Systems next term , and Computer Network in a year.<br> I've learned Python myself the other day (not that hard to pick up because I've learned C++ before ). </p> <p>Now I've got two books about Python. One is Python for UNIX and Linux System Administration, and the other one is Foundations of Python Network Programming. I don't know whether I should learn Python more to arrange system,or to work with the network.</p> <p>Am I clear ?I'll be grateful to any advice!Any comments about two books will do good ,too!</p>
python
[7]
878,891
878,892
key value style javascript array`s length keeps being 0
<p>I fill my key value array like this:</p> <pre><code>/** * Callback: Gets invoked by the server when the data returns * * @param {Object} aObject */ function retrieveStringsFromServerCallback(aObject){ for(var i = 0;i &lt; aObject['xml'].strings.appStringsList.length;i++){ var tKey = aObject['xml'].strings.appStringsList[i]["@key"]; var tValue = aObject['xml'].strings.appStringsList[i]['$']; configManager.addStringElement(tKey,tValue); } } </code></pre> <p>Here is the setter of my object</p> <pre><code>/** * @param {string} aKey * @param {string} aValue */ this.addStringElement = function(aKey, aValue){ self.iStringMap[aKey] = aValue; console.log("LENGTH: "+self.iStringMap.length); } </code></pre> <p>I add about 300 key value pairs, according to google chrome inspector, the <code>iStringMap</code> is filled correctly. However the length of the array seems still to be 0. There must be something wrong. Any help much appreciated</p>
javascript
[3]
5,886,939
5,886,940
Java Free Hosting
<p>I'm looking for a free hosting for my Java web page, that uses Servlets and JSP. There is any good one out there?</p>
java
[1]
746,491
746,492
Is it a good programming practice to return in the middle of Java FOR-EACH loop?
<p>I have a list of objects to iterate over which is a name,value pair. I want the method to return the value when the name matches "inputFile" .. So while iterating through the list is it a good programming practice to do the following:</p> <pre><code>for(NameValuePair nameValuePair: getNameValuePairList()) { if(nameValuePair.name == "inputFile") return nameValuePair.value } </code></pre>
java
[1]
2,380,902
2,380,903
c++ projects for beginners
<p>So I know this is a frequent question, but I still can't find a good one.</p> <p>It's a 3-week internship where I get to teach high school students. I would cover basic c++ first week, and start the project second week.</p> <p>What I need is a project that is doable (for them) in 2 weeks. It is interesting. Somehow I want it to be interactive (something that's cool, something that we get to use a lot or something like that)?</p> <p>Any idea?</p>
c++
[6]
5,646,716
5,646,717
Simple? Increase Field/Box Size
<p>We have a custom CMS on a football website. Within the CMS admin panel is a squad biography section, as shown here:</p> <p><img src="http://i.stack.imgur.com/VTjBJ.jpg" alt="app.php"></p> <p>On the above screenshot you will see the ‘Biography’ section highlighted. The code for this section within /app.php is;</p> <pre><code> &lt;ul class="tr"&gt; &lt;li class="td1"&gt;Biography&lt;/li&gt; &lt;li class="td2"&gt;&lt;input type="text" name="biography" value="&lt;?=$row['biography']; ?&gt;" /&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I’m trying to make the Biography box bigger as this field will require several paragraphs. Currently, it’s just one character limited row.</p> <p>I’m also hoping to replicate making the box bigger on the actual outcome too. Screenshot of which is here: <img src="http://i.stack.imgur.com/C0bYD.jpg" alt="index.php"></p> <p>/index.php contains this code;</p> <pre><code>&lt;ul class="tr"&gt; &lt;li&gt;&lt;?=$row['biography']; ?&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Any help as to how I can make the input and output boxes bigger (to accommodate paragraphs rather than one single line) would be massively appreciated.</p>
php
[2]
2,338,627
2,338,628
IPhone Web Service communication
<p>We need to write an iPhone application.</p> <p>The application would need to consume an web service for storing user information, user session. etc.</p> <p>Also one feature expected is, we should able to ping any user through iPhone application [iPhone would call web service and pass on data however bot sure how the webservice would pass that text to respective iPhone user].</p> <p>I have searched on net for most feasible options on net and came accross some options like,</p> <ol> <li>Polling to web service.</li> <li>WCF restful service for iPhone communication.</li> <li>found some ready made servers for push to communication.</li> </ol> <p>Can you please suggest best suitable and cost effective solution.</p> <p>Thanks in advance.</p>
iphone
[8]
1,165,426
1,165,427
Give alert when the file is download from the attachment in android
<p>I download the *.ics file successfully from the mail attachment by using<br> intent-filter. I need to give an alert at the time of downloading the ics file. How to do this? Please help me to solve.This I am new to android. </p>
android
[4]
2,911,384
2,911,385
Disposable Using Pattern
<pre><code> using (FileStream fileStream = new FileStream(path)) { // do something } </code></pre> <p>Now I know the using pattern is an implementation of IDisposable, namely that a Try/Catch/Finally is set up and Dispose is called on the object. My question is how the Close method is handled.</p> <p><a href="http://msdn.microsoft.com/en-us/library/yh598w02.aspx" rel="nofollow">MSDN</a> says that it is not called, but I have read otherwise.</p> <p>I know that the FileStream inherrits from Stream which is explained <a href="http://msdn.microsoft.com/en-us/library/ms227422.aspx" rel="nofollow">here</a>. Now that says not to override Close() because it is called by Dispose().</p> <p>So do some classes just call Close() in their Dispose() methods or does the using call Close()?</p>
c#
[0]
5,884,870
5,884,871
Modify array values in a file
<p>I have a php file with some arrays in it. I want to modify one of these arrays and write it back to the file. For e.g. say file test.php has contents -</p> <pre><code>&lt;?php $arr1 = array("a"=&gt;"b", "c" =&gt;"d"); $arr2 = array("a2" =&gt; "b2", "c2" =&gt; "d2"); </code></pre> <p>i want to change $arr1 so that test.php now looks like -</p> <pre><code>&lt;?php $arr1 = array("a"=&gt;"b", "c" =&gt;"d", "e"=&gt;"f"); $arr2 = array("a2" =&gt; "b2", "c2" =&gt; "d2"); </code></pre> <p>I do not know what arrays are present in the file beforehand.</p> <p>Edit: i am not adding any variables to the array, only another key value pair. The problem is that the array is part of a file with more arrays in it about which I won't always be aware. I can achieve this if there was only one array in the file, but want to know if it is possible to do this with multiple arrays.</p>
php
[2]
4,866,147
4,866,148
Want android app to wait until user presses a button before continuing
<p>I have a game for android, and when the user wins, it shows a dialog asking if they want to play again. If they say "no", the application exits, and if they say "yes", it starts another game. The problem is that a new game starts as the dialog is displayed, instead of waiting for the user to press a button. The code is like this:</p> <pre><code>if (won) { showDialog(DIALOG_WON_ID); imageAdapter.initializemThumbIds(); // this starts a new game } </code></pre> <p>I don't want the start-new-game line to execute until the dialog is dismissed.</p>
android
[4]
1,718,326
1,718,327
Using Resources in Exceptions
<p>I have an app that uses custom Exceptions, such as this:</p> <pre><code>public class SomeException extends Exception{ private int iCode; private String iMessage; public SomeException(){ iCode = 201; iMessage = **//Get the localized string R.string.error_201??** } @Override public String getMessage() { return iMessage; } @Override public int getCode() { return iCode; } } </code></pre> <p>Obviously, I want lo localize the error message. I have possible solutions but non of them satisfy me.</p> <p>1) Pass "Context" to the constructor, and do ctx.getString(R.string.error_201) --> Fail, as this Exceptions are sometimes thrown from MODEL classes, so they don't have a Context</p> <p>2) Pass "Context" when retriveing the message in getMessage() function, --> Fail, It's necesary to override the super method, to work as all other Exceptions.</p> <p>Solution I have now: All activities in my app have this onCreate:</p> <pre><code>public void onCreate(...){ Utils.RESOURCES = getResources(); ... } </code></pre> <p>Very dirty code... I don't like the solution. My question is then,: is there a way to access the resources without the Context? And most important, How would an application such as mine solve this problem?</p>
android
[4]
2,132,524
2,132,525
Incrementally updating a asp.net web site?
<p>Is there a good way to make incremental changes to an asp.net website without re-publishing the whole site?</p> <p>I'm moving an old website from classic asp to asp.net, and one of the things that used to happen on the site was individual pages being changed in isolation. The site is only on a single server, and has a lot of files so doing a re-publish would take the whole site down for a while. I'd like to avoid that, or at least make that time as short as possible.</p> <p>Each page does have a code behind file, and there's some stuff used by each page in App_Code (just in case that changes the answer).</p>
asp.net
[9]
3,394,929
3,394,930
Using optionsMenu programatically
<p>I'm aware that you can display the options menu by using openOptionsMenu() method, but this only works if the options menu was previously created(by clicking before the menu hardkey), so my question is: Is there any way of creating the optionsMenu for opening it without having to hit the menu hard key?. Thanks in Advance.</p>
android
[4]
363,735
363,736
saving in sharedpreferences take a lot of time
<p>in my app to save configurations I do:</p> <p>((Activity) context).getSharedPreferences("contentList", 0).edit() .putString("contentList", contentListString).commit();</p> <p>((Activity) context).finish();</p> <p>This takes a lot of time until the activity finishes. Is there a reason for this, and how to improve it?</p> <p>Thanks, best regards.</p>
android
[4]
2,019,700
2,019,701
get min display brightness
<p>Is there any way to get minimum display brightness value. Suppose from setting I set displaybrightnessseckbar to 0. But the android system does not make the systems brightness value to 0 rather it set it to a minimum display brightness value. this min display brightness value vary from device to device. How can I get this value</p>
android
[4]
492,008
492,009
PYTHON - Comparing two different files; if a line containing an ID already exists then update else append the line
<p>I have a master file which is the one which will constantly be updated and a file which is created every minute. I want to be able to compare the new file which is created every minute to the already existing master file. So far I've got:</p> <pre><code>with open("jobs") as a: new = a.readlines() count=0 for item in new: new[count]=new[count].split(",") count+=1 </code></pre> <p>This will allow me to compare the first index([0] of each line in my master file. Now at this point I start to confuse myself. I'm guessing it would be something along the lines of:</p> <pre><code>counter=0 for item in new: if new[counter][0] not in master: end = open("end","a") end.write(str(new[counter]) + "\n") counter+=1 end.close() else: REPLACE LINES THAT ALREADY EXIST IN MASTER FILE WITH NEW LINE </code></pre> <p>The IDs won't necessarily be in the same order every time the new file comes in and the new file may contains more entries than the master file at some point.</p> <p>If I haven't made sense or missed some information out then please let me know and I'll try and clarify. Thanks.</p>
python
[7]
4,428,668
4,428,669
Android - Avoiding an activity to destroy, just stopping or pausing it when pushing the back button
<p>I would like to pausing or putting the application on background when pressing the back button, I don't want the application to go through the destroy state. Things are when I override onKeyDown and when I force to pause or stop the application by using onPause, I have some issuees with the wakelock and application crash, but when I press home button I go through onPause method and I have no exception, it's weird!! </p>
android
[4]
3,308,448
3,308,449
TabHost Problem on Android
<p>I've created a tabs using tabhost (Let's called tab "A")</p> <p>Tab "A" is the originator for activity 1</p> <p>In activity 1, it is containing a button widget</p> <p>Question is ....</p> <p>Is it possible for A to handle more than 1 activities (switching), this is done by pressing the button appeared in activity 1 (I need the switched activity is still appeared under tab "A")</p>
android
[4]
2,673,459
2,673,460
How do I write a jQuery selector to match two elements whose ids start with the same string
<p>I have 2 loader images, with element ids loader1 and loader2. I bind to the first one with:</p> <pre><code>$('#loader1') .hide() // hide it initially .ajaxStart(function() { $(this).show(); }) .ajaxStop(function() { $(this).hide(); }) ; </code></pre> <p>How can I bind the same code to loader2 without repeating the whole thing?</p>
jquery
[5]
2,960,414
2,960,415
how to work without with navigation controller
<p>hi before i never use navigation controller, can i use navigation controller like this </p> <p>consider in my app there is <strong>three view</strong> (ie main view, first view, second view) on main view, <strong>two UIButton's with button action</strong> to move into first view and second view respectively<br> and to go back to main view, i have to place navigation controller(like back button wiht title) on first view and second view(note:- not navigation controller on main view)</p> <p>i want to place navigation controller on first view and second view for back to main view <strong>note</strong>:- on my <strong>main view no navigation controller</strong>, navigation controller will be on first and second view used as back buttons and title <strong>can you guide me to the solve this problem</strong></p>
iphone
[8]
2,668,739
2,668,740
unable to find com.android.camera.CropImage activity in android
<p>I am trying to run PhotoStream sample from following link </p> <blockquote> <p><a href="http://android-developers.blogspot.com/2008/09/android-photostream.html" rel="nofollow">http://android-developers.blogspot.com/2008/09/android-photostream.html</a></p> </blockquote> <p>But when i try to set the wallpaper of an image ( reference class ViewPhotoActivity.java) i am getting following error </p> <blockquote> <pre><code>android.content.ActivityNotFoundException: </code></pre> <p>Unable to find explicit activity class {com.android.camera/com.android.camera.CropImage}; have you declared this activity in your AndroidManifest.xml?</p> </blockquote> <p>and i think the following code is causing the problem</p> <pre><code>final Intent intent = new Intent("com.android.camera.action.CROP"); intent.setClassName("com.android.camera", "com.android.camera.CropImage"); intent.setData(Uri.fromFile(mFile)); intent.putExtra("outputX", width); intent.putExtra("outputY", height); intent.putExtra("aspectX", width); intent.putExtra("aspectY", height); intent.putExtra("scale", true); intent.putExtra("noFaceDetection", true); intent.putExtra("output", Uri.parse("file:/" + mFile.getAbsolutePath())); startActivityForResult(intent, REQUEST_CROP_IMAGE); </code></pre> <p>As i tried to find the solution of this problem but didn't get any.</p>
android
[4]
476,696
476,697
jQUery problem reoccuring!
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3430873/problem-working-with-jquery">Problem working with jQuery</a> </p> </blockquote> <p>Hello! The follow is the code i've been using and i dont understand why its not working at all! : </p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script language="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script language="text/javascript"&gt; function hide() { $("#Layer1").hide("fast"); } &lt;/script&gt; &lt;style type="text/css"&gt; &lt;!-- body { background-color: #000000; } #Layer1 { position:absolute; width:200px; height:115px; z-index:1; left: 179px; top: 3px; } #Layer2 { position:absolute; width:101px; height:80px; z-index:2; left: 570px; top: 473px; } --&gt; &lt;/style&gt;&lt;/head&gt; &lt;body&gt; &lt;div id="Layer1"&gt;&lt;img src="body.jpg" width="842" height="554" /&gt;&lt;/div&gt; &lt;div id="Layer2"&gt;&lt;img src="close.jpg" width="63" height="64" OnClick="hide()"/&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I've used dreamweaver for the design.</p> <p>Thanks!</p>
jquery
[5]
776,637
776,638
Add new routes dynamically in asp.net
<p>I am developing a new site where i am using Asp.net routing functionality instead of rewriting to use user friendly and seo friendly urls. For that I have added <b>RouteTable.Routes.MapPageRoute("HomePage", "Home", "~/Home.aspx");</b> such code for my each and every page likewise there is entry for aboutus page, contactus page etc.</p> <p>My first question is, Is this a right way to use routing</p> <p>2) How i can add new routing maps dynamically to this. for ex i have given a option from admin panel to add new pages(physically) and now user should able to give a precise URL for this newly added page.</p>
asp.net
[9]
198,320
198,321
Need to create a string token dynamically base on which method is calling it
<p>This is a minimal code. </p> <p>I have the string Str which is used by various methods. I want to in getId method be able to do 2 things</p> <ol> <li>Assign class="PDP" to it and </li> <li>Give it a value3</li> </ol> <p>So the final string looks like </p> <p><code>&lt;tr class='PDP' id='{2}'&gt; &lt;td {0}&lt;/td&gt;&lt;td&gt;{1}&lt;/td&gt;&lt;/tr&gt;</code></p> <p>But please note that I will need different values for class in different methods so some Str will have PDP, another will have PTM etc. Is there a clean way to achieve this .</p> <pre><code>private const string Str = "&lt;tr&gt;&lt;td &gt;{0}&lt;/td&gt;&lt;td&gt;{1}&lt;/td&gt;&lt;/tr&gt;"; public static string getId() { string field=string.Format(str, value1,value2, found=true? value3:""); } </code></pre>
asp.net
[9]