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,919,591
1,919,592
Androd: application crashes when i use it after leaving it idle for a long time
<p>I am working in android. I have made an application.</p> <p>I used these following things in my application. 1. timers 2. threads 3.call APIs which are returning data regularly.</p> <p>my application is a little bit large, so I unable to upload here code. I installed apk into my android device. This application is running successfully. </p> <p>when I launch my application in device and keep it idle for a long time and then again use it, a crash occurs.</p> <p>I am unable to find out the cause for this crash. please suggest me your opinion about this. You may send some links related to this. You can ask me anything related to my application. I am 24 hour available here.</p> <p>Thank you in advance.</p>
android
[4]
3,603,647
3,603,648
jQuery SELECT change trigger
<p>I use the following jQuery function to perform a slideDown on a DIV, based on the value of a SELECT dropdown:</p> <pre><code>$(function() { $('#show-options').change(function(){ if($(this).val() != '') { $('#' + $(this).val()).slideDown(); } }); }); </code></pre> <p>HTML:</p> <pre><code>&lt;select id="show-options"&gt; &lt;option value=""&gt;Select an Option&lt;/option&gt; &lt;option value="vehicle-type"&gt;Vehicle Type&lt;/option&gt; &lt;option value="vehicle-colour"&gt;Vehicle Colour&lt;/option&gt; &lt;/select&gt; &lt;div id="vehicle-type" style="display: none;"&gt; &lt;!--form elements in here--&gt; &lt;/div&gt; &lt;div id="vehicle-colour" style="display: none;"&gt; &lt;!--form elements in here--&gt; &lt;/div&gt; </code></pre> <p>Now when the form is submitted, any DIVs that were displayed before submission need to be displayed automatically. I can check for the GET variables in my PHP but I need the jQuery code that will mimic the 'change' function - I think this has something to do with triggers or binds.</p>
jquery
[5]
5,368,853
5,368,854
How to get the information about all running activities in the sytem?
<p>I am developing an app related to ActivityManager.</p> <p>I want to get information about all running activityies inside the system by using ActivityManager.</p> <p>How can this be done?</p>
android
[4]
5,059,221
5,059,222
Adding edittext to CClayer in android cocos2d-1
<p>How can I add edittext,textview to the CCLayer in android cocos2d-1?</p> <p>I have tried this code:</p> <pre><code>CCDirector.sharedDirector().getActivity().runOnUiThread(new Runnable() { public void run() { final EditText name=new EditText(CCDirector.sharedDirector().getActivity()); setView(name); } }); </code></pre> <p>But here I want to setview to the CCLayer.</p>
android
[4]
330,989
330,990
How to confirm the insert query is a success?
<p>I am inserting into the database with foll0wing code and it's working fine as I can see the data populates in the db, however I want to capture the result programmatically whether it was a success or failure</p> <p>1) Here is the code to insert</p> <pre><code>public void SignUp(String last_name, String first_name, String email, String password, String confirm_password, String phone) { Connect connect = new Connect(); Connection conn = connect.Connection(); Statement stmt = conn.createStatement(); String query = "INSERT INTO users VALUES(NULL,('" + last_name + "'),('" + first_name + "'),('" + email + "'),('" + password + "'),('" + confirm_password + "'),('" + phone + "'))"; stmt.executeUpdate(query); conn.close(); } </code></pre> <p>2) Here is the code I used to connect </p> <pre><code>public Connection Connection() { Connection conn = null; try { String userName = "admin"; String password = "admin"; String url = "jdbc:mysql://localhost/project"; Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(url, userName, password); System.out.println("\n Database connection established"); } catch (Exception e) { e.printStackTrace(); System.err.println("\n Cannot connect to database server"); } } </code></pre>
java
[1]
4,521,154
4,521,155
ASP.Net Using POST with Server.Execute
<p>I'm trying to do something like </p> <pre><code>Server.Execute("page1.aspx"); </code></pre> <p>but I need to pass POST data to this page.</p> <p>Does anyone know how I can achieve this? Since Server.Execute only takes in 3 params, and none of these are anything to do with POST data.</p> <p><strong>Solution: 7 Hours Later...</strong> </p> <p>Unfortunately, the only way I was able to do this was to pass the parameters in the query string (using a GET request). I've searched the web for a while now, and finally felt this was good enough for my application. I tested, and somehow the GET URL size limit of 4K chars does not hold good in this context. </p> <p>I was able to successfully execute a Server.Execute method with 640K+ chars to another page, and it worked beautifully.</p> <pre><code>Server.Execute("~/pageB.aspx?foo=" + new string('x', 640000)); </code></pre> <p>In pageB: Page_Load();</p> <pre><code>Response.Write(Request["foo"].ToString().Length()); </code></pre> <p>Result: 640000</p> <p>So I guess this will have to do for now. </p> <p>I was afraid of having to send large parameters in the query string, but since it works, who am I to complain! :)</p>
asp.net
[9]
409,688
409,689
Determine if key values in two arrays are equal then update if they are
<p>I've taken up PHP programming as a hobby after work and kids. So, my appologies if this code is bogus...but I've been searching for awhile. Anyways, I am trying to compare the values in two arrays and...where each key value equals another I would like to update that value to '1'. So for example, in one array the values are (2, 4, 1) in the second they are (3, 4, 5). Afterwards the the values that would be in my sql column would be updated to (2, 1, 1). Here is my code. Thank you for any help! </p> <pre><code>$array1 = mysql_fetch_array($x); $array2 = mysql_fetch_array($x1); foreach($array1 as $key =&gt; $value) { if($value == $array2[$key]) { $v = "UPDATE fXnumber SET xnumber = '1'"; mysql_query($v); } } </code></pre>
php
[2]
2,966,925
2,966,926
Open native sms inbox in SonyEricsson using android app
<p>I am doing an app where a button click navigates to device's native sms inbox.</p> <pre><code> Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.mms"); PendingIntent pendingIntent = PendingIntent.getActivity(context , 0,intent,0) ; remoteViews.setOnClickPendingIntent(viewId, pendingIntent ); </code></pre> <p>Its working for Samsung devices. But not responding for the Motorola and SonyEricsson devices. can anyone suggest any other method to do the same activity common for all devices??</p> <p>Thanks in advance</p>
android
[4]
1,469,511
1,469,512
call data without refresh
<p>I am trying to do a small thing, any 1 help me, I really appricciate... I have a drop down menu,I want when I select the value, it will call the related data, which I am access with php+mysql, I dont want to jump to other page and show</p>
jquery
[5]
2,562,348
2,562,349
changing ImageView source
<p>I have an ImageView with a source image set in the xml using the following syntax:</p> <pre><code> &lt;ImageView android:id="@+id/articleImg" style="@style/articleImgSmall_2" android:src="@drawable/default_m" /&gt; </code></pre> <p>now I need to change this image programmatically. What I need to do is delete the old image and add a new one though. What I have done is this:</p> <pre><code>myImgView.setBackgroundResource(R.drawable.monkey); </code></pre> <p>it works but I noticed android stacks the new image on top of the old one (dont ask me how I found out it's not relevant for the discussion :). I definitely need to get rid of the old one before setting the new image.</p> <p>how can I achieve that?</p> <p>thanks</p>
android
[4]
452,718
452,719
move_uploaded_file file not work when it will call two time
<p>i have a function to upload file in php Like:</p> <pre><code>function upload_file($folder,$name) { $dest = "../product/". $folder."/". $name; $src = $_FILES['image']['tmp_name']; if (move_uploaded_file($src, $dest)) { } else { echo "&lt;script&gt; alert('" . $src . "'); window.history.go(-1); &lt;/script&gt;\n"; exit(); } } </code></pre> <p>whene i call function only one time like <code>upload_file('small','abc.jpg')</code> it works fine but i have call two time like:</p> <pre><code>upload_file('small','abc.jpg') upload_file('big','abc.jpg') </code></pre> <p>it not work on second folder 'big'</p> <p>any solution for that ?</p>
php
[2]
1,103,058
1,103,059
Why doesn't `print "hello"` print "hello"?
<pre><code>a=1 if a: print "hello" </code></pre> <p>What is wrong with these code?Actually I am trying to learn python from the google I have installed today itself and working on.I just learnt the command python to execute the .py extension file.But when i execute the above code the compiler gives these error expected an indented block.What does it mean?</p> <p>I dont know becuase I am learning it from right today i have 2 years experiance on c.but im trying to move to a scripting language or some other powerful language and i even heard facebook was developed using the concepts of python so im much interested in learning it and also people told me python is such a tool that got lots of stuff to work and you get amazed.But i dont know where to start and how to make it all</p> <p>.I need your guidelines,suggestions and advices to make my python career very bright.Could you suggest me any good tutorials available for free.and easy way to learn python.I tried it on google but some tutorials are not making sense.I belive people who post the answers on stackoverflow got much talent and skills so i want you to guide me in a right path i supposed to be.Thank you </p>
python
[7]
337,124
337,125
viewing swf files in asp.net
<p>Hey friends, I need to open an swf file without storing it in a temporary location using AJAX Document Viewer. However, it should open on click of an image button and in the same page. How can I do this? </p>
asp.net
[9]
161,690
161,691
php: function breaks when included from different file
<p>I'm trying to write a wrapper around Image_Graph bar charts. I actually wrote the whole thing but in the end didn't work, so now I'm back to the basics. This code below is taken directly from the ImageGraph website as a bar chart example. I just wrapped it in a function (where $data is ignored for now).</p> <p>This function works fine if I call it from the same file it's defined in (say, function.php). However, if I make a second file, caller.php where I just include_once or require_once this file function.php and then just call the function, it breaks.</p> <p>Can anyone help me? I'm probably doing some basic mistake but I just can't figure it out. It might also be something specific to Image_Graph because if I make a simple function that just prints Hello World and call that from another file, it works fine.</p> <p>Thanks, Daniel</p> <pre><code>&lt;?php include_once('Image/Graph.php'); function DrawBarChart($width, $height, $data) { // create the graph $graph = Image_Graph::factory('graph', array($width, $height)); // create the plotarea $plotArea =&amp; $graph-&gt;addNew('plotarea'); // create a dataset $dataset =&amp; Image_Graph::factory('dataset'); // add points $dataset-&gt;addPoint('Denmark', 10); $dataset-&gt;addPoint('Norway', 3); $dataset-&gt;addPoint('Sweden', 8); $dataset-&gt;addPoint('Finland', 5); $plot =&amp; $plotArea-&gt;addNew('bar', &amp;$dataset); $graph-&gt;done(); } ?&gt; </code></pre>
php
[2]
3,959,215
3,959,216
book for compile
<p>I'm developing a compiler for a language (newly created) in java. Help me out my by suggesting some books which could be used or some guideline to start with thsis.</p>
java
[1]
4,817,804
4,817,805
carousel problems
<p>I'm using carousel code Imade 5 classes and usd same as <a href="http://www.codeproject.com/Articles/146145/Android-3D-Carousel" rel="nofollow">http://www.codeproject.com/Articles/146145/Android-3D-Carousel</a> but when i run the program wic i made it's give me and give me error that R.layout.main main:main canot be reslt or not field ... how can i solve this?? and i have another problem in Carousle class:</p> <pre><code>int min = arr.getInteger(R.styleable.Carousel_minQuantity, MIN_QUANTITY); </code></pre> <p>on styleabl cannot be result or faild plz i need help</p>
android
[4]
4,764,628
4,764,629
Directory.Delete doesn't work. Access denied error but under Windows Explorer it's ok
<p>I have searched the SO but find nothing.</p> <p>Why this doesn't work?</p> <pre><code>Directory.Delete(@"E:\3\{90120000-001A-0000-0000-0000000FF1CE}-C"); </code></pre> <p>Above line will throw exception "Access is denied". I have admin rigths and I can delete the dir with Explorer.</p> <p>It looks like some forbidden chars? but Windows Explorer can handle it. How can I delete directories with names like that?</p> <p>Thanks and Greetz</p>
c#
[0]
1,137,859
1,137,860
sending mulitple keyevent using adb shell
<p>I want to send multiple keyevent using adb.</p> <p>After googleing I can to know about <code>adb shell input keyevent 65</code> but using this command I can send only one keyevent.</p> <p>I want to simulate like " SHIFT_KEY + special character".</p>
android
[4]
5,693,750
5,693,751
How to save NSMutableArrays in NSUserDefaults
<p>i have 4 NSmutablearrays with individual data.</p> <p>Now i need to save them in NSuserdefaults individually and retrieve them individually.</p> <p>how can i done this,</p> <p>can any one please post some code.</p> <p>Thank u in advance.</p>
iphone
[8]
2,277,992
2,277,993
Strip Paragraph Tag
<p>In my image.php I am using this code to grab the image caption of each image. The problem is a paragraph tag ( <code>&lt;p&gt;</code> ) is being added around it and I don't want one to be. Could somebody tell me how to strip this tag?</p> <pre><code>&lt;?php if ( !empty($post-&gt;post_excerpt) ) the_excerpt(); ?&gt; </code></pre>
php
[2]
2,108,229
2,108,230
clearInterval doesn't work
<p>I have problems with my clearInterval, It doesn't stop my setInterval, here is code:</p> <pre><code>$(".auto-check").click(function(){ if($('input[name=autorefresh]').is(':checked') == true){ var intervalId = setInterval(load,4000); } else{ alert("Auto Refresh is off"); clearInterval(intervalId); } }); </code></pre> <p>who can tell, where is problem? </p>
javascript
[3]
2,038,751
2,038,752
converting list<int> to int[]
<p>Is there builtin method that would do this or do I always have to manually create a new array and then fill it up with a foreach loop</p>
c#
[0]
2,298,754
2,298,755
jQuery: Select elements that match all of the following classes?
<p>I want to select elements that match multiple classes where the classes could be in any order.</p> <p>I've tried using the <strong>.not()</strong> selector, but it picks all elements that matches <strong>any</strong> of the multiple classes.</p> <p>What I'm looking for is something so it needs to have <strong>all</strong> of the multiple classes.</p> <p>Basically <strong>.hasClass()</strong> but for multiple classes and with a return the elements that fits the match.</p> <p>I've already tried this:</p> <pre><code>$(".Class1.Class2") </code></pre> <p>The problem with that is that is has to be in a certain order which won't work. I need it to work so the classes could be in any order. The element just need to have them, all of them.</p> <p>Thank you!</p>
jquery
[5]
1,908,939
1,908,940
Virtual member call in constructor - why is one okay and the other not?
<p>With the code below, Resharper raises a 'virtual member call in constructor' warning:</p> <pre><code>public class UserDetailViewModel : Screen { public UserDetailViewModel() { // DisplayName is a virtual member of Screen DisplayName = "User Details"; } } </code></pre> <p>Whereas if I change the code so it's like this, the warning disappears:</p> <pre><code>public class UserDetailViewModel : Screen { public UserDetailViewModel() { SetName(); } private void SetName() { DisplayName = "User Details"; } } </code></pre> <p>Why does one raise a warning and the other not? Is the second way somehow correct, or is it just beyond the limit of what ReSharper can detect as potentially dangerous?</p>
c#
[0]
4,175,720
4,175,721
Check HTTP Image path if valid
<p>I have a question in Java how can I check if an image http path is valid or existing?</p> <p>For example:<br> This image is existing. <a href="http://g0.gstatic.com/ig/images/promos/homepage_home.png" rel="nofollow">http://g0.gstatic.com/ig/images/promos/homepage_home.png</a></p> <p>But this one is not. <a href="http://sampledomain.com/images/fake.png" rel="nofollow">http://sampledomain.com/images/fake.png</a></p> <p>I would like to make a logic such that:</p> <pre><code>If(image is existing) - do this Else - do others </code></pre> <p>Thanks</p> <p><strong>UPDATE:</strong> Tried it with this code that I got while googling:</p> <pre><code>import java.awt.Image; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; public class TestImage { public static void main(String[] arg){ Image image = null; try { URL url = new URL("http://g0.gstatic.com/ig/images/promos/homepage_home.png"); image = ImageIO.read(url); } catch (IOException e) { System.out.println("Error"); } } } </code></pre> <p>But I always get an error...I am not sure if this is possible.. Any other thoughts?</p>
java
[1]
5,296,736
5,296,737
I am trying to write a networking software -firewall in server, proxy?
<p>I have question about network programming. My first question was probably about the platform, because the speed and the user friendliness is important. I decided to do it in VC++, not in .net (C#), as I want to use the firewall mechanism, though should find the common way between old windows and after vista, as I was studying about it. Honestly, I have a book titled "Network Programming for Microsoft Windows Second Edition" and another book that is about Active Directory and not an important issue here. I need to use it, too. I don't know how much that book can related to and help my software writing.</p> <p>My software needs to do the Bandwidth allocation job, it needs to do some packet processing and needs to control the internet usage of all clients in the server that receive internet from server, DHCP maybe or maybe through IP address, I don't know, maybe it is good or needed to write a proxy, as for filtering, too. In fact, I need guidance for writing this software, forgot to say that proxy brings a question about connectionless UDP in my mind, if that's the same way I thought: through sockets make a simple bridge.</p> <p>Thanks!</p>
c++
[6]
4,568,611
4,568,612
How to check if a string is one of the known values?
<pre><code>&lt;?php $a = 'abc'; if($a among array('are','abc','xyz','lmn')) echo 'true'; ?&gt; </code></pre> <p>Suppose I have the code above, how to write the statement "if($a among...)"? Thank you</p>
php
[2]
5,321,254
5,321,255
Sending parameters to other sites
<p>look here first <a href="http://stackoverflow.com/questions/2883338/how-can-i-send-a-date-from-one-site-to-other-sites">http://stackoverflow.com/questions/2883338/how-can-i-send-a-date-from-one-site-to-other-sites</a> let me change the question a bit, i didnt really explain myself properly. What i intend to do is get z.php to read a text file called 'sites.txt' which has a list of sites:</p> <pre><code>site1.com/a.php site2.com/b.php site3.com/c.php </code></pre> <p>to execute the urls in the sites in 'sites.txt' i want it to go through siteA.com/z.php?ip=xxx.xxx.xx.xxx&amp;location=UK (z.php will then read 'sites.txt') All sites in the 'sites.txt' file will be executed as </p> <pre><code>site1.com/a.php?ip=xxx.xxx.xx.xxx&amp;location=UK site2.com/b.php?ip=xxx.xxx.xx.xxx&amp;location=UK </code></pre> <p>I hope that makes more sense, i have tried looking around but couldnt find what i was looking for. Thanks for your help so far everyone. site3.com/c.php?ip=xxx.xxx.xx.xxx&amp;location=UK</p>
php
[2]
2,320,263
2,320,264
Which are true and which are false?
<p>So far I know that :</p> <p>(a) is false</p> <p>(b) is true</p> <p>(c) is false</p> <p>(e) is true</p> <p>(f) is false</p> <p>and (g) is true</p> <p>The questions:</p> <p>(a) A final method cannot be overloaded. </p> <p>(b) A final class cannot be subclassed. (c) A static field is not inherited.</p> <p>(d) A protected field is only accessible to subclasses.</p> <p>(e) Every Java class has a unique name.</p> <p>(f) The import statement is just like C and C++’ s #include statement. </p> <p>(g) Java always initializes class fields.</p> <p>(h) Methods in interfaces are always public</p> <p>(i) abstract classes cannot implement interfaces.</p> <p>(j) An inner class is a static nested class.</p>
java
[1]
4,848,785
4,848,786
Python Dynamic Class Object Names
<p>Just a quick question. I've tried Googling this but every time you add "class" to a Python search it gives you classes on Python. D:</p> <p>I've found threads like this: <a href="http://stackoverflow.com/questions/5036700/how-can-you-dynamically-create-variables-in-python-via-to-a-while-loop">How can you dynamically create variables in Python via to a while loop?</a></p> <p>But I don't think that's exactly what I'm looking for since concatenation is also part of the variable.</p> <p>Here's my while loop:</p> <pre><code>def main(): counter = 1 while counter &lt;= 3: print "Name: ",employee[counter].name print "ID Number: ",employee[counter].id_number print "Department: ",employee[counter].department print "Job Title: ",employee[counter].job_title print #LB counter = counter + 1 main() </code></pre> <p>I have my objects set up as:</p> <pre><code>employee1 = Employee("Susan Meyers", 47899, "Accounting", "Vice President") employee2 = Employee("Mark Jones", 39119, "IT", "Programmer") employee3 = Employee("Joy Rogers", 81774, "Manufacturing", "Engineer") </code></pre> <p>This is the error I receive:</p> <pre><code>print "Name: ",employee[counter].name NameError: global name 'employee' is not defined </code></pre> <p>Obviously I have a class set up as well, but I don't think I need to paste that for this. What I want it to do is go through the loop and change the counter from 1 to 2 to 3. That way it'll loop through all three employees. </p> <p>Is it possible to do that? I've only ever done this with arrays so I'm not 100% sure I'm on the right track.</p> <p>Any tips would be great. &lt;3</p> <p>Chelsea</p>
python
[7]
679,091
679,092
Android save contact image programmatically
<p>I am working on one application in which i need to store the contact pro-grammatically. I have successfully saved the contact but not able to save the contact image. </p> <p>I didn't found any example for the same.</p> <p>any help would be appreciated.</p>
android
[4]
4,703,200
4,703,201
What's the use of specifying the type of a HashSet when working with the generic Set interface?
<p>If you instantiate a new HashSet, you usually use the Set interface to work with it afterwards. Just like</p> <pre><code>Set&lt;T&gt; set = new HashSet(); </code></pre> <p>So what is the use of specifying the type of the HashSet explicitly, too? For example:</p> <pre><code>Set&lt;T&gt; set = new HashSet&lt;T&gt;(); </code></pre> <p>I've seen it in quite a couple of books, but I can't think of any use at all. If you need access to the set, you'll work with the interface (which is already parameterized) anyway.</p>
java
[1]
5,636,671
5,636,672
Identifying which files to edit when using php based CMS
<p>I'm trying to make some edits to a website. The website is based on a CMS and runs on PHP.</p> <p>I have some html/css experience and have a thick guide to PHP into book to help me. </p> <p>Among the many edits I'd like to make to the site which are out of the control from the CMS admin area, I'd like to add a Facebook link in the main nav.</p> <p>Now, I would normally, if inheriting someone else's simpe HTMl/CSS site just use the inspect element feature in Chrome of FF and then see whereabout to edit the code.</p> <p>Probably a classic rookie question but how does one do that with PHP? If I right click the nav on my site, how do I know which PHP file to edit? Is there a "best way" here?</p> <p>Here's the site incidentally if it helps at all. I'd like to add (among many other things) a Facebook icon next to the RSS icon in the main nav. I just don't know which file to edit.</p> <p><a href="http://tinyurl.com/byal33m" rel="nofollow">http://tinyurl.com/byal33m</a></p>
php
[2]
1,675,112
1,675,113
Show Add button after Edit button is clicked?
<p>I have a view with navigation bar control on the top. The view is in the second level with a "back" button is displayed on the left by default. In my view class, I added a default navigation edit button on the right:</p> <pre><code>self.navigationbarItem.rightButtonItem = self.editButtonItem; </code></pre> <p>with this line of code, an edit button is on the right side, and when it is clicked, the view (table view) becomes editable with delete mark on the left for each row. After that, the edit button's caption becomes "done". All those are done by the default edit button built in the navigation control, I think.</p> <p>I would like to add an add button the left, or replace "back" button when edit is clicked. I guess I have to implement some kind of delegate in my view class. This would provide a place to plug in my code to add the add button on the left when edit button is clicked, and to restore "back" button back when the done button is clicked. If so, what's the delegate? Or is there any other way to achieve it?</p>
iphone
[8]
1,436,206
1,436,207
Grabbing values from API response
<p>How would I grab values from this api response using python?</p> <p><a href="http://tinychat.com/api/find.room/randomroom" rel="nofollow">http://tinychat.com/api/find.room/randomroom</a></p>
python
[7]
3,780,633
3,780,634
android comparison between arraylist and database?
<p>i am fetching data from server storing it to the database and again storing it to arraylist from database to arraylist and than using in listview. so suppose if i am using direct database i have to query it numberof times so is there any overhead using direct database.</p> <p>thnakx.</p>
android
[4]
4,662,578
4,662,579
Recognise user without using IP
<p>I need to grant access to user with or without credentials.<br> I have tried the <code>SERVER[remote_addr]</code> but it didn't work due to dynamic IP used in the company.<br> Any suggestions? </p>
php
[2]
2,439,271
2,439,272
How to reset cursor to the beginning of the same line in Python
<p>Most of questions related to this topics here in SO is as follows:</p> <blockquote> <p>How to print some information on the same line without introducing a new line</p> </blockquote> <p><a href="http://stackoverflow.com/questions/3249524">Q1</a> <a href="http://stackoverflow.com/questions/493386">Q2</a>.</p> <p>Instead, my question is as follows:</p> <p>I expect to see the following effect,</p> <pre><code>&gt;&gt; You have finished 10% </code></pre> <p>where the <code>10</code> keep increasing in the same time. I know how to do this in C++ but cannot find a good solution in python.</p> <p>// ================== Updated ============================================== Based on the helps from aix and petr, here is the solution to this question:</p> <pre><code># for Python 3 for i in range(0, 101, 10): print('\r&gt;&gt; You have finished %d%%' % i, end='\r') sys.stdout.flush() time.sleep(1) print # for Python 2 for i in xrange(0, 101, 10): # for p2 print '\r&gt;&gt; You have finished %d%%' % i, sys.stdout.flush() time.sleep(1) print </code></pre>
python
[7]
5,138,106
5,138,107
C++ XML to C++ Object Mapping library?
<p>Is there any good automatic xml to C++ object library ?</p> <p>With good benchmark and Multi - Platform support (if not at-least linux ) </p> <p>Edit : More Description </p> <p>I want to library like <a href="http://www.codesynthesis.com/products/xsd/" rel="nofollow">http://www.codesynthesis.com/products/xsd/</a> where I can use any xml as c++ object. </p> <pre><code>XMLOBJECT x=new XMLOBJECT("my.xml"); x-&gt;root x-&gt;root-&gt;child </code></pre> <p>Means XML Data Binding in C++</p>
c++
[6]
4,869,088
4,869,089
create an array from a text file or another array that is based on tabbed spaces?
<p>What I am ultimately trying to do is take a text file that looks like below and organize them into something I can use like an array based on tabbed spaces. </p> <p>// Example //</p> <pre><code>this is no tabbed space this is a tabbed space this is 2 tabbed spaces this is no tabbed space </code></pre> <p>I would like to end up with:(using PHP preferably)</p> <pre><code>$list= array(no \t("string", "string", "string", one \t ("string", "string", "string", tw0 \t("string", "string", "string", etc..)), no \t again starts new("string", "string", array()); </code></pre> <p>I need to keep nesting based on \t spaces and start over when I hit no \t space. Any suggestions or better ways to do this?</p> <p>I need to use this list from a text file to insert into database as categories and use for menu items that have sub levels and as many needed depending on the text file.</p> <p>I figured out how to get them into one array but is there a way to organize them by the tabbed spaces or maybe by if greater than a certain amount of spaces etc..? I am just confused at this piont been trying many different ways but I am truly lost.</p>
php
[2]
5,222,987
5,222,988
What does "new" use when a runtime library is not used?
<p>In C for example, there is no malloc() without a runtime library (libc). And I think for example, on Windows malloc just calls HeapAlloc(). But in C++, the way to allocate dynamic memory is actually a keyword of the language; same for "delete". So therefore, how would "new" work if you compiled your code without a runtime library?</p> <p>Thanks</p>
c++
[6]
3,082,556
3,082,557
Copy content of one STL container to another
<p>How could I create a copy of an unordered_map from an existing one? Could I use assignment operator or I need to iterate it one by one? Also, I am using shared_ptr as the value in the map. Did I need to take extra care because it is shared_ptr?</p> <pre><code>typedef unordered_map&lt;string, shared_ptr&lt;classA&gt;&gt;MAP1; MAP1 map1; map1["abc"] = make_shared&lt;classA&gt;(); MAP2 map2 = map1; ?? //can I use assignment operator?? </code></pre> <p>Thanks.</p>
c++
[6]
639,136
639,137
Passing the same value around in a recursive function?
<p>I've got a recursive function with the signature</p> <pre><code>public static string Recurse(string pattern, ObjectDict dict) </code></pre> <p>The value of <code>dict</code> never changes. It kind of bothers me that I should have to carry around dozens of references to it, and pass it around each time I call the function again. Is there a way around this?</p> <p>By "never changes", I mean after the initial call.</p>
c#
[0]
4,553,017
4,553,018
how to replace a dom node with new node?
<p>I want to replace a existing Dom node with a new node I have created.I am implementing this as </p> <pre><code>String messageBody=" &lt;imgGroup&gt;&lt;img src="src" width="width" height="height" alt="alt" type="type" orient="orient"/&gt;&lt;/imgGroup&gt;" File file=new File("doc.xml"); DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); doc = docBuilder.parse(file); Element node = DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new ByteArrayInputStream(messageBody.getBytes())) .getDocumentElement(); System.out.println(node.getClass()); doc.getDocumentElement().replaceChild((Node)node, doc.getDocumentElement().getFirstChild()); }catch(Exception e){ e.printStackTrace(); } </code></pre> <p>I am getting an run time error <code>WRONG_DOCUMENT_ERR:</code> A node is used in a different document than the one that created it.</p> <p>Can any one suggest how to do it in different way?</p>
java
[1]
4,987,201
4,987,202
Select Text Created By TextRenderer.DrawText
<p>I created text using TextRenderer.DrawText(). I want to select that text and rotate and skew for it. Can u give the step? please...</p>
c#
[0]
199,969
199,970
Serialize Java objects into Java code
<p>Does somebody know a Java library which serializes a Java object hierarchy into Java code which generates this object hierarchy? Like Object/XML serialization, only that the output format is not binary/XML but Java code.</p>
java
[1]
5,073,087
5,073,088
Focus on new window open by window.open
<p>I want to open a new window by window.open and also focus that window even if the tab create new window is not selected.</p> <p>As per my R &amp; D If tab that is not selected and create window by some timer function, then opened window is not display on screen, it just display as blinking on taskbar.</p> <p>Code: </p> <pre><code>win = window.open("",'_blank','titlebar=no, location=no, directories=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, height=50, width=650'); var errorMessage= "Your session will expire in 1 minute,To extend your session, Please press the Extend button."; win.document.write("&lt;html&gt;&lt;head&gt;&lt;title&gt;Session Expire&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;div style='color:red; line-height:50px;' id='message'&gt;"+ errorMessage +"&lt;input type='button' id='btn' value='Extend' /&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;"); win.focus(); </code></pre> <p>I want open new window on center of the screen and the tab which create is not selected, and display new window even if I am currently working on other application</p>
javascript
[3]
4,671,323
4,671,324
How to trigger a button inside a listview (Android)?
<p>I have an activity that extends ListActivity, now I want to enable the click listener button in each row of the list. I did read some similar questions like this, but most of that extend from BaseAdapter to get the button. Actually, with the code below the button event was fired, however I have to double click on the row to fire the event.</p> <pre><code> @Override // How can I trigger a single button instead of firing whole the row protected void onListItemClick(ListView l, View v,final int position, long id) { super.onListItemClick(l, v, position, id); //removeTask(position); ImageView remove = (ImageView)v.findViewById(R.id.remove_task); remove.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { removeTask(position); } }); } </code></pre> <p>I hope my question makes sense. Thanks</p>
android
[4]
3,460,783
3,460,784
how to generate my thumbnails in the background?
<p>I have a <code>ListView</code> and a <code>SimpleCursorAdapter</code>. My code for the <code>SimpleCursorAdapter</code> looks like this:</p> <pre><code>private void listenAdapterErstellen() { adapter = new SimpleCursorAdapter(this, R.layout.my_listlayout, MainController.getInstance().getMyCursor(db), new String[] {"Foo", "Test"}, new int[] {R.id.imageViewFoo, R.id.textViewTest}, 0); adapter2.setViewBinder(new ViewBinder() { public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (columnIndex == 1) { ImageView imageView = (ImageView) view; String Pic = cursor.getString(1); if (Pic != null) { File file = new File(Pic); if (file.exists()) { imageView.setImageBitmap(MainController.getInstance().generateBitmap(Pic, SessionActivity.this)); } } else { imageView.setImageResource(R.drawable.ic_launcher); } return true; } if (columnIndex == 2) { ... } return false; } }); } </code></pre> <p>the problem is, that the my <code>MainController.getInstance().generateBitmap()</code> which generate a small bitmap takes a lot of time. So it takes some time until the list is loaded.</p> <p><strong>How can I generate the image for the list in the background and show the list instantly and then add the pictures?</strong></p>
android
[4]
725,311
725,312
ABPersonCopyImageData on iOS4
<p>the <code>ABPersonCopyImageData</code> function in iOS4 SDK 4.0->4.02 seems to return uncropped image and leads to terrible performance and crashing due to running out of memory. It used to work fine on OC versions 3.0->3.1.3. I've tried upgrading to 4.02 but still same issues</p> <p>Is there a workaround for this?</p>
iphone
[8]
288,413
288,414
Android: WIfi and 3G connectivity
<p>Is there any way, When Wi-Fi is available i should be able to disable my 3G and 2G both(all operator based data ).</p> <p>I want this to do from my application because</p> <p>1> If both Wi-fi and 3G are available then it results in interminnent connectivity. 2> I may be charged if GPRS or 3G data are used, based on packets transferred.</p> <p>Any guidance</p> <p>Thank you... </p>
android
[4]
155,527
155,528
How to stop android service?
<p>I have created a android service. I start the service and stop the service using startService(intent) and stopService(intent). </p> <p>My problem is that even i stop the service; it starts again without any explicit call to startService.</p> <p>Any help appreciated</p>
android
[4]
1,181,351
1,181,352
Getting Audio source of calls
<p>is there any way to receive audio source of call ( input + outpout ) while talking (calling) ? does android allow us to here the input voice ?</p> <p>or I should hook up android ?</p> <p>thanks</p>
android
[4]
2,341,470
2,341,471
PHP numbers manipulation
<p><code>$ch</code> is a character.</p> <p>I need to convert it into 2 numbers like that (example):</p> <pre><code>$ch = 'A' =&gt; ASCII code: 0x41 =&gt; Binary: 0100 0001 =&gt; {4, 1} </code></pre> <p>What is the easiest and fastest method to achieve this ?</p>
php
[2]
5,987,583
5,987,584
Isn't this code snippet for checking digits supposed to return false?
<p>This is to check only digits in a string.. It's returning true when I expected to return me a false.. How can I fix this and why it's returning me a true?</p> <pre><code> &lt;script type="text/javascript"&gt; function test() var str2 ="s123s"; var reg3 =/\d/; alert(reg3.test(str2)); } &lt;/script&gt; </code></pre>
javascript
[3]
1,592,372
1,592,373
Error while running UDPEcho app on simulator
<p>I am very new to iphone world and just downloaded the app and was trying to understand the application flow. For that I made same changes in the build settings but some internal error is thrown. Through terminal it is working fine.</p> <p>What changes will allow me to run that app on simulator. Thanks in advance.</p>
iphone
[8]
5,131,627
5,131,628
Experian QAS address verification causes state drop-down box to hide
<p>Experian QAS has a package called "Address Verification". When installed, the state drop-down box (you normally enter your state into) will at times disappear. Looking at the DOM with developer tools, there is an inline style sheet of visbility:hidden that is applied.</p> <p>Is there a way OOTB to never hide the state drop-down?</p> <p>Thanks</p>
javascript
[3]
3,833,729
3,833,730
getting function's argument names
<p>in PHP Consider this function:</p> <pre><code>function test($name, $age) {} </code></pre> <p>I need to somehow extract the parameter names (for generating custom documentations automatically) so that I could do something like:</p> <pre><code>get_func_argNames('test'); </code></pre> <p>and it would return Array['name','age'] .</p> <p>Is this even possible in PHP ?</p>
php
[2]
2,676,008
2,676,009
Android users tips api?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/10757093/display-a-help-overlay-over-an-android-layout">Display a “help” overlay over an Android layout</a> </p> </blockquote> <p>is there any api that enable us to create user tips/tutorial to users, similar to the tips that appear in Android 4 when used for the first time </p>
android
[4]
2,213,061
2,213,062
Is there a way to tell when a python file is loaded using PYTHONSTARTUP vs. being run as a script?
<p>All, I recently discovered the PYTHONSTARTUP environment variable, and am looking forward to setting up several of my utility functions to automatically load into my interpreter. However, one thing I'd like to be able to do is use the same script to setup the environment variable itself. </p> <p>My issue is determining when the file is run as a script. My thought was to use the <code>if __name__ == "__main__":</code> trick to determine when the file was run as a script, but testing showed that when the file is loaded via PYTHONSTARTUP the name shows as <code>"__main__"</code>.</p> <p>Does anyone know of a way to identify when a file is run as a script vs. when it is loaded via PYTHONSTARTUP?</p>
python
[7]
758,825
758,826
BitmapFactory.decodeByteArray doesn't keep color information when pixel is fully transparent
<p>I use the BitmapFactory.decodeByteArray to generate a Bitmap from a PNG image. Then I use Bitmap.getPixels to retrive all the pixel data. The problem is that when a pixel is set as fully transparent, all the color data seams to be discarded. 0x0000ff00 is being returned as 0x00000000. If I create an image from code which has transparent pixels I make a copy, render that to a canvas, use Canvas.drawColor(0xff000000, Mode.DST_ATOP) and then get all the correct color values with getPixels and then add that with the alpha values I got from the first getPixels call. I can't do that now since the color information seams to be gone. Is there any way to make sure that the color information is stored when generating a Bitmap from a PNG file using the BitmapFactory?</p>
android
[4]
3,010,138
3,010,139
How to format a list of some classes into a nice ASCII table in C#?
<p>Have a LINQ result, need to format it in plain text nicely to send by email.</p> <p>For example each record contains "ProductName", "SalesAmount", "Taxes" And product names could be strings different length for different records.</p> <p>Need to format a list of such records as plaintext table. Using "----------" as horizontal line and "|" as vertical line.</p> <p>As you don't know the max size of product name you don't know the size of vertical line in characters for it. Suppose need to find the maximum product name length and depending on it calculate amount of "-" characters needed. But is there anything that can auto format?</p> <p>Assuming that font is mono-spaced.</p> <p>What is the best way to do it? </p> <p>Thanks.</p>
c#
[0]
1,600,042
1,600,043
DataKeyNames in databound controls must be a property?
<p>I use a ListView along with an ObjectDataSource tied to a business object. This object is defined as follows:</p> <pre><code>public class Employee { public int Id; public string Name; } </code></pre> <p>When I try setting the DataKeyNames property of the ListView to Id, ASP.net blows up and says:</p> <p><strong>DataBinding: 'Employee' does not contain a property with the name 'Id'.</strong></p> <p>However, when I change the object to that:</p> <pre><code>public class Employee { public int Id {get; set;} public string Name; } </code></pre> <p>It works!!!</p> <p>I couldn't find any documentation about this behavior. Why is it not accepting a simple variable for DataKeyNames and instead it insists on a property?</p>
asp.net
[9]
596,586
596,587
i have got the error for w3af like "/usr/bin/w3af_console: 4: /usr/bin/python2.5: not found" is there any solution for that
<p>I have installed w3af using command "sudo apt-get install w3af" but on firing command "w3af_console" it shows me error as shown under</p> <p>/usr/bin/w3af_console: 4: /usr/bin/python2.5: not found</p> <p>i have already installed python2.5.6 as shown in <a href="http://sourceforge.net/apps/trac/w3af/wiki/HowToInstallPython2.5" rel="nofollow">http://sourceforge.net/apps/trac/w3af/wiki/HowToInstallPython2.5</a> but still getting the same problem</p> <p>Please guide me in positive direction</p>
python
[7]
3,551,211
3,551,212
Java NullPointerException 2D array initialized in constructor, but method refuses to acknowledge
<p>I've run into a strange instance of NullPointerExceptionwhere I run the following code,</p> <pre><code>Graph_img g = new Graph_img(3,4); g.randomGraph(); </code></pre> <p>where the constructor and method are the following,</p> <pre><code>public Graph_img(int width, int height){ super(); w = width; h = height; Node[][] Img = new Node[w][h]; } //generate new MRF graph ~75% 0 bilevel public void randomGraph(){ V = new ArrayList&lt;Node&gt;(0); E = new ArrayList&lt;Edge&gt;(0); for(int x=0; x&lt;w; x++) for(int y=0; y&lt;h; y++){ if(Math.random()&gt;0.75) Img[x][y] = new Node(x*h+y,1,2); //&lt;--- NullPointerException else Img[x][y] = new Node(x*h+y,0,2); //&lt;--- NullPointerException V.add(Img[x][y]); } } </code></pre> <p>But if I run with the initialization moved to the method instead of the constructor,</p> <pre><code>public Graph_img(int width, int height){ super(); w = width; h = height; //Node[][] Img = new Node[w][h]; &lt;-- MOVING THIS } //generate new MRF graph ~75% 0 bilevel public void randomGraph(){ V = new ArrayList&lt;Node&gt;(0); E = new ArrayList&lt;Edge&gt;(0); Node[][] Img = new Node[w][h]; //&lt;-- MOVED HERE for(int x=0; x&lt;w; x++) for(int y=0; y&lt;h; y++){ if(Math.random()&gt;0.75) Img[x][y] = new Node(x*h+y,1,2); else Img[x][y] = new Node(x*h+y,0,2); V.add(Img[x][y]); } } </code></pre> <p>Then everything works. I am perplexed - why? Thanks - Steve</p>
java
[1]
946,256
946,257
Overriding ctrl-= in javascript
<p>I'm building a basic online graphics editor, and I want to override the browser zoom, when the user hits Ctrl-= (that is the ctrl key followed by the = key) I want the canvas to get larger (I'll handle this via an event), but any attempt to capture this key combination causes my event to fire and then the page to resize anyway. How do I avoid the browser continuing to resize my browser?</p> <p>I tried this with other keycodes, ctrl-s does not fire the browser save if I override it for example.</p> <p>I realise this isn't an amazing usability idea generally, but in the given context of a design application I believe it to be ok.</p> <p>Thanks!</p>
javascript
[3]
4,250,782
4,250,783
C# opening each textfile and reading all text issue
<pre><code>{ DirectoryInfo dinfo = new DirectoryInfo(@"C:\Documents and Settings\g\Desktop\123"); FileInfo[] Files = dinfo.GetFiles("*.txt"); foreach (FileInfo filex in Files) { string contents = File.ReadAllText(filex); string sharename = Regex.Match(contents, @"\Share+(\S*)(.)(.*)(.)").Groups[2].Value; } } </code></pre> <p>I just want to be able to open each textfile in this directory, read it all, and then pull the regex i have listed, With this code can someone point out where my brain fart is?</p> <p>The best overloaded method match for 'System.IO.File.FileInfo' to 'string' has some invalid arguments Argument '1' cannot convert frm System.IO.FileInfo to string</p>
c#
[0]
2,140,918
2,140,919
How to add to $.get in JQuery error handling function?
<p>How to add to $.get in JQuery error handling function ? My request looks like</p> <pre><code>$.get('www.test.com', temp_parameters, function(data) { alert('data='+data['result']); },"json"); </code></pre> <p>but there is no function if error happens. Where to add that function ?</p>
jquery
[5]
5,399,404
5,399,405
Changing a GridView item's font weight
<p>I have a gridview that contains one linkbutton within itemtemplate. I bind this gridview with a table from my database that displays different items. When the gridview displays records and when the user clicks on an item of gridview then how can i change that item's fontweight to bold and change that same item's color.</p>
asp.net
[9]
762,353
762,354
PHP - Am I allowed to put single quoted, double quoted heredoc syntax or nowdoc syntax strings directly into a functions parameter that uses a string?
<p>Am I allowed to put single quoted, double quoted heredoc syntax or nowdoc syntax strings directly into functions whose parameters require a string like for example <code>strlen('string text')</code> or <code>strlen("some more string text")</code> instead of including a variable for example <code>strlen($str);</code>?</p> <p>If not why?</p>
php
[2]
637,394
637,395
'Google Docs like ' functionality in python
<p>What I have is a UI which allows users to enter info about, say toys.<br> Now the UI is accessible to multiple users at the same time and the info stored by the user gets stored in a file, which may cause accidental overwriting of toy info.<br> The file will contain info of multiple toys but same toy info can not show up again which is quite possible in multi user environment.<br> I am fairly new to web dev. and python too.<br> What should be my first steps to resolve this problem?<br></p> <p>Any help is highly appreciated.<br> Thanks</p>
python
[7]
2,054,789
2,054,790
how to send email from php mail function using gmail account?
<p>I have to send email from my gmail account using php mail() function. I have read the phpmailer but I don't want to include any external apis. Please suggest.</p> <p>Thanks in advance.</p>
php
[2]
4,924,792
4,924,793
Counting values in an array w/ PHP
<p>I need to perform a a task when there are some values in my array. So I used <strong>count</strong></p> <pre><code>count($_SESSION['arrayValues'][$_SESSION['event']]); </code></pre> <p>And my code acts as if there's something in the array, however when I do print_r I get the following:</p> <pre><code>Array ( [0] =&gt; ) </code></pre> <p>So I suppose I need to count values. Tried using <strong>array_count_values</strong> but it does not seem to work for me... I'm a bit confused now.</p>
php
[2]
4,526,003
4,526,004
getting current date with PHP
<p>I am trying to create a variable that gets the current date and time so I can compare it to a deadline (ex: 7/30/12 23:23:10). I put this code in a file called date.php and it is supposed to return a 10 digit number, but instead I get a server error. Can anyone help me create a variable that gets the current time in php?</p> <pre><code>&lt;?php $date = date_create(); echo date_timestamp_get($date); ?&gt; </code></pre>
php
[2]
5,297,152
5,297,153
Is there any jQuery plugin which display an horizontal accordion showing half images?
<p>Basically I need one like this:</p> <p><a href="http://yogafasting.org/" rel="nofollow">http://yogafasting.org/</a></p> <p>First, it displays a partial image and then when you hover it, it shows the full image.</p>
jquery
[5]
1,239,249
1,239,250
Silly, can't figure out php round down :(
<p>I have small problem and it might be silly somewhere, but still i have it :)</p> <p>So the problem is:</p> <p>By doing this </p> <pre><code>round(615.36*0.10, 2, PHP_ROUND_HALF_DOWN); </code></pre> <p>I expect outcome to be <code>61.53</code>, but it's <code>61.54</code>.</p> <pre><code>phpVersion = 5.3.2 </code></pre> <p>Could anyone help me to solve this? Thanks.</p>
php
[2]
2,256,780
2,256,781
How can i get the property in the sequence they have in file
<p>I am using file properties file and loop through that file.</p> <pre><code>Properties Config= new Properties(); Config.load(new FileInputStream("c:\\Config.properties")); Enumeration e = Config.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " -- " + Config.getProperty(key)); } </code></pre> <p>My Input in C:\Config.properties is </p> <p><strong>Input</strong></p> <p>fun1= abc</p> <p>fun2=pqr</p> <p>fun3 mno</p> <p><strong>Output</strong></p> <p>fun2 -- pqr</p> <p>fun1 -- abc</p> <p>fun3 -- mno</p> <p>How can i get this what exactly in the Config file.</p>
java
[1]
5,999,729
5,999,730
Using Helper Classes in PowerMock
<p>I am unit testing some code using PowerMock and Mockito. </p> <p>There are several types of patterns that come up during unit testing of all classes in the project I am working on.</p> <p>What I would like to do is create a shared Helper class to avoid code duplication. The issue is that when I move the code to the Helper and attempt to call it from my test class, PowerMock's functionality doesn't carry to the Helper and I simply get Mockito errors (cannot mock final classes).</p> <p>I tried putting the @PrepareForTest attribute at the head of the Helper class and methods but with no luck. Is there any way to make this work (aside from inheriting from the Helper)?</p>
java
[1]
5,946,169
5,946,170
Is it possible to get variable name of a reference type
<p>Is it possible to get the name of a variable that points to a reference? Take the example below:</p> <pre><code>private void FillArray(int[] array, int count) { array = new int[count]; for (int i = 0; i &lt; array.Length; i++) { array[i] = i; } Debug.WriteLine("Array {0} is now filled up with {1} values", array.Name, count); } </code></pre> <p>There is no property <code>Name</code> for the array that is going to be used in the above method. I know that a workaround would be adding another parameter as string and assign the name to it, but how to do this programitically? Also I know I can make my own implementation, but I am interested to know the answer to this particular question!</p>
c#
[0]
458,958
458,959
Wait for two events with jQuery and execute a callback when both are done
<p>So I have a .click() event on an element. After it's closed, this mob has a transition that happens and an AJAX call that goes through. That's all that happens.</p> <p>What I need is a callback to put inside the <code>.click()</code> function to execute when both of those things are done, even if transitions aren't supported. Here's a timeline:</p> <p>jQueyr needs to wait for the ajax call and the transition, then execute the callback after the ajax call has completed AND the transition has either finished or not happened at all.</p> <p>How can I do this? Thanks!</p> <p><em>NOTE: I'm using <code>$.ajax()</code> for the ajax call and a normal CSS3 transition on the element in question. I can detect transitionEnd with javascript event binding, I have a variable setup for that called transitionEnd and another variable that detects if the browser support transitions call supportsTrans.</em></p>
jquery
[5]
1,760,137
1,760,138
Append text into TextArea
<p>I want to append text inside Textarea. The text should be appended immediate after the cursor position and not at the end. </p> <p>Here is my code:</p> <p>The HTML:</p> <pre><code>&lt;html&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;/head&gt; &lt;body&gt; &lt;textarea id="textarea1"&gt;&lt;/textarea&gt; &lt;br&gt;&lt;input type="button" value="Write blah blah" onclick="addtxt('textarea1')"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The Script:</p> <pre><code>&lt;script&gt; function addtxt(input) { var obj=document.getElementById(input); obj.value+="blah test 123" } &lt;/script&gt; </code></pre> <p>The above code is live at: <a href="http://jsfiddle.net/zGrkF/" rel="nofollow">http://jsfiddle.net/zGrkF/</a></p> <p>Thanks in advance..</p>
javascript
[3]
4,232,311
4,232,312
Javascript Reg ex to match a text
<p>How do i check if a particular text exists in a word on its own or a part of a word? I understand the code below but it work separately.Im looking for a single expression that will also return TRUE for tested,retest but False for test0123,123test. Any help much appreciated</p> <pre><code>var string_1 = "test"; var string_2 = "retests"; /\btest\b/g.test(string_1);//TRUE /\Btest\B/g.test(string_2);//TRUE </code></pre>
javascript
[3]
5,409,576
5,409,577
The use of String.matches() in Java
<p>Let's see the following expressions about <code>String.matches()</code> in Java.</p> <pre><code>System.out.println("55CCEE".matches("[0-9A-Za-z]{6}")); //true System.out.println("CC77HH".matches("[0-9A-Za-z]{6}")); //true System.out.println("CC1156".matches("[0-9A-Za-z]{6}")); //true System.out.println("С".matches("[0-9A-Za-z]{1}")); //false System.out.println("СС".matches("[0-9A-Za-z]{2}")); //false System.out.println("СС5588".matches("[0-9A-Za-z]{6}")); //false System.out.println("СС5589".matches("[0-9A-Za-z]{6}")); //false </code></pre> <p>The first three cases look fine and work as expected. The rest of the cases, however seem to be failing and return <code>false</code> which wasn't expected. Why does this happen?</p>
java
[1]
5,974,864
5,974,865
HtmlButton handler fires twice when clicked (when AutoEventWireup="True")
<p>I have an html button, see below. When it's clicked and AutoEventWireup="true", the Save_Click click handler is fired twice. When AutoEventWireup="False", it fires once. </p> <p>Why is it firing twice? The button is not registered twice and no code which is adding the event handler. Using master page and no Ajax.</p> <pre><code>&lt;button id="Save" accesskey="v" type="submit" runat="server" onserverclick="Save_Click"&gt;&lt;/button&gt; </code></pre>
asp.net
[9]
3,776,165
3,776,166
How do I make a python script wait for sometime?
<p>I'm relatively new to python and I have written a single python script which does the following:</p> <ol> <li>It does some operation and writes the details to a text file(say a.txt)<br/></li> <li>Once the txt file(a.file) is written, the same file is read to do some operations.</li> </ol> <p>The problem I face is once the file(a.txt) is written and same is read, the contents are not read.</p> <p>I use <code>time.sleep()</code> after the txt file(a.txt) is written and then proceeded with reading the same.</p> <p>But whats happening is the script is stopping it's execution for the time period mentioned in the sleep method and the txt file is not read.</p> <p>I need a scenario where the same script must write to a text file and read instantly.</p> <p>Could someone help me please? Thanks in advance.</p>
python
[7]
4,822,951
4,822,952
Jquery adding steps like on instructables.com
<p>If you go to <a href="http://www.instructables.com/" rel="nofollow">http://www.instructables.com/</a> then click on Create->Step by step and as you click "Add step" it adds another step on top of the page and loads that new form. I would like to duplicate that functionality... Can someone point me to the correct direction?</p>
jquery
[5]
5,175,323
5,175,324
How to delete multiple entries from a List without going out of range?
<p>I have a list of integers that contains a number of values (say, 200).</p> <pre><code>List&lt;int&gt; ExampleList; </code></pre> <p>And another list on integers that holds the indexes that need to be deleted from ExampleList. However, this list is not sorted.</p> <pre><code>List&lt;int&gt; RemoveFromExampleList; </code></pre> <p>If it were sorted, I would have run a reverse loop and deleted all the values like this:</p> <pre><code>for (int i = (RemoveFromExampleList.Count-1); i &gt;=0; i--) { ExampleList.RemoveAt(RemoveFromExampleList[i]); } </code></pre> <p>Do I have to sort RemoveFromExampleList, or is there another way to prune the unnecessary values from ExampleList?</p> <p>If I do have to sort, whats the easiest way to sort? Is there any inbuilt C# library/method to sort? </p>
c#
[0]
3,489,463
3,489,464
Observing change in value of member variable
<p>I want to get notification on modification of some class member-variable(may be primitive or user-defined).</p> <p>Can anyone let me know how to achieve this.</p> <p>Thanks</p> <p>Little more clarification to my question:</p> <p>I have scenario something like</p> <p>I have existing menu and menu-items. Now I am putting all these menu-items on toolbar. Since when these menu-items was inside menu-item I get event ON_UPDATE_COMMAND_UI where I call a function and update menu-items states.</p> <p>But now for toolbar I have to put function for checking state every time, variables(which are many in number and also gets modified at many state, for which I have no control).</p> <p>Can anyone suggest me some good alternative, without changing the existing code, since it's very fragile.</p> <p>Is there any way we get some variable change notification from language/compiler, such as the way the Watch variable works in visual studio debugger.</p>
c++
[6]
5,414,319
5,414,320
Queue api calls in iphone sdk
<p>Is there any way to make more than two api calls one by one only after the result of the called one.And all the three api calls have same result fetch method.</p>
iphone
[8]
2,025,190
2,025,191
Module API mismatch between PHP and SSH2 module
<p>I'm trying to install the ssh2 extension for PHP, and after hours of working on it, I've near figured it out. I think.</p> <p>It's compiled and the ssh2.so is in the correct directory and all. The problem, I believe, is version mismatches.</p> <p>Here's the error it's spouting for me:</p> <pre><code>PHP Warning: PHP Startup: ssh2: Unable to initialize module Module compiled with module API=20050922, debug=0, thread-safety=0 PHP compiled with module API=20060613, debug=0, thread-safety=0 These options need to match in Unknown on line 0 </code></pre> <p>I'm pretty much at a dead end. How can I get the correct ssh2 module API?</p>
php
[2]
4,819,253
4,819,254
Starting an exe on the server
<p>I want to execute an exe on the server running a PHP/ASP Web server. Can i write any php/asp file for the same that will initiate the exe on the web server. Do I need to give explicit permissions or permissions are given by default.. or is there any security hole?</p>
php
[2]
1,613,649
1,613,650
Reading data file with varying number of columns python
<p>I have a data-file the first 8 lines of which look like this. (after substituting actual values by letters for clarity of this question)</p> <pre><code> a,b,c d e,f g,h i,j,k l m,n o,p </code></pre> <p>These represent data about transformers in an electric network. The first 4 lines are information about transformer 1, the next four about transformer 2 and so on.</p> <p>The variables a-p can are either integers, floating-point numbers or strings</p> <p>I need to write a script in python so that that instead of data for one transformer being spread onto 4 lines, it should all be on one line. </p> <p>More precisely, I would like the above 2 lines to be converted into </p> <pre><code> a,b,c,d,e,f,g,h i,j,k,l,m,n,o,p </code></pre> <p>and write this to another data-file.<br> How do I do this?</p>
python
[7]
1,566,548
1,566,549
Why was the equals() method in java.util.Comparator made abstract?
<p>Why was the <code>equals()</code> method in <code>java.util.Comparator</code> made abstract, if it is already implemented in the <code>Object</code> class?</p>
java
[1]
4,440,266
4,440,267
statement requires expression of scalar type ('void' invalid)
<p>I am getting warning message in red <code>statement requires expression of scalar type ('void' invalid)</code> at the if statement.</p> <pre><code> - (void)displayviewsAction:(id)sender { FirstViewController *viewController = [[FirstViewController alloc] init]; viewController.view.frame = CGRectMake(0, 0, 320, 480); [self.view addSubview:viewController.view]; [self.view addSubview:toolbar]; if ([audioPlayer pause]){ [timer invalidate]; } else { self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(secondViewController) userInfo:nil repeats:NO]; } [viewController release]; } </code></pre> <p>Any idea how to fix it.</p> <p>Thanks for help.</p>
iphone
[8]
5,388,390
5,388,391
c# string split question
<p>i am splitting a string like this:</p> <pre><code>string[] elements = templine.Split (space, StringSplitOptions.RemoveEmptyEntries); </code></pre> <p>however, i need to get every element from <code>templine</code> except for <code>[1]</code> and assign it to <code>string[] elements</code></p> <p>how do i do this?</p>
c#
[0]
5,376,465
5,376,466
spliting an exml file into smaller files
<p>the xml file contains information about movies. how do i split the xml file into smaller files? ( so each small file is a separate movie)</p>
python
[7]
2,261,149
2,261,150
How to get contact name from number using like in selection in android
<p>Here is the code which iam using </p> <pre><code> private String getContactNameFromNumber(String number) { // define the columns I want the query to return String[] projection = new String[] { Contacts.Phones.DISPLAY_NAME, Contacts.Phones.NUMBER }; // encode the phone number and build the filter URI Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number)); // query time Cursor c = getContentResolver().query(contactUri, projection, null, null, null); // if the query returns 1 or more results // return the first result if (c.moveToFirst()) { String name = c.getString(c .getColumnIndex(Contacts.Phones.DISPLAY_NAME)); return name; } // return the original number if no match was found return number; } </code></pre> <p>but this code returns only number exactly equal to contact number. i want to use like statement so that even last 7 numbers matches i should be able to get the name.. how to write that..?</p>
android
[4]
5,641,426
5,641,427
Access a window by window name
<p>If I open a window using </p> <pre><code>window.open('myurl.html', 'windowname', 'width=100,height=100'); </code></pre> <p>How do I refer to the new window (from the same page that opened it) using 'windowname'? This question is specifically about this. I'm aware that I could save a reference to the handle by using "var mywin = window.open(...)" but I don't care about that in this situation.</p> <p>Thanks, - Dave</p>
javascript
[3]
1,102,515
1,102,516
how to share cookies value from one server into another server in asp.net?
<p>so please can any one tell me, how it is possible to pass Cookies value from 1 server into other server?</p> <p>it is possible???give me some more information about it.</p> <p>thanks lot... </p>
asp.net
[9]
5,109,361
5,109,362
Downloading an XML file as string in C# keeps getting me gibberish
<p>So in my C# application I am downloading an XML file as a string, then doing something with it. Some files are downloaded correctly, but for some files I get gibberish. The weird thing is that when I open those files with my browser (Firefox) I get the data as I should, and not the gibberish.</p> <p>This is my code to download the data:</p> <pre><code>public static string Read(string Address) { return new WebClient().DownloadString(Address); } </code></pre> <p>And this is an example of a file I get gibberish when downloading: <a href="http://thetvdb.com/api/C40F55BF6975A295/series/80379/default/5/16/en.xml" rel="nofollow">http://thetvdb.com/api/C40F55BF6975A295/series/80379/default/5/16/en.xml</a></p> <p>So how can I get the data for these files?</p>
c#
[0]