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
3,884,669
3,884,670
How to show the content of object on IE9
<pre><code>var obj = {'test1':"value1", "test2": "value2" } console.log(obj); </code></pre> <p><strong>reuslt</strong></p> <pre><code>[object, Object] </code></pre> <p>Is is possible to show the content the object not to use JSON.stringify on IE9?<br> like the following<br></p> <pre><code>{'test1':"value1", "test2": "value2" } </code></pre>
javascript
[3]
5,286,437
5,286,438
Automatic/dynamic margin in Android layout
<p>I was wondering if it's possible to set an automatic/dynamic margin (padding?) between elements in an Android layout without having to do it programmatically?</p> <p>For example let's say there is a horizontal LinearLayout which is set to <code>android:layout_width="fill_parent"</code> and that contains five elements. Is there a setting that evenly shares the remaining empty space of the LinearLayout to the margins of the child elements?</p> <p>See image at <a href="http://img63.imageshack.us/img63/8/margin.png" rel="nofollow">http://img63.imageshack.us/img63/8/margin.png</a></p> <p>Thanks for any help!</p>
android
[4]
3,949,905
3,949,906
Recursive Loop to find nested children
<p>Assume I have a Relationship like this table</p> <pre><code>A is a root node . B is a Child of A, C is a Child of A, D is a child of B, E is a child of C, F is a Child of E, G is a Root Node, H is a child of G, </code></pre> <p>and it goes on with nested relations like above</p> <p>I want to put Parent node which is A in a list which all its children and grandchildren like <code>List.Add(Child_of_A)</code></p> <p>How to achieve this? using c#</p>
c#
[0]
4,015,741
4,015,742
How to replace String characters in C#
<p>I would like to replace specific String characters based on some integers value passed dynamically to its index. </p> <p>Unfortunately, String.Replace() expects String value as its arguments. So could anyone please tell me how can I make my requirement possible? </p>
c#
[0]
4,897,359
4,897,360
Is there a way to have a list of all the currencies from the iphone api?
<p>I wanted to allow the user to choose a currency from a list of currencies. Do i have to hardcode all the currencies in the code or can i get it from the api, somehow.</p>
iphone
[8]
3,245,019
3,245,020
NSZombie Enabled, MallocStackLogging
<p>I am testing an EXE_BAD_ACCESS error. I have set NSZombieEnabled, MallocStackLogging, MallocStackLoggingNoCompact to YES. now in the debugger I get this message when I run my app in the debug mode from the device I could see this:</p> <pre><code>iota(3586) malloc: recording malloc stacks to disk using standard recorder iota(3586) malloc: stack logs being written into /private/var/mobile/Applications/8E21A85B-369E-4487-962B-1550E56602DC/tmp/stack-logs.3586.iota.index iota(3586) malloc: Please issue: cp /private/var/mobile/Applications/8E21A85B-369E-4487-962B-1550E56602DC/tmp/stack-logs.3586.iota.suRQjy.link /tmp/ </code></pre> <p>and when I am about to hit the error I get,</p> <pre><code>2011-02-14 14:29:44.350 iota[3586:307] *** -[CFString autorelease]: message sent to deallocated instance 0x81eab70 </code></pre> <p>Finally when I give the command in debugger to see the stack trace</p> <p>(gdb) shell malloc_history 3586 0x81eab70</p> <p>I get</p> <pre><code>malloc_history cannot examine process 3586 because the process does not exist. </code></pre> <p>Can anyone tell me what I am doing wrong, before the error is about the occur , I set </p> <pre><code>set env MallocStackLogging 1 in the debugger too </code></pre> <p>Thanks in Advance</p>
iphone
[8]
4,840,498
4,840,499
algorithm to name files with no probability of repetition
<p>Can someone suggest a complex algorithm in php to name files that would be uploaded so that it never repeats? i wonder how youtube which has millions of videos does it??</p> <p>Right now i use an random number and get its 16 character sha1 hash and name the file with that name but i'm pretty sure it will eventually repeat and generate an error as file will not be able to save in the file system.</p> <p>something like:</p> <pre><code>$name = sha1(substr(sha1(md5($randomnumber)),0,10)); </code></pre> <p>somebody once told me that its impossible to break the hash generated by this code or at least it'll take 100 years to break it.</p>
php
[2]
1,187,771
1,187,772
Jquery - Select td value for all the tr with a class
<p>I have a table</p> <pre><code>&lt;table&gt; &lt;tr class="PO1"&gt;&lt;/tr&gt; &lt;tr class="PO2"&gt;&lt;/tr&gt; &lt;tr class="PO3"&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p>How can i loop through all tr with class <code>"PO1"</code> and get the value of each <code>'td'</code> value?</p> <pre><code>$("table#id tr .PO1").each(funtion(i) { // how to get the td values?? }); </code></pre> <p>Thanks</p>
jquery
[5]
1,778,025
1,778,026
Displaying a video in C# with Visual Studio 2010
<p>Before I start, I'm using Visual Studio C# Ultimate 2010</p> <p>I made a small WPF program which only displays a video when I click on a button. When I click on my play button, the video is not displayed but on a friend's computer, it does. With exactly the same code. So I think it's a version problem, but I'm not sure. I've checked the version of Visual Studio but we have the same.</p> <p>Do you have an idea of solution?</p> <p>Best regards, Kevin</p>
c#
[0]
259,154
259,155
What means that kind of declaration in c++?
<p>What does this kind of declaration mean in c++?</p> <pre><code>CSomething &amp; SOMETHING = m_vSOMETHING[m_iSOMETHING]; </code></pre>
c++
[6]
4,486,899
4,486,900
Python code, self not defined
<pre><code>class makeCode: def __init__(self,code): self.codeSegment = code.upper() if checkSegment(self.codeSegment): quit() self.info=checkXNA(self.codeSegment) def echo(self,start=0,stop=len(self.codeSegment),search=None): #--&gt; self not defined pass </code></pre> <p>Not working... </p> <ul> <li>it says that the variable <strong>self</strong> is not defined when it actually was; </li> <li>the function <code>checkSegment</code> returns 1 if the input was not a string made of nucleotids letter, or if that contains nucleotids that can't be together;</li> <li>it quits if that happens, that's ok it works perfectly; </li> <li>then it assigns the information (if it's RNA or DNA) checking with the function <code>checkXNA</code> that returns a string with the information "dnaSegment" or "rnaSegment"; works perfectly. </li> </ul> <p>But then the function <code>echo</code> which will be designed for printing more specific information tells me that self is not defined, but why? </p>
python
[7]
4,989,126
4,989,127
windows application open console and write in it
<p>How can i open console in C# graphical windows application and then write some data in console. Can i even open a console from win app?</p>
c#
[0]
2,308,914
2,308,915
Are there any strategies (or libraries) for performant varints and varlongs in Java?
<p>Currently, I am serializing some long data using <code>DataOutput.writeLong(long)</code>. The issue with this is obvious: there are many many cases where the longs will be quite small. I was wondering what the most performant varint implementation is? I've seen the strategy from protocol buffers, and testing on Random long data (which probably isn't the right distribution to test against), I'm seeing a pretty big performance drop (about 3-4x slower). Is this to be expected? Are there any good strategies for serializing longs as quickly as possible while still saving space?</p> <p>Thanks for your help!</p>
java
[1]
5,359,535
5,359,536
global variable in app with service: use Application or SharedPreferences class?
<p>My App uses one service in the background. To share data between the UI and Service I'm currently using IPC... but I wonder if it's possible to use the Application class or the SharedPreferences class to easily share global variables between the service and the Activities.</p> <p>I found example code on how to use the Application class to create global variables: <a href="http://www.helloandroid.com/tutorials/maintaining-global-application-state" rel="nofollow">http://www.helloandroid.com/tutorials/maintaining-global-application-state</a></p> <p>Here I found an example to use SharedPreferences: <a href="http://marakana.com/forums/android/examples/63.html" rel="nofollow">http://marakana.com/forums/android/examples/63.html</a></p> <p>which one is better for sharing data between an activity and service ?</p>
android
[4]
2,762,782
2,762,783
Error while fetching the array
<p>I have the following code which is generating error while fetching the elements of the array </p> <pre><code> $task = new task(); $task-&gt;connect(); $services = $task-&gt;viewTask_front_android($_GET['pno']); print_r($services); while($info = mysqli_fetch_assoc($services)) { Print "&lt;b&gt;Name:&lt;/b&gt; ".$info['starttime'] . " "; } ?&gt; </code></pre> <p>from the print_r(services) iam getting </p> <pre><code>Array ( [task_id] =&gt; 14 [user_id] =&gt; 123 [employee_id] =&gt; 456 [service_id] =&gt; 2 [starttime] =&gt; 2:00 AM [endtime] =&gt; 4:00 AM [servicename] =&gt; se a [servicedescription] =&gt; ddsdsd [employeename] =&gt; dsd [employeepicture] =&gt; pictures/noimage.gif [pic_path] =&gt; pictures/noimage.gif ) </code></pre> <p>is there any problem with while($info = mysqli_fetch_assoc($services)) it is generating error <code>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\proj\android\services.php on line 70</code></p>
php
[2]
1,409,875
1,409,876
How do I test against app variables such as if ${EXECUTABLE_NAME}
<p>I want to do a conditional statement in my prototype such as:</p> <pre><code>if (${EXECUTABLE_NAME} == "MyAppName") </code></pre> <p>as I am using multiple targets for the custom skins of the app.</p> <p>Thanks</p>
iphone
[8]
3,614,834
3,614,835
python data type comparisons
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3270680/how-does-python-compare-string-and-int">How does Python compare string and int?</a> </p> </blockquote> <p>Can any one explain the below.how is the 'a' compared to 1 Internally is a and 1 ASCII val is compared or how is it i.e, there is some conversion happening with 'a' and then compared or how is this.Please explain</p> <pre><code>&gt;&gt;&gt; 'a' &gt; 1 True &gt;&gt;&gt; 'a' &gt; 'b' False </code></pre>
python
[7]
1,628,134
1,628,135
how to set windowonfocuschange() event in android
<p>i have an image view whose image should keep on changing every 5 seconds when the window in which it is drawn has focus. when the window loses focus then the thread that was changing the image should close.</p> <p>for the above to happen i need to implement the onwindowfocuschange(boolean haswindowfocus) method, but i don't know how to implement the same</p> <p>thank you in advance.</p>
android
[4]
887,600
887,601
Apply jQuery plugin in title is present
<p>I have a jQuery pluging that I currently apply to a particular class</p> <pre><code>$(".myClass").myPlugin({ ... }); </code></pre> <p>Currently it will apply it to any <code>&lt;th&gt;</code> in my table that has the class <strong>.myClass</strong></p> <p>How can I re-write the code to call that plugin if the class is present <strong>and</strong> <code>&lt;th&gt;</code> has the <strong>title</strong> attribute?</p>
jquery
[5]
14,360
14,361
Events in C++
<p>I'm not sure how to look for this online... I think they might be called something different in C++</p> <p>I want to have a simple event system, somthing like</p> <pre><code>event myCustomEvent; myCustomEvent.subscribe( void myHandler(string) ); myCustomEvent.fire("a custom argument"); // myHandler prints out the string passed in the first argument event myNewCustomEvent; myNewCustomEvent.subscribe( void myNewHandler(int) ); myNewCustomEvent.fire(10); // myHandler prints 10 </code></pre> <p>I can do this pretty easily with a simple class -- but when i want to have an event that passes a different type or amount of arguments to the subscriber i have to write, and define an entirely new event class.. I figure there has to be some library, or maybe even something native in Visual C++ 2008 that will work something similar to this. It's basicly just an implementation of the Observer pattern, so it can't be too impossible to do in C++</p> <p>This really makes me appreciate how nice it is in JavaScript not to have to worry about the arguments you are passing.</p> <p>Tell me if this is a stupid question.</p>
c++
[6]
2,503,304
2,503,305
split vs. explode in php
<p>What is the different between explode and split?</p>
php
[2]
3,365,290
3,365,291
iPhone:How to create thread running in the background always?
<p>I want to initiate a separate thread apart from main thread and do some operations continuously even when my app is closed. I tried <code>detachNewThreadSelector</code>, but it doesn't work continuously and that too it needs my app to be launched. </p> <p>And whenever I don't need it, I want to stop the thread as well. It is possible in Android, don't know how to do in iOS. How can I achieve it, could someone guide me on this? I am developing on iOS 4.3 SDK.</p>
iphone
[8]
2,342,900
2,342,901
Compile aspx page "on the fly"
<p>I am trying to build an aspx page at runtime (by another aspx page which finally redirects to the new one). As far as I understand, aspx pages MUST be precompiled before a user can view them. In other words, the aspx page must be compiled to the DLL in the /bin folder.</p> <p>Is there a away to tell IIS, or to order it by VB.NET code, to compile a page before I am redirecting my user to the page?</p> <p>Any help would be greatly appriciated.</p>
asp.net
[9]
4,849,229
4,849,230
Javascript showcase website
<p>I would like to present some Javascript examples in a Wordpress blog. Since Wordpress doesn't allow me to embed Javascript in blog posts, I am restricted to only present the code. Is there a website where I can showcase some Javascript examples so that at least I can link to an external html file that contains my javascript code?</p>
javascript
[3]
1,126,587
1,126,588
display images dynamically from folder using php
<p>i am new to php i am working on image upload to folder and displaying it from the same folder and added checkbox to each diasplayed image.. but my problem is images are displaying one below the other but i want to diasply each image and the corresponding checkbox in sperate column can any one pls help me out in this thanks in advance.. here is my code.</p> <pre><code>&lt;?php $path = "small"; $dir_handle = @opendir($path) or die("Unable to open folder"); while (false !== ($file = readdir($dir_handle))) { if($file != '.' &amp;&amp; $file != '..' &amp;&amp; $file != 'Thumbs.db') { echo "&lt;input type=CHECKBOX name=$file&gt;"; echo "&lt;img src='small/$file' alt='$file'&gt;&lt;br /&gt;"; } } closedir($dir_handle); ?&gt; </code></pre>
php
[2]
798,127
798,128
Can foreground threads be aborted on application shutdown in C#.Net?
<p>I inherited a c# winforms app (.NET 2.0) which creates a thread upon startup in a singleton class. This thread handles messages from a messaging topic (Tibco EMS).</p> <p>When the app is shutdown, the thread doesn't remain the the background? How is this possible? Is there something else happening that can abort this thread?</p> <p>Code snippet: </p> <pre><code>public class Startup { public static void main(string [] args) { MySingletonClass.Instance.Init(); // do other things below Application.Run(new MainForm()); } public class MySingletonClass { // singleton code //.. //.. private Thread t; public void Init() { t = new Thread(new ThreadStart(poll)); t.Start(); } private void poll() { while(true} { // listen for messages and process but there is no break clause // exceptions are also handled within to ensure control doesnt go out } } </code></pre> <p>Pls. don't write to tell me this is bad code. I know it and i was going to refactor it when i realised that the app actually shutdowns correctly inspite of this aberration. So i want to understand how this is possible.</p> <p>Thanks for your help</p>
c#
[0]
1,278,924
1,278,925
How to get one individual digit from a number that has more than one digit in it
<p>So I have a four digit number that is player-input in a simple puzzle I am making, I want to be able to check each digit, say I want to check the second digit to the right, if the number happens to be 4601 then of course it will be 6 but is their a faster way other than testing every single four digit number? I found a few results with search but they didn't help, they just confused me more, please phrase any answers so anyone can understand them. Also i am using c++. </p>
c++
[6]
4,255,058
4,255,059
How to implement .scrollTo plugin with a dropdown list
<p>How to implement <code>.scrollTo</code> plugin in a dropdown list? When I choose one option from a dropdown list, it gets the value and shows specific div but how to make this div scroll up instantly after the user chooses the option? I used this plugin already with links a href and this is easy but I have no idea how to implement it with dropdowns. Here is the html:</p> <pre><code>&lt;select id="miasto"&gt; &lt;option value="v1"&gt;opt1&lt;/option&gt; &lt;option value="v2"&gt;opt1&lt;/option&gt; &lt;option value="v3"&gt;opt1&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Divs to be be displayed after selecting an option:</p> <pre><code>&lt;div id="v1" class="schowaj" style="display:none"&gt;div1 content&lt;/div&gt; &lt;div id="v2" class="schowaj" style="display:none"&gt;div2 content&lt;/div&gt; &lt;div id="v3" class="schowaj" style="display:none"&gt;div3 content&lt;/div&gt; </code></pre> <p>jQuery:</p> <pre><code>$(function(){ $('#miasto').change(function(){ var divToShow = $('#'+$(this).val()); $('.schowaj').not(divToShow).hide('slow'); divToShow.show('slow'); }); }); </code></pre>
jquery
[5]
1,128,664
1,128,665
Jquery property disable
<p>Is there any property in jquery to help me check if a txtbox is disabled? and it lets me compare through an if statement?</p> <p>for example:</p> <pre><code> if ($('#ctl00_ContentPlaceHolder1_TextBox3'). == "false") { } </code></pre>
jquery
[5]
5,619,864
5,619,865
Is there an automated way to catch property self-assignment?
<p>Consider the following code:</p> <pre><code>class C { public int A { get; set; } public int B; public C(int a, int b) { this.A = A; // Oops, bug! Should be `this.A = a`. No warning this.B = B; // Oops, bug! Should be `this.B = b`. `warning CS1717: Assignment made to same variable; did you mean to assign something else?` } } </code></pre> <p><code>A</code> and <code>B</code> are almost exactly the same thing, but one has a bug I will miss.</p> <p>Is there a way I can get catch the first case at compile time?</p> <p><strong>EDIT:</strong> Some of the answers &amp; comments want to explain to me that properties and fields aren't the same thing. I know that already. They explain why the compiler doesn't have a warning here; I get that. But I wrote a bug, and I don't like writing bugs. So my question is "<strong>How can I make sure I never, ever write this bug ever again?</strong>"</p>
c#
[0]
4,827,600
4,827,601
How to remove entry from an object
<p>How do I remove an entry, such as [2] from below?</p> <pre><code>var object = {}; object[0] = true; object[1] = true; object[2] = true; </code></pre>
javascript
[3]
1,845,297
1,845,298
generator comprehension
<p>May i just a quick question.what does generator comprehension do?And how does it work?i couldnt find a tutorial about it. Thanks in advance</p>
python
[7]
3,583,510
3,583,511
Error with return in Java?
<p>I get an error in the code from this part of my code:</p> <pre><code>public boolean findCustomer(String inPersonalNumber){ // check if personal number already exist for (int i=0; i&lt;customerList.size();i++) { if(customerList.get(i).getCustomerPersonalNumber().equals(inPersonalNumber)){ return true; } } return true; } </code></pre> <p>When I remove the first return true and instead to the last return true, it don't get the error in my eclipse code, but why can't I have the first place and would this be the same? Thanks!</p> <p>EDIT: The error message from eclipse say: This method must return a result of type boolean. I'm confused because isn't that what I have done?!</p> <p>Yes, a break must be in the code</p> <p>Can I write the method in some other way?</p> <p>EDIT NUMBER 2<br> Why isn't this code working?</p> <pre><code>public boolean findCustomer(String inPersonalNumber){ // check if personal number already exist for (int i=0; i&lt;customerList.size();i++) { if(customerList.get(i).getCustomerPersonalNumber().equals(inPersonalNumber)){ return true; } else { return false; } } } </code></pre> <p>This method returns a boolean value so I don't understand why I get an error!? The code looks right to me?</p>
java
[1]
2,073,621
2,073,622
conversion of string representing HH:MM:SS.sss format into HH:MM:SS.ssssss format in python
<p>I have string which is representing time in HH:MM:SS.sss format ,Now i have to convert this sting into HH:MM:SS.ssssss format.Please let me know how to do this?</p>
python
[7]
3,808,302
3,808,303
Game engines for IPhone game development
<p>I am totally new to IPhone game development enviornment. Kindly suggest me with some common game engines used for developing games on IPhone. </p> <p>Jimmy</p>
iphone
[8]
509,654
509,655
Combining Form fields in $header CC:
<p>Can anyone tell me on how to combine multiple form fields (which contain email addresses) and incorporate them into a $header CC: ?</p> <p>I currently have this:</p> <pre><code>$headers .= 'CC: &lt;'.$_POST['submitted_by'] ."&gt; \r\nReply-To:&lt;".$_POST['submitted_by']."&gt;"; </code></pre> <p>which works fine but I now need to add another field "sales" to the Cc: and everything I try does not work.</p>
php
[2]
905,362
905,363
Set Image Path from outside drive from our application's root directory
<p>I am using ASP image control for image display or HTML image control for that, I want to set the image URL of image that is outside of our web application's root directory... On Which way this is Possible???</p>
asp.net
[9]
2,202,695
2,202,696
"un"toggling a div with jQuery
<p>I'm using jQuery's .toggle method to create a menu that opens and closes when a div is clicked. Here is my code: </p> <pre><code>$(".header").toggle(function() { $(this).find(".parent").fadeIn("fast"); $(this).css("background-color","red"); }, function() { $(this).find(".parent").fadeOut("fast"); $(this).css("background-color","white"); }); $(document).click(function() { $('.parent').fadeOut("fast"); $(".header").css("background-color","white"); }); $(".parent").click(function(event){ event.stopPropagation(); }); </code></pre> <p><a href="http://jsfiddle.net/bmcmahen/X9S5C/8/" rel="nofollow">http://jsfiddle.net/bmcmahen/X9S5C/8/</a></p> <p>This works well until I click outside of the pop-up menu to close it, and then try to click on the menu button again. It then requires a double click. What I need to be able to do is to untoggle the click on the div from the $(document).click function. Any idea on how I'd do this? </p>
jquery
[5]
2,636,053
2,636,054
Suppose I have a dictionary. How do I strip out all the keys? Edit: This is a nested dictionary
<p>And have a big blob of values, with a space in between?</p> <p>Edit: What if I have nested dictionaries? The current solutions work if my values are all strings. But what if my values are nested dictionaries?</p>
python
[7]
5,706,948
5,706,949
Getting blank screen when switching between activities
<p>I am working on an app , where I am switching between two activities. When control is inside onStart of second activity , there is screen drawing and processing logic being handled.Because of this , when switching between the two activities happens, there is a blank screen that comes up.</p> <p>Along with this , i also need to render a live video feed in background of my activities/app</p> <p>What could be the best way to deal with this?</p> <p>TIA</p>
android
[4]
5,788,525
5,788,526
Time it would take me to learn c++ given my speed?
<p>I am a student in second year of engineering and my life is hard, nowadays. To make my future secure and at least get good jobs, I have started learning C++; I have learned J2SE, ASP.NET (little, basic C#), PHP (little), HTML, CSS, AJAX, Javascript, SQL, a little android development (I have built a benchmark app) in 4 months and have received 1 gold medal in CSS and 1 each in HTML, CSS, Java. </p> <p>I am able to make things in C#, Java and all other, so I can apply all this knowledge. I was able to do all this, because I loved learning and I hate to ask this question. How much time would it take me to learn C++, good-enough to get good jobs at Google, Microsoft? I am currently learning data structures, so that's excluded.</p>
c++
[6]
5,236,917
5,236,918
When do lists, collections etc throw a java.util.ConcurrentModificationException in Java?
<p>The following code uses a simple list and displays elements contained in the list through a foreach loop and again through a while loop.</p> <pre><code>final public class Main { public static void main(String... args) { List&lt;String&gt;list=new ArrayList&lt;String&gt;(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); for(Object o:list) { System.out.printf("\n"+o); } Iterator&lt;String&gt;listIterator=list.iterator(); //list.add("E"); If uncommented, throws an exception. //list.add("F"); while(listIterator.hasNext()) { System.out.printf("\n"+listIterator.next()); } } } </code></pre> <hr> <p>When the commented two lines above the while loop are uncommented, it throws an exception <code>java.util.ConcurrentModificationException</code>. If those commented lines are placed above this line <code>Iterator&lt;String&gt;listIterator=list.iterator();</code>, it works well. Such exceptions are very common while handling entities in <strong>EJBs</strong>. Why does this happen? How can it be avoided?</p>
java
[1]
5,872,867
5,872,868
Is there any way to optimize Map of List?
<p>given the following code?</p> <pre><code>final Map&lt;String, List&lt;E&gt;&gt; map = new HashMap&lt;String, List&lt;E&gt;&gt;(); List&lt;E&gt; list = map.get(mapKey); if (list == null) { list = new ArrayList&lt;E&gt;(); map.put(mapKey, list); } list.add(value); </code></pre> <p>If there any way I can avoid the null check? But let the Map automatically create the List for me for my first time insertion?</p> <p>I remember I once saw a specialized Map which is able to do this. However, I forget where I saw already :(</p>
java
[1]
2,845,885
2,845,886
Navigation Menu Error jQuery
<p>I'm trying to create a menu, but when you change the horizontal tab, vertical position is not updated, so when it goes back (when you go forwards works) it fails. </p> <p><em>So, if you on "Applications", and you press the down arrow of the keyboard, and then you go to "Games" and later you go back again, it says "position:auto", it should say 160px.</em></p> <p><a href="http://jsfiddle.net/xBzdr/1/" rel="nofollow">http://jsfiddle.net/xBzdr/1/</a></p> <p>Using the developer console, you can read "position: X" when you change the horizontal tab.</p>
jquery
[5]
3,670,141
3,670,142
JavaScript for-loop... for(i=0;i<10;i--)s=s+i;
<pre><code>for ( i = 0; i &lt; 10; i-- ) s = s + i; </code></pre> <p>Why does the following loop return an error?</p>
javascript
[3]
682,203
682,204
variable used withing multiple selector
<p>ok, yet another jquery selector nightmare for me ! i've read about 20 questions with similar topic, but I couldnt find one with my problem ... sorry if it did exist ( probably does somewhere ) its seems pointlessly easy but somehow I cant get it to work.</p> <p>I have a list of img, and when you click on one, I get hold of its 2nd class. Once I have this second class, i want to hide or show other element who have that class</p> <p>heres some code to clarify : </p> <pre><code>&lt;ul id="thumbail_list"&gt; &lt;li class="image fantome"&gt;&lt;img src="images/fantome.png"/&gt;&lt;/li&gt; &lt;ul&gt; </code></pre> <p>lets say I click on my fantome image I want that somewhere else a paragraph with class texte and fantome which is hidden by default become visible.</p> <pre><code>$('#thumbail_list li').click(function() { var Chosenclass = $(this).attr('class').split(' ')[1]; var texte = '.text .' + Chosenclass ; var image = '.image .' + Chosenclass ; $('.image').fadeIn('slow', function(){ $(image).fadeOut('slow', function(){ $(texte).fadeIn('slow'); }); }); } </code></pre> <p>but I cant get this to work, console doesnt show me any error, and I,ve put alert everywhere and it always show me what I want ... but the invisible text wont show.</p>
jquery
[5]
2,019,358
2,019,359
Postpone execution of code inside document.ready()
<p>I have a document.ready function that I am using to slide toggle and it looks like this:</p> <pre><code>$(document).ready(function() { if ($("div[id='feature-content']").is(":visible")) { $("div[id='feature-content']").hide(); $("div[id='feature-content']").slideToggle(9000).delay(4000); } $("div[id='feature-content']").slideToggle(9000).delay(4000); }); }); </code></pre> <p>I want the slide toggle to occur only after say, 5 secs, after rendering the page. So I modified the above code by including a setTimeOut() like below:</p> <pre><code>$(document).ready(function() { window.setTimeout(function() { if ($("div[id='feature-content']").is(":visible")) { $("div[id='feature-content']").hide(); $("div[id='feature-content']").slideToggle(9000).delay(4000); } $("div[id='feature-content']").slideToggle(9000).delay(4000); }); } , 15000 ); }); </code></pre> <p>But I am not able to get it to work. Can someone help me to accomplish my objective?</p> <p>Thank you.</p>
jquery
[5]
5,255,333
5,255,334
Enhancing Help option in my android application
<p>I need to add help menu in my android application to help users know about the app for first time when they start <a href="http://i.stack.imgur.com/Tys2r.png" rel="nofollow">Should show pop up screen like this </a> well, I can do this by adding such images but Is there any library or sample project available that I can use to achieve this! <a href="http://developer.android.com/design/patterns/help.html" rel="nofollow">here is developers link down there is a semi transparent image </a></p>
android
[4]
2,588,662
2,588,663
android- OnStart never called when files come from the Gallery
<p>what am i doing wrong here or is this a feature. </p> <p>My <code>Activity</code> is set up in the manifest to be recipients for images.<br> I select an image in the Android <code>Gallery</code> and press share.<br> My activity start and i do stuff with the image. </p> <p>Now, when long-press Home button and open my mail<br> and then go back to my <code>Activity</code> i was expecting the<br> <code>OnStart()</code> to be called.<br> It is not called.<br> I place breakpoints on other places and they work.</p> <p>This <code>Activity</code> does not have a <code>.LAUNCHER</code> setup<br> an can only be accessed this way. </p>
android
[4]
1,893,901
1,893,902
iPhone: How do I create a simple Done button?
<p>Newbie alert! I have a simple calculator with 4 text input fields. When I tap into a field the number pad appears and I enter numbers. No problems so far. Now, when testing this using the simulator I press return on the keyboard and using TextFieldShouldReturn my fields perform their calculations perfectly and the number keypad disappears nicely. The problem is, the number keypad does not have a 'Done' key so if I place a button let's say on the toolbar how do I code it to perform the action of the Return key?</p>
iphone
[8]
2,760,440
2,760,441
DateTime.TryParse for only a Time parameter?
<p>I am writing a service that calls a method at 4pm and 5am. I would like to keep these times from being hard coded and so I would like to have put them in my appconfig. </p> <p>Here is the code I have:</p> <pre><code>public bool CheckTime() { DateTime startTime; DateTime endTime; DateTime.TryParse(ConfigurationManager.AppSettings["ProcessingStartTime"], out startTime); DateTime.TryParse(ConfigurationManager.AppSettings["ProcessingEndTime"], out endTime); if(DateTime.Now.TimeOfDay.Equals(startTime) || DateTime.Now.TimeOfDay.Equals(endTime)) return true; else return false; } </code></pre> <p>But, since I only want to store the time as a string (something as easy as "4:00pm") how do I parse and encapsulate JUST the time in a DateTime object? Or is there another object? I don't care about the date, it just has to be M-F of any given week of any given year.</p> <p>Thanks guys.</p>
c#
[0]
5,527,044
5,527,045
Moving application in background on back button event
<p>Is it possible to move the app in background when we click on device back button in android?</p> <p>background means application moves to screen(application) from where it launches ?</p>
android
[4]
3,720,952
3,720,953
C# Homework - control structures (for, if)
<p>I got a homework assignment today: "Create a program that calculates out how many ways you can add three numbers so that they equal 1000."</p> <p>I think this code should work, but it doesn't write out anything.</p> <pre><code>using System; namespace ConsoleApp02 { class Program { public static void Main(string[] args) { for(int a = 0; a &lt; 1000; a++) { for(int b = 0; b &lt; 1000; b++) { for(int c = 0; c &lt; 1000; c++) { for(int puls = a + b + c; puls &lt; 1000; puls++) { if(puls == 1000) { Console.WriteLine("{0} + {1} + {2} = 1000", a, b, c); } } } } } Console.ReadKey(true); } } } </code></pre> <p>What am I doing wrong? Any tips or solution?</p>
c#
[0]
4,155,621
4,155,622
How to represent a time table from 1-12 with java sysout?
<p>i was wondering how to make a time table from 1-12 with java sysout</p> <p>here's the time table:</p> <p><img src="http://i.stack.imgur.com/P3Blq.jpg" alt="enter image description here"></p> <p>please advise, thanks.</p> <p>EDIT: this was a question in an interview to be answered in less than 10 seconds, and i couldn't figure it out in time.</p> <p>BTW, the empty row is not important.</p>
java
[1]
3,727,181
3,727,182
Jquery $("#selector") returns empty data
<p>I've a field in the form,trying to get this value using jquery.It is always returning null.</p> <p>Where am i going wrong ?</p> <p>Here is what i tried <a href="http://jsfiddle.net/9gJGM/" rel="nofollow">http://jsfiddle.net/9gJGM/</a></p>
jquery
[5]
5,388,991
5,388,992
Safety using $_SERVER variables
<p>I'm working on a system that relies in $_SERVER['REMOTE_ADDR'] to get the user address and check it against a white list of addresses. Is this approach safe? Or is there a way of forcing values in superglobal variables?</p> <p>Thank you, Diogo</p>
php
[2]
785,329
785,330
Android: Pause Streaming Audio on MediaPlayer
<p>I have this method to play an audio file with a button:</p> <pre><code>final MediaPlayer mediaplayer = MediaPlayer.create( this, Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.inro)); mediaplayer.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { if (mediaplayer.isPlaying()) { mediaplayer.pause(); } else { mediaplayer.start(); } } }); </code></pre> <p>What I'm trying to do is, when the audio is playing and the user clicks the button again, the audio wil pause, but when he clicks it again the audio will resume.</p> <p>Can anybody help me with that? Thank you</p> <p><strong>UPDATED:</strong></p> <pre><code>@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_nav_back: WWHApplication.getMapActivityIntance().getVideoLocationDB(); WWHApplication.getMapActivityIntance().initLocations(); if (category == 'f') { if (WWHApplication.getFavoritesListActivityIntance() != null) WWHApplication.getFavoritesListActivityIntance() .loadListView(); } finish(); break; case R.id.btn_tool_audio: final MediaPlayer mediaplayer = MediaPlayer.create(this, Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.inro)); if (mediaplayer.isPlaying()) { mediaplayer.pause(); } else { mediaplayer.start(); } break; </code></pre>
android
[4]
3,814,193
3,814,194
JQuery returns undefined when I access my image attribute
<p>I have an image on my html document and I've put it like this:</p> <pre><code>&lt;img src="picture.jpg:/&gt; </code></pre> <p>I reference it in jquery by:</p> <pre><code>$('img').click( function() { alert($(this).attr('width')); }); </code></pre> <p>It catches the event but it returns undefined value. Is there another way on how to extract the width and height?</p>
jquery
[5]
26,425
26,426
Looking for a way to see if an application is closed
<p>Is there a good way to check if an entire application (not an activity!) is closed by the user? I want to log the time a user spends using the application, so a simple activity <code>onPause()</code> ,<code>onStop()</code> or <code>onDestroy()</code> is not sufficient.</p> <p>There are several ways an application can be closed, either the user pressing the home button, search button or simply leaving the application. Is there a unified (eg. simple) way to see if any of these things happened?</p>
android
[4]
4,930,678
4,930,679
How does Integer.parseInt works
<p>The method public static int parseInt(String str) and public static int parseInt(String str, int redix)</p> <p>How does it work?</p> <p>&amp; what is the difference between them?</p>
java
[1]
5,482,277
5,482,278
How to parse json url using android?
<p>I want parse json url,my json url contains following structures</p> <pre><code>{"content":{"item":[{"category":"xxx"},{"category":"yy"} ]}} </code></pre> <p>how to read this structure,anybody knows give example json parser for that.</p> <p>Thanks </p>
android
[4]
3,699,293
3,699,294
How to store data if checkbox is selected
<p>I'm doing this one using PHP.</p> <p>I'm doing some basic quiz application and it has a backend. On my backend, I am setting up a quiz for students to answer. One of my interface is like this.</p> <p><img src="http://i.stack.imgur.com/ELwTk.png" alt="enter image description here"></p> <p>If the user checked the box, it means 1950 is the answer. How would I process that one in my database to determine that 1950 has been the answer of the question.</p> <p>My Database is like this.</p> <pre><code>tbl_choices Id,Choice,isAnswer </code></pre> <p>so ideally, it would be stored like this.</p> <pre><code>tbl_choices ID CHOICE isAnswer 001 1900 0 002 1800 0 003 1950 1 004 1850 0 </code></pre> <p>My question here is how would I code it in a sense when a user will check the checkbox and the textinput right beside it will have a value of <code>isAnswer</code> as <code>1</code>.</p> <p>Just an additional info: When a user will click that <code>+</code> button it will add a new textinput and if user will click <code>-</code> button it will delete a textinput, but I got that all covered.</p> <p>The choices are dynamic, it will changed, that above that I've shown you is just an example.</p> <p><em>P.S: Sorry for the title, I don't know what's the title of this kind of question :-)</em></p> <p>Your help would be greatly appreciated and rewarded!</p>
php
[2]
3,802,107
3,802,108
dismissing the NumberPad keyboard from a UIScrollView
<p>I have an application with UIScrollView added as a subview of UIView. This Scroll view has a textfield with keyboard type set to numberPad. Now the problem is , i want to dismiss the keyboard when i tap anywhere else in the scroll view. how can i do this ... ?</p>
iphone
[8]
1,141,137
1,141,138
message passing to another user in c++
<p>i need to create a class that will enable a user to send a secret message to another individual. The class should contain the id number of the person who constructed the messages as well as the id number of the person who is to receive the message. The class should also contain an attribute that will store the message that is being transmitted. The maximum number of characters in the message should be 30.</p> <p>Valid id numbers should range from 1 to 20 inclusive. Any other id number is invalid and should signal an error. Create a utility function that will check the id number and print an appropriate message where applicable. Also create appropriate operations for storing additional data that is required by the class.</p> <p>The class should also facilitate an encryption operation that will ensure that the message is kept secret. As a simple test you are required to implement an encryption operation that will reverse and store the message content. You should also include a decryption algorithm that will convert the scrambled message to its original state.</p> <p>Write a menu driven main program that will demonstrate the use of the class. The menu options are: 1. Enter message details. 2. Encrypt message 3. Decrypt message 4. Print message details 5. Exit program</p>
c++
[6]
1,283,258
1,283,259
to check the combination of pressed buttons
<p>I have 4 buttons (a1, a2, b1, b2). They can combinate: a1-b1; a1-b2; a2-b1; a2-b2.It means that "a1" and "a2" cann't be chosen together. So after clicking "a1" I need to block "a2".And depends on what 2 buttons were pressed, it will be differenet actions.I tried something like this</p> <pre><code>if(a1.isPressed()|| b1.isPressed()){ a2.setClickable(false); b2.setClickable(false);} </code></pre> <p>but it didn't work.</p> <h1>Update:</h1> <p>I tried to add boolean variable a1Boolean = false; boolean a2Boolean = false; And after each click `a1.setOnClickListener(new View.OnClickListener() {</p> <pre><code> @Override public void onClick(View v) { a1Boolean = true;` </code></pre> <p>And then to check in the method </p> <p><code>private boolean geta1_b1() { if (a1Boolean || b1Boolean) { a2.setClickable(false); b2.setClickable(false); } return true; }</code></p> <p>but when I call this method before all these clicks, of corse, it didn't work, because I didn't press any buttons yet. Any ideas how to find a right decision?</p>
android
[4]
3,704,479
3,704,480
Can someone help me solve this timer problem in a plugin?
<p>My code can be seen here: <a href="http://www.jsfiddle.net/wdJM2/" rel="nofollow">http://www.jsfiddle.net/wdJM2/</a> What I want to know is why my kill button doesn't stop the timer function in my plugin. Any solutions??</p>
jquery
[5]
2,299,041
2,299,042
What PHP function will print the name of an array with its contents?
<p>When I use Smart::Comments in Perl, I can see the name of the hash I am dumping (i.e. %person, below). . .</p> <pre><code>[pdurbin@macbook ~]$ cat /tmp/person.pl #!/usr/bin/perl use strict; use warnings; use Smart::Comments; my %person = ( 'hair' =&gt; 'golden', 'eyes' =&gt; 'blue', ); ### %person [pdurbin@macbook ~]$ perl /tmp/person.pl ### %person: { ### eyes =&gt; 'blue', ### hair =&gt; 'golden' ### } [pdurbin@macbook ~]$ </code></pre> <p>. . . but in PHP I only see "Array", no mention of $person. . .</p> <pre><code>[pdurbin@macbook ~]$ cat /tmp/person.php &lt;?php $person = array( 'hair' =&gt; 'golden', 'eyes' =&gt; 'blue', ); print_r($person); [pdurbin@macbook ~]$ php /tmp/person.php Array ( [hair] =&gt; golden [eyes] =&gt; blue ) [pdurbin@macbook ~]$ </code></pre> <p>I've tried <code>print_r()</code>, <code>var_export()</code>, and <code>var_dump()</code> but is there some other PHP function that will print the name of an array with its contents?</p>
php
[2]
2,150,095
2,150,096
Execute a PHP CGI script as a background process?
<p>Can I run a PHP CGI script as a background process using exec() ?</p>
php
[2]
5,362,771
5,362,772
Exception inside catch block
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/833946/in-c-will-the-finally-block-be-executed-in-a-try-catch-finally-if-an-unhandled">In C# will the Finally block be executed in a try, catch, finally if an unhandled exception is thrown ?</a> </p> </blockquote> <p>Will finally be executed in this scenario (in C#)?</p> <pre><code>try { // Do something. } catch { // Rethrow the exception. throw; } finally { // Will this part be executed? } </code></pre>
c#
[0]
5,932,536
5,932,537
trouble removing element using remove()
<p>Im having some trouble removing part of a cloned element:</p> <pre><code>console.log($(this).closest('tr').clone().find('td:last')); //this is the td that i want to remove $(this).closest('tr').clone().remove('td:last').append('&lt;td&gt;&lt;input type="button" value="Del" class="removesystem"/&gt;&lt;/td&gt;').appendTo('.targetbox table'); //doesnt get removed here. i tried with .end() after remove() as well, without any success. </code></pre> <p>Have i missed something? Thanks</p>
jquery
[5]
3,773,930
3,773,931
Python - How to average user input value based on provided keys?
<p>I am attempting to write a script that allow users to submit letter grades for baseball prospects and have those grades averaged based on what users submit. </p> <ol> <li>User inputs grade for a prospect (B+ for prospect1)</li> <li>All inputs are converted from lettergrades to numbergrades so they can be averaged. </li> <li>Prospects are sorted by highest to lowest grades.</li> <li>Grades are re-converted back to letter grades. </li> </ol> <p>I believe I have step 2 covered but I am iffy on how to complete the rest of the code.</p> <p>To simplify things, let's say we are given a list of 5 prospects. Users will grade each of them. As each additional user adds their input of grades, the average grade of each prospect should be updated and the order of their ranking simultaneously sorted. </p> <pre><code>prospects = ['prospect1', 'prospect2', 'prospect3', 'prospect4', 'prospect5'] grades = {'A+':98, 'A':95, 'A-':92, 'B+':88, 'B':85, 'B-':82, 'C+':78, 'C':75} #grading system where A+ = 98, A = 95 etc def numbergrade(lettergrade): return grades[lettergrade] #function to convert lettergrade to numbergrade </code></pre> <p>How would you compile a list that would add an element every time there is a new user input and at the same time have the grade match the correct prospect? Should I be using a dictionary here?</p>
python
[7]
652,347
652,348
Preload a view in android?
<p>I have a hidden view in android that I show in response to a button press. The first time I show it there's a bit of a delay, and it hitches. After that it shows\hides smoothly.</p> <p>Is there a way to preload a view so it's ready to be drawn smoothly the first time it's called upon?</p>
android
[4]
4,132,823
4,132,824
Not allowed to include a default constructor - Java Basics
<p>Class A:</p> <pre><code>public class A { private String firstName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } </code></pre> <p>Class B:</p> <pre><code>public class B extends A{ private int billNum; B(String firstName, String billNum) { super(firstName); setBillNum(billNum); } public int getBillNumr() { return billNum; } public void setBillNum(int billNum) { this.billNum = billNum; } </code></pre> <p>1.) Now i want to add a default <strong>like</strong> constructor like <code>B() {}</code>, but i am not allowed to do so. Why is this ?</p>
java
[1]
5,717,107
5,717,108
Change android softkeyboard sample designs, button and background images
<p>I'm building a custom keyboard by modifying the android softkeyboard sample from the SDK. I want to change the images of the buttons and the backgrounds but I can't figure out where those values are stored. Where are they stored or how can i change the image or simply color?</p>
android
[4]
1,903,301
1,903,302
How to write onclick actions for dynamically generated textviews in android?
<p>I have to display the textviews dynamically in android and need to write onclick action for each textview. I am able to display the textviews dynamically but I didnt get how to write the onclick action for each textview. Please help me regarding this...Will be thankful to you..</p>
android
[4]
5,848,666
5,848,667
Overloading operator== but it doesn't get called (comparing pointers?)
<p>I'm trying to overload the == operator to compare between two objects. For some reason the overloaded handler is never called.</p> <pre><code>class gxCallback { public: virtual bool operator==(const gxCallback &amp;aOther) const { // This is never called return true; } }; typedef std::vector &lt; gxCallback* &gt; CallbackList; void gxObservable::Fire( gxCallback *aCallback ) { CallbackList::iterator iCallback; for ( iCallback = mCallbacks.begin(); iCallback != mCallbacks.end(); ++iCallback ) { if ( aCallback == *iCallback ) // The comparison is never made via the overloaded == { // Do something } } } </code></pre>
c++
[6]
5,671,810
5,671,811
Freezing first column in DataGridView in C#
<p>I have a DataGridView of student with 15 columns, so I want to freeze the first column (PK). How can I do that?</p>
c#
[0]
1,536,364
1,536,365
How do I distribute free copies of a paid iOS app?
<p>Can anybody tell me how I can give my paid app a free download option to one of my friend from iTunes Connect. What I mean is that I will give my friend a code by which he can download my app without paying. Can anyone tell me if there is any option in iTunes Connect to do this?</p>
iphone
[8]
3,198,947
3,198,948
Java JAR application: how does the structure look like? (Eclipse)
<p>I'm a seasoned PHP programmer with backgrounds within Powershell, JavaScript etc. I see the benefits with Java and wish to dig deeper.</p> <p>All the documentation though is too advanced for me atm.</p> <p>A typical PHP structure:</p> <pre><code>index.php classes/class_get.php classes/class_set.php </code></pre> <p>Where in index.php you would have the lines</p> <pre><code>require_once "classes/class_get.php"; require_once "classes/class_set.php"; </code></pre> <p>Now in Java... I understand Windows files are in .JAR format. No problem here, easy to understand. I am confused when creating this in eclipse. Is the strucutre;</p> <pre><code>Main.java src*/defaultPackage**/myClass.java </code></pre> <p>* folder<br> ** package</p> <p>Where in the Main.java file you would declare "import myClass.java"?</p> <p>Also other packages such as the following:</p> <pre><code>import java.awt.*; import java.awt.event.*; import java.net.URL; import javax.swing.*; </code></pre> <p>I am getting errors, and this manifest file, I haven't heard of it in any tutorials yet?</p>
java
[1]
4,053,593
4,053,594
android background issue
<p>I'm having an issue with my background. Depending on my manifest settings I either have the background being squished when i bring up a soft keyboard like this:</p> <p>![enter image description here][1]</p> <p>Or else I get this with the graphics being pushed off the screen: ![enter image description here][2]</p> <p>If I tap the black area the graphics come down, but now the EditText is pushed down like this: ![enter image description here][3]</p> <p>How do I fix this? The top should always look like the last image, but I should always see the edittext.</p>
android
[4]
652,699
652,700
Animate gallery view in android?
<p>Is it possible to flip images in gallery when i shift from left to right , or give an effect similar to iPhone. The simple scrolling images look very dull.</p>
android
[4]
3,999,248
3,999,249
Play a wav file retrieved from a database on the iPhone?
<p>I have alot of wav files stored in sqlite3, but when I retrieve one of them, I can't play it. The retrieve code is </p> <p>NSData *soundData = (NSDATA *)sqlite3_column_blob(statement, 0); mPlayer = [[AVAudioPlayer alloc] initWithData:soundData error:&amp;error];</p> <p>The data is stored as binary and it's there when I search for it using sqlite3.</p>
iphone
[8]
5,545,074
5,545,075
Coding convention checking tool for C++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/93260/a-free-tool-to-check-c-c-source-code-against-a-set-of-coding-standards">A free tool to check C/C++ source code against a set of coding standards?</a> </p> </blockquote> <p>Are there some coding convetion tools for C++ for example which check that class names start with big letters, which check names of function parameters, which check how curly brackets are placed etc.?</p>
c++
[6]
5,158,516
5,158,517
setting Maxmimu lenght for obout Edit control?
<pre><code> In my web application i am using obout Edit control. I want to restrict the user to type only 400 characters how can i restrict the user.i write javascript like this. </code></pre> function textCounter(field,cntfield,maxlimit) { if (field.value.length > maxlimit) { alert("Cannot type more than 450 characters"); field.value = field.value.substring(0, maxlimit); } else { cntfield.value = maxlimit - field.value.length; } } <p>// this is text box</p> <p> </p> <p>but it is giving error like no onkeydown for editor.</p>
asp.net
[9]
1,999,738
1,999,739
Writing to a servlet from a java class and reading from another application
<p>I want my java class , which has the processed information , to write to a servlet. Then I want the separate module to read this information from the servlet. Is it possible to do so?</p> <p>In many examples I found writing to a servlet and getting back the response to the same java class. I want the content which has written to the servlet to remain until my other application reads from it. </p> <p>Please , any help is appreciated.</p>
java
[1]
2,279,711
2,279,712
Show updated text file in python
<p>Below is my python code:</p> <pre><code>filename = 'ToDo.txt' def preview(): temp = open(filename, 'r') print temp.read() print '\n' temp.close def new_task(): temp = open(filename, 'a') while True: new_entry = raw_input('Enter New Task: ') if new_entry == 'exit' or new_entry == 'quit': break if new_entry == 'preview': print '\n' preview() break temp.write(new_entry + '\n') temp.close </code></pre> <p>I think it should display modified file with new entry saved if input is "preview", but it doesn't. Any idea to do the same.</p>
python
[7]
41,641
41,642
Android list view on click
<p>i have a list view with 15 items. when i click on any item i want to change the screen(Intent). how can i change the activity on item selected in android? any tutorial or source code?</p> <p>thanks in advance.</p>
android
[4]
4,848,057
4,848,058
Increment by any constant number in a single SQL Update statement?
<p>Update a field by +1 (or any other integer increment) in table in sql, (PHP - Im using txt-db-api) in a single update statement. </p> <p>Something like</p> <pre><code>UPDATE tablename SET current_value = current_value+1 where condition=true </code></pre> <p>Although field is integer type but is not Auto_Increment type.</p> <p><strong>Edit</strong></p> <p>Actually I am not using MySQL but a flat text db called txt-db-api in PHP. I elaborate it as, increment a field value without knowing actual value or retrieving it (only knowing that it is an integer type) by any constant number or +1 (in my case).</p> <p>CODE IS LIKE THIS:</p> <pre><code>$ip_who=$_SERVER['REMOTE_ADDR']; $query="UPDATE ratingtable SET rating_value='".valuealready+1."', rater_ip='$ip_who'; </code></pre>
php
[2]
3,957,808
3,957,809
How to remove the <a> and </a> from <a>link</a>
<p>How to remove the <code>&lt;a&gt;</code> and <code>&lt;/a&gt;</code> from <code>&lt;a&gt;link&lt;/a&gt;</code>? via JavaScript</p>
javascript
[3]
4,630,068
4,630,069
What does "Could not initialize class com.ibm.icu.impl.JavaTimeZone" mean?
<p>"An error has occurred. See error log for more details. Could not initialize class com.ibm.icu.impl.JavaTimeZone"</p>
android
[4]
5,326,248
5,326,249
Type mismatch: cannot convert from ArrayList to List
<p>I have only this, but my compiler says:Type mismatch: cannot convert from ArrayList to List So what is the problem can anyone tell me ? I'm using Elipse Java EE IDE.</p> <pre><code>import java.awt.List; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; public class Main { public static void main(String[] args) { List list = new ArrayList(); } } </code></pre>
java
[1]
3,253,248
3,253,249
please help me to solve this minimal javascript code problem
<p>My inputs are: an array of object names and objects. I want to loop through the array for object name and then output something from corresponding object. My code is as follows:</p> <pre><code> options=["bold","italic"] ; var bold ={ action: function(){ alert("&lt;strong&gt;just bold&lt;/strong&gt;"); }, b_p: "-40px bold" }; var italic ={ action: function(){ alert("&lt;em&gt;an italic&lt;/em&gt;"); }, b_p: "-20px italic" }; for(i=0;i&lt;options.length;++i) { document.write(options[i].b_p); } </code></pre> <p>My desired output: "-40px bold -20px italic" but I get an error saying: "undefined undefined".</p> <p>Please help me to find out my mistake/ignorance here.</p> <p>Thanks.</p> <p>/<strong><em>*</em>**<em>*</em>**</strong>/ Update: the problem is solved below :-) Thanks communtiy</p>
javascript
[3]
609,239
609,240
Build failed when adding app to iphone device
<p>I have created a application in iphone and i have provision certificate for testing it in iphone.I connected xcode 4 with iphone and i changed the iphone stimulator to my iphone.I run the xcode ,all the files are complied but last there shows a failed message.It is not given any error message.I build my app with ios4.3,but my iphone is ios4.1.Is this is the issue for the build error?.Please help me to solve this. Thanks in advance.</p>
iphone
[8]
5,440,717
5,440,718
jquery small issue I need help with
<p>Hi I need help with a bit of jquery, I am renaming dropdown lists when a checkbox next to them is clicked. I want to get the selected option value of the dropdown called 'Prev' in the code below and assign to the checkbox that is clicked. I hope it makes sense. Thanks</p> <pre><code>$('.mutuallyexclusive').live("click", function() { checkedState = $(this).attr('checked'); $('.mutuallyexclusive:checked').each(function() { $(this).attr('checked', false); $(this).attr('name', 'chk'); }); $(this).attr('checked', checkedState); if (checkedState) { jQuery('#myForm select[name=cat.parent_id]').attr('name', 'bar') // here is the bit i need help with // get the selected option of the dropdown prev and set it to $(this).val.. something along those lines var prev = $(this).prev('select').attr("name", 'cat.parent_id'); } else { var prev = $(this).prev('select').attr("name", 'dd'); } }); }); </code></pre>
jquery
[5]
3,046,895
3,046,896
What is PHP's each() function useful for?
<p>What do people use the <code>each($array)</code> for? </p> <p><a href="http://theserverpages.com/php/manual/en/function.each.php" rel="nofollow">http://theserverpages.com/php/manual/en/function.each.php</a></p>
php
[2]
2,429,228
2,429,229
Get the class of the first DIV from inside HTML
<pre><code>&lt;div class="first"&gt; &lt;div class="second"&gt; etc &lt;/dv&gt; &lt;/div&gt; </code></pre> <p>How can I get the class of the first div ? ("first") using jQuery ?</p> <p>I have this html inside a variable "$body_html"</p>
jquery
[5]
2,249,003
2,249,004
Can server port similar with other server
<p>I am new in C# programming , sorry advance. I am making program which i need to receive data form client side that is located in other city. i have some confusion that is it possible that my server IP and server Port which i will use can be similar with other server.</p>
c#
[0]
2,069,157
2,069,158
How to save indexed arrays to a session with a for loop?
<p>This is basic stuff but I seem to be way too beginner to make it work. Down here I would like to somehow get my 100 arrays into different sessions, but anything like that does not seem to work and I wonder why?</p> <pre><code>for($i=1; $i&lt;=100; $i++) { $age = rand(1,100); $table[] = $age; $_SESSION[$i] = $table[]; } </code></pre> <p>Later I need to be able to echo $age of all 100 sessions printed also using for loop. If I do like down there again it just says about undefined override and gives number of all 100 $i's.</p> <pre><code>for($i=1; $i&lt;=100; $i++) { echo $_SESSION[$i]; } </code></pre>
php
[2]
1,475,822
1,475,823
Why I get this 0 as answer for (1/10) in Python?
<p>I am trying this in Python 2.7 Interpreter.</p> <pre><code>&gt;&gt;&gt; print 1/10 0 &gt;&gt;&gt; print float(1/10) 0.0 &gt;&gt;&gt; print 1/5 0 &gt;&gt;&gt; a = 1/5 &gt;&gt;&gt; a 0 &gt;&gt;&gt; float(a) 0.0 &gt;&gt;&gt; </code></pre> <p>I want a value in floating point when I divide. Any idea on the logic behind this zero out put and please let me know how to do it correctly.</p>
python
[7]
2,953,090
2,953,091
Any way to tell when any button in a layout is UN-pressed
<p>(Android 3.2) I have a TableLayout with 9 buttons. I want to know when any of them are un-pressed, i.e., when a press is complete, i.e., ACTION_UP. I don't care which button, I just want to know when any button which had been pressed has just been released.</p> <p>I was hoping there was an <strong>Android::onTouch</strong> in the XML, like there is an Android::onClick, and I could point them all at one onTouch event handler to look for an ACTION_UP. But there isn't. I'm trying to avoid writing 9 separate OnTouchListeners.</p> <p>Any suggestions?</p> <p>Thanks in advance.</p>
android
[4]