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,891,369
5,891,370
print_r showing empty results from POST
<p>Why is <code>$email</code> and <code>$pass</code> not printing out, they are posting as empty. I'm getting the following results from <code>print_r()</code></p> <pre><code> [email] =&gt; [password] =&gt; </code></pre> <p>Below is my code. What am i doing wrong</p> <pre><code>&lt;?php $email = $_POST["data[User][email]"]; $pass = $_POST["data[User][password]"]; $base = 'https://api.whatever.com/Api?'; $params = array( 'Format' =&gt; 'json' ,'email' =&gt; "$email" ,'password' =&gt; "$pass" ); $url = $base . http_build_query( $params ); $result = file_get_contents( $url ); echo '&lt;pre&gt;'; print_r( json_decode( $result ) ); echo '&lt;/pre&gt;'; ?&gt; </code></pre>
php
[2]
3,557,602
3,557,603
Problems with adding prime numbers in C++
<p>My code works for numbers up to 300 or 20. But it doesn't work for 2000000. I tried using long instead, but it still didn't work.</p> <pre><code>#include &lt;iostream&gt; bool prime(int i) { bool result = true; int isitprime = i; for (int j = 2; j &lt; isitprime; j++) { ///prime number tester if (isitprime % j == 0) { result = false; break; } } return result; } int main(void) { using namespace std; long sum = 0; for (long i = 2; i &lt;= 2000000; i++) { if (prime(i)) { sum += i; } } cout &lt;&lt; sum &lt;&lt; endl; system("pause"); return 0; } </code></pre>
c++
[6]
4,936,305
4,936,306
two array in Foreach
<p>Good morning, folks.</p> <p>I have a question here.</p> <p>I have three select. Brings first product, quantity brings Second, Third brings value. These are more select muntiplos as an array;</p> <pre><code>Ex: $quantity = "1,2,3"; $value = "20.00,30.00,20.00"; </code></pre> <p>Foreach had to do it.</p> <pre><code> qty value $S ="1 * 20.00"; $S ="2 * 30.00"; $S ="1 * 20.00"; </code></pre> <p>I am sending the page to have two to do the calculation. More not getting to do two foreach with the data value and quantity.</p> <p>Anyone know how I can sum this Vazer?</p> <p>I would be very grateful.</p> <pre><code>EX: &lt;select class="product" name=product[]" id="product[]"&gt; &lt;option value="1"&gt; Plan 1 &lt;/ option&gt; &lt;option value="2"&gt; Plan 2 &lt;/ option&gt; &lt;/ select&gt; &lt;select class="quantity" name=quantity[]" id="quantity[]"&gt; &lt;option value="1"&gt; 1 &lt;/ option&gt; &lt;option value="2"&gt; 2 &lt;/ option&gt; &lt;/ select&gt; &lt;select class="value" name=value[]" id="value[]"&gt; &lt;option value="1"&gt; 20:00 &lt;/ option&gt; &lt;option value="2"&gt; 30.00 &lt;/ option&gt; &lt;/ select&gt; Post $quantity = $_POST["quantity"]; $value = $_POST["value"]; $quantity = explode(',', $quantity_e); $value = explode(',', $value_e); foreach ($quantity as $q &amp;&amp; $value as $v) { // ??? $v = $v * $q; // ???? } </code></pre>
php
[2]
4,749,485
4,749,486
Storing Highlighted text in a variable
<p>Is there a javascript function that will allow me to capture the text that is currently highlighted with the cursor and store it in a variable? I've been trying document.selection.createRange().text but this hasn't been working. Are there any possible alternatives? Here's the code:</p> <pre><code>function moremagic(){ var output = document.selection.createRange(); alert("I Work!");} </code></pre> <p>When I run the function, it doesn't make it to the write statement so I know something is wrong.</p>
javascript
[3]
3,676,222
3,676,223
java the system can not find the file specified
<p>I used Java to copy file but it appeared a exception (the system can not find the file specified).</p> <p>The codes are </p> <pre><code>public static void copyFile(String sourceFile, String destFile){ try { InputStream in = new FileInputStream(sourceFile); OutputStream os = new FileOutputStream(destFile); byte[] buffer = new byte[1024]; int count; while ((count = in.read(buffer)) &gt; 0) { os.write(buffer, 0, count); } in.close(); os.close(); } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>The test codes</p> <pre><code>public static void main(String[] args) { String name = getFileName("D:/z/temp.txt"); String target = "D:/tem.txt"; copyFile(name, target); } </code></pre> <p>the exception is <code>java.io.FileNotFoundException: temp.txt(the system can not find the file specified)</code></p> <ol> <li>The file 'temp.txt' is existence.</li> <li>The path is right no problem.</li> </ol> <p>I guess that is the problem of Permissions. who can come up with the answer thanks!</p>
java
[1]
5,692,799
5,692,800
PHP Pathfinder not returning results
<p>I been trying to make a PHP path finder from examples in other languages and tweaked it for my game's need but its not returning any values.</p> <p>I should note - I get no errors in my error log file either so I'm guessing its a logic mistake?</p> <p>Hope some one can spot it cos i cannot see the mistake =/</p> <p>Code: <a href="http://www.paste.to/NDI3MTE1" rel="nofollow">http://www.paste.to/NDI3MTE1</a></p>
php
[2]
2,393,563
2,393,564
Background server in Android
<p>I need to program a Background "process" that would periodically buffer certain types of data like A, B, C. These data should be available to different Apps. For example App X receives data A and App Y receives data type B through the background.</p> <p>What are my best options for designing such a server?</p> <p>Is "Android Service" the way to go? </p> <p>Can I have a simple C server running natively as a startup process called by init? If yes, how can I make the data available to the Dalvik Apps?</p> <p>Could you provide some starting points?</p> <p>Thanks a lot </p>
android
[4]
3,227,544
3,227,545
checking if a value is one of many constants
<p>In Python, you can:</p> <pre><code>if error_code in (1213,1205,1317,2006,2013): ... </code></pre> <p>How can you concisely do the same kind of check - seeing if an int is one of many choices - in Java?</p> <p>UPDATE: the solution I adopted:</p> <pre><code>private static final Set&lt;Integer&gt; MySQLRetryCodes = Collections.unmodifiableSet(new HashSet&lt;Integer&gt;( Arrays.asList( 1205, // lock timeout 1213, // deadlock 1317,2006,2013 // variations on losing connection to server ))); </code></pre> <p>and then later:</p> <pre><code>if(MySQLRetryCodes.contains(sqlError.getErrorCode()) { ... </code></pre>
java
[1]
1,534,746
1,534,747
How do you use JavaScript?
<p>I'm not a professional programmer, but having a PhD in an engineering field, I've taught myself many programming languages over the years. The past few years I've been using primarily Ruby, and now I'm trying to learn JavaScript so I can do a bit of web programming.</p> <p>I guess like a lot of people, I had a mostly negative impression of JavaScript going in, but as I'm studying the language (through the book JavaScript: The Good Parts by Crockford), I find that the functional part of the language is really neat. I dabbled in Haskell a few years ago, so I had some idea about functional programming.</p> <p>I'm wondering how professional programmers tend to use the language. Do you stick to one paradigm when writing in JavaScript, or do you use it like a swiss army knife, and used different paradigms for different problems? Is there a "most popular" way to use it these days, or does it simply depend on the programmer, problem, company, etc.?</p>
javascript
[3]
5,265,714
5,265,715
How to take input in an array + PYTHON?
<p>Hi I am new to python and want to take input in an array. The python doc is not well described about arrays. Also I think I have some hiccups with the for loop in python.</p> <p>I am giving the C code snippet which I want in python: </p> <p>C Code:</p> <pre><code>printf("Enter howmany elements you want: "); scanf("%d",&amp;n); printf("Enter the numbers in the array: ") for(i=0;i&lt;n;i++) scanf("%d",&amp;arr[i]); </code></pre>
python
[7]
1,603,751
1,603,752
to send a text file to server using javascript
<p>I need to send a text file to server and get it saved. how can i do it using javascript???</p>
javascript
[3]
4,294,520
4,294,521
Creating a simple text file based search engine
<p>I need to create a simple text file based search engine asap (using PHP)! Basically it has to read files in a directory, remove stop and useless words, index each remaining useful word with how many times it appears in each document.</p> <p>I guess the pseudo code for this is:</p> <pre>for each file in directory: read in contents, compare to stop words, add each remaining word to array, count how many times that word appears in document, add that number to the array, add the id/name of the file to the array,</pre> <p>also need to count the total amount of words (after useless removal i guess) in the whole file, which im guessing can be done afterwards as long as i can get the file id from that array and then count the words inside....?</p> <p>Can anyone help, maybe provide a barebones structure? I think the main bit i need help with is getting the number of times each word appears in the document and adding it to the index array...</p> <p>Thanks</p>
php
[2]
1,740,595
1,740,596
Modification of build events and project dependencies programmatically
<p>In my project, I use a template wizard to include projects from project templates. I also need to programmatically set the project dependencies and build actions programmatically. How can I do the same (at runtime) without directly modifying the csproj file?</p>
c#
[0]
5,194,828
5,194,829
Jquery .load and inner jquery .append
<p>Ive just started using jquery for the .load ajax functionality. When i load an external page to a specific div it loads fine. inside the external page there is an .append that .appends javascript to the head. This works on the initial load but when i use .load to load it this portion is not showing. </p> <pre><code>//This is the .load for the div function loadContent(elementSelector, sourceUrl) { url = ""+sourceUrl+""; $(""+elementSelector+"").load(url); alert(url); } //This is the append in the other page that is embedded in a js var cUrl = "http://intensedebate.com/js/genericCommentWrapper2.php?acct="+idcomments_acct+"&amp;postid="+idcomments_post_id+"&amp;title="+idcomments_post_title+"&amp;url="+idcomments_post_url; alert(cUrl); commentScript.type = "text/javascript"; commentScript.src = cUrl; $('head').append(commentScript); </code></pre> <p><strong>EDIT: The alert(cUrl) runs every time. But the head append isnt rendering.</strong></p>
jquery
[5]
4,396,620
4,396,621
How can I print error messages from my function when the arguments are invalid?
<p>I just started to learn Java. There is a course in MIT and there is <a href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-092-introduction-to-programming-in-java-january-iap-2010/assignments/MIT6_092IAP10_assn02.pdf" rel="nofollow">an assignment</a> to write a class for pay calculation. Part of the task is:</p> <blockquote> <ul> <li>The base pay must not be less than the minimum wage ($8.00 an hour). If it is, print an error.</li> <li>If the number of hours is greater than 60, print an error message.</li> </ul> </blockquote> <p>The code I have written is as follows:</p> <pre><code>public class fooCorporation { private float totalPay; private float calc; public float totalPay(double basePay, int hours){ if(hours &lt;= 40){ totalPay = (float) (basePay * hours); } else if(hours &gt; 40){ int extraHours = hours - 40; float payForFortyHours = (float) (basePay * hours); float payForextraHours = (float) (basePay * 1.5 * extraHours); totalPay = payForFortyHours + payForextraHours; } return totalPay; } public static void main(String[] args){ fooCorporation foo = new fooCorporation(); System.out.println("employee 1: " + foo.totalPay(7.50,35)); System.out.println("employee 2: " + foo.totalPay(8.20,47)); System.out.println("employee 3: " + foo.totalPay(10.00,73)); } } </code></pre> <p>The problem I am facing is how to print an error message from the function <code>totalPay()</code> when some conditions are not met. Can the above logic be written in a different way?</p>
java
[1]
842,520
842,521
copy a map into another map
<p>I have a map like this:</p> <pre><code>map&lt;prmNode,vector&lt;prmEdge&gt;,prmNodeComparator&gt; nodo2archi; </code></pre> <p>I need to have an identical copy of this map. How is the fast way to make this? I have tried this: </p> <pre><code>map&lt;prmNode,vector&lt;prmEdge&gt;,prmNodeComparator&gt; copiamap( nodo2archi ); </code></pre> <p>but it doesn't work. The copiamap is empty. Thank you very much</p>
c++
[6]
1,921,944
1,921,945
How to extract first and last strings in a sequence?
<p>I am new to python programming..can someone suggest some way to do the following:</p> <p>The whole data is stored in a file and comes . And I can not disturb the sequence.</p> <p>I want to extract out the first and last nodes of the chains.There are several such chains like this. And the data content is in Giga Byte.</p> <p>I am clueless about how to go about it in python. Can someone be kind enough to help.</p>
python
[7]
4,101,734
4,101,735
getting error like ur view controller and nib file
<p>i have observed 1 warning when i am opening my nib file ,but that doesnt effected my out put .. i want to to know what causes this error its showing ' View Controller' has both its 'View' and 'NIB Name' properties set. This configuration is not supported.</p>
iphone
[8]
6,018,799
6,018,800
Want to animate splash screen in android
<p>I want to add fade in and fade out to splash screen after a few seconds of loading, is there any sample for doing this to my splash layout?</p>
android
[4]
2,419,077
2,419,078
How to create shadow in JSF input field and keep it when the user clicks on it
<p>I have this JavaScript which is used for creating shadow into input field:</p> <pre><code>&lt;!-- input field shadow --&gt; var placeholder = "#{GlassfishController.date}" $("input").on({ focus: function() { if (this.value == placeholder) { $(this).val("").removeClass("shadow"); } }, blur: function() { if (this.value == "") { $(this).val(placeholder).addClass("shadow"); } } }).trigger("blur"); </code></pre> <p>Now the script displays the time format. But when I click with the mouse in the field the text disappears. I want to modify the script to disappear only when I type key. How I can do this?</p> <p>Best Wishes </p>
javascript
[3]
5,299,564
5,299,565
Asp.net how to correct the error
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5482806/asp-net-how-to-correct-the-error">Asp.net how to correct the error</a> </p> </blockquote> <p>I'm designing my web page My code</p> <pre><code>public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { } public void onflbload(object sender,EventArgs e) { // Create a byte[] from the input file int len =flbload.PostedFile.ContentLength; byte[] pic = new byte[len]; flbload.PostedFile.InputStream.Read (pic , 0, len); // Insert the image and comment into the database SqlConnection connection = new SqlConnection( @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI"); try { connection.Open (); SqlCommand cmd = new SqlCommand ("insert into tblphotosetting " + " (BillNo,CustomerName,Address,StartDate,EndDate,Systemurl,Numberofcopies,Amount,Total ) values (@text, @text,@text,@text,@text,@pic,@text,@text,@text)", connection); cmd.Parameters.Add("@BillNo",TextBox1.Text); cmd.Parameters.Add("@CustomerName",TextBox2.Text); cmd.Parameters.Add("@Address",TextBox3.Text); cmd.Parameters.Add("@StartDate",Rdbsdate.SelectedDate); cmd.Parameters.Add("@EndDate",Rdbddate.SelectedDate); cmd.Parameters.Add ("@Systemurl", pic ); cmd.Parameters.Add("@Numberofcopies",TextBox7.Text); cmd.Parameters.Add("@Amount",TextBox8.Text); cmd.Parameters.Add("@Total",TextBox9.Text); cmd.ExecuteNonQuery (); } finally { connection.Close (); } } } </code></pre> <p>My error image and record are not store in my database</p>
asp.net
[9]
2,660,852
2,660,853
How to serialize a Object into a list of parameters?
<p>Without knowing the keys of a JavaScript <code>Object</code>, how can I turn something like...</p> <pre><code>var obj = { param1: 'something', param2: 'somethingelse', param3: 'another' } obj[param4] = 'yetanother'; </code></pre> <p>...into...</p> <pre><code>var str = 'param1=something&amp;param2=somethingelse&amp;param3=another&amp;param4=yetanother'; </code></pre> <p>...?</p>
javascript
[3]
2,602,738
2,602,739
advantages of php over other scripting language
<p>What are the advantages of using php over other scripting languages for website development?? When should we use php??</p>
php
[2]
455,337
455,338
problem with aspx url
<p>i m building website in asp.net when i run my pages i expect that my brower should display url like this <a href="http://www.fixpic.com/uploo.aspx" rel="nofollow">http://www.fixpic.com/uploo.aspx</a></p> <p>but instead of this it displays <a href="http://www.fixpic.com/" rel="nofollow">http://www.fixpic.com/</a><strong>(S(vqr0tz45005i2c450544ut45))</strong>/uploo.aspx</p> <p>what could be the reasons behind it,,might be coz i m trying to make sessions but if that is the case than how can i remove these long characters from the url</p>
asp.net
[9]
1,447,049
1,447,050
Captivate - framework issue
<p>I am a Android developer need quick help on a strange issue with Samsung Captivate. I use <code>android:windowSoftInputMode="adjustPan"</code> for an activity which has a list of EditText in it. The page can expand by adding more EditText views, when it grows long and onFocus of last field soft keyboard pops up and the activity doesn't completely push up. So the EditText view falls behind the soft keyboard.</p> <p>The strange thing is same the activity and same code moves up without any issues for all other Android devices like HTC Aria, Xeperia, etc. Only Samsung Captivate doesn't move up completely, not sure why its device specific. Is it a framework issue?</p> <p>With regards, Visva</p>
android
[4]
1,074,076
1,074,077
www.domain.com not displaying website but www.domain.com/index.php displays it correctly
<p>I have a Php website and I recently renewed the domain and hosting. When I checked www.domain.com it it not displaying website but when I check for www.domain.com/index.php displays it correctly.. what shall I do to make this correct.</p>
php
[2]
2,612,855
2,612,856
Help understanding some C# code
<p>Can someone please explain to me the following method? I don't quite understand what it does, and how it does it.</p> <pre><code>private List&lt;Label&gt; CreateLabels(params string[] names) { return new List&lt;Label&gt;(names.Select(x =&gt; new Label { ID = 0, Name = x })); } </code></pre>
c#
[0]
2,703,142
2,703,143
Possible reasons for not being able to see a control from the codebehind?
<p>I am looking at a Main.Master with a single <code>&lt;asp:Content&gt;</code> control and inside that some ASP.NET login stuff (LoginView, LoginName, etc).</p> <p>I tried adding a <code>Label</code> like so:</p> <pre><code>&lt;asp:LoginName ID="LoginName1" runat="server" FormatString="Welcome {0} &lt;br /&gt;" /&gt; &lt;asp:Label ID="Label1" runat="server" /&gt; </code></pre> <p>but it doesn't show in the codebehind.</p> <p>Any obvious reason for this?</p>
asp.net
[9]
2,443,603
2,443,604
Stop countdown when it reaches to "0"
<p>I want to stop this counter when it reaches to 0, can anyone help me?</p> <pre><code>function countdown() { var i = document.getElementById('counter'); if (parseInt(i.innerHTML)&lt;=0) { } i.innerHTML = parseInt(i.innerHTML)-1; } setInterval(function(){ countdown(); },1000); </code></pre>
javascript
[3]
859,116
859,117
drawing on an android activity
<p>I am trying to put a background image and draw on top of that screen. I assumed activity will have a on draw method, but it does not have. it seems i need to use surfaceview. Can I put a surfaceview on top of the image view and make it transparent ? any example/tutorial i can refer to ?</p>
android
[4]
4,618,706
4,618,707
How to send parameter?
<p>How can I send image path to the function? My code is:</p> <pre><code>&lt;a href="#" onclick="addElement(this.id);" id="cricket" tabindex="1"&gt;Cricket&lt;/a&gt; </code></pre> <p>I want to send my image path in the function <code>addElement</code> along with the <code>id</code>. </p>
javascript
[3]
2,075,480
2,075,481
How do I select all list items in an unordered list that contain a checkbox that's checked?
<p>I have <code>'ul &gt; li'</code> to get all of the list items, but I need to only grab the items that contain a checkbox that's checked. </p> <p>So you can see this visually, it looks like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt; &lt;input type="checkbox" checked="checked"&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="checkbox"&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="checkbox" checked="checked"&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want to pull the 1st and 3rd item.</p> <p>Thanks in advance.</p> <p>So, I have</p>
jquery
[5]
413,217
413,218
Calling upon a method to change textbox value
<p>I have a method called BuyShares() that is supposed to take a value in a textbox and add another user input value to it. I would like to use a messagebox that sets off the method by the user clicking okay. The only problem is that I can't seem to call upon the method. This is the method.</p> <pre><code>public void BuyShares(int anAmount) { int newShares; newShares = GetInvestmentShare() - anAmount; SetInvestmentShare(newShares); } </code></pre> <p>And this is the messagebox I have set up</p> <pre><code> private void button1_Click(object sender, EventArgs e) { DialogResult result; result = MessageBox.Show("Your transaction is complete", "Success", MessageBoxButtons.OK); if(result==DialogResult.OK) { txtStockSharesTab3.Text=?????? } </code></pre> <p>This is a windows form application and the program has several different classes</p>
c#
[0]
2,781,542
2,781,543
How to toggle between images
<p>I currently have a title and an image to the left <img src="http://i.stack.imgur.com/z85fk.jpg" alt="Before text is clicked"></p> <p>When a user clicks on this link a description appears </p> <p><img src="http://i.stack.imgur.com/TkT0C.jpg" alt="Text appears"></p> <p>I do this using:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { $(".hidden").hide(); $("p.show").click(function () { $(this).next(".hidden").toggle() }); $("p.show").hover().css('cursor', 'pointer'); }); &lt;/script&gt; </code></pre> <p>However I would like the image to change when the text appears. I tried using replaceWith but that didn't work. I am still new to jQuery so any advice is great. I don't need an answer but just a pointer on what is best.</p> <pre><code>&lt;p style="color:Black;float:left;padding-top:0px;" class="show"&gt; &lt;img alt="+" src="resources/images/plussign.jpg" style="float:left; margin-right:10px;"/&gt;What is EFM?&lt;br /&gt;&lt;/p&gt; &lt;div class="hidden"&gt; &lt;p style="margin-left:20px;"&gt; &lt;br /&gt;EFM, also known as Ethernet in the First Mile, is an Ethernet leased line service that runs over copper rather than the fibre optic cable used for other Ethernet services. The copper is provided in bonded pairs, making the connection extremely robust. If one copper pair fails, the others remain live, meaning you don’t suffer any downtime and can continue working with reduced bandwidth until normal service is restored.&lt;/p&gt; &lt;/div&gt; </code></pre>
jquery
[5]
5,864,266
5,864,267
binary_search with Pointers
<p>i want to implement binary_search with pointers</p> <pre><code>#include &lt;cstdlib&gt; #include &lt;iostream&gt; using namespace std; int binary_p(int x[],int size,int target){ int *p=&amp;x[0]; int *q=&amp;x[size]; while(p&lt;q){ int mid=(p+q)&gt;&gt;2; if (target==x[*mid]) return 1; else if(target&lt;x[*mid]) q=mid-1; else p=mid+1; } return -1; } int main(int argc, char *argv[]) { int x[]={2,4,6,7,9,10,12}; int size=sizeof(x)/sizeof(int); int target=9; cout&lt;&lt;binary_p(x,size,target)&lt;&lt;endl; system("PAUSE"); return EXIT_SUCCESS; } </code></pre> <p>but here is error list</p> <pre><code> prog.cpp: In function ‘int binary_p(int*, int, int)’: prog.cpp:10: error: invalid operands of types ‘int*’ and ‘int*’ to binary ‘operator+’ prog.cpp:11: error: invalid type argument of ‘unary *’ prog.cpp:12: error: invalid operands of types ‘int*’ and ‘int’ to binary ‘operator*’ prog.cpp:12: error: invalid conversion from ‘int’ to ‘int*’ prog.cpp:13: error: invalid conversion from ‘int’ to ‘int*’ prog.cpp: In function ‘int main(int, char**)’: prog.cpp:30: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result </code></pre> <p>please could anybody give me advise</p>
c++
[6]
267,002
267,003
A function that will loop through span class and add text at the end
<p>I'm trying to do a function, used some pieces of other functions, to loop through the class with a specific name using JS and adding a '*' at the end of whatever is inside those HTML tags. It's not working perfectly, so what do I need to change? The class name is "price".</p> <pre><code>function insertAfter(referenceNode, newNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } function getValues(objName) { var arr = new Array(); var el = document.createElement("span"); el.innerHTML = "*"; arr = document.getElementsByClassName(objName); for(var i = 0; i &lt; arr.length; i++) { var obj = document.getElementsByClassName(objName).item(i); insertAfter(obj, el) } }; getValues("price"); </code></pre>
javascript
[3]
5,454,071
5,454,072
How to play a sound when user touches a particular area on the screen
<p>I am designing an app which consists of an image...</p> <p>I am trying to play sound by using the following code...</p> <pre><code> - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self.view]; if (CGRectContainsPoint(CGRectMake(320,480,0,0),point));//CGRectMake(5, 5, 40, 130), point)) { AVAudioPlayer *player; if(!player){ NSString* resourcePath = [[NSBundle mainBundle] resourcePath]; resourcePath = [resourcePath stringByAppendingString:@"/try.wav"]; NSLog(@"Path to play: %@", resourcePath); NSError* err; //Initialize our player pointing to the path to our resource player = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:resourcePath] error:&amp;err]; if( err ){ //bail! NSLog(@"Failed with reason: %@", [err localizedDescription]); } else{ //set our delegate and begin playback player.delegate = self; [player play]; } } } } </code></pre> <p>In the above code the sound play when touch is detected anywhere on the screen. I want to play 5 different sounds when user touches differern place on the screen(say 1.wav when user touch between 100-200 in width and 50-100 in height). Can anyone please help me how to set the radius and also to play different sounds when touched in the radius specified...</p>
iphone
[8]
5,557,087
5,557,088
Am I taking a risk if I give a distributor an unsigned apk?
<p>A distributor is asking for an unsigned version of my app's apk. Is there some security risk I am taking if I give it to him? I'm not really sure of the purpose of the signature.</p>
android
[4]
1,577,391
1,577,392
MapView Invoking in Android
<p>I can't get the MapView to work in Android.<br> I am currently using this code, and already got my Map API key.</p> <pre><code>public class ShowMap extends MapActivity { private MapController mapController; private MapView mapView; private LocationManager locationManager; public void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.main); // bind the layout to the activity // create a map view RelativeLayout linearLayout = (RelativeLayout) findViewById(R.id.mainlayout); mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); mapView.setStreetView(true); mapController = mapView.getController(); mapController.setZoom(14); // Zoon 1 is world view locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new GeoUpdateHandler()); } @Override protected boolean isRouteDisplayed() { return false; } public class GeoUpdateHandler implements LocationListener { @Override public void onLocationChanged(Location location) { int lat = (int) (location.getLatitude() * 1E6); int lng = (int) (location.getLongitude() * 1E6); GeoPoint point = new GeoPoint(19240000, -99120000); mapController.animateTo(point); // mapController.setCenter(point); } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } } } </code></pre>
android
[4]
4,290,019
4,290,020
How do you make a shared network file read-only using Python?
<p>Using Python, what's the correct way to set a file to be read-only when the file is located on a network share (being served from a Windows 2003 Server)?</p> <p>I'm running Python 2.6.2 in OS X (10.6.1).</p> <p>The following code throws an exception (as expected) when path is local, but <code>os.chmod</code> appears to have no effect when path points to a Windows share.</p> <pre><code>import os, stat path = '/Volumes/Temp/test.txt' # Create a test file. open(path, 'w').close() # Make the file read-only. os.chmod(path, stat.S_IREAD) # Try writing to it again. This should fail. open(path, 'w').close() </code></pre>
python
[7]
3,715,356
3,715,357
Memory Usage estimation
<p>I am wondered about the memory usage of variables and I tried this :</p> <pre><code>#include &lt;iostream&gt; int main() { char* testChar1 = "Hi"; char* testChar2 = "This is a test variable"; char* testChar3 = ""; std::cout &lt;&lt;sizeof(testChar1)&lt;&lt;std::endl; std::cout &lt;&lt;sizeof (testChar2) &lt;&lt;std::endl; std::cout &lt;&lt;sizeof(testChar3)&lt;&lt;std::endl; } </code></pre> <p>output is :</p> <pre><code>4 4 4 </code></pre> <p>I think I am not doing the right thing. I want to know how much memory every variable uses in stack .</p> <p><strong>EDIT 1</strong></p> <p>At the same time if I does <code>char* testChar3 = NULL</code>; the program crashes. So does it mean there is no memory usage for the same?</p>
c++
[6]
2,046,395
2,046,396
How can we set a text field in android that only allow us to enter positive integer number
<p>How can i set a text field in ANDROID that only allow positive integer numbers like 0, 1, 2, 3, 4, and so on</p>
android
[4]
5,935,465
5,935,466
jquery will not submit ajax post requests
<p>Im having a a few javascript gremlins, for some reason my jquery ajax post request is not going out at all. All of my code 'looks' ok, but javascript is not my strong point, can anybody see where im going wrong?</p> <pre><code>$(".deleteWeek").click(function(e){ var answer = confirm("This will delete the selected week. Are you sure?"); if(answer){ $.ajax({ type: 'POST', url: 'http://localhost/todo/index.php/home/ajax_delete', data: { page_id : $(this).attr('id') }, success: tableRedraw(data), dataType: 'html' }) } e.preventDefault(); }) </code></pre> <p>and if it helps, my tableRedraw function:</p> <pre><code>function tableRedraw(data){ $('.week').remove(), $('thead').after(data) } </code></pre> <p>my click event is definitely being registered, i can put alerts in handler and they come up alright, but as far as firebug is concerned, there is nothing happening on the ajax side. Any help would be hugely appreciated.</p>
jquery
[5]
1,048,413
1,048,414
PHP read from a webpage that requires authentication
<p>I'm trying to get the content of a webpage that require authentication using PHP.<br> Ideally, I'd like to use the simple html dom parser: <a href="http://simplehtmldom.sourceforge.net" rel="nofollow">http://simplehtmldom.sourceforge.net</a>.<br> Anyone knows of a way to do this?</p> <p>Edit:<br> Tried the following code:<br> <code>$ch = curl_init();<br> curl_setopt($ch, CURLOPT_URL, $url);<br> curl_setopt($ch, CURLOPT_POSTFIELDS, 'username=' . urlencode($username) . '&amp;password=' . urlencode($pass));<br> curl_setopt($ch, CURLOPT_POST, 1);<br> curl_setopt($ch, CURLOPT_HEADER, 0);<br> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);<br> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);<br> curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br> curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);<br> echo curl_exec($ch);<br> curl_close($ch); </code></p> <p>But now I get a 405 HTTP error.</p>
php
[2]
1,244,865
1,244,866
How to make advertising script be the latest element loaded?
<p>I want to make ads to load last.so,after all the website's page elements are loaded,what code do i need to make an ad load last ?</p> <p>thank you</p>
javascript
[3]
3,927,477
3,927,478
How to get last opened date of an application in android?
<p>I want to get other applications last opened and used date in an android application...</p> <p>Can anybody help on this?</p>
android
[4]
4,129,320
4,129,321
Foreach through different objects but all implement same interface possible?
<p>Suppose I have this</p> <pre><code>interface Movable {//some stuff} </code></pre> <p>And I have</p> <pre><code>class Car implements Movable {//some stuff} </code></pre> <p>And also maybe I have</p> <pre><code>class Bike implements Movable {//some stuff} </code></pre> <p>I noticed that if I had this:</p> <pre><code>ArrayList&lt;Movable&gt; movableThings = new ArrayList&lt;Movable&gt;(); movableThings.add(some kind of Car) movableThings.add(some kind of Bike) movableThings.add(some kind of Bike) </code></pre> <p>This can be called:</p> <pre><code>for(Movable m: movableThings) </code></pre> <p>But if I call this I get incompatible types:</p> <pre><code>for(Bike b: movableThings) </code></pre> <p>Can someone explain, and maybe offer a better way? I know I can use foreach Movable m: movableThings and then use instanceof to check for Bikes but is there another way?</p> <p><strong>Edit:</strong> alright thanks for clarifying guys... so I guess I either use instanceof or redesign my game</p>
java
[1]
2,153,485
2,153,486
JQUERY copy contents of a textbox to a field while typing
<p>I am trying to copy the contents of a textbox into a div simultaneously while the user is typing. Here is <a href="http://jsfiddle.net/6HmxM/" rel="nofollow">THE CODE ON JSFIDDLE</a> The error that is am facing is, <strong>the length of the value copied inside the div is always one less than that of the textbox</strong>. what error am i making in the script?</p>
jquery
[5]
3,531,698
3,531,699
jquery selector negative or null
<p>Is there any selector that do this?</p> <p>Select all input field which value is negative or null.</p> <blockquote> <p>$('input[value&lt;=0]') //this does not work</p> </blockquote>
jquery
[5]
2,450,211
2,450,212
Multiple '@' symbol in email address not working with .net 2005
<p>In our application we send email to user of applications. When our user email address is like paulo.macedo@company.com.br@company, it fails with exception of system.net.mime.mailbnfhelper.readmailaddress</p> <p>So can a email address have multiple '@' symbol and can .net MailMessege object handle it?</p>
asp.net
[9]
4,625,027
4,625,028
assistance with jquery toggle focus
<p>I have in a sidebar:</p> <pre><code>&lt;div id="yyy"&gt; [shortcode]&lt;/div&gt; </code></pre> <p>It outputs a title that when hovered on drops down to show a menu.</p> <p>When hovering on the title a background color shows up and disappears when the mouse moves down to the menu items.</p> <p>I need for the background color to remain as long as the menu has focus, I need something like:</p> <pre><code>If div.domTip_tipBody has focus then #yyy a.tippy_link {background:red;} </code></pre> <p>[The following I got from here][1]</p> <p>I think this will give me what I am looking for but I do not know how to translate</p> <pre><code>.answerSpace to ? .normProf to ? opacProf to ? </code></pre> <p>in:</p> <pre><code>$('.answerSpace').bind('blur', function(){ $('.normProf').removeClass("normProf").addClass('opacProf'); }); $('.answerSpace').bind('focus', function(){ $('.opacProf').removeClass("opacProf").addClass('normProf'); }); </code></pre>
jquery
[5]
3,875,480
3,875,481
Dimen value not working like expected
<p>I'm having trouble understanding the dimen resource attribute.</p> <p>I have 3 value folders: value-normal, value-large and value-xlarge.</p> <p>I have defined the titlesize as 20 for normal, 25 for large and 30 for xlarge, this is my normal value file:</p> <pre><code>&lt;resources&gt; &lt;dimen name="titleSize"&gt;20sp&lt;/dimen&gt; &lt;/resources&gt; </code></pre> <p>But when I try to get this value</p> <pre><code>Resources r = getResources(); tvTitleSize = r.getDimension(R.dimen.titleSize); </code></pre> <p>tvTitleSize is equal to 40 which is offcourse to big. Why is the value the double of the original and how can I fix this? </p> <p>Ps: my device is galaxy nexus.</p>
android
[4]
4,444,499
4,444,500
In what cases legacy Java code would not compile on newer versions
<p>Java is striving to be backward compatible. (It is to such an extent that it crippled its generics for that).</p> <p>But are there situations when old code would not compile on newer versions (more importantly Java 5, and the forthcoming Java 7)</p>
java
[1]
928,965
928,966
Merging 2 collections
<p>How to combine 2 collections in such a way that the resultant collection contains the values alternatively from both the collections </p> <p>Example :- Col A= [1,2,3,4] Col B= [5,6,7,8]</p> <p>Result Col C=[1,5,2,6,3,7,4,8]</p>
c#
[0]
2,211,745
2,211,746
Drawing in Google map
<p>I am developing an application for iPhone,which allows the user to draw a line or select an area on the map.Please any one guide me to implement this.......</p>
iphone
[8]
1,086,510
1,086,511
how to convert array into variables in php
<p>I want to create a function that takes the name of a table and an array with the column name and value to use it to generate an INSERT in MySQL</p> <p>Check my code.</p> <p>Unfortunately this technique does not work as it always generates a comma after each value and this generates an error when entering data. Anyone know a better way to create this function?</p> <pre><code>&lt;?php $arrayDados = array('nome' =&gt; 'Renato', 'idade' =&gt; 24, 'peso' =&gt; 36, 'mae' =&gt; 'neide'); $colunas = ""; $valores = ""; $tabela = 'cadastro'; foreach ($arrayDados as $key =&gt; $value) { $colunas .= $key . ', '; $valores .= $value.', '; } $sql = "INSERT INTO $tabela ($colunas) VALUES ($valores)"; echo $sql;` </code></pre>
php
[2]
3,784,726
3,784,727
Preventing a js file from being called twice
<p>Is there a way to put a variable in a javascript file so that it increments whenever the file is called (like a <code>static</code> var in Java)? I want to use it to prevent calling a js file twice. Or, is there another way to do this?</p>
javascript
[3]
3,494,348
3,494,349
FileNotFoundException when using FileWriter
<p>I am trying to write some message to text file. The text file is in the server path. I am able to read content from that file. But i am unable to write content to that file. I am getting FileNotFoundException: \wastServer\apps\LogPath\message.txt (Access Denied).</p> <p>Note: File has a read and write permissions.</p> <p>But where i am doing wrong. Please find my code below.</p> <p>Code:</p> <pre><code> String FilePath = "\\\\wastServer\\apps\\LogPath\\message.txt"; try { File fo = new File(FilePath); FileWriter fw=new FileWriter(fo); BufferedWriter bw=new BufferedWriter(fw); bw.write("Hello World"); bw.flush(); bw.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } </code></pre> <p>Please help me on this?</p>
java
[1]
1,665,104
1,665,105
How to correctly open UTF-8 files in RichTextBox?
<p>I have a question. This code open fine the txt files with english text, but when I trying to open the txt files with cyrillic text... the cyrillic symbols are "squares". Is it possible to resolve this problem?</p> <pre><code> string fileData = openFileDialog1.FileName; StreamReader sr = new StreamReader(fileData); richTextBox.Text = sr.ReadToEnd(); sr.Close(); SavedFile = saveFileDialog1.FileName; dataTextBox.SaveFile(SavedFile, RichTextBoxStreamType.PlainText); </code></pre> <p>Solution:</p> <pre><code> string fileData = openFileDialog1.FileName; StreamReader sr = new StreamReader(fileData, Encoding.Default); richTextBox.Text = sr.ReadToEnd(); sr.Close(); </code></pre>
c#
[0]
4,865,125
4,865,126
How can i set timer in iPhoneGame app?
<p>i have an game application.I want to set a timer from the beginning upto end.Can any one tell me how to set timer on iphone app?</p> <p>thanks in advance...</p>
iphone
[8]
3,972,211
3,972,212
Flip a DIV onclick
<p>I'm using the <a href="http://lab.smashup.it/flip/" rel="nofollow">Flip!</a> plugin to flip a div on click and revert the flip when a user clicks the div again. The code below makes the DIV flip but does not flip it back when you click it again.</p> <p>JavaScript</p> <pre><code>$(function(){ $("#flipbox").bind("click",function(){ $("#flipbox").flip({ direction:'rl', content:'this is my new content', onEnd: function(){ $("#flipbox").bind("click",function(){ $("#flipbox").revertFlip(); }); } }) return false; }); </code></pre> <p>});</p> <p>HTML</p> <pre><code>&lt;div id="flipbox"&gt; Hello! I'm a flip-box! :) &lt;/div&gt; </code></pre> <p>Appreciate any help.</p>
jquery
[5]
3,378,539
3,378,540
How to display picture in imageview photo taken by camera in android
<p>can anybody tell How to display picture in imageview photo taken by using front camera in android can anybody provide code</p> <p>Thanks</p>
android
[4]
2,210,183
2,210,184
PHP Key value FOREACH
<p>Ok I have a file that is trying to retrive job numbers out of a database call and then put them into key value pairs to return to my jquery function that will export them to my page. I am getting a 500 error when I try to run the page and it is on this page. What am I doing wrong with this output/call?</p> <pre><code>$output = new array(); $job = new job; $jobs = $job-&gt;get_from_db( "`code` = '" . $_GET['term'] . "'" ); foreach ( $jobs as $key =&gt; $current) { $output[$key]['value'] = $current-&gt;code; $output[$key]['id'] = $current-&gt;id; } echo json_encode($output); </code></pre>
php
[2]
3,870,826
3,870,827
jQuery: How to write a function on click, hold and move?
<p>I started learning jQuery just yesterday, and I like it very much.</p> <p>And now I decided to write a script where I can change the <code>margin-left</code> of an image when I click on it, hold the clicking and move the mouse. </p> <p>Depending on mouse coordinates I must change the image's <code>margin-left</code>. Could you give me an idea how I can do it? Thanks.</p>
jquery
[5]
5,182,113
5,182,114
Confused about logcat mode and others
<p>I m new to android. I m confused with the logcat. There are many mode of logcat -verbose,debug,error,info etc. Whats the difference between them.</p> <p>Whats the difference between debug and error? </p> <p>What is stack trace?</p> <p>Difference between logcat and console? </p> <p>Thanx</p>
android
[4]
1,796,424
1,796,425
how I can overcome this error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'const char []'
<pre><code>#include &lt;iostream&gt; using std::cout; using std::cin; using std::endl; #include &lt;cstring&gt; void initialize(char[],int*); void input(const char[] ,int&amp;); void print ( const char*,const int); void growOlder (const char [], int* ); bool comparePeople(const char* ,const int*,const char*,const int*); int main(){ char name1[25]; char name2[25]; int age1; int age2; initialize (name1,&amp;age1); initialize (name2,&amp;age2); print(name1,age1); print(name2,age2); input(name1,age1); input(name2,age2); print(name1,age1); print(name2,age2); growOlder(name2,&amp;age2); if(comparePeople(name1,&amp;age1,name2,&amp;age2)) cout&lt;&lt;"Both People have the same name and age "&lt;&lt;endl; return 0; } void input(const char name[],int &amp;age) { cout&lt;&lt;"Enter a name :"; cin&gt;&gt;name ; cout&lt;&lt;"Enter an age:"; cin&gt;&gt;age; cout&lt;&lt;endl; } void initialize ( char name[],int *age) { name[0]='\0'; *age=0; } void print ( const char name[],const int age ) { cout&lt;&lt;"The Value stored in variable name is :" &lt;&lt;name&lt;&lt;endl &lt;&lt;"The Value stored in variable age is :" &lt;&lt;age&lt;&lt;endl&lt;&lt;endl; } void growOlder(const char name[],int *age) { cout&lt;&lt; name &lt;&lt;" has grown one year older\n\n"; *age++; } bool comparePeople (const char *name1,const int *age1, const char *name2,const int *age2) { return(*age1==*age2 &amp;&amp; !strcmp(name1,name2)); } </code></pre>
c++
[6]
4,580,861
4,580,862
Android scaling image vertically
<p>I am trying to create a mini progress bar that will indicate how much data a user has used. It doesn't even need to animate, I just need it to change in size based on a variable I have set up. So when I load up the screen, how much of the progress bar is filled up will depend on a variable I have set up in Java.</p> <p>I have managed to get this working horizontally by using</p> <pre><code>scale = new ScaleAnimation(0.0f, 1.5f, 1.0f, 1.0f,1.0f, 1.0f); </code></pre> <p>This will start the image from nothing and stretching out to its full size, so I can use it as a horizontal progress bar which is great. </p> <p>Now I woulda thought doing this vertically instead would be a simple matter of just changing the fromY to 0 and the toY to the new size I want. However when I do this, by changing the fromY to 0.0f and the toY to 2.0f, the image actually moves and stretches at the same time rather than stretching. Also the image moves position for some reason. It starts off higher up than where I positioned in using XML, and moves down to the original position and stretches out to the new scale I set up.</p> <p>The code I use to try and stretch it vertically is</p> <pre><code>scale = new ScaleAnimation(1.0f, 1.0f, 0.0f, 2.0f, 1.0f, 1.0f); </code></pre> <p>So can someone please explain why it stretches horizontally fine, but when I try to stretch it vertically, it suddenly moves and stretchs at the same time.</p> <p>Would be very grateful for any help.</p>
android
[4]
517,697
517,698
How do you use collection initializers to create a new dictionary?
<p>If you can do this in List</p> <pre><code>List&lt;int&gt; a = new List&lt;int&gt;() { 2, 4, 6, 8, 10 }; </code></pre> <p>how can you do the same thing in Dictionary?</p> <pre><code>Dictionary&lt;int, bool&gt; b = new Dictionary&lt;int, bool&gt;() { ?, ?, ? }; </code></pre>
c#
[0]
5,936,814
5,936,815
How can I track the reason why an ASP.NET Session times out?
<p>I'm trying to track down an issue on an ASP.NET v3.5 application where the <code>HttpSession</code> times out before its (default) 20 minutes. We're seeing behaviour where the session is lost only a few minutes into a session, at random and with no discernible cause such as unhandled exceptions. As far as I can tell, the ASP.NET worker process is not dying, otherwise that would have explained the dropped session.</p> <p>What approach should I use to monitor when the session is dropped? Is there some event I can listen to, or some other hook in the <code>System.Web</code> namespace?</p> <p>Also, can someone confirm that the countdown to expiration is reset by web activity? That is, the session's lifetime gets reset to the (default) 20 minutes each time the web client makes an HTTP GET or POST?</p>
asp.net
[9]
852,990
852,991
How to know when there is network blip at the time of download using ReadableByteChannel and FileOutputStream?
<p>I would like to download a file of size 50MB using the below code and it works fine. But it was stopped when there is a network blip.</p> <p>How to know when there is problem at the time of download</p> <pre><code> URL finalURL = new URL(downloadURL); ReadableByteChannel rbc = Channels.newChannel(finalURL.openStream()); FileOutputStream fos = new FileOutputStream(localPath); fos.getChannel().transferFrom(rbc, 0, 1 &lt;&lt; 24); </code></pre> <p>Thanks in advance.</p>
java
[1]
2,067,867
2,067,868
Stop AsyncTask in Fragments when Back Button is pressed
<p>i have an activities that host fragments. pressing a button goes from fragment A to fragment B through a FragmentTransaction and the added to the back stack. Now fragment B has an AsyncTask implementation which loads images from an sdcard and publishes it as an image is loaded. if i press the Back button, my app crashes. . The error report indicates that the async task is the problem as it was still loading when the Back button was pressed, so my question is, how can i or where should i stop the AsyncTask when the Back button has been pressed to return to the previous fragment/activity?.. Thank you.</p>
android
[4]
551,352
551,353
When is finally run if you throw an exception from the catch block?
<pre><code>try { // Do stuff } catch (Exception e) { throw; } finally { // Clean up } </code></pre> <p>In the above block when is the finally block called? Before the throwing of e or is finally called and then catch?</p>
c#
[0]
2,670,168
2,670,169
If jQuery is that great, why then browser vendors do not will to build it in?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3279091/why-web-browsers-dont-have-jquery-built-in">Why web browsers don&#39;t have jQuery built in?</a> </p> </blockquote> <p>If jQuery is that great, why then browser vendors do not will to build it in?</p>
jquery
[5]
172,343
172,344
How to create an iPhone app base on the content from a Wordpress site? (Just like the one by Mashable)
<p>I have a WP site. Now wanna create an iPhone app base on the content from my site so that the visitors can read my site easier.</p> <p>I wanna create one just like the iPhone app by Mashable (the Mashable should be based on WP)</p> <p><a href="http://itunes.apple.com/us/app/mashable/id356202138?mt=8" rel="nofollow">http://itunes.apple.com/us/app/mashable/id356202138?mt=8</a></p> <p>Anyone can advise me how should I start? Or any template of such?</p>
iphone
[8]
1,191,101
1,191,102
Java fixed number of elements in an array
<p>When I create an array in Java - int array[] and array=new int[some number] -</p> <p>How can I construct it if I don't know how many values it will hold so that I have enough space in it?</p>
java
[1]
1,256,040
1,256,041
A problem with using System.Collections.Specialized.BitVector32: a bug?
<p>I'm trying to do a short simulation where i needed a small bit array, and I chose System.Collections.Specialized.BitVector32. </p> <p>I'm running it inside a single-threaded object, in a single-threaded loop about 1,000,000 times, each time for indexes {0,1,2}. </p> <p>Here is the code:</p> <pre><code>private System.Collections.Specialized.BitVector32 currentCalc = new System.Collections.Specialized.BitVector32(); private void storeInCurrent(int idx, bool val) { currentCalc[idx] = val; if (currentCalc[idx] != val) { throw new Exception("Inconceivable!"); } } </code></pre> <p>To my understanding, the exception should not be thrown, but sometimes it does! An exception is not thrown every time, but in a fair percent - a CONSTANT 1/6 of the time! (which is even stranger)</p> <p>What am I doing wrong? </p>
c#
[0]
4,818,451
4,818,452
can anybody elaborate single threded model in webapp?
<p>Hi When do we need single threded model in webapp while designing web application in java.</p>
java
[1]
1,155,016
1,155,017
Parse string which contain special character
<p>How to Parse string which contain special character like</p> <pre><code>I ][][came][][][I][][][][Saw][][][][][][I][][][][Won][][][][ </code></pre> <p>Can anyone please solve it</p>
java
[1]
1,601,716
1,601,717
How to do a 3-tier using PHP
<p>I have a requirement from a client for my PHP Web application to be 3-tier. For example, I would have a web server on Apache in the DMZ, but it should NOT contain any DB connections. It should connect to a Middle server that would host the business objects but be behind the firewall. Then those objects connect to my SQL cluster on another server.</p> <p>I have actually done this using .NET, but I am not sure how to setup my stack using PHP. I suppose I could have my UI front tier call the middle tier using REST based web services if I create my middle tier as a second web server, but this seems overly complex.</p> <p>The main reason for this is advanced security: we can not have any passwords on the DMZ first tier web server. The second reason is scalability - to have multiple server on different tiers that can handle the requests. The Last reason is for deployment - it is easier if I can take one set of servers offline for testing before putting them back in production. </p> <p>Is there a open source project that shows how to do this? The only example I can find is the web server hosting files from a shared drive on another machine (kind of how DotNetNuke pretends to be 3-tier), but that is NOT secure.</p> <p>Note: I HAVe looked in SO for this answer, and I do see a lot of similar questions, but have not found anyone that actually answered. This is NOT about a Data Access Layer (although I will use it) - my primary question is the design between UI and the Middle Tier.</p>
php
[2]
2,201,363
2,201,364
Sort list on base of multiple criteria
<p>I would like to sort a list on base of multiple criteria. </p> <pre><code>public class CustomerComparator implements Comparator&lt;Customer&gt; { public int compare(Customer customer1, Customer customer2) { int comparison = -1; comparison = customer2.getCustomerPriority().compareTo(customer1.getCustomerPriority()); if( comparison == 0 ) { comparison = customer1.getCustomerNumber().compareTo(customer2.getCustomerNumber()); } return comparison; } } </code></pre> <p>Basically, I want to sort in following order. Customer with higher priority should be on top of the list, and if two customers have same priority than one with lower customer number should go first. </p> <p>Original:</p> <pre><code>Customer Priority 1 0 2 0 3 1 4 0 5 0 </code></pre> <p>it should be sorted as below:</p> <pre><code>Customer Priority 3 1 1 0 2 0 4 0 5 0 </code></pre> <p>Thanks for help. DD</p>
java
[1]
2,789,170
2,789,171
Merging adapters in android
<p>I am having two different data in two different adapters. Now i want to merge both data in a single adapter. is this possible?? How can I do that?</p> <p>Regards,</p> <p>vani</p>
android
[4]
1,072,649
1,072,650
invalid embedded statement error 88
<p>Why does the following fail:</p> <pre><code>while (true) int a; if(true) int a; if(true) int a = 5; if(true) int a = somestaticfunction(); </code></pre> <p>apperently if fails with: "invalid embedded statement error 88" on visual studio.</p>
c#
[0]
3,493,406
3,493,407
I am using a modal view to display content on the screen but keyboard covering some field
<p>I am displaying a modal dialog but the keyboard is covering some of the editable fields. Is there any way of making the view move automatically...or must I manually write the code required to do this? i.e. change the location of the modal view etc</p> <pre><code>UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:editViewController]; navController.modalPresentationStyle = UIModalPresentationFormSheet; navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [editViewController release]; [self presentModalViewController:navController animated:YES]; </code></pre>
iphone
[8]
886,069
886,070
Taking picture result in a distorted image
<p>I'm using the the Android SDK sample to get an image from the camera. The code below is the only logic I added to the code. Essentially I'm taking the picture converting it to a bitmap and displaying it. Unfortunately this results on a real phone as a distorted image (on the emulator it is just fine)</p> <p>Any help will be appreciated</p> <p></p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch(keyCode){ case KeyEvent.KEYCODE_CAMERA: mCamera.takePicture(null, null,new PictureCallback(){ @Override public void onPictureTaken(byte[] data, Camera camera) { showPicture(data); } }); break; } return super.onKeyDown(keyCode, event); } void showPicture(byte[] data) { if (data != null) { Bitmap picture = BitmapFactory .decodeByteArray(data, 0, data.length); ImageView view = new ImageView(this); view.setImageBitmap(picture); this.setContentView(view); } } </code></pre> <p></p>
android
[4]
2,866,038
2,866,039
how to communicate from PC to Android device?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3803871/android-apps-communicating-with-a-device-plugged-in-the-usb-port">Android apps, communicating with a device plugged in the USB port</a> </p> </blockquote> <p>We can access the android device from PC through USB port. But here i want to do a bit different thing. That is, I want to send message from PC to android device programmatically. That means there are two application one will be installed on android device and the other will be install on PC. I will send message from PC to the device and the device's app will get the message.</p> <p>So how can I do this? Can anyone know the answer or any advice, please answer me.</p> <p>Thanks in Advance, gsmaker</p>
android
[4]
5,898,208
5,898,209
php undefined index..using isset() with is_array()
<p>This is my code:</p> <pre><code>if(is_array($ItemAttr["Actor"])){ $Actors = implode(", ", $ItemAttr["Actor"]); } else { $Actors = $ItemAttr["Actor"]; } </code></pre> <p>I'm getting <code>undefined index: Actor in **line 1** and **line 3**</code></p> <p>I guess i should use isset() function. Can anyone tell me how to combine that function with is_array() function..?</p>
php
[2]
5,255,140
5,255,141
Android notification sounds getting suppressed by system notification
<p>I have a simple app that looks for a pattern of text in the incoming text message, and then alerts. Based on the text, the alert may have to last for a minute (like a pager). Notification alert sound is being set off, but the problem is.. the default SMS notification alert takes over (while my alert is supposed to last for a minute or more).</p> <p>How do I handle this? </p>
android
[4]
2,641,936
2,641,937
Access JS object with a key
<p>I can access a value like <code>driver.my_friends["793659690"].name</code> but now I am using it in a loop where <code>key</code> will hold the key.</p> <p><code>driver.my_friends[key].name</code> doesn't work. Says undefined, and <code>driver.my_friends["key"].name</code> will look for a key named key. So how do I use it so that the variable of the variable is evaluated too.</p>
javascript
[3]
634,819
634,820
Data structure using c++
<p>if we are having are having an array of pointer i.e. </p> <pre><code>struct node*ptr[]; </code></pre> <p>and if we want to initialize its value of first index (<code>ptr[0]</code>) by null then how can we do that?</p>
c++
[6]
2,479,811
2,479,812
How to copy and paste 4th line a another file using python
<p>I have txt file1 contains </p> <pre><code>line 1 line 2 line 3 line 4 line 5 </code></pre> <p>Second text file contains </p> <pre><code>line 6 line 7 line 8 line 9 </code></pre> <p>need to paste all 6,7,8,9 line in file 1 in 4th line how can do this using python</p>
python
[7]
2,865,573
2,865,574
Storing directories/files list
<p>I design a multi-threaded application that will monitor and handle files in selected folders (according to user preference).</p> <p>What is the best way to store information on the files ? (e.g. User add xxx directory, I need to go over the directory and add all the files and sub dir to my application)</p> <p>Should I use a standard database? which one?</p> <p>EDIT: The application is intended to be used on a PC, and the internal database is local. The files/directory tree information will contain a mapping from local location to cloud location.</p> <p>Thanks</p>
java
[1]
4,258,313
4,258,314
jQuery appendTo function not working
<p>Why is my function not working:</p> <p><a href="http://jsfiddle.net/c5r6P/25/" rel="nofollow">FIDDLE</a></p> <p>HTML:</p> <pre><code>&lt;div class="cash"&gt;1234.00&lt;/div&gt; &lt;div class="cash"&gt;123456.00&lt;/div&gt; &lt;div id="total"&gt;&lt;/div&gt; </code></pre> <p>JS:</p> <pre><code>function formatPrice(price) { return price.reverse().replace(/((?:\d{2})\d)/g, '$1 ').reverse(); } // Need to extend String prototype for convinience String.prototype.reverse = function() { return this.split('').reverse().join(''); } $('.cash').each(function(){ $(this).html().formatPrice().appendTo('body'); }); </code></pre> <p>I tried this as well, no luck:</p> <pre><code>$('.cash').each(function(){ $(this).html() = i; formatPrice(i).appendTo('body'); }); </code></pre> <hr> <p>Even whenstripping it down to a basic function, it still does not append my stuff...Am I losing my mojo?</p> <pre><code>$('.cash').each(function(){ $(this).html().appendTo('body'); }); </code></pre> <p>Thanks</p> <p>UPDATE: The function is just suppose to do this:</p> <p>formatPrice('1234.00') //convert to "1 234.00" formatPrice('123456.00') //convert to "123 456.00"</p>
jquery
[5]
3,995,401
3,995,402
writecodeonline.com/php/ Copy&Paste
<p>I have just copied a load of code that runs fine into <a href="http://writecodeonline.com/php" rel="nofollow">writecodeonline.com</a> and i get this error:</p> <pre><code>Warning: file_get_contents(http://e0.writecodeonline.com/php5/engine.php?code=class+domino+%0D%..............9%09% in /homepages/26/d94605010/htdocs/lz/writecodeonline.com/php/index.php on line 5 </code></pre> <p>It seems to be if i write the code in the editor it runs ok but something to do with C&amp;P?</p> <p>Has anyone else run into the same problem and found a work around? I have been asked to use this website so kinda need to get it working.</p>
php
[2]
1,272,443
1,272,444
PHP: how can I display the properties of my object?
<p>I have an object $rows</p> <p>If I use echo $rows the content is displayed in my html page, however I would like to select only some parts of the content but I cannot see inside the variable how it is structured... thanks</p>
php
[2]
3,757,623
3,757,624
php fetch value on other page
<p>I am having three images.</p> <pre><code>&lt;a href="a.php" class="btn"&gt;&lt;img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/1.png"&gt;&lt;span class="bqy_no"&gt;1&lt;/span&gt;&lt;/a&gt; &lt;a href="a.php" class="btn"&gt;&lt;img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/2.png"&gt;&lt;span class="bqy_no"&gt;2&lt;/span&gt;&lt;/a&gt; &lt;a class="show_img3 btn" href="a.php"&gt;&lt;img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/2.png"&gt;&lt;span class="bqy_no"&gt;BRAUCHE MEHR&lt;/span&gt;&lt;/a&gt;&lt;div class="hide_img3"&gt;&lt;a href=#&gt;2&lt;/a&gt;&lt;a href="#"&gt;3&lt;/a&gt;` </code></pre> <p>I want that on click of 1st, i should be redirected to a page a.php and get the value i.e if clicked thrugh 1, then on a.php i should get 1 and if clicked throught 2, i should get 2 on a.php</p>
php
[2]
353,522
353,523
Layout in android
<p>I want to place an <code>ImageButton</code> on another <code>ImageView</code> in android.</p> <p>How should I do it?</p>
android
[4]
1,384,159
1,384,160
validation in asp.net using validators
<p>i am using validator for validating blank textbox. my problem is,i want to make the validation to false means the textbox can be blank,when i select Complete from dropdownlist.</p> <p>How can i do this.</p>
asp.net
[9]
1,050,613
1,050,614
How to use onConfigurationChanged() and newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE in android 2.3.3
<p>I am using <code>onConfigurationChanged()</code>. In that, when I am changing from LandScape to Portrait, it is calling <code>if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)</code> and shifting to Portrait from LandScape. But when I am changing from Portrait to Land-Scape, it is not changing to LandScape because it is calling <code>if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)</code> so, it is not changing from LandScape to Portrait. Please help.</p> <pre><code>public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); //int orientation = this.getResources().getConfiguration().orientation; if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("Entered to change as Portrait ","PPPPPPPPPPPPPPPPP"); setContentView(R.layout.settings); } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Log.d("Entered to change as LandScape ","LLLLLLLLLLLLLLLLLLLL"); setContentView(R.layout.settings); } } </code></pre>
android
[4]
4,317,688
4,317,689
Finding the variables (read or write)
<p>I'd like to develop a small debugging tool for python programs.In Dynamic Slicing How can I find the variables that are accessed in a statement? And find the type of access (read or write) for those variables (in Python).### Write: A statement can change the program state Read : A statement can read the program state .<em>*</em>*For example in these 4 lines we have: (1) x = a+b => write{x} &amp; reads{a,b} (2)y=6 => write{y}&amp;reads{} (3) while(n>1) => write{} &amp;reads{n} (4) n=n-1 write{n} &amp; reads{n}</p>
python
[7]
1,581,254
1,581,255
Eclipse does not recognize some coda-parts
<p>Sorry for the unspecific title, but I do not know how to formulate it. </p> <p>I have the following problem:</p> <p>I Have installed Android SDK on my laptop and on another PC. I have to work on both PC. When transport a Project form my Laptop, I sometimes get the problem, that on the PC, parts of the code get the XXX cannot be resolved to a type.</p> <p>Example: The Code is not so interesting, the problem is in the line, "AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);"</p> <pre><code>package com.example.alertdialog; import android.app.Activity; import android.content.DialogInterface; import android.os.Bundle; public class AlertDialog extends Activity { /** Called when the activity is first created. */ public static final int DIALOG_DELETE_YES_NO_MESSAGE = 1; public static final int DIALOG_DELETE_ALL_MESSAGE = 2; public class ExampleApp extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); alt_bld.setMessage("Do you want to close this window ?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Action for 'Yes' Button } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Action for 'NO' Button dialog.cancel(); } }); AlertDialog alert = alt_bld.create(); // Title for AlertDialog alert.setTitle("Title"); // Icon for AlertDialog alert.setIcon(R.drawable.icon); alert.show(); } } </code></pre> <p>}</p> <p>In another case, extend a class from a BaseAdapter. On the Laptop, I can overwrite functions like "getVIew", on the PC, there is an Error if I use "@Override".</p> <p>This is the error I get: "Multiple markers at this line - implements android.widget.Adapter.getView - The method getView(int, View, ViewGroup) of type ImageAdapter must override a superclass method"</p> <p>Any ideas as to what the problem is?</p>
android
[4]