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
2,488,391
2,488,392
Length of a char array
<p>I have the code like this:</p> <pre><code>#include &lt;iostream.h&gt; #include &lt;fstream.h&gt; void main() { char dir[25], output[10],temp[10]; cout&lt;&lt;"Enter file: "; cin.getline(dir,25); //like C:\input.txt ifstream input(dir,ios::in); input.getline(output,'\eof'); int num = sizeof(output); ofstream out("D:\\size.txt",ios::out); out&lt;&lt;num; } </code></pre> <p>I want to print the length of the output. But it always returns the number 10 (the given length) even if the input file has only 2 letters ( Like just "ab"). I've also used strlen(output) but nothing changed. How do I only get the used length of array?</p> <p>I'm using VS C++ 6.0</p>
c++
[6]
4,805,666
4,805,667
Adding time to date format in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5165428/how-to-set-time-to-a-date-object-in-java">How to set time to a date object in java</a> </p> </blockquote> <p>I Have Date like 2008-12-10 00:00:00.000 and the Time is as 13:47.</p> <p>I want to Add both date and Time to get the correct value.what code i should write.</p>
java
[1]
4,687,701
4,687,702
Correct syntax to preserve javascript context with prototyping
<p>So I know that I can fix the scope of my module class below using <code>bind</code> as in <a href="http://stackoverflow.com/a/1441692/148998">this answer</a>.</p> <p>The only thing is that I use a slightly diffrerent syntax for my module and I am not quite sure how to apply it? </p> <p>My question is then, how do I apply bind to my function correctly so that the context of <code>this</code> is my module?</p> <p>Code:</p> <pre><code>var module = (function () { var module = function (name) { this.getName= function() { return name; } }; module.prototype = { something: function () { // my function needs to access getName from here... } }; return module; })(); </code></pre> <p>Usage:</p> <pre><code>var foo = module('nameValue'); foo.something(); </code></pre>
javascript
[3]
4,521,259
4,521,260
Grid view using arraylist in android
<p>How to show the gridview data's using array list</p>
android
[4]
4,042,053
4,042,054
Extract a Byte C++
<p>I have </p> <pre><code>int chop (char* input, unsigned int length) { for (int chopper = 0; chopper &lt; = length; chopper++) { //how to pass 1byte this input to another function //Will this for loop help? } } </code></pre> <p>How do I extract one byte of from this input for my further processing? Thank you</p>
c++
[6]
5,971,312
5,971,313
Android How Much space is free on the SD card?
<p>What is an effective way to determine how much free space is on the SD card?</p>
android
[4]
6,004,646
6,004,647
reference a method from a class by using a variable
<p>I know how in Java, a class is referenced like <code>com.google.googlemaps.exampleClass.exampleMethod()</code>. Is it possible to interchange the first parts of the referenece (in this case, the <code>com.google.googlemaps</code>) using a variable (<code>Class c</code>)?</p> <p><strong>EDIT</strong> Ok, after some confusion, I'm going to (try to) provide an example</p> <p>We have Class <code>A</code>. I can add a new instance of it. Each instance has the variables <code>name</code> (a String), and <code>redir</code> (currently in turmoil). <code>redir</code> is the variable which is supposed to hold the reference for the class, so I can call a specific method from those classes, so <code>redir</code> is like <code>com.google.googlemaps</code> etc.</p>
java
[1]
2,904,858
2,904,859
How to skip Enter key in RichTextBox
<p>I have to implement transparent textbox (my case is text box with gradient background). The easiest implementation was transparent RichTextBox which I have found on <a href="http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_23508382.html" rel="nofollow">http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_23508382.html</a></p> <p>The only problem with that that I need to have single entry line, not a multyline</p> <p>How to preprocess Enter key?</p>
c#
[0]
3,794,602
3,794,603
concatenate char * to string
<p>I have a function which is expecting a string, I was wanting to concatenate const char * to a string to be returned.</p> <p>Here is example code to help illustrate this scenario:</p> <pre><code>void TMain::SomeMethod(std::vector&lt;std::string&gt;* p) { p-&gt;push_back(TAnotherClass::Cchar1 + "/" + TAnotherClass::Cchar2); } </code></pre> <p>and here is the other class these are from:</p> <pre><code>class TAnotherClass { public: static const char * Cchar1; static const char * Cchar2; }; const char * TAnotherClass::Cchar1 = "Home"; const char * TAnotherClass::Cchar2 = "user"; </code></pre> <p>im getting the following error: invalid operands of types 'const char*' and 'const char*' to binary operator +</p> <p>Why is this not valid? please help</p>
c++
[6]
4,906,414
4,906,415
How to Get element of Iframe?
<p>i want to automate page using web browser automation.</p> <p>In the there is only an iframe at runtime value comes to that iframe.</p> <p>when i try get the value of i frame it returns only the iframe not whole page html,</p> <p>I want to click a href of i frame.</p> <p>Please help me to solve this problem I am code.</p> <pre><code> HtmlDocument dd = (HtmlDocument)loginBrowser.Document.GetElementById("UIFrame"); </code></pre>
c#
[0]
4,427,225
4,427,226
Error generic array creation
<pre><code>public class TwoBridge implements Piece{ private HashSet&lt;Hexagon&gt;[] permutations; public TwoBridge(){ permutations = new HashSet&lt;Hexagon&gt;[6]; </code></pre> <p>Hi, I'm trying to create an array of Sets of hexagons (hexagons being a class i created).</p> <p>However I get this error when I try to compile </p> <pre><code>oliver@oliver-desktop:~/uni/16/partB$ javac oadams_atroche/TwoBridge.java oadams_atroche/TwoBridge.java:10: generic array creation permutations = new HashSet&lt;Hexagon&gt;[6]; ^ 1 error </code></pre> <p>How can I resolve this?</p>
java
[1]
4,038,334
4,038,335
Ctr+s event on clicking a hyperlink
<p>I have a hyperlink, when i click this link Ctr+s event should be fired which results in prompting to save the webpage. How can i call Ctr+s event when clicking a link I needs this in javascript or jquery</p>
javascript
[3]
2,847,101
2,847,102
How to get the substrings in a string by using regular expressions
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11100379/retrieving-the-substring-based-on-condition-from-a-string-in-iphone">retrieving the substring based on condition from a string in iphone</a><br> <a href="http://stackoverflow.com/questions/11102005/identifying-the-string-in-between-two-strings-in-iphone">Identifying the string in between two strings in iphone</a> </p> </blockquote> <p>I am new to iphone. I have small doubt that is, I have a lot of strings(nearly 66) like in the format href="/mp3/KJV/21_Ecc/Ecc_KJV.zip" In a single string but the difference of all those is changing names in the place of Ecc but all are in same format.So,my request is to how to get the all strings which are started with (href=") and ends with (.zip) using regular expressions and how to write a regular expression for the above format string to identify all strings in that format.</p>
iphone
[8]
3,434,329
3,434,330
Loop not incrementing ASP.NET VB
<pre><code>'Add items to db' Function recordOrder() Dim objDT As System.Data.DataTable Dim objDR As System.Data.DataRow objDT = Session("Cart") Dim intCounter As Integer Dim con2 As New System.Data.OleDb.OleDbConnection Dim myPath2 As String myPath2 = Server.MapPath("faraxday.mdb") con2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" &amp; myPath2 &amp; ";" Dim myCommand2 As New System.Data.OleDb.OleDbCommand Dim sql As String myCommand2.Connection = con2 con2.Open() 'variables' Dim order_date As String Dim coupon_ID As String Dim customer_id As String Dim quantity As String 'variables' Try For intCounter = 0 To objDT.Rows.Count - 1 objDR = objDT.Rows(intCounter) order_date = System.DateTime.Now.Date coupon_ID = objDR("ID") quantity = objDR("quantity") myCommand2.Parameters.Add("@order_date", SqlDbType.VarChar).Value = order_date myCommand2.Parameters.Add("@coupon_ID", SqlDbType.VarChar).Value = coupon_ID myCommand2.Parameters.Add("@customer_id", SqlDbType.VarChar).Value = custID myCommand2.Parameters.Add("@quantity", SqlDbType.VarChar).Value = quantity myCommand2.CommandText = "INSERT INTO orders(order_date, coupon_id, customer_id, quantity) VALUES ( @order_date ,@coupon_ID,@customer_id,@quantity)" myCommand2.ExecuteNonQuery() Next Catch ex As Exception Finally If con2.State = ConnectionState.Open Then con2.Close() End If End Try End Function </code></pre> <p>The loop is not incrementing (intCounter). Please HELP...</p>
asp.net
[9]
2,201,257
2,201,258
I have an application running on Android SDK API 16 but not on any else version. What could be the possible reasons?
<p>Please someone explain the possible reasons and solutions.</p>
android
[4]
2,176,034
2,176,035
JQuery selectmenu how to style some options differently
<p>Probably a simple one guys but I'm really struggling with it. Would really appreciate some help or advice if anyone can offer it, thanks.</p> <p>I'm using JQuery selectmenu and all I would like to do is set a different style for any OPTION that has a particular class. The class is "outofstock", so my code is as follows;</p> <pre><code>&lt;select name="dd1" id="dd1"&gt; &lt;option value="1"&gt;item 1&lt;/option&gt; &lt;option value="2" class="outOfStock"&gt;item 2&lt;/option&gt; &lt;option value="3"&gt;item 3&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I would just like the second option that has class="outOfStock", to be styled with a different text or BG colour.</p> <p>I have tried many (many, MANY) variations on this but just cannot get anything to work.</p> <pre><code>&lt;style type="text/css"&gt; .ui-selectmenu-menu-item .outOfStock{background:red;} &lt;/style&gt; </code></pre> <p>Any pointers would be appreciated, thanks.</p>
jquery
[5]
5,556,741
5,556,742
float 0 returns as empty string in php
<p>could anyone explain why float 0 is empty? The code below will show "weird"</p> <pre><code>$empty = (float)"0"; if($empty == "") echo "weird"; </code></pre> <p>On the other hand if i were to the code below, it will never show "weird".</p> <pre><code>$empty = (float)"0.01"; if($empty == "") echo "weird"; </code></pre>
php
[2]
495,030
495,031
Using conditionals inside a loop
<p>I am trying to achieve a check with the <code>if...else</code> statement that only squares the odd numbers between 100 and 150, otherwise the number is just printed.</p> <p>How can I revise my <code>if</code> statement to achieve this please? An educated guess is that an operator or combination of operators are used.</p> <pre><code> for (i=100; i&lt;=150; i++) { if (i === 0) { console.log(i * i); } else { console.log(i); } } </code></pre>
javascript
[3]
533,686
533,687
c# HtmlAgility Pack - Unable to get image src
<p>This is the code I have. I am trying to learn how to get all the img src from a URL. But, the <strong>imgs</strong> variable in my below code is always null. What am I doing wrong, please?</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Net; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml("http://archive.ncsa.illinois.edu/primer.html"); HtmlAgilityPack.HtmlNodeCollection imgs = doc.DocumentNode.SelectNodes("//img"); if (imgs != null) { foreach (HtmlAgilityPack.HtmlNode img in imgs) { string imgSrc = img.Attributes["src"].Value; } } Console.ReadKey(); } } } </code></pre>
c#
[0]
958,796
958,797
Can a class Extend or Override himself?
<p>Suppose we have a class. We create an object from the class and when we do the class Extends himself base on the object initialization value..</p> <p>For example:</p> <pre><code>$objectType1 = new Types(1); $objectType1-&gt;Activate(); // It calls an activation function for type 1 $objectType2 = new Types(2); $objectType2-&gt;Activate(); // It calls an activation function for type 2 </code></pre> <p>I don't want to use the standard procedure of class extending:</p> <pre><code>class type1 extends types{} </code></pre>
php
[2]
1,654,033
1,654,034
What does var x = x || {} ;
<p>what does the following code do in java script:</p> <pre><code>var x = x || {}; </code></pre>
javascript
[3]
4,994,890
4,994,891
Image.onload doesnt work at all for IE
<pre><code>var icon1 = new Image(); var wid1; var hei1; icon1.src = resource; // resource is Image URL here icon1.onload = function () { wid1 = icon1.width; hei1 = icon1.height; var rati = wid1 / hei1; }; </code></pre> <p>This code is to calculate the ratio of width and height to further maintain the aspect ratio of the image but it doesn't work at all on IE. is there anything else that i can use for maintaining the aspect ratio of image that will work on all browsers?</p>
javascript
[3]
3,740,664
3,740,665
Two way sync adapter in Android
<p>I have gone through a number of links and after spending a huge amount of time over this, someone can please let me know the simplest approach to implement the Sync Adapter in Android which is 2 way. I mean the changes made on the remote database get reflected on the Android Device and the changes from the device should get updated on the server too.</p> <p>Also, how to edit the contacts from the default contacts app editor??</p> <p>Would like to give thanks in advance as it will prove to be a great help if someone answers my question.</p>
android
[4]
1,833,256
1,833,257
Pattern matching in dictionary using python
<p>In the following dictionary,can the elements be sorted according the last prefix in the key</p> <pre><code>opt_dict=( {'option1':1, 'nonoption2':1, 'nonoption3':12, 'option4':6, 'nonoption5':5, 'option6':1, 'option7':1, }) for key,val in opt_dict.items(): if "answer" in key: //match keys last prefix and print output print "found option 1,4,6,7" //in ascending order elif "nonanswer" in key: //match keys last prefix and print output print "found option 2,3,5 " //in ascending order </code></pre> <p>Thanks..</p>
python
[7]
2,942,800
2,942,801
how to know if file is still open for writing
<p><br> i have a function that writes to a file , how can i using another script check if the file is being used for writing or it is closed ?</p> <p><strong>Edit :</strong> this file might be opened for writing by other script/application/system ... </p> <p>thank you .</p>
php
[2]
5,313,452
5,313,453
How do I pass the selected item's ID from a ListView to an AlertDialog in Android?
<p>Here's the scenario: I have a ListActivity, and long-pressing on an item brings up a context menu. One item in the context menu is "delete", and that brings up a confirmation box (and AlertDialog). When the user presses OK in the confirmation dialog, I need to know the ID of the item that was originally selected, so that I can actually delete it.</p> <p>The flow looks like this: </p> <pre> This event: Causes Android to call: ----------------------------------------------------- Long press an item -> onCreateContextMenu() Select context menu item -> onContextItemSelected() call showDialog() -> onPrepareDialog() user clicks OK -> onClick() </pre> <p>In onCreateContextMenu and onContextMenuSelected, I can get at the id of the selected item from the ContextMenuInfo. In onPrepareDialog, however, I no longer have access to that information. The rub is that onPrepareDialog needs this information to set up an onClick listener on its POSITIVE button.</p> <p>I know that, during onContextMenuSelected, I can stash the selected item's ID away into a field of my activity. I have done that, and it works. But it's also really ugly. The statefulness that it introduces makes me uneasy. Has anybody else seen a better way to pass such information around than to use fields in the activity?</p>
android
[4]
1,991,494
1,991,495
Run Hierarchy Viewer on W7(doesn't work)
<p>I am working on Android. I try inside a terminal execute java -jar hierarchyviewer.java </p> <p>And I have this error</p> <p>11:46:48 E/adb: Failed to get the adb version: Cannot run program "adb": CreateP rocess error=2, the system cannot find the file specified</p> <p>I can run the hierarchyviewer.jar from /tools/lib (double click) I can see the graphic interface but it does not show anything, I cannot see the tree and stuff. I am using Windows 7, 64 bit and I am executing the emulator and/or the device before running hierarchyviewer.</p> <p><a href="http://developer.android.com/guide/developing/tools/hierarchy-viewer.html" rel="nofollow">http://developer.android.com/guide/developing/tools/hierarchy-viewer.html</a></p>
android
[4]
3,621,615
3,621,616
Android-Video View in Fullscreen
<p>I am trying to make this VideoView to appear in full screen mode:</p> <pre><code>public class ViewVideo extends Activity { private String filename; private static final int INSERT_ID = Menu.FIRST; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); System.gc(); Intent i = getIntent(); Bundle extras = i.getExtras(); filename = extras.getString("videofilename"); VideoView vv = new VideoView(getApplicationContext()); setContentView(vv); vv.setVideoPath(filename); vv.setMediaController(new MediaController(this)); vv.requestFocus(); vv.start(); } @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, INSERT_ID, 0,"FullScreen"); return true; } @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch(item.getItemId()) { case INSERT_ID: createNote(); } return true; } private void createNote() { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } } </code></pre> <p>The video is playing from the sdcard. Only thing is when I click on the fullscreen menu button, the application "stops unexpectedly". Please help me out, how to get the video to run in full screen? Thanks in advance.</p>
android
[4]
2,587,601
2,587,602
how do i use string replace to remove a carrage return from a string
<p>Hi how do I use string replace to remove a carrage return from a string</p> <p>here is the string:</p> <pre><code>{ $content = '&lt;p&gt;some random text &lt;a href= "http://url.co.uk/link/"&gt;link text&lt;/a&gt; some more random text.&lt;/p&gt;'} </code></pre> <p>and here is the sring replace command</p> <pre><code>{$content=str_replace('carrage return', '', $content);} </code></pre> <p>The think I cant seem to find is what to replace 'carrage return' with. The reason for this is that I am doing a reg expression on the string which fails if there is a carrage return in the serached for string as that then doesnt match the reg expression.</p> <p>Also on an asside note if some one posts a response to my question how do I query them back on the posting.</p> <p>second asside how the hell do i get html to show up properly on here ive tried '' "" () {} :(</p> <p>be gentil im a newby and already got punched in the face on here :( second post and someone dropped a load of my score :(</p>
php
[2]
981,029
981,030
How to make short codes? php
<p>I want to make short codes, like a wordpress...</p> <p>Sample:</p> <blockquote> <p>[CODE]</p> </blockquote> <p>will be replaced to</p> <blockquote> <p>code();</p> </blockquote>
php
[2]
923,196
923,197
Can I assign a static class to a variable?
<p>My question is whether I can assign a static class to another variable (and of what type would that be) ?</p> <p>Say I have</p> <pre><code>public static class AClassWithALongNameIDontWantTotType{ public static bool methodA() { stuff } } </code></pre> <p>and then I have </p> <pre><code>class B{ } </code></pre> <p>Can I make it so that inside of <code>class B</code> I can reassign this class to something with a shorter name, like:</p> <pre><code>SomeType a = AClassWithALongNameIDontWantTotType </code></pre> <p>and then be able to do</p> <pre><code>a.methodA() </code></pre> <p>?</p> <p>I can get out a function by doing something like</p> <pre><code>Func&lt;bool&gt; a = AClassWithALongNameIDontWantTotType.methodA() </code></pre> <p>but I would prefer to have the whole class.</p> <p>Thanks!</p>
c#
[0]
4,240,991
4,240,992
jquery selector to select a tags inside every li in the ul block
<p>Here is an image which shows my ul block</p> <p><img src="http://i.stack.imgur.com/8bOxR.jpg" alt="enter image description here"></p> <p>every li is identical to the expanded li shown. How do I select all of these a tags within this ul ?</p> <p>I tried using something like </p> <pre><code> $('ul:has(li) &gt; a') </code></pre> <p>but that does not seem right. Also I need to target the ul by its Id. Any help with this appreciated. Thanks ,</p>
jquery
[5]
3,516,197
3,516,198
traverse dom to find $(.more) of div that contains class .disable
<p>I have this dom tree: </p> <pre><code>&lt;li class="badge_listtwo"&gt; &lt;div class="badge_spacetwo"&gt; &lt;p class="badge_title"&gt;$badge_title&lt;/p&gt; &lt;div class="badge_button"&gt; &lt;img src="badgeImages/sample.png" /&gt; &lt;a href="#" id="$badge_id" class="more"&gt;More&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="badge_button"&gt; &lt;a href="#" class="disable"&gt;Disable&lt;/a&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p>I was wondering how, using jquery, I can get the "id" of .more based on finding which <code>&lt;li&gt;</code> contains the .disable class (how would I traverse it efficiently is what Im asking because I'm trying to store this id in var badge_id)</p>
jquery
[5]
1,100,878
1,100,879
change the value of the button of the button clicked
<p>On inserting the new <code>&lt;li&gt;</code>, I have to set the value of the button clicked to Delete. How can I do that? </p> <p>With the actual code, it`s working only once, and on adding other list, the button no more has the the value 'Delete'. </p> <pre><code>$("#mylist :button").click( function() { var text = $(this).val(); if (text == "Delete") { $(this).parent().remove(); } else { $(this).val("Delete"); } }); $("#mylist li:last-child").live('click', function() { $(this).parent().append('&lt;li&gt;' + '&lt;input type = "textbox"&gt;' + '&lt;input type = "button" value= "Save"&gt;' + '&lt;/li&gt;'); }); &lt;div&gt; &lt;ul id="mylist"&gt; &lt;li id="1"&gt;1&lt;button id="Button3"&gt;Delete&lt;/button&gt; &lt;/li&gt; &lt;li id="2"&gt;2&lt;button id="Button2"&gt;Delete&lt;/button&gt;&lt;/li&gt; &lt;li id="3"&gt;3&lt;button id="another_entry"&gt;Save&lt;/button&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre>
jquery
[5]
1,770,560
1,770,561
Trying to create a text file log using java
<p>I'm new to programming and trying to create a log file. The code I have written works at sending the message and the time to a text file . But every time I send another message it just records over the previous. I want to have a list of messages and times just not the latest one.</p> <pre><code>public void run () { String message; try { while ((message = reader.readLine()) != null){ System.out.println( "You voted " + message + " You the best") ; BufferedWriter out = new BufferedWriter(new FileWriter("test.txt")); out.append(message + "\n"); TimeZone tz = TimeZone.getTimeZone("UTC"); // or PST, MID, etc ... Date now = new Date(); DateFormat df = new SimpleDateFormat (" yyyy.MM.dd hh:mm:ss "); df.setTimeZone(tz); String currentTime = df.format(now); String timeStamp = new SimpleDateFormat().format( new Date() ); FileWriter aWriter = new FileWriter("test.txt", true); aWriter.write(currentTime + " " + "\n"); aWriter.flush(); aWriter.close(); out.write(message); out.close(); everyoneMessage(message); } // close while }catch(Exception ex) {ex .printStackTrace();} } // close run }// close inner class </code></pre>
java
[1]
2,906,336
2,906,337
How to know if the current browser is loaded with C# code
<p>I am working with the Image generation of a browser, but doing so i am taking a snapshot of the browser from the code, in windows form. But if the browser is not loaded in the specific time (suppose 15 seconds) then a blank snapshot occur. Anyone help me with this .</p>
c#
[0]
65,261
65,262
Rounding issue in Java
<p>I'm trying to do a quick 2 vars equation solver using Cramer's rule but for some reason java keeps on rounding my answers so i don't get the right answer.</p> <p>the basic rule for getting single answer is </p> <pre><code>((a11*a22)-(a12*a21))!=0) </code></pre> <p>and the solution should be</p> <pre><code>double sol1 = (b1*a22-b2*a12) / (a11*a22-a12*a21); double sol2 = (b2*a11-b1*a21) / (a11*a22-a12*a21); </code></pre> <p>but for some reason i get -4.0 and 4.0 instead of -4.0 and 4.5 for 1,2,3,4,5,6</p> <p>that's the problematic code if it helps:</p> <pre><code>if (((a11*a22)-(a12*a21))!=0) { double sol1 = (b1*a22-b2*a12) / (a11*a22-a12*a21); double sol2 = (b2*a11-b1*a21) / (a11*a22-a12*a21); System.out.println("Single solution: ("+sol1+", "+sol2 +")"); } </code></pre>
java
[1]
4,095,267
4,095,268
Python always thinks my string is the highest possible number
<pre><code>if month == 1 or 10: month1 = 0 if month == 2 or 3 or 11: month1 = 3 if month == 4 or 7: month1 = 6 if month == 5: month1 = 1 if month == 6: month1 = 4 if month == 8: month1 = 2 if month == 9 or 12: month1 = 5 </code></pre> <p>This code <em>always</em> returns month1 5. I'm quite new at programming, what am I doing wrong? (I guess it involves the fact that 12 is the highest number. But == means equals right?)</p>
python
[7]
176,259
176,260
Is "overflow" a historical term, or does physical overflowing really still happen?
<p>I believe that during arithmetic overflow (in the context of an integer variable being assigned a value too large for it to hold), bits beyond the end of the variable could be overwritten.</p> <p>But in the following C++11 program does this really still hold? I don't know whether it's UB, or disallowed, or implementation-specific or what, but when I take the variable past its maximum value, on a <em>modern</em> architecture, will I <em>actually</em> see arithmetic overflow of bits in memory? Or is that really more of a historical thing?</p> <pre><code>int main() { // (not unsigned; unsigned is defined to wrap-around) int x = std::numeric_limits&lt;int&gt;::max(); x++; } </code></pre>
c++
[6]
2,339,886
2,339,887
Jquery Menu Request
<p>I want a jquery menu like this link </p> <p>the menu in link is in Flash format</p> <p><a href="http://www.atid1.com/default/" rel="nofollow">Flash Menu</a></p> <p>when i hover on parent menu with mouse all sub menus will open</p> <hr> <p>I think now this is the correct answer</p> <pre><code>&lt;div class="hoverMenuItem" id="item1"&gt; Menu Item&lt;/div&gt; &lt;div class="hoverMenuItem" id="item2"&gt; Menu Item&lt;/div&gt; &lt;div class="hoverMenu" style="display: none; position: absolute;"&gt; &lt;!--menu laid out--&gt; &lt;/div&gt; &lt;div class="hoverMenu" style="display: none; position: absolute;"&gt; &lt;!--menu laid out--&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $('.hoverMenuItem').mouseover(function () { //var id = $(this).attr("id"); //var itemNum = id.substring(4); //$('#menu' + itemNum).slideDown(250); $('.hoverMenu').slideDown(250); }); $('.hoverMenuItem').mouseout(function () { //var id = $(this).attr("id"); //var itemNum = id.substring(4); //$('#menu' + itemNum).slideUp(250); $('.hoverMenu').slideUp(250); }); }); &lt;/script&gt; </code></pre> <p>but there is a problem</p> <p>in this way how can we Determine childs for each parent ?</p>
jquery
[5]
1,019,029
1,019,030
Need to upload a file using HttpPost in android
<pre><code>I would like to upload a name.txt file without ussing MultiEntitiy "importing a large file" as my file is small in size... I have written the following code but unable to upload a file.. thanks for your concern... URL url = new URL(strUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); // Allow Inputs conn.setDoOutput(true); // Allow Outputs conn.setUseCaches(false); // Don't use a Cached Copy conn.setRequestMethod("POST"); conn.setRequestProperty("userfile", strEmailAddress + ".txt"); dos = new DataOutputStream(conn.getOutputStream()); dos.writeBytes("Content-Disposition: form-data; name=\"paramName\""); Helper.printLogD(" connection " + conn.getContent().toString()); String temp = getStringFromInputStream(conn.getInputStream()); Helper.printLogI("temp" + temp); </code></pre>
android
[4]
644,530
644,531
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]
4,394,029
4,394,030
Camera Preview Issue?
<p>In my Application the camera preview is working properly in both in potrait and in landscape mode .No crashes are occuring.but the users are complainting that the crashes are occuring when they are using the same. what is the problem with this? please anyone help me to solve this issue</p>
android
[4]
5,986,928
5,986,929
interchangeable derived class method from base class c++
<p>i am pretty sure this is a simple question for a long time c++ user, this should be a pattern or the problem should be solved in any other way but given i am Python developer and a total novice with c++ i don't know how it's usually done.</p> <p>Suppose that i have a class where i want to store a pointer to an object that can be of 1 of two different classes that respects an interface, for example:</p> <pre><code>class AllPlayers { public: virtual void play(); }; class VlcPlayer: public AllPlayers { public: virtual void play(); }; class Mplayer: public AllPlayers { public: virtual void play(); }; class MyMediaPlayer { public: MyMediaPLayer(int playerType); AllPlayers m_player; }; MyMediaPlayer::MyMediaPlayer(int PlayerType) { if (PlayerType == 0) { VlcPlayer tmp_player; m_player = static_cast&lt;AllPlayers&gt; (tmp_player); } else { Mplayer tmp_player; m_player = static_cast&lt;AllPlayers&gt; (tmp_player); } } MyMediaPlayer test(0); test.play(); </code></pre> <p>First, i know this would not work and that it seems pretty normal why but how could i get this effect? i would like to have a member of a class for what i am going to use ever the same methods, implemented using a interface and i would like to avoid trying to cast to every of the derived classes every time i am going to use one of his methods.</p>
c++
[6]
4,920,969
4,920,970
Counting online users using asp.net
<p>I'm to create a website for which I need to count the online users and show it on the home page all the time. I'm not interested to apply ready-to-use modules for it. Here is what I have already done:</p> <p>Adding a Global.asax file to my project</p> <p>Writing the following code snippet in the Global.asax file:</p> <pre><code>void Application_Start(object sender, EventArgs e) { Application["OnlineUsers"] = 0; } void Session_Start(object sender, EventArgs e) { Application.Lock(); Application["OnlineUsers"] = (int)Application["OnlineUsers"] + 1; Application.UnLock(); } void Session_End(object sender, EventArgs e) { Application.Lock(); Application["OnlineUsers"] = (int)Application["OnlineUsers"] - 1; Application.UnLock(); } </code></pre> <p>Actually it works fine but I have found the following bug: --> Even if the user close the browser, the real count of online users is not shown since the session timeout is still alive!</p> <p>Is there any solution but changing the session timeout interval?</p>
asp.net
[9]
1,174,193
1,174,194
Animation to the last element added to a ListView
<p>I have this codesnippet which initialize a ListView from a <code>SQLite</code> database</p> <pre><code> public void RefreshCaseList() { lastTenCases = db.getAllCases(7); if (lastTenCases.size() &gt; 0) error.setText(""); lastCases.setAnimation((Animation)AnimationUtils.loadAnimation(MainClass.this ,R.anim.push_left_in_80)); lastCases.setAdapter(new CustomAdapter(MainClass.this, lastTenCases)); registerForContextMenu(lastCases); } </code></pre> <p>This method is called each time a new element is added to the database, the following piece of code</p> <pre><code>lastCases.setAnimation((Animation)AnimationUtils.loadAnimation(MainClass.this ,R.anim.push_left_in_80)); </code></pre> <p>Will make an animation to the whole List when a new item is added, the list will be pushed in from left. Can anybody give me a hint on how to add animation to only the last element which is created and added to the list?</p> <p>Many Thanks. </p>
android
[4]
1,798,434
1,798,435
Is it a good idea to put a conversion operator in an iterator to convert it to pointer?
<p>I saw the following code today:</p> <pre><code>options.push_back(&amp;*i); </code></pre> <p>Where <code>i</code> is an iterator and the container <code>options</code> stores pointers to the type of <code>*i</code>. The resulting <code>&amp;*i</code> is a bit ugly and I started to wonder:</p> <blockquote> <p>Is it a good idea to add a conversion operator for converting to a pointer of <code>*i</code>?</p> </blockquote> <p>What do you think?</p>
c++
[6]
1,239,497
1,239,498
GridView, RowDataBound event executing twice for each row
<p>I have a GridView that is using an SQLDataSource to bind to a database.</p> <p>For some reason my RowDataBound event on the GridView is executing twice.</p> <p>Why is this happening?</p>
asp.net
[9]
2,684,493
2,684,494
Is there any library to track call time and sms time in android?
<p>I want to a software to calculate call time and sms time usage in Android, anyone has idea about any build-in library which handle such things ????</p> <p>any way I can extract call logs in Android???</p>
android
[4]
2,470,047
2,470,048
Iphone TabBar Application
<p>I start to develop app in tab bar application template..</p> <p>Here my first page is login page after loagin it go to home page and all navigation will happen..</p> <p>Here i don't want tab bar only in login page.How to doo this?</p> <p>Thanks..... </p>
iphone
[8]
5,555,520
5,555,521
Lint and old API level warning
<p>I compile against Android 4.2 (API 17), in my Manifest I have:</p> <pre><code>&lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="10"/&gt; </code></pre> <p>In code I use:</p> <pre><code>String first = sdf.format(new Date(context.getPackageManager().getPackageInfo(context.getPackageName(), 0).firstInstallTime)); </code></pre> <p>Field firstInstallTime was introduced in API 9.</p> <p>Lint does not warn me, i.e. that this field is not valid in API 8. What am I missing, how should one detect this? </p> <p>If I compile against Android 2.2 (API 8), I find the error and a bunch of extra errors due to new features used (> API 8) and the project won't compile.</p> <p>(I'm aware of handling such things in runtime with for example Build.VERSION.SDK_INT)</p> <p>What's the best way of working?</p> <p>Why is lint not working?</p> <p>Thanks!</p>
android
[4]
1,669,273
1,669,274
show latitude and longitude both from GPS and cellular network together
<p>Is it possible to show latitude and longitude both from GPS and cellular network together. I am using Eclipse.</p>
android
[4]
4,787,857
4,787,858
Best way to send "messages" from PHP to Java on the same workstation
<p>What is the best way to send "messages" from PHP script to Java program in <strong>real time</strong>. PHP script and Java programs are both working at the same work station with OS Windows. Maybe some kind of client/server? The main feature is <strong>real time</strong>; that's why I don't want to use files.</p> <p>PS: I'm going to send logger messages (php) and display (java) them at OS system tray tooltip. PPS: I'm real noob in Java; it will be my first Java program. :)</p> <p>Thank you.</p>
java
[1]
1,467,829
1,467,830
How can we find the jdk path in the system drives(like C,D etc) using java program?
<p>Hi can anyone tell me "<strong>How can we find the jdk path in the system drives(like C,D etc) which is currently used by user using java program?</strong>"</p>
java
[1]
2,200,147
2,200,148
linked list in c/c++
<p>I am going to multiply two polynomial that user must enter.</p> <p>in the first step (getting info from user) I got this error:</p> <pre><code>Unhandled exception at 0x00a315cb in linked polinomials.exe: 0xC0000005: Access violation writing location 0x00000000. </code></pre> <p>I got this error after that I want to enter an other element of polynomial.</p> <pre><code>struct polynomial{ float coef ; int exp ; polynomial *next ; } *first, *second ,*result; </code></pre> <pre><code>first = new(polynomial); //init first first -&gt;coef = 0; first-&gt;exp = 0 ; first-&gt;next = 0; </code></pre> <pre><code>while(ch != 'n') { cin &gt;&gt; temp_c ; cin &gt;&gt; temp_e ; first-&gt;coef = temp_c; first-&gt;exp = temp_e; cout &lt;&lt; "Do you want to enter another ? (y or n) :" &lt;&lt; endl; ch = getch(); first = first-&gt;next; } </code></pre>
c++
[6]
5,981,330
5,981,331
C++ Simple GUI for Windows, Linux and Mac
<p>I am looking for a simple gui for C++ program.It will be you used for a simple project &amp; must be in file without dll and stuff like that.And must run on Windows,Linux and Mac.</p> <p>Excuse my English.I am doing my best.</p>
c++
[6]
4,479,224
4,479,225
read through first N lines of a file in python
<p>Typically, when reading a file, I use the for line n fileobject: construct. Is there a simple way to just loop over the first N (or some arbitrary subset) of lines in a file, so that I don't have to read in the entire file?</p>
python
[7]
4,203,216
4,203,217
How to compare two dates in php and echo newer one?
<p><strong>How to compare two dates in php and echo newer one?</strong></p> <p>My dates are in the following format: <code>date("F j, Y, g:i a");</code> which give us <code>August 12, 2011, 9:45 am</code>.</p> <p>My dates are as follow:</p> <ul> <li>date 1 <code>$created</code></li> <li>date 2 <code>$updated</code> / if no updated have been made value is <code>0000-00-00 00:00:00</code></li> </ul> <p>Any suggestion much appreciated. </p>
php
[2]
1,873,269
1,873,270
concatenation output problem (toString Array) - java
<p>I am trying to display the output as "1(10) 2(23) 3(29)" but instead getting output as "1 2 3 (10)(23)(29)". I would be grateful if someone could have a look the code and possible help me. I don't want to use arraylist.</p> <p>the code this </p> <pre><code>// int[] Groups = {10, 23, 29}; in the constructor public String toString() { String tempStringB = ""; String tempStringA = " "; String tempStringC = " "; for (int x = 1; x&lt;=3; x+=1) { tempStringB = tempStringB + x + " "; } for(int i = 0; i &lt; Group.length;i++) { tempStringA = tempStringA + "(" + Groups[i] + ")"; } tempStringC = tempStringB + tempStringA; return tempStringC; } </code></pre>
java
[1]
1,304,324
1,304,325
Initialize ref. field with ref. parameter: Is a copy made?
<p>I am wondering if a copy is made in the following situation, or if both references will point to the same object. Consider an class with a single const ref field which is initialized from const ref parameter:</p> <pre><code>class Foo { public: Foo(const vector&lt;double&gt;&amp; the_doubles) : my_doubles(the_doubles) {} private: const vector&lt;double&gt;&amp; my_doubles; } </code></pre> <p>So, will my_doubles point to the same vector that was passed in to the constructor, or will a copy be created?</p>
c++
[6]
4,067,758
4,067,759
can i pass a string between two javascript files
<p>Is it possible to pass a string from one .js to another .js file. For Example main.html contains javascript. I need to pass a string from main.html to another html file that loads a javascript file during run time. Is it possible?</p>
javascript
[3]
5,989,868
5,989,869
Android apps on phones and tablets
<p>I'm developing a project that needs to work on both tabs and smart phones with different screen sizes, but I'm not sure how to achieve that. Should I use different codes for different devices or I need to deal with the drawable folder with h/l/m/xhdpi or there is another way to do that ? </p>
android
[4]
5,192,776
5,192,777
how to detect button pressed and released in iphone
<p>how to detect a button is pressed and released because i want to perform two actions </p> <p>first is auto increment when a button is pressed and hold a... and to stop the auto increment when a button is released .......</p> <p>please tell me what button actions are to be used to do this ....</p> <p>i tried with touchup inside touch down touch up out side but it is not working correctluy can any one please help me how to make it working correctly..... </p> <p>thank you.</p>
iphone
[8]
4,925,925
4,925,926
Infinite loop while reading stdio.h
<p>why does the following program gets stuck in an infinite loop??</p> <pre><code>int main() { string fname = "C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include\\stdio.h"; char line[985]; ifstream file(fname.c_str()); if(file == NULL) { cout&lt;&lt;"unable to open"; exit(0); } while(!file.eof()) { file.getline(line,'\n'); cout&lt;&lt;line&lt;&lt;'\n'; } } </code></pre>
c++
[6]
623,751
623,752
Convert ushort to string
<p>I have a ushort that consists of two bytes.</p> <p>15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0</p> <p>Y = bits 10-0, twos complement mantissa integer.</p> <p>N = bits 15-11, twos complement integer.</p> <p>X = Y * 2^N</p> <p>I need to ouput X as a string.</p> <p>This is what I have tried:</p> <pre><code> private string ConvertLinearToString(ushort data) { int N; int Y; int X; N = Convert.ToInt16(GetBitRange((byte)data, 0, 5)); Y = Convert.ToInt16(GetBitRange((byte)data, 6, 11)); X = Convert.ToInt16(Y * Math.Pow(2, (double)N)); return Convert.ToString(result); } private byte GetBitRange(byte b, int offset, int count) { return Convert.ToByte((b &gt;&gt; offset) &amp; ((1 &lt;&lt; count) - 1)); } </code></pre> <p>I'm stuck trying to convert the GetBitRange() formula to use ushort and also how to handle the twos complement.</p>
c#
[0]
4,650,374
4,650,375
Is Eval my only option?
<p>I'm wondering if Eval() is the only option I really have for calling scripts on my server and also executing the javascript on those files.</p> <p>I see every where about security issue with Eval and people don't recommend it - so is there any safe way to request files with javascript and execute that JS ?</p>
javascript
[3]
2,960,812
2,960,813
Python method/function arguments starting with asterisk and dual asterisk
<p>I am not able understand where does these type of functions are used and how differently these arguments work from the normal arguments. I have encountered them many time but never got chance to understand them properly.</p> <p>Ex:</p> <pre><code>def method(self, *links, **locks): #some foo #some bar return </code></pre> <p>I know i could have search the documentation but i have no idea what to search for.</p>
python
[7]
1,983,058
1,983,059
Simple way to do dynamic but square layout
<p>I'm using a GridView to display a bunch of views which are essentially LinearLayouts. I want the LinearLayouts to all be square, but I also want them to be dynamically sized--that is, there are two columns and I want the LinearLayouts to stretch depending on the size of the screen but remain square. Is there a way to do this through the xml layout or do I have to set the heights and widths programmatically?</p>
android
[4]
3,827,973
3,827,974
Problems with dynamic array creation using pointers
<p>I'm trying to create a 2d dynamic array using the values of an array of <code>int</code> as my pointers. I don't know how to put this in words exactly, so here is the code. Maybe you'll understand what I'm trying to do if you see it.</p> <pre><code>#include "stdafx.h" #include &lt;iostream&gt; using namespace std; int main(){ const int length =5; int arr[5]={1,1,3,9,1}; int* AR[length]; for (int i=0; i&lt;length;i++) { for (int j=0; j&lt;(arr[i]); j++){ AR[i] = new int (arr[i]); AR[i][j]=93; cout&lt;&lt;"["&lt;&lt;AR[i][j]&lt;&lt;"] "; } cout&lt;&lt;endl; } for (int i = 0; i &lt; length; i++) { for (int j=0; j&lt;arr[i]; j++) { delete[] AR[i]; delete []&amp;AR; } } return 0; } </code></pre> <p>Whenever I run it with <code>arr[] &lt; 4</code> it runs perfectly, but if the size of <code>arr</code> exceeds 4 values it crashes. Can you see why?</p>
c++
[6]
1,038,357
1,038,358
How to tell Jquery about Appended form row
<p>Hi I've got a form that can have a row of items added via ajax. But when this row is added, the new inputs can't receive focus.</p> <p>In trying to work this out, i discovered they do receive focus if an alert is triggered during the bind function.</p> <p>I have looked around for answers, but i just can't get it to work. I think "live" function might be related but i don't really get how to use it. </p> <p>here is my code. </p> <pre><code>$("#doogal").bind("click", function (event) { $.ajax({data:$("#doogal").closest("form").serialize(), dataType:"html", success:function (data, textStatus) {$("#saleitems").append(data);}, type:"get", url:"\/saleitems\/add\/" + $rows}); $rows = $rows + 1; // alert("uncomment this to enable focus"); $("#autoComplete_1").focus(); return false; }); </code></pre> <p>Thanks!</p>
jquery
[5]
3,425,194
3,425,195
Print true values separately
<pre><code>a = 'abcdef' ,'ijklmno' , 'pqrst' b = 'ijklmno' , 'zxy' c = b in a print c </code></pre> <p>output :</p> <pre><code> True , False </code></pre> <p>How to print the value of true separately . i'e 'ijklmno' is true so i want to print it seperately</p>
python
[7]
3,875,824
3,875,825
stop camera click sound programmatically in android
<p>I am using android's default camera to click images from within my app. I want to stop the click sound that it does on clicking an image. Is there a way to stop that click sound programtically?</p> <p>Thanks.</p>
android
[4]
5,629,589
5,629,590
Referencing a parameter in a function directly
<p>I'm trying to edit a piece of code written by a development company, which uses the following construct a lot:</p> <pre><code>$dbcol = grabdata($strSqlB,'','','','','','',2); </code></pre> <p>Is there really not an easier way to do this? The code is completely unreadable. </p> <p>I would have thought that the following would work, and work well for readability:</p> <pre><code>$vars = array("parameter1" =&gt; $strSqlB, "parameter7" =&gt; 2); $dbcol = grabdata($vars); </code></pre> <p>is there anything that needs to be refactored in the function itself to make this work? Is there anything else clever we could do to make this less of a clusterfudge? </p>
php
[2]
3,858,143
3,858,144
not working function with no errors
<p>I've implemented a function to display an avl tree after inserting nodes into it like this</p> <pre><code>template&lt;class nodetype&gt; void AVLtree&lt;nodetype&gt;::display() const { display(Proot); } template&lt;class nodetype&gt; void AVLtree&lt;nodetype&gt;::display(Node&lt;nodetype&gt; * ptr) const { if(ptr==0) return ; cout&lt;&lt;ptr-&gt;value&lt;&lt;" "; display(ptr-&gt;Pleft); display(ptr-&gt;Pright); } </code></pre> <p>after compiling,there were no errors ,the program worked but nothing were printed on the screen</p> <p>help me please....!! thanks</p>
c++
[6]
2,753,760
2,753,761
run time error running the stack which could be due to array size
<p>I created a class that runs a stack. However when I run the main class it gives a runtime error. The class runs like a stack but when the numbers entered go over the stack size its supposed to call a method that copies the array add more size to the stack.</p> <p>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 at IntegerStack.push(IntegerStack.java:26) at Lab15.main(Lab15.java:18)</p> <p>I think the problem lies within this class I dont know exactly where my problem lies. I could be wrong but it could be with my copy of the array. </p> <pre><code> import java.util.Arrays; public class IntegerStack { private int stack []; private int top; public IntegerStack(int SIZE) { stack = new int [SIZE]; top = -1; } public void push(int i) { if (top == stack.length) extendStack(); else stack[++top]= i; } public int pop() { return stack[top--]; } public int peek() { return stack[top]; } public boolean isEmpty() { if ( top == -1) return true; else return false; } private void extendStack() { stack = Arrays.copyOf(stack, 2 * stack.length); } } </code></pre>
java
[1]
4,050,395
4,050,396
Hide application icon
<p>I am doing an Android application. I want to hide the application icon in the emulator and I want to start my application by pressing some numbers, for instance 456#. Is there a way to do this?</p>
android
[4]
5,097,044
5,097,045
Python method parameter list
<p>in a method definition why would someone set the formal parameter <code>amount</code> equal to the constant <code>PERMANENCE_INC</code> in the formal parameter list?</p> <pre><code>def increasePermanence(self, amount=PERMANENCE_INC): """ Increases the permanence of this synapse. """ self.permanence = min(1.0, self.permanence+amount) </code></pre>
python
[7]
890,092
890,093
Python. figuring out how to input a correct phone number
<p>So I'm new to python and I'm writing a program that accepts a phone number in the format XXX-XXX-XXXX and changes any letters to their corresponding numbers. I need to check the entry and make sure it's in the correct format, and if its not, allow it to be reentered. I'm having a hard time getting it to prompt me for a new number, and even when that works sometimes, it will still translate the original, wrong phone number.</p> <p>This is my code so far:</p> <pre><code>def main(): phone_number= input('Please enter a phone number in the format XXX-XXX-XXXX: ') validNumber(phone_number) translateNumber(phone_number) def validNumber(phone_number): for i,c in enumerate(phone_number): if i in [3,7]: if c != '-': phone_number=input('Please enter a valid phone number: ') return False elif not c.isalnum(): phone_number=input('Please enter a valid phone number: ') return False return True def translateNumber(phone_number): s="" for char in phone_number: if char is '1': x1='1' s= s + x1 elif char is '-': x2='-' s= s + x2 elif char in 'ABCabc': x3='2' s= s + x3 </code></pre> <p>.....etc this part isn't important</p>
python
[7]
932,193
932,194
Reading standard output from process, always empty
<p>Running this code:</p> <pre><code>Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "tool.exe"; p.Start(); p.WaitForExit(); </code></pre> <p>Makes tool.exe run, and output some content on standard output. However, if I try to capture the content using:</p> <pre><code>Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName = "tool.exe"; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); Console.WriteLine(output); Console.ReadLine(); </code></pre> <p>Then nothing gets outputted, i.e. my variable "output" is always empty.</p> <p>I've verified that tool.exe indeed outputs to standard output (and not standard error).</p> <p>Anyone have a clue of what's going on? Starting to feel stupid here, as it seems to be a real text book example...</p>
c#
[0]
3,357,294
3,357,295
Android ScreenSize
<p>Per the android multiple screen design<br> "As you design your UI for different screen sizes, you'll discover that each design requires a minimum amount of space. So, each generalized screen size above has an associated minimum resolution that's defined by the system. These minimum sizes are in "dp" units—the same units you should use when defining your layouts—which allows the system to avoid worrying about changes in screen density.</p> <pre><code>xlarge screens are at least 960dp x 720dp large screens are at least 640dp x 480dp normal screens are at least 470dp x 320dp small screens are at least 426dp x 320dp </code></pre> <p>" DisplayMetrics class gives me access to actual width and height of the screen. However is the above table available programmatically. Or do I need to store these values as constants in my app. The second option seems hacky. </p>
android
[4]
1,948,137
1,948,138
How to copy a xml file from res/raw folder to sd card of android?
<p>I want to copy a xml file from res/raw folder to the sd card. This question is actually specific to the ODK Collect. But any help would be appreciated. I have looked at <a href="http://stackoverflow.com/questions/3851712/android-how-to-create-a-directory-on-the-sd-card-and-copy-files-from-res-raw-to">Android: How to create a directory on the SD Card and copy files from /res/raw to it??</a> and other similar posts on the web but I was still unable to copy. Maybe, its because I am working on ODK Collect. This is my code for copying the file:</p> <pre><code> try { InputStream in = getResources().openRawResource(R.raw.problem2); OutputStream out = new FileOutputStream(Collect.FORMS_PATH+"/problem2"); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) &gt; 0) { out.write(buf, 0, len); } in.close(); out.close(); } catch(IOException e) { } </code></pre> <p>Thanks in advance.</p>
android
[4]
140,650
140,651
how can show error or warning in the page
<p>I have a site in a server.</p> <p>Because of settings, no error or warning is displaying in the page</p> <p>How can i change the setting, using .htaccess file</p>
php
[2]
516,641
516,642
How to minimize duplication code in Android without creating Objects
<p>I have multiple activities in which I want to use same code in those activity. I finished it with having same bunch of code in each activity. How can minimize this redundant code. For doing this I dont want to create object and use it's methods for removing redundancy...</p> <p>Plz help... Thank U....</p>
android
[4]
5,498,929
5,498,930
Why data show one row.I want show all row.Please helpme
<pre><code> Connection conn = null; String url = "jdbc:jtds:sqlserver://192.168.1.11:1433/"; String dbName = "koh;Instance=MSSQLSERVER;"; String userName = "bit"; String password = "1234"; String driver = "net.sourceforge.jtds.jdbc.Driver"; try { Class.forName(driver).newInstance(); conn = DriverManager.getConnection(url+dbName,userName,password); Log.w("connect","Connect Success"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT LocalDesc FROM StaffPosition WHERE LocalDesc IN ('XXX','Administrator','Trainner')"); String[] items44 = new String[] {}; while (rs.next()) { items44 = new String[]{rs.getString("LocalDesc")}; } Spinner spinner = (Spinner) findViewById(R.id.spinner1); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String( this,android.R.layout.simple_spinner_item, items44); adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); conn.close(); }catch (Exception e) { Log.w("can't connect",e.toString()); } } </code></pre> <p>data is show one row . Show XXX but not show Administrator and Trainner. Do you like this.Pleast example to me.</p>
android
[4]
695,299
695,300
javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details
<p>Whenever I tried to run my Google App Engine project(using JSF 2 and Apache MyFaces), got following error:</p> <p><strong>java.lang.NoClassDefFoundError: javax.naming.InitialContext is a restricted class. Please see the Google App Engine developer's guide for more details.</strong></p> <p>Any solution?</p>
java
[1]
523,894
523,895
jQuery .each() this and element
<p>Inside a .each() callback, is there any difference between <code>this</code> and the second argument of the callback function?</p> <p>For example, in the following code:</p> <pre><code>$("example").each( function(index, element) { // body }); </code></pre> <p>is there any difference between <code>this</code> and <code>element</code>? Is the second argument just provided so you can choose a name?</p>
jquery
[5]
2,968,938
2,968,939
always returns nil in iPhone
<p>I am trying to apply Mike Chen's answer <a href="http://stackoverflow.com/questions/1325897/how-can-i-take-a-photo-frequently-with-iphone/1328176#1328176">here</a>, using SDK 3.0. In delegate.m file I implement;</p> <pre><code>[viewController.view addSubview:[[objc_getClass("PLCameraController") sharedInstance] previewView]]; </code></pre> <p>and in viewcontroller.m I implement:</p> <pre><code>PLCameraController *cam = [objc_getClass("PLCameraController") sharedInstance]; CapturedImage = [cam _createPreviewImage]; </code></pre> <p>but 'cam' is always nil. Any suggestions? </p>
iphone
[8]
5,490,793
5,490,794
os.path.isfile does not work as expected
<p>I am trying to scan my harddrive for jpg and mp3 files. </p> <p>I have written the following script which works if I pass it a directory with file in the root but does not return anything if I pass it the root directory. </p> <p>I am new to Python so would love some help.</p> <pre><code>def findfiles(dirname,fileFilter): filesBySize = {} def filterfiles(f): ext = os.path.splitext(f)[1][1:] if ext in fileFilter: return True else: False for (path, dirs, fnames) in os.walk(dirname): if len(fileFilter)&gt;0: fnames = filter(filterfiles,fnames) d = os.getcwd() os.chdir(dirname) for f in fnames: if not os.path.isfile(f) : continue size = os.stat(f)[stat.ST_SIZE] if size &lt; 100: continue if filesBySize.has_key(size): a = filesBySize[size] else: a = [] filesBySize[size] = a a.append(os.path.join(dirname, f)) # print 'File Added: %s' %os.path.join(dirname,f) _filecount = _filecount + 1 os.chdir(d) return filesBySize </code></pre>
python
[7]
1,768,985
1,768,986
How to run a method at XX:XX:XX time?
<p>HI</p> <p>I want to run a method in my program evry X hours, how to do that ? Im googling and there is nothing :/</p>
java
[1]
5,691,733
5,691,734
error in running recursion
<p>if running function returns server misconfiguration error</p> <pre><code> function build_path($cid) { $result = array(); $DB = new MySQLTable; $DB-&gt;TblName = 'shop_categories'; $where['cat_id']['='] = $DB-&gt;CleanQuest($cid); $res = $DB-&gt;Select('cat_id,cat_name,cat_parent', $where); if($res !== 'false') { $pid = mysql_fetch_array($res); if($pid['cat_parent'] !== 0) { Echo $pid['cat_parent']; build_path($pid['cat_parent']); } else { Echo $pid['cat_id']; return true; } } return false; } </code></pre> <p>I can't find an error here. Please help.</p> <p>Sorry for disturbing you all. The trouble was in comparison 'if($pid['cat_parent'] !== 0)': $pid['cat_parent'] was a string with int(0)</p> <p>Can i build this function to store full path without using GLOBALS and SESSION vars?</p>
php
[2]
593,537
593,538
copy() & getcwd() works locally, not online
<p>This line of code works for me locally:</p> <pre><code>$copythumb = copy($externalsource, getcwd().'\\img\\covers\\'.$id.'thumb.jpg'); if (!$copythumb) {echo 'Couldn\'t add thumbnail';} </code></pre> <p>But when I upload it to my server I just get "Couldn't add thumbnail" and it's not copied. I've tried to change <code>\\img\\covers\\</code> to <code>/img/covers/</code> with no luck. Ive' also messed around with <code>dirname(realpath(__FILE__))</code> and <code>$_SERVER['DOCUMENT_ROOT']</code></p> <p>Local:</p> <pre><code>echo getcwd(); //returns D:\Server\www\project </code></pre> <p>Server:</p> <pre><code>echo getcwd(); //returns /storage/content/xx/xxxxxx/xxx.com/public_html/project </code></pre> <p>Would be really thankful if someone could provide any help!</p>
php
[2]
2,624,881
2,624,882
jquery - JSON to <table>
<p>I have Json of the form</p> <pre><code>[{"id":39,"data":1},{"id":40,"data":2}] </code></pre> <p>It does not parse properly with <code>jQuery.parseJSON()</code></p> <p>I need to take this data and create a html <code>table</code>. I was thinking of creating the HTML dynamically in the js. </p> <p>A. How can I parse the json?<br /> B. Is dynamic html the best route?</p> <p><strong>Update</strong> <br />I apologize. Evidently my question is not clear. Here is the jquery</p> <pre><code>$.get('Service.aspx', { p1: value, p2: value }, function (data) { notesJson = data; alert(notesJson);//Json comes back as I said here... var noteSet = jQuery.parseJSON(notesJson); alert(noteSet.notes); }); </code></pre> <p>notes does exist in the Json. The second alert fails "undefined".</p>
jquery
[5]
5,109,719
5,109,720
Cache ? Or Not?
<p>I have an ajax application, it will call the webmethod in the Bussiness Server (WebGarden) and the webmethod will create file or delete file or getfiles from the File Server (RAID 1) </p> <p>My Problem is that if I do the following</p> <ol> <li>Directory.GetFiles(...)</li> <li>CreateFile(or DeleteFile)</li> <li>Directory.GetFiles </li> </ol> <p>Then, I got the same result at 1 and 3</p> <p>I think this is because the cache, but I dont know where has the cache and how can I fix the problem. </p> <p>My Language is C# and the Server is Webgarden. maxworkprocess=4, Raid 1 </p> <p><strong>ADD:</strong> I think there is no problem with the code , because it had been working on it over 4 years, however when I moving the app to the new server, the problem always happens.</p>
c#
[0]
2,494,829
2,494,830
how to shorten a string by certain number of characters?
<p>Is there a php function that can chop let's say 10 chars of the end of a string without calling strlen ? So I can avoid unnecessary repeating of variable names. </p> <p>all I know is <code>substr($str,0,strlen($str)-10);</code></p>
php
[2]
2,384,871
2,384,872
Select dropdown and auto check the checkbox if the selected value of dropdown is not empty
<p>When people selected the dropdown and then the checkbox will be auto checked if the selected value of dropdown is not empty. But I met "sel[i] is undefined" error.</p> <p>Javascript part:</p> <pre><code>var chk = document.getElementsByTagName("input"); var sel = document.getElementsByTagName("select"); for (var i=0; i&lt; sel.length; i++) { sel[i].onchange = function(){ if (sel[i].value !== ''){ chk[i].checked = true; } else{ chk[i].checked = false; } }; } </code></pre> <p>HTML part:</p> <pre><code>&lt;form name="form1"&gt; &lt;div class="container"&gt; &lt;input id='checkbox_id1' name='checkbox_id1' type='checkbox' value='1' /&gt;&lt;/label&gt;&amp;nbsp; Select &lt;label&gt; &lt;select id="select_id1" name="select"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="111"&gt;111&lt;/option&gt; &lt;option value="222"&gt;222&lt;/option&gt; &lt;/select&gt; &lt;/label&gt; &lt;hr&gt; &lt;input id='checkbox_id2' name='checkbox_id1' type='checkbox' value='1' /&gt;&lt;/label&gt;&amp;nbsp; Select &lt;label&gt; &lt;select id="select_id2" name="select"&gt; &lt;option value=""&gt;&lt;/option&gt; &lt;option value="111"&gt;111&lt;/option&gt; &lt;option value="222"&gt;222&lt;/option&gt; &lt;/select&gt; &lt;/label&gt; &lt;/div&gt; </code></pre> <p></p> <p>jsfiddle: <a href="http://jsfiddle.net/planetoid/GwEuu/" rel="nofollow">http://jsfiddle.net/planetoid/GwEuu/</a></p>
javascript
[3]
1,020,021
1,020,022
How to debug when an app is launched with URL Scheme from Safari
<p>I want to test my app for my app launched with a URL scheme from Safari, how can that be done?</p>
iphone
[8]
1,802,609
1,802,610
Simultaneously toggling 2 divs in 1 container + 2 in another container
<p>I'm not sure how to search for this: on a gallery page I want to be able to toggle the image between its original size and 2x by clicking on it <strong>but also</strong> by clicking a zoom button in another container which changes state (indicating you can either zoom in or out in concordance with the image div current state)</p> <p>I got as far as toggling the image by clicking it or the button but I don't know how to also toggle the button.</p> <p>Thanks.</p>
jquery
[5]
4,309,856
4,309,857
appending html string with .append() does not work?
<p>I am rather new to jquery, so please bear with me. I have created an HTML page containing a number of hooks to which I want to append new elements. Appending a string works as expected:</p> <pre><code>$(theParentNode).append ("blurb1"); </code></pre> <p>But appending HTML does not:</p> <pre><code>$(theParentNode).append ("&lt;b&gt;blurb2&lt;/b&gt;"); </code></pre> <p>When I check the resulting DOM there are no children of the parent node. And finally, when I try this:</p> <pre><code>$(theParentNode).append ("blurb1"); $(theParentNode).append ("&lt;b&gt;blurb2&lt;/b&gt;"); $(theParentNode).append ("blurb3"); </code></pre> <p>only the first child node shows up in the parent's list of children. A final experiment involved adding a "span" instead of a "b" element. In that case I get an error from jquery: div is null, line 6443 of jquery-1.7.2.js</p> <p>I must be overlooking something very basic, but still it's difficult why it doesn't work since append is supposed to take html strings... Thanx for any help!</p>
jquery
[5]
4,282,995
4,282,996
download a site and upload to other server
<p>I built a website on www.weebly.com with their tools Now I wanna to host it on another server.It allows export of site as a zip format so I downloaded my site in zip format but the pages are not opening as original.Slide show photo gallery and others are not working.I do not have much knowledge of java. please provide me a solution to download site appearing as original.</p>
javascript
[3]
2,625,017
2,625,018
Accessing IMEI # From Web Application
<p>Is there any possibility that can i get the IMEI # Of Mobile from a web application. Suppose a request comes from a mobile then i can get the imei # from that request ?</p>
asp.net
[9]