Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
5,594,905
5,594,906
Tab bar in a View instead of Window
<p>Is it possible to use tab bar in a view instead of window? Seems everyone add tab bar to their window.</p> <p>My first screen is a login screen, which doesn't need tab bar. After user login, it change to the second screen, which contain a tabbar.</p> <p>Thank you for your time :)</p>
iphone
[8]
4,365,035
4,365,036
Using static variables to store user info on Android
<p>I'm making an android app which has to frequently call some .net web services using the kSoap2 library. The user has to log in each time the app is launched (a decision that is out of my hands). I have one class which calls the web services. Each web service requires a username, a password and one other data string to access it. When the user successfully logs in I store the correct username, password and other piece of data in 3 private static variables inside the web services class, to use when I need to call other web services.</p> <p>Could this approach end up being problematic down the road?</p>
android
[4]
4,286,264
4,286,265
how to clear a buffer after use?
<p>I am using a BufferedReader. I just wanna know how to clear the BufferedReader after every line is read values from keyboard. I am using like</p> <pre><code>BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String male = br.readLine(); </code></pre> <p>please help me out.</p>
java
[1]
3,678,991
3,678,992
"Splitting an empty string with a specified separator returns ['']"—but I'd prefer [] instead
<p>I'm splitting a string using:</p> <pre><code>my_string.split(',') </code></pre> <p>Sometimes the string is empty, which returns <code>['']</code>. </p> <p>My use-case is such that it would be more convenient to receive an empty list. In my application, an empty string is equivalent to no items. <code>['']</code>, however, is a list with one item, <code>''</code>. </p> <p>Is there a way I can get around this without conditional or additional logic? I've got a dictionary key assignment that's like:</p> <pre><code>d = { 'key': map(lambda x: x.strip(), my_string.split(',')), } </code></pre> <p>It would be cool to keep it this way, all directly at the key assignment.</p>
python
[7]
3,322,170
3,322,171
'live' responses on time consuming php scripts?
<p>Many times i run time consuming PHP scripts that echo status updates like 'batch 1 finished', 'batch 2 finished' etc. </p> <p>i've noticed that sometimes the server responds in a 'live' manner and you can see these status updates as the 'jobs' finish, printed on the browser.</p> <p>But in other times you have to wait for the script to end, and the browser displays all the status updates at once.</p> <p>When does the first happen? Is it the browser? Is it PHP setup? The way the script is coded? </p>
php
[2]
3,241,243
3,241,244
jQuery: How do I select all P children of my parent?
<p>html:</p> <pre><code>&lt;style&gt; hidden { display:none;} &lt;/style&gt; &lt;div id="div1"&gt; &lt;a href="#" onclick="expandSiblingParagraphs(this)"&gt;+&lt;/a&gt; &lt;p&gt;Hello&lt;/p&gt; &lt;p class="hidden"&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer vulputate, nibh non rhoncus euismod, erat odio pellentesque lacus, sit amet convallis mi augue et odio. Phasellus cursus urna facilisis quam. Suspendisse nec.&lt;/p&gt; &lt;p class="hidden"&gt;Another hidden paragraph&lt;/p&gt; &lt;/div&gt; </code></pre> <p>The Javascript I am trying:</p> <pre><code>var expandSiblingParagraphs = function(elt){ $(this).parent()....? }; </code></pre> <p>I want to select all P's that are children of the clicked element's parent, and remove the hidden class from them. In the logic I don't want to assume anything about the id of the containing div, or even that there is a containing div. I just want all P children of the parent container. </p> <p>How do I do that? </p> <p>In <a href="http://docs.jquery.com/Selectors" rel="nofollow">the selector syntax</a>, I can find a way to get descendants or children. I can't find a way to select parents or ascendants. Am I missing something? thanks.</p>
jquery
[5]
780,048
780,049
Set a select option using variable in jQuery
<p>Im using jquery cookie plugin to set a cookie for my dropdown. This means when someone selects either Yes or No from the dropdown then the value writes to the cookie.</p> <p>This works, I can successfully console.log the cookie value too. But When I try to use the cookie to AUTO-SELECT the dropdown value it matches, it just sticks to 'no' all the time.</p> <p>am I missing something?</p> <p><strong>html</strong></p> <pre><code>&lt;select id="delete"&gt; &lt;option value="no"&gt;No&lt;/option&gt; &lt;option value="yes"&gt;Yes&lt;/option&gt; &lt;/select&gt; </code></pre> <p><strong>jquery</strong></p> <pre><code>$(document).ready(function(e) { var thiscookie = $.cookie('1C'); $('#delete').val(thiscookie); $('#delete').change(function(){ var choice = $(this).find("option:selected").val(); $.cookie('1C',choice); }); }); </code></pre> <p>Note: If I set the val of the selectbox in jquery to 'yes' it doesn't work either</p>
jquery
[5]
3,737,742
3,737,743
in_array doesn't make any sense
<pre><code>$arr = array( 'test' =&gt; array( 'soap' =&gt; true, ), ); $input = 'hey'; if (in_array($input, $arr['test'])) { echo $input . ' is apparently in the array?'; } </code></pre> <p>Result: hey is apparently in the array?</p> <p>It doesn't make any sense to me, please explain why. And how do I fix this?</p>
php
[2]
1,317,066
1,317,067
Help needed in a calendar based app
<p>I am creating a calendar based app.</p> <p>I have two dates say present date, and future date(due date), now i need to show the difference between these two dates in terms of days, hours, minutes &amp; seconds and i want to show a timer which will continues to decrement second by second as the time increases and ultimately reaches to zero when due date comes.Basically it will be showing that how much days, hrs and seconds are left for the event.</p> <p>How can I do that, please help me.</p> <p>It would be a great help if i can get a similar kind of sample code.</p> <p>Many Thanks in advance. iPhone Developer</p>
iphone
[8]
3,921,007
3,921,008
How to get domain name of the server which hosts included JavaScript?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3548857/how-to-get-the-location-src-of-a-javascript-file">How to get the location (src) of a javascript file?</a> </p> </blockquote> <p>I have a JavaScript that will be included on third party sites, using <code>&lt;script src="" &gt;</code>. It will be potentially hosted on couple of different domains/hosts of mine. I need to get a domain name of the server that hosts the script, not the domain name of the server that included the script file. So if i host the script file on ABC.COM and it gets included from ZYX.COM i need to retrieve ABC.COM. I could hard-code the domain name inside the script but i rather keep a single version of my code. </p> <p>Is there a way to do this from within JavaScript?</p>
javascript
[3]
5,789,526
5,789,527
how do i write this out in php? (where i would use the >> to print out content)
<p>i remember a while ago i used a method like this to print out content so i didnt have to use slashes every time i had to use a quotation.</p> <pre><code>&gt;&gt; some text here "and more text something; </code></pre> <p>what was that called? and how did it look</p> <p>thanks</p> <p>this im gonna write down :p</p>
php
[2]
5,589,693
5,589,694
Is Java not installed correctly? Exception in thread "main" java.lang.NoSuchMethodError
<p>Recently when I write any code and compile it, then try to run it I get this exception:</p> <blockquote> <p>Exception in thread "main" java.lang.NoSuchMethodError</p> </blockquote> <p>At first I thought there is something wrong in my code, but I couldn't find anything wrong with it. When trying to run a <code>HelloWorld</code> example that had worked before, if works, but if I copy the exact same code into a file <code>HelloWorld2</code> I get this exception again.</p> <p>The code is identical but when I used <code>javap</code> to decompile both class files I found a difference. In <code>HelloWorld</code> (the original file)</p> <pre><code>"public static void main(java.lang.String[])"; </code></pre> <p>and in <code>HelloWorld2</code> (the new one)</p> <pre><code>"public static void main(String[])"; </code></pre> <p>without <code>java.lang.</code>.</p> <p>I recompiled the old <code>HelloWorld</code> with <code>javac</code> and now when I try to run it it doesn't work and I get the same exception. None of my old code now works if I recompile it.</p> <p>I've searched everywhere but can't find a solution to this problem - any idea what is going on here?</p>
java
[1]
4,498,639
4,498,640
How to share data in facebook
<p>How to share data in Facebook through android application. is that any Intent call used to share our data in Facebook. I searched in google but i dint get any proper guidance. if anyone did this issue pls guide me. </p>
android
[4]
5,334,710
5,334,711
Casting double to int like java
<p>I need some help casting a big double to int, in java:</p> <pre><code>(int)System.currentTimeMillis(); //result -186983989 (java) </code></pre> <p>The result always return the int32.minvalue, but I need the same result as java. but in C#:</p> <pre><code>DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); TimeSpan span = DateTime.UtcNow - Jan1st1970; Int32 resultado = (int)span.TotalMilliseconds; //result is always -2147483648 and i need same as java </code></pre> <p>Thanks in advance, can see this image <a href="https://public.blu.livefilestore.com/y1pwU6fnT0v663NPqa7cSwwU9MSFQeO1TjdOdip1GFn8Eqg0Fgo_rsA3ER2jw5RDpXGOa1WiMc_PFIzzjxkqWe9zQ/wtf.png?psid=1" rel="nofollow">https://public.blu.livefilestore.com/y1pwU6fnT0v663NPqa7cSwwU9MSFQeO1TjdOdip1GFn8Eqg0Fgo_rsA3ER2jw5RDpXGOa1WiMc_PFIzzjxkqWe9zQ/wtf.png?psid=1</a>.</p>
c#
[0]
4,569,544
4,569,545
Can't get Python to import from a different folder
<p>I can't seem to get Python to import a module in a subfolder. I get the error when I try to create an instance of the class from the imported module, but the import itself succeeds. Here is my directory structure:</p> <pre><code>Server -server.py -Models --user.py </code></pre> <p>Here's the contents of server.py:</p> <pre><code>from sys import path from os import getcwd path.append(getcwd() + "\\models") #Yes, i'm on windows print path import user u=user.User() #error on this line </code></pre> <p>And user.py:</p> <pre><code>class User(Entity): using_options(tablename='users') username = Field(String(15)) password = Field(String(64)) email = Field(String(50)) status = Field(Integer) created = Field(DateTime) </code></pre> <p>The error is: AttributeError: 'module' object has no attribute 'User'</p>
python
[7]
4,359,127
4,359,128
Strange problem with NSMutableArray - Possibly some memory corruption
<p>I am trying to update data in a table view using a NSMutableArray. Quite simple :(</p> <p>What is happening is that I get my data from a NSURLConnection Callback, which I parse and store it in an array and call reload data on the table view. The problem is that when cellForRowAtIndexPath is called back by the framework. The array still shows the correct count of the elements but all string objects I had stored earlier are shown as invalid.</p> <p>Any pointers</p>
iphone
[8]
2,872,541
2,872,542
Java Set of Bytes
<p>Hello Can anyone help me to know how can I have a "Set" of Bytes in Java? Thank you</p>
java
[1]
211,298
211,299
How do I format my String to include the needed white space?
<p>I have a String that I want to format in Java. Here is my code:</p> <hr/> <pre><code>import java.util.*; public class Test{ public static void main(String[] args){ String a = "John College of NY NY 10286"; a = removeSpaces(a); System.out.println(a); } public static String removeSpaces(String s) { StringTokenizer st = new StringTokenizer(s," ",false); String t = ""; while(st.hasMoreElements()){ t = t + ";" + st.nextElement(); } return t; } </code></pre> <p><hr/> <BR> When I run my code I get this back: (don't mind the semicolon in the front) </p> <hr> <pre><code>;John;College;of;NY;NY;10286 </code></pre> <p><hr> <BR> The output text should be separated by a semicolon in three parts like so, and it should preserve the 1 or 2 white spaces in the last two: <BR></p> <hr> <pre><code>;John;College of NY;NY 10286; </code></pre> <p><hr> I am not sure how to keep the the white space between "College" and "of" &amp; "of" and "NY". Or the two white spaces between "NY" and "10286". How can I format the line? </p>
java
[1]
4,095,604
4,095,605
(string) and .toString and other typecasting why is it needed?
<p>may i know why is there .toString() when you can use (String) instead? and vice versa and also for numbers can use the wrapper class's so why do we need to have a (double)? etc</p>
java
[1]
5,425,420
5,425,421
Remove all occurrences except last?
<p>I want to remove all occurrences of substring = <code>.</code> in a string except the last one.</p> <p>E.G:</p> <pre><code>1.2.3.4 </code></pre> <p>should become:</p> <pre><code>123.4 </code></pre>
javascript
[3]
5,994,339
5,994,340
jquery "html" function returns weird behaviour
<p>i used jquery "html" function:</p> <pre><code>$('#color .updateMoney').html('1'); </code></pre> <p>to replace a certain string but instead it replace the content with an anchor wrapping like this:</p> <pre><code>&lt;a xmlns="http://www.w3.org/1999/xhtml"&gt;1&lt;/a&gt; </code></pre> <p>Why is that so?</p>
jquery
[5]
2,064,502
2,064,503
How can i play animation of frames in an activity
<p>i have individual frames in jpg stored in a folder on SD card. I would retrieve them and then what i want is that i want to play these frames 1 by 1 in an activity. How do i play animation of those in an activity?</p> <p>i want the playing to be smooth. A small example would suffice! Help appreciated! Thanks</p>
android
[4]
4,300,938
4,300,939
how to determine that the navigation bar's back button has been clicked and then showing a alert
<p>working on a game based project.i am having a view controller as GameScreen. on the top of Gamescreen having a navigation bar with back button(default).Now if user clicks on back button i have to show alert. so how to determine "backbutton got clicked."? any suggestion? Thanks </p>
iphone
[8]
5,796,305
5,796,306
What is the correct return type of strpos? Searching for the '@' char
<p>For example I have a string <code>I am @ the penthouse.</code></p> <p>I need to know how to find the character "@" in php string and the position of the character.</p> <p>I tried strpos but its not working.</p> <p>Thanks for the help in advance.</p> <p>EDIT:</p> <p>I've been using this for get the character:</p> <pre><code>$text = "I am @ the penthouse"; $pos = strrpos($text, '@'); if($pos == true) { echo "yes"; } </code></pre>
php
[2]
5,060,789
5,060,790
calculate different number when run each time
<p>i have a multimap in which there are 1000 numbers. Now i need to generate a random number. say its 560. then i will take 560th element of an array. i used rand.</p> <pre><code>int number = 0; int size = mmap.size(); int rand = rand() % size + 1; </code></pre> <p>but the problem is , i am running this program n times. each time, i am getting same number of random values. How to generate random values each time when i run the program.</p> <pre><code> i tried using including random library. it gave error when i compile. </code></pre>
c++
[6]
4,640,015
4,640,016
How calculate checksum using 8-bit addition of all bytes in the data structure
<p>I need to calculate checksum from byte array. Its some serial port packet. I have just this text: </p> <p>Checksum is calculated using 8-bit addition of all bytes in the data structure.Overflows are not taken into account (1 byte).</p> <p>How do 8-bit addition?</p> <p>Need it in C#.</p>
c#
[0]
388,405
388,406
how to show form questionery after button ok click in confirmation jquery
<p>i want to show form questionery after button ok click in confirmation jquery.thanks...</p> <pre><code>$("input[value='Close']").click(function () { var ValidComment = document.getElementById('comment_update').value; if (ValidComment == '') { $("#ErrorUpdate").text("Comment is Required"); return false; } else { return confirm('Are you sure to close this ticket ?'); --show form here-?? } }); </code></pre>
jquery
[5]
6,009,681
6,009,682
In Python how to construct a str for help(object)
<p>I need a str object created out of the text displayed in help(some_object). simply typecasting to str doesn't work.</p> <pre><code>&gt;&gt;&gt; s = str(help(object)) &gt;&gt;&gt; print s None </code></pre> <p>Whats the correct way to do this ?</p>
python
[7]
1,267,075
1,267,076
How apple transfer money to iphone developer
<p>I know that iPhone developer needs developer certificate $90/yr and all this transaction done via cradit card. How actually apple transfers money to the developer. I am a novice Indian developer dont know how the actual process works.</p> <p>I accept that this is not a programming topic. Yet its a programmer topic. </p>
iphone
[8]
3,920,999
3,921,000
Loading webview within application
<p>I am trying to load a web page within my application. </p> <p>I have added the permission</p> <p>In the xml layout I add the webview within my Relative Layout:</p> <pre><code>&lt;WebView android:id="@+id/webview" android:layout_marginLeft="250px" android:layout_marginTop="80px" android:layout_width="180px" android:layout_height="160dip" /&gt; </code></pre> <p>I then call this within a button:</p> <pre><code> WebView MyWebView = (WebView) findViewById(R.id.webview); MyWebView.getSettings().setJavaScriptEnabled(true); MyWebView.loadUrl("http://www.stackoverflow.com"); </code></pre> <p>But this opens a new browser within my application when I want it to only open it within the height and width.</p> <p>Thanks </p> <p>Edit: Forget this, it works now, I have moved my whole application to a new one and it works great :)</p>
android
[4]
5,912,370
5,912,371
How to combine 2 arrays into 1 array
<p>I have 2 arrays like that:</p> <pre><code>array1 ( [0] =&gt; Array ( [id] =&gt; 133 ) [1] =&gt; Array ( [id] =&gt; 134 ) ) array2 ( [0] =&gt; 1 [1] =&gt; 2 ) </code></pre> <p>My problem is: how can I combine two arrays into one array like:</p> <pre><code>array3 ( [133] =&gt; 1 [134] =&gt; 2 ) </code></pre> <p>Thanks for any help :D</p>
php
[2]
1,124,195
1,124,196
register my application via url
<p>The principle is to attach a URL like: IDL://user:password When the user click the button connect, we get identifying information and we lunch connection.</p> <p>The application will be opened at the beginning of a relationship of type "idl://".</p> <p>The application will be able to automatically authenticate the user whose credentials will be added to the URL as: idl://username: password.</p> <p>Does any one have an idea how can i do this?</p> <p>thanks</p>
android
[4]
955,597
955,598
Providing context for JQuery ID selector helps?
<p>For performance, which is faster?</p> <pre><code>$('#' + strControlId); </code></pre> <p>or</p> <pre><code>$('#' + strControlId, $('#' + strContextId)); </code></pre>
jquery
[5]
5,036,428
5,036,429
How does java get to know which implementation object of interface to return?
<p>Please be gentle while answering, I am not a java developer (or developer in General)</p> <p>While trying xml parsing with java I came across following - </p> <pre><code>NodeList nodelist = document.getElementsByTagName("item"); </code></pre> <p>Herein xml dom object let me collect all objects depending on tag name I provide, but return type is an Interface called - nodelist. Since interface can not be instantiated it was a bit surprising for me.</p> <p>Keeping break point and debugging the code I realized that I actually get object for class DeepNodeListImpl which implements NodeList interface. </p> <p>How does this happen? How does java know to return object of "some implementation" held by my Interface "object" in the statement declared above.</p> <p>One more thing - while reading the java <a href="http://download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/NodeList.html" rel="nofollow">api</a> I found that IIOMetadataNode implements the NodeList but my previous code snippets does not get me object of type IIOMetadataNode </p>
java
[1]
5,040,525
5,040,526
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c
<p>This is one of the culprit characters: œ</p> <p>I need to be able to make the string UTF-8 somehow.</p> <p>Please note that files are UTF-8 and that the origin of the string is a client socket connection. I need a way to convert any non UTF-8 string to UTF-8.</p> <p><strong>EDIT:</strong> My solution is good enough for my case where the problematic characters are extras that I can discard safely. They are the result of the fact that I cannot control all clients that connect to my server and some clients seem to be sharing a common socket library or something that ads the extra characters. Normal they should not be there as the entire transmission should only contain UTF-8.</p> <p>I would however be more then happy to chose any answer that gives me a general solution that can convert the string to UTF-8 not just some copy pasted answers from the first Google result like some people just did to get some extra experience. </p> <p>I don't care if I convert or remove the extra characters the data sent is something to be analyzed by humans so it does not matter, but a real solution does.</p> <p>Can someone actually think for once and come up with a fully working solution?</p>
python
[7]
4,693,378
4,693,379
Error: "jQuery is not defined", but jquery is loaded
<p>but trying to operate jquery validate plugin 1.6 but im getting this error in Chrome inspector:</p> <blockquote> <p>Uncaught ReferenceError: jQuery is not defined. ------ jquery.validate.min.js:15</p> </blockquote> <p>I'm loading jquery 1.4.4 in my page.</p> <p>Any idea?</p> <p>Regards</p> <p>Javi</p>
jquery
[5]
1,792,598
1,792,599
Mega Dropdown menu seen on sitepoint: How do I show the menu on mouse click
<p>Is there a way to display the dropdown menu shown on sitepoint by mouse click. <a href="http://www.sitepoint.com/blogs/2009/03/31/make-a-mega-drop-down-menu-with-jquery/" rel="nofollow">http://www.sitepoint.com/blogs/2009/03/31/make-a-mega-drop-down-menu-with-jquery/</a></p> <p>Currently, it shows the menu only on mouse hover.</p>
jquery
[5]
5,282,008
5,282,009
LNK4221 and LNK4006 Warnings!
<p>I basically making a static library of my own. I have taken my code which works and now put it into a static library for another program to use. In my library I am using another static library which I don't want the people who will be using my API to know. Since, I want to hide that information from them I can't tell them to install the other static library. Anyway, I used the command line Lib.exe to extract and create a smaller lib file of just the obj's I used. However, I get a bunch of "LNK4006 :second definition ignored" linker warnings for each obj I use followed by "LNK4221 no public symbols found;archive member will be inaccessible".</p> <p>I am doing this work in vs2008 and I am not sure what I am doing wrong. I am using the #pragma comment line in my .cpp file I have also modified the librarian to add my smaller .lib along with its location. my code simply makes calls to a couple functions which it should be able to get from those Obj file in the smaller lib. All my functions are implemented in .cpp file and my header just have the includes of the third party header files and come standard c++ header files. nothing fancy. I have actually no function definitions in there atm. I was going to put the API definition in there and implement that in the .cpp for this static lib that i was going to make. However, I just wanted to build my code before I added more to it. s</p> <p>Any help would be appreciated. is this a vs2008 configuration issue? or a program issue I am not sure. </p> <p>thanks for the help!</p> <p>here is what I researched... <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;815773" rel="nofollow">http://support.microsoft.com/default.aspx?scid=kb;EN-US;815773</a></p> <p>no solution to it there however....</p>
c++
[6]
5,746,963
5,746,964
How can i measure steps while walking or jogging with Android?
<p>Is it the SensorManager API that i have to use to measure steps? Any sample code or tutorial?</p>
android
[4]
2,786,286
2,786,287
logical problem in mailing a HTML File
<p>I want to send and HTML file using JSP. But the problem is..<br> 1) When we develop any HTML File we mention some CSS and JavaScript files.<br> 2) So, when i am sending the file, it is missing all the format what i defined in other page(in form of CSS and javascript).<br> 3) So, now I want to implement such a logic by which, it can read all the CSS and JavaScript file and send it with mail together.<br> 4) With same file position and structure. That is, i want to maintain the directory position of CSS and JavaScript.<br> 5) It is possible, but for this i would have to send the CSS/JS file also.That thing i don't want to do explicitly. </p> <p>Some possible solution what i thought before asking here.......<br> a) I can add all CSS/JS contents in HTML file, so that it will go with html file at the single time.<br> b) But it is ok with one or two file. But if I have plenty of files in my website then I would have to copy this content in all file which i don't want.<br> c) zip all the file together and mail it. But, it also i don't want. I want to mail only .HTML file.<br> d) I can read HTML file and read the file which has included or added in HTML and mail it implicityly. but in this case, directory structure will not be mentened. </p> <p>I know it is different type of question. I don't want the code. I just want the logic..<br> Plz help me...</p>
java
[1]
5,297,992
5,297,993
Dilemma working with skillful subordinates
<p>This is not a technical question but more to managing technical expectation to myself. Currently i am just along managing website (WP based), managing web services, do some web development works in this company. Some projects i need to outsource, manage the outsourcing until the project is complete. I am not a powerful PHP developer (i just have the basics), but i love Wordpress, so most of the project i use WP as the platform.</p> <p>Even i am alone, i am quite happy because my work more to managing than doing the hard coding. But the time has come i need to grow this team, i have found skillful developer and designer to join my team. They are very skillful, have great portfolios.</p> <p>My boss want me to find a great team so my team can grow. My dilemma now is i am afraid if i approve the new candidates to my team than maybe i will be removed from the team sooner or later since i am not skillful as them, even i am more senior than them in this company.</p> <p>On the other hand, i heard it is great to work with more skillful person as you can develop yourself faster. </p> <p>Now i am stuck which way to choose.</p>
php
[2]
1,230,408
1,230,409
Declare & set multiple variables
<p><strong>I always though that if I declare these three variables that they will all have the value 0</strong></p> <pre><code>int column, row, index = 0; </code></pre> <p>But I find that only index equals zero &amp; the others are junk like 844553 &amp; 2423445.</p> <p>How can I initialise all these variables to zero without declaring each variable on a new line?</p>
c++
[6]
2,027,425
2,027,426
PHP - check json value after one hour
<p>I have created a function, which get twitter count using json.</p> <p>But, I want to recheck it agian after some time, like an hour. But currently it checks every time when a page loads. and which effect page loading time.</p> <p>there is already a PHP function which do exactly what i want, but I cant remember it, I just remember that the function start from <code>tr....</code> </p> <p>Here is my function, which check twitter follower :</p> <pre><code>function follower( $tw ) { $tw = @json_decode(file_get_contents('http://api.twitter.com/1/users/show.json?screen_name='.$tw)); $tw_followers = number_format($tw-&gt;followers_count); return $tw_followers; } </code></pre> <p><strong>EDIT:</strong></p> <p>I found that PHP function:</p> <pre><code>set_transient('follower', $tw_followers, 60*60*24); </code></pre> <p>please guide me if I am wrong</p>
php
[2]
4,704,141
4,704,142
How to convert byte to the same string in Java
<p>I try to convert byte to the same string. Such as below:</p> <pre><code>byte b = (byte)0xAA; </code></pre> <p>Then, convert byte b to the same string as below:</p> <pre><code>String s = "AA"; </code></pre> <p>How can I do it?</p>
java
[1]
4,232,977
4,232,978
In Android is it possible to transfer ownership of a touch event?
<p>I am developing a modal movie player that changes mode based on gestures. At the moment the different modes are separated into individual ImageViews, since each mode's composition and interaction is distinct.</p> <p>I am holding the views in a single ViewGroup. The ViewGroup will ensure that only one ImageView is visible at any time. The views will be togged via gestures.</p> <p>One such gesture is a drag. Currently I am handling gestures within the ImageViews, and via callbacks triggering the ViewGroup to switch views.</p> <p>I am having a problem with transfer of the move action from the current view to the switched view. The current view detects the move touch event, then triggers the switch. However, the new view does not see the remainder of the touch event.</p> <p>My question is, is it possible to transfer ownership of a touch event from one view to another?</p>
android
[4]
3,027,771
3,027,772
How to create a library and call the header files using < > instead of ""?
<p>I've been writing a library lately for my C++ computer class. I would like to put all my .lib and my header files inside a folder outside the project that's going to be calling the library. How can I call the library header files using the &lt; > operators instead of the " "?</p> <p>I'm using visual studio [specifically VS03]</p> <p>Thanks, Y_Y</p>
c++
[6]
3,896,844
3,896,845
UITable first section contains a
<p>So, I can provide a picture in a bit if that would help clarify.</p> <p>I currently have a UITableView with alot of rows. The first row of the table is a search bar. Great, works fine.</p> <p>I've just added "plain" indexes, alphabetic headings before each section displayed in the table. I've also added right most index for jumping quickly to any section.</p> <p>However, since the UISearchBar is part of the of the table (the first element) when the UISearchBar is drawn, it pushes the UISearchBar over a bit, squishing it. It looks silly. One option is not make the UISearchBar part of the table, but I have no where else to put it.</p> <p>Any idea how to get the right most index to sit over the UISearchBar?</p> <p>Thanks, </p> <ul> <li>sk</li> </ul>
iphone
[8]
393,935
393,936
How can I find the sum of two numbers which are in String variables?
<p>In this code fragment i can't sum a and b :</p> <pre><code>String a= txtnum1.getText(); String b= txtnum2.getText(); JOptionPane.showMessageDialog(null,a+b); </code></pre> <p>...because a and b defined by String so this code work like this if i'll give a=10 b=20 then my output is 10+20=1020</p> <p>how can i fix it ?</p>
java
[1]
4,385,297
4,385,298
Replacing jars in tc server
<p>I have created two Projects in STS One is common which will be bundles as a jar file in Maven. I have another Project EntWeb which has a depndency on common.jar. The EntWeb will be generated as war file and will be deployed in tc server.</p> <p>The problem now is everytime I change some java files in common project I need do a Maven install in EntWeb project. which is taking more time.</p> <p>Is there a way in tc server I an replace the common jar directly without installing again in EntWeb. Any help would be greatly appreciated.</p> <p>Anand</p>
java
[1]
98,240
98,241
How to: Creat PHP link to KML element
<p>I wrote a lengthy KML file containing multiple Placemark tags -- each has the usual components: name, LookAt, styleURL, Point ... and so on. Now, I want to create links to each placemark from a PHP file. The following link in the PHP file opens the KML file in Google Earth, as expected: (a href="http://www.galapagos.to/kmz/galapagos.kml") (my site name is galapagos.to and the parens are actually angle brakets) Now, I add an placemark id to the above, as follows: (a href="http://www.galapagos.to/kmz/galapagos.kml#Watson") (the "Watson" at the end is the ID of one of the Placemarks. When I click the link in the PHP file, the KML file again opens, but the #Watson at the end is ignored. So the big question -- Is there some way to get a KML file to go to the specified ID name, as is standard practice in HTML files? Any suggestions? thanks, John </p>
php
[2]
498,849
498,850
what's the best way to add a class to the div with a class of post every 4 seconds using jquery?
<p>what's the best way to add a class to the div with a class of post every 4 seconds using jquery?</p> <pre><code>&lt;div class="34 post"&gt; &lt;img width="311" height="417" src="#" class="#" alt="newspapers" /&gt; &lt;h2&gt;&lt;a href="#"&gt;Headline News Part 2&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;testing new content&lt;/p&gt; &lt;/div&gt; &lt;div class="9 post"&gt; &lt;img width="311" height="417" src="#" class="#" alt="newspapers" /&gt; &lt;h2&gt;&lt;a href="#"&gt;Headline News Part 2&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;testing new content&lt;/p&gt; &lt;/div&gt; &lt;div class="6 post"&gt; &lt;img width="311" height="417" src="#" class="#" alt="newspapers" /&gt; &lt;h2&gt;&lt;a href="#"&gt;Headline News Part 2&lt;/a&gt;&lt;/h2&gt; &lt;p&gt;testing new content&lt;/p&gt; &lt;/div&gt; </code></pre> <p>so i want the first to have a class of "display" then after 4 seconds, i want to remove the class on that one and add it to the second one. and then after 4 more seconds, remove it from the second and add it to the third. when it gets to the end it loops back around.</p>
jquery
[5]
1,560,017
1,560,018
DrawRect in CPLayerHostingView?
<p>0 Hi, i am using Core-plot . but when i declare the normal UIView as CPLayerHostingView,how can i handle drawRect of that view , i cant give another custom UIview name and write code in drawRect of that view?please any help to handle drawRect of CPLayerHostingView?</p>
iphone
[8]
296,977
296,978
StatusBarOrientation animation problem on iPad
<p>I'm developing app for iPhone that is show other view each orientation(Portrate and Landscape).</p> <p>and I programed no statusBar animation like this.</p> <blockquote> <p>[application setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];</p> </blockquote> <p>But when I launch app on iPad and rotate it,</p> <p>statusBar Animation occered!</p> <p>Why statusBar Animation setting is ignored?</p>
iphone
[8]
1,003,655
1,003,656
Using roundMinutes in Java
<p>I am trying to get the hour and minute and then round the minutes to the nearest 5. I found the java Calendar class with the roundMinutes function here: <a href="http://www.rakeshv.org/docs/java/rakeshv/org/rakeshv/utils/Calendar.html#roundMinutes%28int,%20int%29" rel="nofollow">enter link description here</a></p> <p>How would I use this in code? I have tried creating a Calendar object, a Date object, but nothing shows me this method to use. Providing an example would be great!</p>
java
[1]
3,985,691
3,985,692
Get the clicked link text in wordpress using javascript
<p>I have website with a side bar links like this</p> <pre><code>Budget NAM Rules Contacts </code></pre> <p>I want the link name When user clicks the link for example he clicked (Rules) JavaScript grabs the link name for me further compare it with an if or switch statement and open the specific page the user clicked.</p>
javascript
[3]
472,280
472,281
how do we pass an arbitrary function to another function
<p>I have a question continuing the post <a href="http://stackoverflow.com/questions/1174169/function-passed-as-template-argument">function passed as template argument</a>. In the provided code:</p> <pre><code>#include &lt;iostream&gt; void add1(int &amp;v) { v+=1; } void add2(int &amp;v) { v+=2; } template &lt;void (*T)(int &amp;)&gt; void doOperation() { int temp=0; T(temp); std::cout &lt;&lt; "Result is " &lt;&lt; temp &lt;&lt; std::endl; } int main() { doOperation&lt;add1&gt;(); doOperation&lt;add2&gt;(); } </code></pre> <p>what about a third function which has a different parameter set layout, e.g.</p> <pre><code>double add3(double v1, double v2) { return v1+v2; } </code></pre> <p>If this is not achievable using template at all, how do we pass an arbitrary function to another function? And how do we handle the parameter set with all kinds of possibilities? I know python may be able to do it by passing a tuple (kwargs**), but not sure about C/C++.</p>
c++
[6]
2,613,868
2,613,869
Voice Recognition in Android
<p>When i click on Voice Search button on Android (SDk 2.2 ) phone then an icon with a mic and text SPEAK NOW appears on phone screen. After speaking any command like "hello" a new screen with text "WORKING" and a progress bar appears. I want to know where does Voice recognition happen and where does actual Voice Analysis takes place?</p> <p>Which APIs can be used to capture both events?</p>
android
[4]
2,856,956
2,856,957
onItemClick ... passing the position in my array to somewhere else
<p>Does the "<code>position</code>" parameter in the <code>onItemClick</code> reference the position in the <code>Adapter</code>, which might include, say, the footer and header as well. I'm asking because I want to be able to pass the actual position in the underlying array that I'm using with my <code>adapter</code>. Can I just pass "<code>position</code>" and I'll be good to go?</p>
android
[4]
5,706,320
5,706,321
Weird behaviour of jquery's hide/show with the 'slide' effect. How to change?
<p>When doing </p> <pre><code>$('.mydiv').show('slide', {direction:up}, 1500); //syntax may be a little off </code></pre> <p>jQuery seems to - just before starting the animation - make room for the soon to be showed div. This creates a non-smooth effect making all elements below the showed div shift away in one big go.</p> <p>I would like to see the elements below the div move away as the div is animated/showed. The jQuery native hide()/show() function works like this, how come the slide effect of hide/show doesn't?</p> <p>Anyone knows how to fix it?</p>
jquery
[5]
3,463,353
3,463,354
jQuery ~ draggable function not work in append object
<p>When I click and append a new div call block2, the draggable drag &amp; stop not work?</p> <p>How to fix it??</p> <p>DEMO: <a href="http://jsfiddle.net/hbGkN/1/" rel="nofollow">http://jsfiddle.net/hbGkN/1/</a></p> <p>HTML</p> <pre><code>&lt;div id="btn"&gt;&lt;input name="click" type="button" value="Click" /&gt;&lt;/div&gt; &lt;div class="block1" style=" width:100px; height:100px; background:orange;"&gt;I am Block1&lt;/div&gt; </code></pre> <p>JS</p> <pre><code>$('#btn').click(function(){ var $newDiv=$('&lt;div class="block2" style=" width:100px; height:100px; background:green;"&gt;I am Block2&lt;/div&gt;'); $( "#btn").parent().append($newDiv); }); $('.block1').draggable({ drag: function() { $('.block1').text('Drag Now!'); }, stop: function() { $('.block1').text('Stop Now!'); } }); $('.block2').draggable({ drag: function() { $('.block2').text('Drag Now!'); }, stop: function() { $('.block2').text('Stop Now!'); } }); </code></pre>
jquery
[5]
5,643,252
5,643,253
date format time ago
<p>I'm still a beginner to PHP, but I need help with something. I got a date format for comments, and I'm trying to insert a "time ago" format. And I'm having trouble with it. This is the code:</p> <pre><code>&lt;?php $name = mysql_real_escape_string($_POST['name']); $comment = mysql_real_escape_string($_POST['comment']); $submit = $_POST['submit']; $date = date("M jS Y | g:i a T"); $ip = "".$_SERVER['REMOTE_ADDR'].""; if($submit) { if($name&amp;&amp;$comment) { $query=mysql_query(" INSERT INTO comment (id, articleid, name, comment, date, ip) VALUES ('','". mysql_real_escape_string($_GET['id']) ."','$name','$comment','$date','$ip') "); header("Location: " . mysql_real_escape_string($_GET['id']) . ""); } else { echo "&lt;div class='red'&gt;You must fill in all fields!&lt;/div&gt;"; } </code></pre> <p>} ?></p> <p>Here's the output:</p> <pre><code>&lt;div class="article-body"&gt; &lt;div class="user"&gt;&lt;b&gt;&lt;?php echo $row['name'] ?&gt;&lt;/b&gt; &lt;span&gt;says:&lt;/span&gt;&lt;/div&gt; &lt;div class="comments"&gt; &lt;?php echo $row['comment'] ?&gt; &lt;br /&gt;&lt;p&gt;&lt;/p&gt; &lt;p style="font-size:12px;"&gt;Posted on &lt;b&gt;&lt;?php echo $row['date'] ?&gt;&lt;/b&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I tried fiddling with a couple codes by using Google, but none successful, as I'm a noob. Haha.</p> <p>Any tuts on this? </p> <p>Thanks!</p>
php
[2]
4,164,614
4,164,615
Option menu style change on change of style of activity in manifest
<p>Initially in the manifest when i don't set any theme inside the activity tag my option menu look like this which is default..</p> <p>But once i set this theme <code>android:theme="@android:style/Theme.NoTitleBar"</code> in the activity tag of my manifest file the option menu style changes.</p> <p>Screen shots after adding <code>android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"</code></p> <p><img src="http://i.stack.imgur.com/FbWW5.png" alt="enter image description here"> Why this happen.</p>
android
[4]
2,376,920
2,376,921
How to get hold of a method name without using magic strings
<p>In java is there any library to get the field name without using any magic strings, for example, for following class</p> <pre><code>class User { int id; int getId() { return id; } void setId(int id) { this.id = id; } } </code></pre> <p>Now what i want is something like this,</p> <pre><code>String fieldName = Utility.getFieldName(User.getId()); </code></pre> <p>this should return text "id" </p> <p>I know this is not achievable by usual means, but I am thinking if it can be done by wrapping the User class with a dynamic proxy (so this would be more like </p> <pre><code>String fieldName = Utility.getFieldName(Utility.createProxy&lt;User&gt;().getId()); </code></pre> <p>) and intercepting the method call and obtaining method name from stack, and use some thread joins to look it like a simple method call when looked at the Utility class. Does anyone knows if there is any library to do this type of operation?</p>
java
[1]
165,528
165,529
Why is my private enum still visible to other classes
<p>I have an enum <code>_levels</code> which is declared as private but it's still accessible to other classes. What I want is to access it by using a property.</p> <p>Please consider my code below.</p> <p>Thanks.</p> <pre><code>public sealed class TestClass { private static TestClass instance = new TestClass(); private enum _levels { A, B, C, D, E, F, G, H, ASE, SE, SSE, TL, AM }; public TestClass(){} public static TestClass Instance { get { return instance; } } public _levels Levels { get { return _levels; } } } </code></pre>
c#
[0]
5,848,938
5,848,939
Application not installing on android emulator
<p>I am developing an application in android Geocoder.When I run the applicaion its showing<br> [2011-01-11 11:08:13 - GeoTourProject] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Name' [2011-01-11 11:08:25 - GeoTourProject] Application already deployed. No need to reinstall. [2011-01-11 11:08:25 - GeoTourProject] \GeoTourProject\bin\GeoTourProject.apk installed on device [2011-01-11 11:08:25 - GeoTourProject] Done!</p> <p>What should i do to install the application on android stimulator....??</p> <p>Thanks in advance Tushar Sahni</p>
android
[4]
542,188
542,189
google v8 - performance for multithreaded applications C++
<p>I precompile and store the context and script. I just run the script in the following funtion. I have a function as follows:</p> <p>Execute{</p> <pre><code> //isolate is a member variable initialized in constructor. v8::Locker l( isolate ); v8::Isolate::Scope iscope( isolate ); v8::HandleScope handle_scope; for(int i = 0; i &lt; 1; i++) { //pV8Item is the object (structure) where is store the persistent handle of context and compiled script ( pV8Item-&gt;contextOrder )-&gt;Enter(); ( pV8Item-&gt;objOrder )-&gt;SetInternalField( 0, v8::External::New(order) ); ( pV8Item-&gt;sRulepCompExp )-&gt;Run() } } </code></pre> <p>I call the above function 100000 times. There is a performance hit on the timing. Any idea on how to improve the performance.</p>
c++
[6]
2,859,003
2,859,004
Operation with complex number
<p>I'd like to know how perform some simple operations with complex number without using the real and the imaginary parts separately.</p> <p>ex:</p> <pre><code> complex&lt;double&gt; A(0.0,1.0); complex&lt;double&gt; B; B=A*2+A; </code></pre> <p>It doesn't compile (error C2678: binary '*' : no operator found which takes a left-hand operand of type 'std::complex' (or there is no acceptable conversion)). I read it's a problem of conversion. That's a problem, especially in the case of more complex code.</p> <p>Does it exist a way to do operations with complex number?</p>
c++
[6]
4,419,007
4,419,008
Android Record Audio
<p>i found that code to record, but I always get:</p> <p>The method setOutputFile(FileDescriptor) in the type MediaRecorder is not applicable for the arguments (Uri)</p> <p>So how would I need to describe the filepath that it works? thx</p> <pre><code>// Prepare recorder source and type MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // File to which audio should be recorded File outputFile = getFileStreamPath("output.amr"); Uri target = Uri.parse(outputFile.getAbsolutePath()); recorder.setOutputFile(target); // Get ready! recorder.prepare(); // Start recording recorder.start(); // Stop and tidy up recorder.stop(); recorder.release(); </code></pre>
android
[4]
4,172,982
4,172,983
how to extend the length of time when fgetcsv function of php is reading csv file?
<p>am having a problem here, i read a csv file using fgetcsv function then loop it, and write it into an xml file...when am using the script in a not so big data, everything works perfectly and writes the xml file....but when i use it in a huge csv, the xml can't finished being written and end up in an unclosed token thing</p> <pre><code> if (($handle = fopen("C:\\xampp\htdocs\yii\branch\seo_tagsdev.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 10000000, ",")) !== FALSE) { $num = count($data); // echo "&lt;p&gt; $num fields in line $row: &lt;br /&gt;&lt;/p&gt;\n"; $row++; for ($c=0; $c &lt; $num; $c++) { $url = $doc-&gt;createElement('url'); $root-&gt;appendChild($url); $loc = $doc-&gt;createElement('loc',htmlentities($data[$c])); $url-&gt;appendChild($loc); $lastmod = $doc-&gt;createElement('lastmod',date('Y-m-d')); $url-&gt;appendChild($lastmod); $freq = $doc-&gt;createElement('changefreq','daily'); $url-&gt;appendChild($freq); $priority = $doc-&gt;createElement('priority',0.9); $url-&gt;appendChild($priority); // echo $data[$c] . "&lt;br /&gt;\n"; } $doc-&gt;save("C:\\xampp\htdocs\yii\branch\seo_tagsdev.xml"); } </code></pre> <p>i even adjusted the length parameter of fgetcsv and yet it doesn't work at all</p>
php
[2]
1,073,178
1,073,179
Pre defined functions vs User Defined?
<p>Im coding in <strong>php</strong> and taking part in a coding competition which gives points to scripts on the basis of memory usage, running time, and ofcourse accuracy of algorighm. I got the algo right and working for all test cases. But I got a little less marks than I expected. To save lines of code, I used strpos() function in a loop. when I changed strpos() function to manually finding string function that I made, my points increased... Now I'm confused... I guess I can make more points if I use my own defined functions instead of all library functions I used (strlen,strpos,etc) ...</p> <p>Does making our own defined functions in scripts help in making the code faster ? I'm not a professional but have worked in php for 3-4 years and never thought of saving time/memory before :P so I'm kinda stuck over here...</p>
php
[2]
4,728,102
4,728,103
Populate a container by clicking a link ...currently it does this on load
<pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $("a").click(function(event) { alert("Thanks for visiting!"); }); }); &lt;/script&gt; &lt;style&gt; div.iframe-link { position: relative; float: left; width: 175px; height: 205px; margin: 0 1em 1em 0; border: 3px solid blue; } a.iframe-link { position: absolute; top:0; right: 0; bottom: 0; left: 0; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;a href="swedish.html"&gt;click link to populate container&lt;/a&gt;&lt;br&gt; &lt;!-- note: it populates the container at load currently ... I only want it to populate after clicking the link --&gt; &lt;div class="iframe-link"&gt; &lt;iframe src="swedish.html?style=sandbeach" style=" border-width:2 " width="175" height="175" frameborder="2" scrolling="no"&gt;&lt;/iframe&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
92,125
92,126
Is there a jQuery method that determines whether an element is currently being animated or not in the form of a boolean?
<p>The reason I ask is because I want to disable clicking of a show button WHILE the element it is animating is in the process of being animated.</p>
jquery
[5]
1,714,532
1,714,533
Need jQuery.load() to return HTML but server-side handler method only accepts POST method?
<p>What do you do if you call the <code>load</code> method like so:</p> <pre><code>$('#result').load('/return_result'); </code></pre> <p>and you get a server error that says </p> <pre><code>Request method 'GET' not supported </code></pre> <p><code>load()</code> seems perfect for what I want to do - return HTML from the server and put it into the <code>#result</code> element.</p>
jquery
[5]
3,909,075
3,909,076
Android: How to check if a pending Notification was delivered?
<p>Is there a way for the sender of a <code>Notification</code> to know when that <code>Notification</code> is delivered to the receiver? i.e. Some method that can check if a the user has clicked on a given <code>Notification</code>.</p> <p>What I'm trying to accomplish is this: Have my <code>Service</code> send a notification with a <code>PendingIntent</code> to start ActivityA. But if the user starts ActivityA without clicking on the Notification, I would like the service to cancel the <code>Notification</code> and send a direct Intent to ActivityA</p>
android
[4]
2,734,140
2,734,141
Python 2.5 dictionary 2 key sort
<p>I have a dictionary of 200,000 items (the keys are strings and the values are integers).</p> <p>What is the best/most pythonic way to print the items sorted by descending value then ascending key (i.e. a 2 key sort)?</p> <pre><code> a={ 'keyC':1, 'keyB':2, 'keyA':1 } b = a.items() b.sort( key=lambda a:a[0]) b.sort( key=lambda a:a[1], reverse=True ) print b &gt;&gt;&gt;[('keyB', 2), ('keyA', 1), ('keyC', 1)] </code></pre>
python
[7]
9,452
9,453
Are array/list lengths and string hashcodes memoized?
<p>Does anyone happen to know if, in .NET (4.0, if it matters), the Length property of an array, or the Count property of a <code>List&lt;T&gt;</code> is stored after it's been calculated, until the array/list is changed?</p> <p>I ask because a record linkage program I'm working on is already horrifically complex enough as it is, and I'd rather not add another O(n) on top of things if I can help it.</p> <p>Along similar lines, is the hashcode of an instantiated System.String memoized? Looking at it through the debugger, I can see that <code>List&lt;T&gt;</code> has a private _size member that <em>could</em> be where Count gets its value, but I see nothing for int[] or string indicating that they store it anywhere.</p> <p>I can see the size vs. speed tradeoff, but can anyone tell me for sure if there are backing fields that hold these? For example, since in C#, strings are immutable, wouldn't it make sense to calculate the hashcode the first time <code>GetHashCode</code> is called, and just store it for every later use?</p>
c#
[0]
4,833,453
4,833,454
Can NSLog crash application?
<p>I am new to iPhone SDK.I am printing each and every array in console.No matter how much data consume.and I note that some times my application is crashing.it gives me BAD_ACCESS and pointer showing on my NSLog line.I am confused can NSLog crash the application? Here is my code : </p> <pre><code>for (int i = 0; i &lt; [UserNeedListArray count]; i++) { EndUserNeed* aEndUser = [UserNeedListArray objectAtIndex:i]; if ([appData.CurrentUser.userId isEqualToString:aEndUser.UserId]) { NSMutableArray* temp = [[NSMutableArray alloc]init]; [temp addObject:aEndUser]; NSLog(@"%@",temp); [arr_ShowMyOnly addObject:[temp objectAtIndex:0]]; NSLog(@"%@",arr_ShowMyOnly); [temp removeAllObjects]; [temp release]; temp = nil; } } </code></pre> <p>Please help me.Thanking you...</p>
iphone
[8]
3,679,052
3,679,053
Javascript - Why do method variables survive within a callback?
<p>Say you have [<a href="http://jsfiddle.net/Wrz6X/" rel="nofollow">Fiddle</a>]</p> <pre><code>function TestMethod() { var lifespan = "blah"; $.ajax({ url: "http://www.google.com", success: function (data) { alert(lifespan); }, error: function (errorData) { alert(lifespan); }, dataType: 'html' }); } </code></pre> <p>Why is it that <code>lifespan</code> still exists when the callback fires? What else persists through asynchronous calls? What allows this to happen, is there some kind of "runtime" ,if you will, in javascript that keeps code alive during the process? If so, when does it know when to start letting in memory items die?</p>
javascript
[3]
2,130,284
2,130,285
How download with php google trends/insign cvs file?
<p>How download with php google trends/insign cvs file?</p> <p>reproduce:</p> <ol> <li><p>go to : <a href="http://www.google.com/trends?q=london%2C+paris&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0" rel="nofollow">http://www.google.com/trends?q=london%2C+paris&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0</a></p></li> <li><p>in this page exist option to download cvs file that have all query result data by click. I need to that by php.</p></li> </ol> <p>Thanks,</p> <p>Yosef</p>
php
[2]
2,805,358
2,805,359
Explicit conversion exists c#
<p>The following line of code presents the title error:</p> <pre><code>ITestClass t = new TestClass(); </code></pre> <p>TestClass implementation:</p> <pre><code> public class TestClass : ITestClass { public static TestClass Instance { get { return TestClass.Instance; } } //Interface members } </code></pre> <p>I have another set of classes with similiar interfaces where this cast works, why doesn't it work here?</p>
c#
[0]
2,479,531
2,479,532
Android library project - how to get context?
<p>I have been happily refactoring code from different versions of the same app (paid/free) into Android library projects so that the actual apps can simply customize the library and reduce code duplication.</p> <p>One thing I'm started to wonder is what getApplicationContext() inside the library code means? Is is the same ApplicationContext as one would get from the child apps? What happens when I access SharedPreferences from a library project's getApplicationContext() instead of the original app's ApplicationContext()? Will the SharedPreferences file be same or different?</p> <p>What if I had used the activity to access SharedPreferences? Does it matter that the activity is now a library activity and not the original app? Is the SharedPreferences the same?</p> <p>Thanks for clarifying.</p>
android
[4]
5,457,235
5,457,236
Creating instances in a loop with different variables
<p>I'm tring to create class instances in a loop. All instances need to be assinged to a different variable. These variables can be a sequence of letters like [a,b,c].</p> <pre><code>class MyClass(object): pass for i in something: #create an instance </code></pre> <p>If the loop turns 3 times, I want the loop make something like that:</p> <pre><code>a = MyClass() b = MyClass() c = MyClass() </code></pre> <p>Is there a way to do that?</p>
python
[7]
5,914,726
5,914,727
Is it possible to use long double as an integer? (adding, substracting, multiplying, dividing, perbit operations ...)
<p>As far as I know in C++ standart <code>sizeof(long double)</code> is 10 byte = 80 bit => the variable of this <code>long double</code> type can carry 2^80 different values. So my question is here, is it possible to write some wrapper or I don't know what (using, maybe, perbit operations). To use <code>long double</code> (or it wrapper) as full integer? And if there is possible, then why standart doesn't give as 80bit integer?</p>
c++
[6]
3,798,681
3,798,682
How can I store the data that populates a div upon an onClick event and then repopulates that div upon refresh?
<pre><code>$('#submit').on('click',function(event){ var timeIn = (document.getElementById("timeIn").value); var timeOut = (document.getElementById("timeOut").value); var aDate = (document.getElementById("datepicker").value); $('#timeIn').val(' '); $('#timeOut').val(' '); $('#datepicker').val(' '); $('.daysContain').find('div').eq(inArray.length-1).append('Time In: ' + timeOut); $('.daysContain').find('div').eq(outArray.length-1).append('Time Out: ' + timeIn); $('.daysContain').find('div').eq(weekArray.length-1).prepend(aDate); }); </code></pre> <p>Im in the process of creating an inner office 'Project-Time' application that will allow employees a way of inputting time spent on a project. The above js function works but now I need a way to retain the data after a refresh. Im not looking for exacts I simply need a push in the right direction (this is the first time I've had to deal with this hurdle). Any <i>good</i> suggestions are welcome- </p>
javascript
[3]
1,362,204
1,362,205
how to back from third viewController to first viewcontroller?
<p>I've a problem that I move from first viewcontroller to third viewcontroller by pushviewcontroller but when i do popViewControllerAnimated it comes to second viewcontroller but I need to come to first. pls some one help me</p>
iphone
[8]
5,508,162
5,508,163
php - how to catch error "Maximum number of allowable file uploads has been exceeded"
<p>I can't seem to catch this just by using PHP. This is what I did:</p> <pre><code>$maxFiles = (int)ini_get('max_file_uploads'); if ($maxFiles &lt; count($_FILES['name'])) { echo 'ERROR'; } </code></pre> <p>But <code>count($_FILES['name'])</code> is always equal to <code>$maxFiles</code> (if the error occurs). And I really don't want to change the condition to <code>==</code> ... it doesn't seem right. </p>
php
[2]
5,058,256
5,058,257
Is assigment simultaneous to indexing valid?
<p>I just discovered this line and I'm wondering if it's valid code. Please note that I don't wonder what it does - that's obvious. I just want to know if it's OK code, academically speaking (and by that I mean that its validity lies in compliance to a standard or at least a generally accepted practice). I know it works in the browsers it needs to.</p> <pre><code>target.src = urls[index = ++index % urls.length]; </code></pre>
javascript
[3]
3,329,301
3,329,302
javascript to rotate an image
<p>i have rotating image in my webpage.<br> link is below: </p> <p><a href="http://equosinfotech.com/testdemo/test.html" rel="nofollow">http://equosinfotech.com/testdemo/test.html</a> </p> <p>everything works fine as i wanted, i just want to slow down the rotation speed of the image as its too fast and i am not able to find a way to slow it down. </p> <p>(you can see the code from the page source) </p> <p>i just need anyone to help me to slow down the rotation. </p> <p>javascript i am using:</p> <pre><code> var stop = function (){ $("#image").rotate({ angle:0, animateTo:0, callback: stop, easing: function (x,t,b,c,d){ // t: current time, b: begInnIng value, c: change In value, d: duration return c*(t/d)+b; } }); } $(document).ready(function() { rotation();​ $("#image").rotate({ bind: { mouseover : function() { stop(); }, mouseout : function() { rotation(); } } }); }); var rotation = function() { $("#image").rotate({ angle: 0, animateTo: 360, callback: rotation, easing: function(x, t, b, c, d) { // t: current time, b: begInnIng value, c: change In value, d: duration return c * (t / d) + b; } }); } </code></pre>
javascript
[3]
3,200,943
3,200,944
How to search for column value in TableLayout?
<p>How to search rows which are dynamically created in table layout of android? I'm having a table layout which contains name and code as columns, how do i search those rows for particular name/code?</p> <p>I'm trying to add tag in this way:</p> <pre><code>TextView empFirstName = null; int i,j; for (i=0; i&lt;employees.size();i++){ final Employee employee = (Employee) employees.get(i); int count = 0; TableRow empData = new TableRow(this); empData.setId(300+count); empData.setClickable(true); /*empData.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT ));*/ //tr.setClickable(true); final TextView empCode = new TextView(this); empCode.setId(300+count); empCode.setText(employee.getCode()); empCode.setTextSize(16); empCode.setPadding(2,2, 2, 2); empCode.setLayoutParams(new TableRow.LayoutParams( 0, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 2 )); empData.addView(empCode); final TextView empName = new TextView(this); empName.setId(300+count); empName.setText(employee.getCallName()); empName.setTextSize(16); empName.setPadding(2, 2, 2, 2); empName.setLayoutParams(new TableRow.LayoutParams( 0, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 4 )); empData.addView(empName); empFirstName = new TextView(this); empFirstName.setId(007); empFirstName.setText(employee.getFirstName()); empFirstName.setTag(i); } </code></pre> <p>I'm trying to use setTag(), how do i retrieve value of text using getTag()}</p>
android
[4]
3,597,359
3,597,360
image preview in javascript
<p>The following code doesn't work in Firefox and Chrome but works in IE. Can anyone tell me why it doesn't work in browser except IE with solution. Thanks in advance.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function hello() { var a=document.getElementById("upload").value; alert(a); document.getElementById("previewIMG").src=a; document.getElementById("previewIMG").style.display="block"; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="img" enctype="multipart/form-data"&gt; &lt;input type="file" name="upload" id="upload" /&gt; &lt;input type="button" name="submit" value="Upload Me Now" onClick="javascript:hello();"&gt; &lt;img id="previewIMG" src="" style="display:none;" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
1,583,903
1,583,904
How to put two data sources in the same listView?
<p>I have a search page get data from two sources:</p> <p>1- my data base</p> <p>2- web service function</p> <p>How to put this two data sources in my list view?</p>
asp.net
[9]
4,018,849
4,018,850
Declaring a data type dynamically in C++
<p>I want to be able to do the following:</p> <p>I have an array of strings that contain data types:</p> <pre><code>string DataTypeValues[20] = {"char", "unsigned char", "short", "int"}; </code></pre> <p>Then later, I would like to create a variable of one of the data types at runtime. I won't know at compile time what the correct data type should be.</p> <p>So for example, if at runtime I determined a variable x needed to be of type int:</p> <pre><code>DataTypeValues[3] x = 100; </code></pre> <p>Obviously this won't work, so how could I do something like this?</p>
c++
[6]
3,137,631
3,137,632
Trouble with Variable value in function
<p>I have the following script where a variable gets its value from an input field, however when I run my function its not working, returns nothing. Im new to JS so im unsure if it needs to be part of a function *even though Ive tried this with no luck) or what...</p> <pre><code>///////////////////////////////////////////////////////////////////// // Variables // Content/SLA var ContentMinutes = ''; var ContentMinutesSelector; // Switch Case var ServiceLevel = 5; var NoOfFrames = 2; // Render Time (Hairier the Better) var AvgFrameRenderTime = ''; var AvgFrameRenderTimeSelector = 10; // Switch Case var CoresInTest = document.getElementById('CoresInTest').value; // Other var EstimatedCoreHours = NoOfFrames * CoresInTest * AvgFrameRenderTimeSelector; // Cost Estimate var CostEstimate = ServiceLevel * EstimatedCoreHours; ///////////////////////////////////////////////////////////////////// // Functions function CalculateEstimate() { // Estimate Cost parseInt(document.getElementById("PriceEstimate").innerHTML=CostEstimate.toFixed(2)); // Estimate Core Hours parseInt(document.getElementById("EstimatedCoreHours").innerHTML=EstimatedCoreHours.toFixed( 2)); } </code></pre> <p>my PriceEstimate and EstimatedCoreHours fields are both just empty divs, <code>&lt;div id="EstimatedCoreHours"&gt;&lt;/div&gt;</code>, My calculations work if i define a value for the variable as opposed to <code>document.getElementById</code> so I believe I must need to run a function or something to update all the vartiables?</p> <p>But if I set...</p> <pre><code>var CoresInTest = document.getElementById('CoresInTest').value; </code></pre> <p>to</p> <pre><code>var CoresInTest = 10; </code></pre> <p>Then it works fine...</p> <p>Its not actually my return, the problem is my variables arent calling, IF i define them with a number then it works.</p>
javascript
[3]
4,286,144
4,286,145
Why does the concat method seem to ruin my Array reference
<p>Why does this not alert a,b,c?</p> <pre><code>var results=[]; function test(r){ var abc = ['a','b','c']; r=r.concat(abc); } test(results); alert(results); </code></pre>
javascript
[3]
600,167
600,168
UI design for Arabic Support apps in Android
<p>Hi <br> I am trying to provide Arabic Language support for my Android App. Arabic Language support is provided by default by Android 2.3. So, I want to know are there any UI changes that I need to change while providing support for Arabic language support in Android . As the letters in Arabic were written from right to left , what are the constraints that I need to follow in Android UI layout design and also in coding . Or else otherwise will Android itself will take care of reading the data we entered ,whether it is typed from right to left.</p> <p>Can anyone help me in sorting out this issue? <br></p> <p>Thanks in Advance,</p>
android
[4]
2,689,641
2,689,642
Error creating object in IE8
<p>I have the following code:</p> <pre><code> var APP= APP || {}; APP.settings = { apiRoot: "http://localhost/appapi", siteRoot: "http://localhost", }; </code></pre> <p>This code works in Chrome and Firefox but is throwing an error in IE8, <code>Unable to set value of the property 'settings': object is null or undefined</code> </p> <p>This isn't my code so I'm at a bit of a loss to why this isn't working?</p>
javascript
[3]
757,407
757,408
jQuery simple function with callback
<p>hi i'm trying writing down a function wich will do somenthing then bind a callback when finished, i would like to specify the callback when i init the js function...</p> <pre><code> function hello(arg1,arg2,callback){ alert(arg1 + arg2); callback; } hello('hello','world',function callback(){ alert('hey 2); }); </code></pre> <p>sorry for banal question, i'm trying to understand how to pass a callback function to a function :P</p> <p>thanks</p>
javascript
[3]
4,733,270
4,733,271
why don't string object refs behave like other object refs?
<pre><code>string a = "a"; string b = a; string a = "c"; </code></pre> <p>Why does string <code>b</code> still have the value <code>"a"</code> and not <code>"c"</code>?</p> <p>As string is an object and not a stack value type, what's with this behaviour?</p> <p>Thanks</p>
c#
[0]
5,879,608
5,879,609
view on press onpress: Change background color on press? How do I show that the View is being pressed?
<p>Hey, I have, for the time being, a custom view with a 9-patch image as a border.</p> <p>That custom view is placed three times in a LinearLayout, so it looks like this:</p> <pre><code>+------------------------+ | CustomView | +------------------------+ | CustomView | +------------------------+ | CustomView | +------------------------+ </code></pre> <p>I have attached a click event listener to the View, so it is clickable. But then I click it, I cant see that I am clicking it - there is no change in color.</p> <p>So, Im thought that I'd attach a "onPress" listener, and then change the background of the view but I couldnt find such a listener.</p> <p>So, the question is - how do I create the behaviour on the View so I can see that it is being pressed? this is normally done in Android with a green background to indicate that it is now being pressed.</p> <p>Regards</p>
android
[4]
1,311,279
1,311,280
PHP: Is this syntax okay for calling a function with arguments?
<p>I'm wondering if there are any syntactic problems calling a function that only has one argument with multiple arguments. For example:</p> <pre><code>function foobar( $biff ) { // do stuff... } </code></pre> <p>... and then call the function:</p> <pre><code>echo foobar( 'Hello', 'world', '!!!' ) </code></pre> <p>I believe that <code>$biff === 'Hello'</code>, right?</p> <p>And then I will use <code>array_slice( func_get_args(), 1 );</code> to play with the args <code>'world'</code> and <code>'!!!'</code>.</p> <p>Is this right or is this not recommended?</p> <p>P.S. I am working inside a function wrapper, which holds a lot of other functions containing various numbers of arguments.</p>
php
[2]