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,745,866
2,745,867
app crashes while writing data together
<p>I am trying to write NSData objects together. It's a 450 mb file. I'm doing it with 50mb chunks like so:</p> <pre><code>for (NSString *packetName in listOfFiles) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *packetPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:packetName]; NSData *packetData = [[NSData alloc] initWithContentsOfFile:packetPath]; [output seekToEndOfFile]; [output writeData:packetData]; [fileManager removeItemAtPath:packetPath error:&amp;error]; NSLog(@"Removed file after appending data success: %i Error: %@", success, [error localizedDescription]); [self updateManifestColumn:@"IsParsed" withValue:YES forFile:packetName inTable:tableName]; packetData = nil; [packetData release]; [pool release]; } [output closeFile]; </code></pre> <p>I call this method, right after I received the packets in connectionDidFinishLoading. I saved those files to the Documents directory so the user could download first on Wifi, and then the restitching could happen afterwards. This is done in a DataManager class which handles these types of operations so I don't have didReceiveMemoryWarning like I would in a ViewController. I do not get a Memory warning on the Console when I run the app on the device connected to my machine. </p> <p>What should I do if it's in the middle of writing the data to ensure that the data is correct when the user receives it? Would it be better to do this with smaller packets? Does that make it safer? Thanks!</p>
iphone
[8]
4,714,087
4,714,088
movie orientation
<p>How can I detect a movie orientation (portrait or landscape) or width and height of it? For example, when using UIImagePickerController:</p> <pre><code>- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info { if ([[info valueForKey:UIImagePickerControllerMediaType] isEqualToString:(NSString*)kUTTypeMovie]) { NSURL *videoURL = [info valueForKey:UIImagePickerControllerMediaURL]; } } </code></pre> <p>how can I get this information from videoURL?</p> <p>Now I'm trying to locate a video thumbnail images in /tmp directory and work with them but this method is not stable.</p> <p>Thanks in advance.</p>
iphone
[8]
2,004,088
2,004,089
jquery ajaxSubmit replaceTarget javascript
<p>I have a div in this pattern:</p> <pre><code>&lt;div id="register_container"&gt; ... &lt;script type="text/javascript"&gt; $(document).ready(function() alert('hi'); $("#customer").css("backgroundColor", "red"); $('#add_item_form').ajaxSubmit({target: "#register_container", replaceTarget: true}); &lt;/script&gt; &lt;/div&gt; </code></pre> <p>The first run around I get a background color of red on the #customer select box and an alert. The 2nd...n times around I get an alert but the #customer background doesn't change. It seems to be operating on the "Old" stuff. How can I fix this?</p>
jquery
[5]
1,357,826
1,357,827
Add values to app.config and retrieve them
<p>I need to insert key value pairs in app.Config as follows:</p> <pre><code>&lt;configuration&gt; &lt;appSettings&gt; &lt;add key="Setting1" value="Value1" /&gt; &lt;add key="Setting2" value="Value2" /&gt; &lt;/appSettings&gt; &lt;/configuration&gt; </code></pre> <p>When I searched in google I got the following code snippet</p> <pre><code>System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Add an Application Setting. config.AppSettings.Settings.Add("ModificationDate", DateTime.Now.ToLongTimeString() + " "); // Save the changes in App.config file. config.Save(ConfigurationSaveMode.Modified); </code></pre> <p>The above code is not working as ConfigurationManager is not found in System.Configuration namespace I'm using .NET 2.0. How to add key-value pairs to app.Config programatically and retrieve them?</p>
c#
[0]
1,582,027
1,582,028
time now in Riyadh (KSA) , by javascript
<p>How are you ?</p> <p>I want to add block in site about time now in Riyadh (+3 time zone) (Capital of saudi arabia) </p> <p>for example when the visitor from Germany or Spain come to my site , he wants to know the time in Riyadh , how can show the time now in Riyadh .</p> <p>also I want the time 12h ( 12:10:25 am ) ..</p> <p>Thank you very much for helping me ..</p>
javascript
[3]
6,014,129
6,014,130
Device Id through Java?
<p>How can i find the device of my fingerprint reader through the Java programming? Is there any specific method in any specific package?</p>
java
[1]
2,388,799
2,388,800
c++ - relearning
<p>I haven't done C++ for about three years and looking to get back and ready. What is the best way? any open source projects that I might want to look at to recall all the details and be ready for interviews? I started reading (again) C++ Primer 5th edition but was wondering whether there's more efficient way since I did program in C++ for few years before. </p> <p>Just wanted to add: Does anyone know about open source projects related to finance? (e.g. servers, fix, etc)</p>
c++
[6]
3,782,937
3,782,938
java - codesprint2 programming contest answer
<p>I recently took part in Codesprint2. I was unable to submit the solution to the following question. <a href="http://www.spoj.pl/problems/COINTOSS/" rel="nofollow">http://www.spoj.pl/problems/COINTOSS/</a> ( I have posted the link to the problem statement at spoj because the codesprint link requires login )</p> <p>I checked out one of the successful solutions, ( url : <a href="http://pastebin.com/uQhNh9Rc" rel="nofollow">http://pastebin.com/uQhNh9Rc</a> ) and the logic used is exactly the same as mine, yet I am still getting "Wrong Answer"</p> <p>I would be very thankful if someone could please tell me what error I have made, as I am unable to find it. Thank you.</p> <p>My code : </p> <pre><code>import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.DecimalFormat; import java.util.StringTokenizer; public class Solution { static double solve( int n, int m ) { if( m==n ) return 0; if( m==0 ) return ( Math.pow( 2, n+1 ) - 2 ); else { double res = 1 + ( Double )( solve( n, m+1 ) + solve( n, 0 ))/2; return res; } } public static void main( String[] args ) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader( System.in )); int n, m; int t = Integer.parseInt( br.readLine() ); StringTokenizer tok; String s; for( int T=0; T&lt;t; T++ ) { s = br.readLine(); tok = new StringTokenizer( s ); n = Integer.parseInt( tok.nextToken() ); m = Integer.parseInt( tok.nextToken() ); DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(2); df.setMinimumFractionDigits(2); System.out.println( df.format ( solve( n, m ) )); } } </code></pre> <p>}</p>
java
[1]
5,803,551
5,803,552
Javascript Array of objects - how do i loop through and get the object values
<p>Im having some issues creating an array of objects in javascript</p> <p>Please see my code below and tell me where im going wrong..</p> <p>I simply want to loop through and access the values</p> <pre><code>&lt;!-- Read XML Script --&gt; &lt;script type="text/javascript"&gt; // Object array var myArray = []; $(document).ready(function () { $.ajax({ type: "GET", url: "HighScore.xml", dataType: "xml", success: function (xml) { $(xml).find('challenger').each(function () { var name = $(this).find('Name').text(); var watts = $(this).find('Watts').text(); var Mins = $(this).find('Mins').text(); // objects in the array challenger = new Object(); challenger.name = name; challenger.watts = watts; challenger.Mins = Mins; myArray.push(challenger); }); // look into the array for (obj in myArray) { // do i need to cast ?? how can i view the object ?? alert(obj + " - "); } }, error: function () { alert("error"); } }); }); &lt;/script&gt; </code></pre>
javascript
[3]
5,123,780
5,123,781
Get the end of string with Javascript
<p>I am storing a string (url) in a variable it can look like one/two/three/test.aspx?ID=12312 I want to extract the querystring value, not from window.location but from the html</p> <p>I thought I could use substring and write</p> <pre><code>var link = ($(this).find('a').attr('href')); var qs = link.substring( link.indexOf("="), text.indexOf(" ") ) </code></pre> <p>but it returns the string before the = and not after.</p> <p>What am I doing wrong? Thanks in advance.</p>
javascript
[3]
1,979,393
1,979,394
How to create round cornered Map View in Android?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5211731/adding-rounded-corners-to-a-mapview">Adding rounded corners to a mapview</a> </p> </blockquote> <p>For my Android application i need to create a round cornered MapView, I surfed in Google i could found any solution. Please some body help to solve this problem if you knows this.</p> <p>Thanks in Advance, </p> <p>Rajapandian</p>
android
[4]
1,235,222
1,235,223
Convert to word representation of a number
<p>Using C# I need to convert an integer to it's word representation, and only go up to 5 to 10. Is there a better way to do it than this?</p> <pre><code>static string[] numberwords = { "zero", "one", "two", "three", "four", "five" }; public static string GetNumberAsString(int value) { return numberwords[value]; } </code></pre>
c#
[0]
4,369,876
4,369,877
Android: how to make keyboard enter button say "Search" and handle its click?
<p>I can't figure this out. Some apps have a EditText (textbox) which, when you touch it and it brings up the on-screen keyboard, the keyboard has a "Search" button instead of an enter key.</p> <p>I want to implement this. How can I implement that Search button and detect press of the Search button?</p> <p><strong>Edit</strong>: found how to implement the Search button; in XML, <code>android:imeOptions="actionSearch"</code> or in Java, <code>EditTextSample.setImeOptions(EditorInfo.IME_ACTION_SEARCH);</code>. But how do I handle the user pressing that Search button? Does it have something to do with <code>android:imeActionId</code>?</p>
android
[4]
3,601,246
3,601,247
How to generate unique 3 or 4 letter alpha strings based on first & last name
<p>I need to loop through every one in the DB and give them a unique 3/4 letter stock symbol like code.</p> <p>I've got roughly 600 names (of people) and want to generate stock symbol like unique codes for them all, but based roughly on the names (like stock symbols).</p> <p>For example: Dale Cooper could be DCO/DAC/DC, but Darren Cooper should generate a different code as all 600 should be unique.</p> <p>first_name and last_name are in different columns.</p> <p>Advice much appreciated.</p>
php
[2]
4,124,923
4,124,924
android: How to hide group indicator in BaseExpandableListAdapter when child count = 0
<p>Please help me hide the group indicator in BaseExpandableListAdapter when child count is zero. I have a list of groups with various dynamic child counts and I would like to hide the icon only for those groups that do not have any children. What is the proper way to do this?</p>
android
[4]
4,999,915
4,999,916
Image URL in a ASP.Net Page
<p>I have a default image in my folder in visual studio.</p> <p>How can I get the server path to find the image in runtime in code?</p> <pre><code>if (String.IsNullOrEmpty(entry.Picture)) { //image1.ImageUrl = @"F:\Temp\Projects\IMEICHECK\IMEICHECK\Images\Design\New\no-image.gif"; } else image1.ImageUrl = entry.Picture; </code></pre>
asp.net
[9]
4,599,870
4,599,871
Difference between local variables and arguments
<pre><code>function addLinks () { for (var i=0, link; i&lt;5; i++) { link = document.createElement("a"); link.innerHTML = "Link " + i; link.onclick = function (num) { return function () { alert(num); }; }(i); }} </code></pre> <p>A closure is created for each link; each closure has reference to the scope in which it was created. Since argument <code>num</code> has been updated on each loop, on <code>click</code> on the first link it should alert <code>4</code>. Isn't it?</p>
javascript
[3]
5,095,565
5,095,566
how to set textMode = Multiline for dynamic text box in c#
<pre><code>TextBox txt = new TextBox(); txt.TextMode = "MulitiLine"; </code></pre> <p>is not working </p> <p>how to set <code>textMode = Multiline</code> for dynamic text box in c#</p>
c#
[0]
4,291,921
4,291,922
How to hide (disable) specific days using CalenderExtender Plus in ASP.NET
<p>In my ASP.NET application, I created a page which has a textbox with CalenderExtenderPlus in which the user can select a date. I need to disable the some days (holidays, etc.) such that the user is not able to select those days.</p> <p>I'm looking for functionality similar to jQuery Datepickers "beforeShowDay".</p> <p>How might I accomplish this?</p>
asp.net
[9]
972,272
972,273
How can I calculate log base 2 in c++?
<p>Here is my code.</p> <pre><code>#include &lt;iostream&gt; #include&lt;stdlib.h&gt; #include&lt;stdio.h&gt; #include&lt;conio.h&gt; #include&lt;math.h&gt; #include &lt;cmath&gt; #include &lt;functional&gt; using namespace std; void main() { cout&lt;&lt;log2(3.0)&lt;&lt;endl; } </code></pre> <p>But above code gives error. Error code is : error C3861: 'log2': identifier not found. How can i calculate log2 using c++?</p>
c++
[6]
3,624,428
3,624,429
Which one of these sites to start learning python? (complete beginner)
<p>Sorry if this question isn't allowed, but of these 3 which one do you recommend for a complete beginner? (I have absolutely NO programming knowledge, this is my first ever language)</p> <ul> <li><a href="http://greenteapress.com/thinkpython/html/index.html" rel="nofollow">greenteapress.com/thinkpython/html/index.html</a></li> <li><a href="http://thenewboston.org/list.php?cat=36" rel="nofollow">thenewboston.org/list.php?cat=36</a></li> <li><a href="http://net.tutsplus.com/sessions/python-from-scratch/" rel="nofollow">net.tutsplus.com/sessions/python-from-scratch/</a></li> </ul>
python
[7]
4,059,128
4,059,129
GPS is on, yet LocationManager returns null
<p>The GPS on my Android phone is on, supported by the fact that :</p> <pre><code>location_manager.isProviderEnabled(LocationManager.GPS_PROVIDER) </code></pre> <p>returns true.</p> <p>Yet, the following line :</p> <pre><code> Location location = location_manager.getLastKnownLocation(LocationManager.GPS_PROVIDER) ; </code></pre> <p>returns null.</p> <p>What could be the reason ?</p> <p>Thanks.</p>
android
[4]
599,499
599,500
Backslash in JavaScript
<p>In my javascript code I have </p> <pre><code>onchange="document.getElementById('user_name').value = document.getElementById('theDomain').value + '\\' + document.getElementById('fake_user_name').value" </code></pre> <p>here backslash doesn't work. What is the problem? How should I write it?</p> <p>example: I want to have "x.com\joe" by using domain name(x) and fakeusername (joe) but the result I get is just joe when I use '\' </p>
javascript
[3]
5,099,080
5,099,081
Expected constructor, destructor, or type conversion before '*' token
<p>I honestly have no idea why this is happening. I checked, double-checked, and triple-checked curly braces, semicolons, moved constructors around, etc. and it still gives me this error.</p> <p>Relevant code follows.</p> <p>BinTree.h</p> <pre><code>#ifndef _BINTREE_H #define _BINTREE_H class BinTree { private: struct Node { float data; Node *n[2]; }; Node *r; Node* make( float ); public: BinTree(); BinTree( float ); ~BinTree(); void add( float ); void remove( float ); bool has( float ); Node* find( float ); }; #endif </code></pre> <p>And BinTree.cpp</p> <pre><code>#include "BinTree.h" BinTree::BinTree() { r = make( -1 ); } Node* BinTree::make( float d ) { Node* t = new Node; t-&gt;data = d; t-&gt;n[0] = NULL; t-&gt;n[1] = NULL; return t; } </code></pre>
c++
[6]
2,011,259
2,011,260
C++: avoid optimizing out variable
<p>I have some useful code in constructor or class <code>Valuable</code>. I want be sure it's executed before <code>submain</code>. How can I guarantee that it's not optimized out?</p> <pre><code>int main() { // Dear compiler, please don't optimize ctor call out! Valuable var; return submain(); } </code></pre> <p>Is local variable enough? Do I need to use <code>static</code>:</p> <pre><code>static Valuable *v = new Valuable(); delete v; v = NULL; </code></pre> <p>Can I shorten previous to one liner:</p> <pre><code>delete new Valuable(); </code></pre>
c++
[6]
3,329,262
3,329,263
create tree from linux directory stucture
<p>I need to create a tree from a linux directory stucture. For example:</p> <pre><code>. 0 ./file1.txt 1 ./file2.txt 2 ./site 3 ./site/file3.txt 4 ./site/ru 5 ./site/ru/file4.txt 6 </code></pre> <p>Each node is a directory or file(if it has no children) and has ID(>=0). The root ID is 0. Parent ID is always lower than child ID. I've created 2 classes:</p> <pre><code>class Node&lt;T1, T2&gt; { T1 key; T2 value; List&lt;Node&lt;T1, T2&gt;&gt; children; Node(T1 key, T2 value) { this.key = key; this.value = value; children = new ArrayList&lt;Node&lt;T1, T2&gt;&gt;(); } public boolean isFile() { return children.size() == 0; } } </code></pre> <p>and </p> <pre><code>public class DirectoryTree&lt;T1 extends Comparable&lt;T1&gt;, T2&gt; { private Node&lt;T1, T2&gt; root = null; public DirectoryTree(T1 key, T2 value) { root = new Node&lt;T1, T2&gt;(key, value); } } </code></pre> <p>How can I fill the tree?</p>
java
[1]
3,579,166
3,579,167
Basic Authentication
<p>I have one VS application named Dotnetpanel, which provides a lot of webservices.</p> <p>I created another another VS application say TestModule in which I need to create the webservice client. But when I try to create a client and call the webservice in TestModule, an error occured"The request failed with HTTP status 401: Unauthorized." From one of articles I have read that</p> <p>DotNetPanel API implemented as a set of SOAP Web Services.</p> <p>Requirements: WSE 3.0 or Basic Authentication <strong>**Each API call should have user’s credentials provided**</strong></p> <p>Basic Authentication: For interacting with DotNetPanel API you should use Basic Authentication. DotNetPanel recognizes “Authorization” header with the user credentials provided in the following format: username:password.</p> <p>So my question is I have a user credentials which can pass to the TestModule and after that how can I call the DotnetPanel webservices from the TestModule with Basic Authentication.</p> <p>Regards</p> <p>Fenix</p>
asp.net
[9]
2,019,760
2,019,761
Dock like Shortcuts
<p>I'm looking to develop a program which allows users to drag their desktop shortcuts onto a dock / slideout bar on the desktop. How can i make it possible for a 'Desktop Shortcut' to be dragged onto the Dock to create a Shortcut there?</p>
c#
[0]
3,496,815
3,496,816
how to perform action(listener) from the function?
<p>I use the following code to return the Scroll View from the function.That Scroll View contain number of check boxes . I call this function and it return the Scroll View correctly.But how to get the value if any of the check box is checked i need to perform some action.How to do this ?</p> <p>Scroll View return Function:</p> <pre><code> public ScrollView MyViewGroup(String[] Fields,int width,int height)throws Exception{ ScrollView sc=new ScrollView(context); sc.setLayoutParams(new LayoutParams(width, height)); TableLayout tbl=new TableLayout(context); for(int i=0;i&lt;Fields.length;i++){ TableRow tr=new TableRow(context); CheckBox ch=new CheckBox(context); ch.setId(i); ch.setText(Fields[i]); tr.addView(ch); tbl.addView(tr); } sc.addView(tbl); return sc; } </code></pre> <p>and i use this function like the following way</p> <pre><code> LinearLay.addView(MyGui.MyViewGroup(strarr[],200,200); </code></pre> <p>Note :</p> <p>MyGui class i create TextViews,EditTexts,Buttons and ScrollView .By using this MyGui Class i create the GUI 's only.I have one activity myform .In that myform class when i click the submit button i need get the checked value's and get some other Edittext Values from the user and take action for the submit Button only.Is there any possibility to do this ???? </p>
android
[4]
3,741,866
3,741,867
Android Color (setColor in Paint) Needs Negative Integer?
<p>I'm simply trying to paint/draw to the Canvas in Android. However, when I set the color using hex values or using the setARGB method, it doesn't work. But when I use Color.x (eg, Color.GREEN) it works. Here's the code:</p> <pre><code> Bitmap image = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(image); Paint paintBackground = new Paint(); int green = Color.argb(0, 0, 255, 0); // 65280 (Won't work) green = 0x0000ff00; // 65280 (Won't work) paintBackground.setARGB(0, 0, 255, 0); green = paintBackground.getColor(); // 65280 (Won't work) green = Color.GREEN; // -16711936 (Works!) paintBackground.setColor(green); green = paintBackground.getColor(); // -16711936 paintBackground.setStyle(Paint.Style.FILL); canvas.drawRect(0, 0, bitmapWidth, bitmapHeight, paintBackground); </code></pre> <p>So basically Color.GREEN returns -16711936 - and this WORKS. However, the hex value is 65280 - and this DOES NOT WORK. That is, it doesn't paint the green rectangle.</p> <p>I need to use hex values because I need to set the color to <code>0x00ffff00</code> here and then later to a different hex value.</p> <p>Does Android Color (setColor in Paint) Need a Negative Integer?</p>
android
[4]
3,143,831
3,143,832
Programmatically start UserControlTestContainer.exe
<p>I implemented a C# user control and succesfully tested it with the UserControlTestContainer.exe by manually interacting with it. Now I would like to programmatically, instead of manually, feed data into the control, through my unit tests and then automatically display the control filled with that data. I guess I need to create an instance of the control, fill it up and then programatically start the container with the control as parameter, don't I? How do I succeed displaying my filled control? The solution doesn't have to involve the above mentioned container of course, any other suggestion to get the work done would be very appreciated.</p>
c#
[0]
3,455,549
3,455,550
Automatically invoking operations/actions
<p>We need to send newsletter/messages to our users at certain times. This is done on the web; however, we want this to be done automatically for certain time. Although this problem suits the Window Service kind model, but we are hosting on public domain; therefore, we can't use this option. </p> <p>Is there any way that this particular action can be invoked automatically at a certain point (time) specified in configuration in the web.config.</p> <p>Currently this is done by manually invoked the operation through admin panel.</p> <p>Platform - ASP.NET 3.5<br> Language - C#</p>
c#
[0]
4,032,725
4,032,726
how to pass a variable thru URL in php
<p>Hi I am trying to pass a value from one file to another file via URL.</p> <p>The way i do is: <code>&lt;a href='fund_view.php?idfund="&lt;? echo $row['idfund']; ?&gt;"'&gt;</code></p> <p>after all i get the right value in other file using </p> <pre><code>$aidi = $_GET['idfund']; echo 'ID= '.$aidi;` </code></pre> <p>But the result i get is this format <code>ID= \"10\"</code></p> <p>the url after i pass the id looks like </p> <pre><code>http://example.com/fund_view.php?idfund="10" </code></pre> <p>and what i want the result to be is just <code>ID="10"</code>.</p>
php
[2]
4,526,885
4,526,886
Is it safe to use a class inside the package sun.misc?
<p>For example should I use <a href="http://java-doc.narod.ru/sun/misc/IOUtils.java.html" rel="nofollow">sun.misc.IOUtils</a>?</p>
java
[1]
2,904,887
2,904,888
Comparing numbers in a file to a console input
<p>I am trying to write a program to read in a number from the console, and then read an arbitrary number of numbers from a file. It should then print out how many times the console number appears in the list read from the file. I am not sure how to do the second part can anyone help me with how to count how many times the number appears. The only code I have so far is for the first part.</p> <p>My idea for the second part was something like this:</p> <pre><code> while(!inputfile.eof){ if(inputfilenumber == consolenumber){ counter = counter + 1; } </code></pre> <p>but I can't seem to put this into practice as I am not sure how it would work. </p>
c++
[6]
3,860,189
3,860,190
why local timeZone String is getting appended in the UTC date?
<p>I want to get a Date Object in UTC Time Zone so i am converting it first to a String which is returing me correct UTC Date String but when i am again parsing it to Date object then Local Time Zone String(ie. IST) is getting appended in that Date instead of UTC.</p> <pre><code> Date date = new Date(); DateFormat timeFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); timeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String estTime = timeFormat.format(date); date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss", Locale.ENGLISH).parse(estTime); </code></pre>
java
[1]
3,023,054
3,023,055
Android onCreate() Method called twice when device rotated. (ICS)
<p>I'm developing on an android tablet application and I have to manage application orientation. I got a problem that every time when I rotate the device onCreate() will be called.</p> <p>I fixed this problem on Honeycomb (3.1) by set this line in Manifest.xml file at the activity tag and it works well. </p> <pre><code> android:configChanges="keyboardHidden|orientation" </code></pre> <p>But this problem came back again when I test my app on ICS Tablet. Does anyone know how to fix this problem? </p> <p>Thanks </p> <p>Regards.</p>
android
[4]
2,457,716
2,457,717
How to store user input of one character into EACH element of an array in C++?
<p>I want the user to input just one character, say 'Y', then I want Y to be stored in each element of an array (ie: array[9]) so that when I print it would be like 'YYYYYYYYY', or when it's a 2d array (ie: array[2][2]) it would look like:</p> <pre><code>YYY YYY YYY </code></pre>
c++
[6]
2,449,388
2,449,389
how to put one listview inside another listview in java file in android?
<p>I have an xml file with a gallery and listview named main.xml.Another xml file with webimageview and listview named list.xml.Now I need to attach the main.xml to the listview in list.xml in java file.how can i do that?pls help with some ideas..</p>
android
[4]
2,024,782
2,024,783
Last six months list in PHP
<p>I need the previous six months list and am using the following code for that.</p> <pre><code>for ($i=6; $i &gt;= 1; $i--) { array_push($months, date('M', strtotime('-'.$i.' Month'))); } print_r($months); </code></pre> <p>Its gives the wrong output as follows</p> <pre><code>Array ( [0] =&gt; 'Dec' [1] =&gt; 'Dec' [2] =&gt; 'Jan' [3] =&gt; 'Mar' [4] =&gt; 'Mar' [5] =&gt; 'May' ) </code></pre> <p>It must be</p> <pre><code>Array ( [0] =&gt; 'Nov' [1] =&gt; 'Dec' [2] =&gt; 'Jan' [3] =&gt; 'Feb' [4] =&gt; 'Mar' [5] =&gt; 'Apr' ) </code></pre> <p>Where am i wrong. Help please</p>
php
[2]
539,079
539,080
Is there any cache in jvm or a way how to speed up method which sometimes takes longer?
<p>Hi is there any cache or settings of the jvm to speed up methods call? </p> <p>e.g: I do have a web service and when I call it once per 10minutes or so it's quite slow processing takes around 8-10s in comparison to calling it once per 20seconds-the result is roughly around 5s.</p> <p>Nothing else except this is running on the server. Is there a way to speed it up? (I cannot cache any objects or so.)</p> <p>I used JProfiler, I call it with the same parameters. It's doing exatly the same thing. The difference is between times when I call it. How long the server is idle. 1 or 30minutes is difference.</p> <p>Thanks</p> <p>EDIT: platform is: AIX java: IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc64-64 .. server: tomcat</p>
java
[1]
1,047,954
1,047,955
Jquery to create a popup div on hover?
<p><a href="http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/" rel="nofollow">This</a> is a pretty cool jquery popup technique for an image. Does anyone know the best way to get a similar thing working to get a div-enclosed table as the pop-up? What I'm trying to do is let the user hover over an image to get a bigger version of the image plus a caption and other details.</p>
jquery
[5]
1,720,860
1,720,861
join two lists by interleaving
<p>I have a list that I create by parsing some text. Let's say the list looks like </p> <pre><code>charlist = ['a', 'b', 'c'] </code></pre> <p>I would like to take the following list</p> <pre><code>numlist = [3, 2, 1] </code></pre> <p>and join it together so that my combined list looks like</p> <pre><code>[['a', 3], ['b', 2], ['c', 1]] </code></pre> <p>is there a simple method for this?</p>
python
[7]
1,084,043
1,084,044
New Android Developer Console: Update Apk and Store Listing before Publish
<p>I tried uploading an update for the first time using the NEW DEVELOPER CONSOLE. I was very confused and reverted back to the old developer console. I do not understand how to upload a new apk AND edit the store listing (e.g. recent changes) before publishing. I seem to be able to upload APK and publish, or update the store listing and publish, but not BOTH before publishing. This seems very strange to me.</p> <p>This is what I tried:</p> <ol> <li><p>I uploaded my apk using the "Simple Mode", but was then prompted to "Publish Now" before getting a chance to change the store listing (e.g. recent changes). Why?</p></li> <li><p>I changed to "Advanced Mode" and was able to upload my apk and save as a draft. I then tried to access the Store Listing, but this said that I could not save changes since I had archived or reactivated one or more apks.</p></li> <li><p>I changed tactics. I started with going to Store Listing and modified my recent changes. Then I tried going to the APK area to upload my new version and it says that it can't save the Store Listing without publishing... what the heck???</p></li> </ol> <p>This is just retarded, or am I misunderstanding the whole concept of "publishing"?</p> <p>All I want to do is to publish RECENT CHANGES and a new APK at the same time!</p>
android
[4]
95,332
95,333
Unused References in c# application
<p>I develop WinForms applications. How can I understand which references that I have added to my application are in use, and which ones are unused?</p> <p><strong>If I don't remove unused references, will they degrade my application performance?</strong></p>
c#
[0]
4,428,685
4,428,686
Why does my jQuery-script not work with Internet Explorer 7
<p>As I've got errors in IE7 - I should to take a closer look at JS file - written before ...(by others). </p> <p>at this point I'm not sure about anything, so I'd like to ask you - from my point of view is this wrong (aslo spacing can cause problems, I think) - but it is done all over the site:</p> <pre><code>(function ($) { $(document).ready( function() { //the code }); })(jQuery); </code></pre> <p>oh and yes, the error in IE8: </p> <blockquote> <p>HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) - which make me think the JS is in error.</p> </blockquote> <p>I know that this is a silly question, but thanks for your answer.</p>
jquery
[5]
2,049,266
2,049,267
how to modify the document selection in javascript?
<p>I wanna modify the document selection (user currently selected by mouse or keyboard), how to do it in a cross browser way?</p>
javascript
[3]
3,422,006
3,422,007
conversion of String to Image android
<pre><code>ArrayList&lt;String&gt; arl =(ArrayList&lt;String&gt;) getIntent().getSerializableExtra("WordList"); </code></pre> <p>I want a string stored in this array to be converted into image and display the same in the imageview. Anybody suggest how to implement it.</p>
android
[4]
4,621,024
4,621,025
Casting to string versus calling ToString
<pre><code>object obj = "Hello"; string str1 = (string)obj; string str2 = obj.ToString(); </code></pre> <p>What is the difference between <code>(string)obj</code> and <code>obj.ToString()</code>?</p>
c#
[0]
5,552,538
5,552,539
incorrect week_of_year
<p>Have next function to get week of year:</p> <pre><code>static public Integer getWeek(Date date) { Calendar cal = Calendar.getInstance(); cal.setMinimalDaysInFirstWeek(1); cal.setTime(date); Integer week = cal.WEEK_OF_YEAR; Integer month = cal.MONTH; if ((week == 1) &amp;&amp; (month == 12)) week = 52; return week; } </code></pre> <p>Call the function with date=02.01.2013</p> <p>What I see in debug:</p> <ol> <li>date = Wed Jan 02 00:00:00 SAMT 2013</li> <li>week = 3</li> <li>month = 2</li> </ol> <p>I want to get: week=1, month=1. Right?</p> <p>Where am I wrong?</p> <p>JRE 1.6</p> <p>Thanks a lot for advance.</p>
java
[1]
583,414
583,415
How to display Coloumn name in WPF ListBox
<p>I am working WPF I display dataContext into the listbox but I want to display Coloumn name. How I can do it..</p>
c#
[0]
75,611
75,612
Remove a row and set back the same ID to next row with jQuery
<p>I have HTML rows containing IDs, like</p> <pre><code>1 2 3 4 </code></pre> <p>When I remove ID 2 with jQuery I want that ID 3 should set to 2, like</p> <pre><code>1 2 3 </code></pre>
jquery
[5]
4,412,974
4,412,975
PHP variables issue
<p>I am doing a languages page for my website, placing all texts in variables such as:</p> <pre><code>if($language=='en') { lang[1]="Welcome, ".$user."!"; lang[2]="You have earned ".$pts." pts yesterday"; } elseif($language=='fr') { lang[1]="Bienvenue, ".$user."!"; lang[2]="Vous avez remporté ".$pts." pts hier"; } </code></pre> <p>I include this at the top of each page. However, the problem is that in many pages, some of the variables inside the $lang[X] variables (such as $user or $pts for instance) are only declared a few lines before their echo line or they even change a couple of times within a same page, so when the language vars are loaded via an include, they take the value of $user or $pts at that moment and not at the moment of their echo.</p> <p>Is there a way to use the technique in such a way that the vars inside the $lang[X] are taken at the moment of their echo and not at the moment of their include()?</p>
php
[2]
4,620,728
4,620,729
Asp.net SQL backed sessions
<p>If I have sessions backed by SQL Server and run a command sequence like</p> <pre><code>HttpContext.Current.Session['user'] HttpContext.Current.Session['user'] </code></pre> <p>Will this make 2 requests to the session DB table to fetch the value, or does asp.net do anything special with the Session object to prevent multiple DB hits?</p>
asp.net
[9]
4,973,249
4,973,250
get an element of a matrix
<p>I have a matrix of object and I want to get an element of it giving the int of the place.</p> <pre><code>Computer matrix[][]=new Computer[rows][cols] public Computer getComputerInTheMatrix(int n_rows,int n_cols){ return matrix[n_rows][n_cols]; } </code></pre> <p>is it right this method?</p>
java
[1]
1,338,642
1,338,643
Decimal to string conversion issue
<pre><code>Math.Round((ClosePrice - OpenPrice), 5) = -0.00001 </code></pre> <p>But When I convert it into tostring it gives "-1E-05"</p> <pre><code>Math.Round((ClosePrice - OpenPrice), 5).ToString() = "-1E-05" </code></pre> <p>Why this is so ? How can I get "-0.00001"</p>
c#
[0]
418,019
418,020
I need to transfers all visits from domain.com/example/xxx to domain.com/mypages/?id=xxx using php
<p>I need to transfers all visits from domain.com/example/xxx to domain.com/mypages/?id=xxx using php</p> <p>Thanks in advance guys, How do I do this ?</p>
php
[2]
3,842,214
3,842,215
Get server path minus file name in PHP
<p>I have a PHP script I am writing that will be used on more than one server. So it could be at any of these:</p> <pre><code>/home/14535/domains/something.com/html/miller/test/index.php /home/12345/domains/something.com/html/jones/test/dir4/index.php /home/11112/domains/something.com/html/smith/test/test2/test3/index.html </code></pre> <p>in any above case in need to return the full path minus the index.php or index.html</p> <p>How can I <strong>reliably</strong> return the full server path of the current directory MINUS the actual script name? (There will be some image uploading etc and that is why I need this path).</p> <p>Thanks, Chris</p>
php
[2]
577,704
577,705
hide a portion of button under textedit
<p>I am trying to achieve exactly something like this</p> <p><img src="http://i.stack.imgur.com/l9lk9.png" alt="alt text"> - a text view on left and a button to its right - Button should be wrap_text - textedit should occupy the remaining space</p> <p>If you carefully see the image in the image the buttons left curved border are hiding under the text view.</p> <p>I am using relative layout to adjust the button height according to this</p> <p><a href="http://stackoverflow.com/questions/4188859/how-to-get-a-buttons-height-to-match-another-elements-height">How to get a button&#39;s height to match another element&#39;s height?</a></p> <p>But I am unable to hide the left portion of the button. </p>
android
[4]
3,123,033
3,123,034
BufferedReader issue - doesn't respond properly
<p>I found this TCP server online, I want to modify it a little bit to return different message than was typed in the client. It doesn't work as I want; the <code>else {}</code> works "like a charm" but the first if doesn't - the client is still waiting for input.</p> <p>server.java</p> <pre><code>while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); System.out.println("Received: " + clientSentence); String test="hey"; String tempus="tster"; if(clientSentence.contains(test)==true){ System.out.println(tempus); outToClient.writeBytes(tempus); } else{ capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } </code></pre> <p>client.java</p> <pre><code>public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in)); Socket clientSocket = new Socket("localhost", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); } </code></pre>
java
[1]
4,851,527
4,851,528
Printing to multiple output files in java
<p>I have two arrays that I want to print to separate files. Here's my code:</p> <pre><code> try { PrintStream out = new PrintStream(new FileOutputStream( "Edges.txt")); for (i = 0; i &lt; bcount; i++) { out.println(b[i][0] + " " + b[i][1]); } out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } try { PrintStream out = new PrintStream(new FileOutputStream( "Nodes.txt")); for (i = 0; i &lt; bigbIter; i++) { out.println(bigb[i]); } out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } </code></pre> <p>If I only use the first set of try / catch / catch, it works perfectly. But when I use both it doesn't work, giving me the errors "illegal start of type ... } catch" and "error: class, interface, or enum expected". What am I doing wrong?</p>
java
[1]
5,975,960
5,975,961
Is their a way to check duplicate images with different names using php?
<p>Is their a way to check duplicate images with different names using php ? i want to delete all duplicates ></p>
php
[2]
5,212,318
5,212,319
Curtain up and down type animation to remove a view?
<p>I have an application in which i want to include a curtain raiser type animation to remove my splash view from the window?can anybody help me how to achieve this?</p>
iphone
[8]
5,664,667
5,664,668
Adding values to some divs withing a wrapped set with jquery
<p>I am so bad with jquery I should ask for forgiveness :)</p> <p>I have a div element similar to this:</p> <pre><code>&lt;div id="MyDiv"&gt;&lt;span id="Title"&gt;&lt;/span&gt;&lt;div id="Text"&gt;&lt;/div&gt;&lt;/div&gt; </code></pre> <p>I find it with the proper selector:</p> <pre><code>var myDiv = $("#MyDiv") </code></pre> <p>Now that I have this wrapped set I would like to find the "Title" span and "Text" div to put some text in each WITHOUT modifying the "MyDiv" div in the page so I can do something like the following:</p> <pre><code>CallMyFunction(myDiv); </code></pre> <p>How do I do that?</p> <p>Thanks for your help.</p>
jquery
[5]
3,338,982
3,338,983
How to establish an internet link between an android phone and laptop using Java
<p>I am developing a team viewer kind of application to access remote computer using android phone for academic purpose. How can one establish a connection between the phone and PC using the Internet specifically.</p>
android
[4]
2,964,541
2,964,542
Not understanding why this won't sum up properly
<pre><code>grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5] def grades_sum(grades): sum = 0 for i in grades: sum += grades[i] print(grades_sum(grades)) </code></pre> <p>That's my code and I'm trying to understand why I'm getting an out of index traceback.</p>
python
[7]
3,250,559
3,250,560
Hosting a html page of images on localhost and accessing it through web crawler, and downloading the image
<p>I have created a web crawler in python that accesses the web page &amp; downloads images from that page. The code of web crawler is:</p> <pre><code># ImageDownloader.py # Finds and downloads all images from any given URL. import urllib2 import re from os.path import basename from urlparse import urlsplit url = "http://www.yahoo.com" urlContent = urllib2.urlopen(url).read() # HTML image tag: &lt;img src="url" alt="some_text"/&gt; imgUrls = re.findall('img.*?src="(.*?)"', urlContent) # download all images for imgUrl in imgUrls: try: imgData = urllib2.urlopen(imgUrl).read() fileName = basename(urlsplit(imgUrl)[2]) output = open(fileName,'wb') output.write(imgData) output.close() except: pass </code></pre> <p>I have to show a demo in class, so I built a simple web page with some images &amp; hosted it on <code>localhost</code> but the web crawler which I have created is not accessing the html page and not downloading the images.</p> <p>Can anyone help me out in accessing the html page on <code>localhost</code> from the crawler?</p>
python
[7]
3,805,928
3,805,929
What do I do after studying the basics of Python?
<p>If someone now studies the basics of the Python what should he do after that? Are there specific books he must read? Or, what exactly?</p> <p>In other words, what is the pathway to mastering Python?</p> <p>Thanks</p>
python
[7]
2,331,573
2,331,574
Python, documentation strings within classes
<p>How do I print documentation strings within classes</p> <p>For functions i can do this:</p> <pre><code>def func(): """ doc string """ print func.__doc__ </code></pre> <p>Is it possible to do the same thing with a class</p> <pre><code>class MyClass(object): def __init__(self): """ doc string """ i = MyClass() print i.__doc__ </code></pre> <p>This doesn't work. It only prints out <code>None</code>.<br> Am writing a text game and I want to use the doc string as an instruction to the player without using the <code>print</code> command</p> <p>Thanks</p>
python
[7]
891,061
891,062
Escape quotes while spliting string in javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1293147/javascript-code-to-parse-csv-data">Javascript code to parse CSV data</a> </p> </blockquote> <p>Simple and straight, if I have a string like: 1001,"abc, xyz", 34</p> <p>I want it to split into 3 strings not 4. If I use split(','), it splits abc and xyz into two strings however I want it as a single string as it is inside double quotes.</p> <p>So my final outcome should be:</p> <pre><code>1001 abc, xyz 34 </code></pre> <p>What should I use inside split(), so that I can get expected output?</p>
javascript
[3]
3,614,654
3,614,655
Block fsockopen() errors
<p>I would like to block the errors that fsockopen() gives me. </p> <blockquote> <p>(Warning: fsockopen() [function.fsockopen]: unable to connect to 50.31.65.135:27015 (Connection timed out) in /home/reverbga/public_html/query/query.php on line 6)</p> </blockquote> <p>I just want it to not show that, as I use fsockopen as a way to see if the server is online.</p> <p>This is my code:</p> <pre><code>&lt;?php $serialized = file_get_contents('http://module.game-monitor.com/50.31.65.135:27015/data/server.php'); $players = unserialize($serialized); $array = (array) $players; $fp = fsockopen("50.31.65.135", 27015, $errno, $errstr, 1); if (!$fp) { echo "&lt;img width='20' height='20' src='bullet_red.png' /&gt;OCRP: OFFLINE"; } else { echo "&lt;img width='20' height='20' src='bullet_green.png' /&gt;OCRP: {$array['player']}/{$array['maxplayer']}"; } ?&gt; </code></pre>
php
[2]
1,743,519
1,743,520
Pass more values in doInBackground AsyncTask Android
<p>How to pass more values in the <code>doInBackground</code> </p> <p>My <code>AsyncTask</code> looks like this. </p> <pre><code>private class DownloadFile extends AsyncTask&lt;String, Integer, String&gt; { @Override protected String doInBackground(String... sUrl) { { } } </code></pre> <p>Is it possible somehow to pass more values on my <code>protected String DoInBackground</code> </p> <p>for example: <code>protected String doInBackground(String... sUrl, String... otherUrl, Context context)</code></p> <p>And how to <code>execute</code> the <code>AsyncTask</code> after? <code>new DownloadFile.execute("","",this)</code> or something?</p>
android
[4]
683,779
683,780
FormsAuthentication.RedirectFromLoginPage is not working
<p>I am working on a LoginPage.Everything related to database or C# code is working fine but after successul login I am unable to redirect to Home.aspx,am I missing Something? Pls help. <strong>Code:</strong></p> <p><strong>Web.Config:</strong></p> <p> </p> <pre><code>&lt;/authentication&gt; &lt;authorization&gt; &lt;deny users="*"/&gt; &lt;/authorization&gt; </code></pre> <p><strong>C# Code:</strong></p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { string source = "server=localhost\\sqlexpress;Database=LogInDB;Trusted_Connection=True"; SqlConnection con = new SqlConnection(source); con.Open(); SqlCommand cmd = new SqlCommand("proc_LogIn", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ID", SqlDbType.Int).Value = TextBox1.Text; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = TextBox2.Text; SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false); } else { Response.Write("Invalid credentials"); } } </code></pre>
asp.net
[9]
1,554,806
1,554,807
How do I detect a max. recursion depth exceeded exception in Python?
<pre><code>try: recursive_function() except RuntimeError e: # is this a max. recursion depth exceeded exception? </code></pre> <p>How do I tell when the maximum recursion depth has been reached?</p>
python
[7]
1,476,744
1,476,745
Why the callback function (2nd animation callback) executes as loop causing images to keep on moving left?
<p>My images are absolute positioned horizontally and should move right to end after each interval.</p> <p>When the first image reaches the last images place they should come back left to the beginning position. </p> <p>My code does this but it keeps on moving the images left to thousands of px.<br> After that they start moving right again.</p> <p>Why is that?</p> <pre><code>$(document).ready(function() { //alert("Ok"); var w = 0; $('ul&gt;li').each(function(i, o) { $(this).css({ "position": "absolute", "left": 5 + w + 'px' })`enter code here` w = w + 210; }); var lastPos = parseInt($("ul&gt;li:last").css("left")); //alert(lastPos); var I = 0; setInterval(function() { I = parseInt($("ul&gt;li:first-child").css("left")); //$("#i1").text(I); $("ul&gt;li").animate({ left: "+=210px" }, 500, function() { I = parseInt($("ul&gt;li:first-child").css("left")); $("#i2").text(I); $("#i4").text(I &gt; lastPos) if (I &gt; lastPos) { //here comes the problem $("ul&gt;li").animate({ left: "-=" + lastPos }, 500, function() { I = parseInt($("ul&gt;li:first-child").css("left")); $("#i3").text(I); }); } }); }, 4000); }) </code></pre>
jquery
[5]
1,859,467
1,859,468
How can you add multiple input fields in a clone() with incrementing ID's with JQuery?
<p>Using JQuery i am cloning this fieldset:</p> <pre><code>&lt;fieldset class="pollQuestion" id="pq1"&gt; &lt;ul&gt; &lt;label&gt;Answers&lt;/label&gt; &lt;li id="answerFields"&gt; &lt;input type="text" id="formanswer1" value="" /&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="button" class="addAnswer" value="Add Answer" /&gt; &lt;input type="button" class="delAnswer" value="Remove Answer" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/fieldset&gt; </code></pre> <p>When i Clone() this fieldset, how can i add input fields inside the li#answerFields?</p> <p>I want my clone to look like this: </p> <pre><code>&lt;fieldset class="pollQuestion" id="pq1"&gt; &lt;ul&gt; &lt;label&gt;Answers&lt;/label&gt; &lt;li id="answerFields"&gt; &lt;input type="text" id="formanswer1" value="" /&gt; &lt;input type="text" id="formanswer2" value="" /&gt; &lt;input type="text" id="formanswer3" value="" /&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="button" class="addAnswer" value="Add Answer" /&gt; &lt;input type="button" class="delAnswer" value="Remove Answer" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/fieldset&gt; </code></pre> <p>ANY and ALL help is MUCH appriciated!</p>
jquery
[5]
3,690,978
3,690,979
How to convert string to byte in Java
<p>I have a String array. I want to convert it to byte array. I use the Java program. For example:</p> <pre><code>String str[] = {"aa", "55"}; </code></pre> <p>convert to:</p> <pre><code>byte new[] = {(byte)0xaa, (byte)0x55}; </code></pre> <p>What can I do?</p>
java
[1]
5,524,730
5,524,731
stringstream won't convert to correct number value
<p>[SOLVED] See my answer below.</p> <p>I am trying to use stringstream (named ss) to convert some strings to ints and some to double and such, but the values are all coming out wrong. I have a vector of strings named vec, initialized like this:<br/> [0] = ID # in hex<br/> [1] = phone number<br/> [2] = last name<br/> [3] = first name<br/> [4] = sales number<br/> [5] = percent of sales<br/> Now I go through the vector and put the values into int, string, or double:</p> <pre><code>std::string lname, fname, pnum; int ID; double sales, percent; if(vec.size()!=6) { //throw exception } else { ss&lt;&lt;std::hex&lt;&lt;vec[0]; ss&gt;&gt;ID; pnum = vec[1]; lname = vec[2]; fname = vec[3]; ss&lt;&lt;vec[4]; ss&gt;&gt;sales; ss&lt;&lt;vec[5]; ss&gt;&gt;percent; } </code></pre> <p>but the output looks like this for every customer. What are my ints always 1 and my doubles always this weird number?</p> <p>Customer made: Langler Tyson 1 7667230284 2.12303e-314 2.12201e-314 </p>
c++
[6]
4,323,455
4,323,456
Cannot implicitly convert type 'int' to 'string'
<p>My code:</p> <pre><code>public void FillMaxBankCode() { try { DataSet ds = new DataSet(); ds = bol.SelectMaxBankCode(); string j = ds.Tables[0].Rows[0].ToString(); txtbankid.Text = int.Parse(j); //ERROR HERE } catch (Exception ex) { MessageBox.Show(ex.Message); } } public DataSet SelectMaxBankCode() { try { **Squery = "EXEC SelectMaxBankCode";** return dal.DBread(Squery); } catch (Exception ex) { throw ex; } } </code></pre> <p>I am new to C# and the above code show error.. can anyone help?</p>
c#
[0]
4,121,230
4,121,231
php echo variable combining test problem
<p>I have the following in a for loop over $x. $x is from 1 to 100. I have variables t1 to t100 already assigned. I want to echo them without typing each one individually, hence the for loop. BUT the following does not work...How can I fix this?</p> <p>echo "<br>'$t.$x'";</p>
php
[2]
5,544,734
5,544,735
Error in "C:\Users\lenovo\Desktop\android-sdk_r06-windows\android-sdk-windows>>SDK Setup.exe"
<p>Ihave had "Failed to fetch URL <a href="https://dl-ssl.google.com/android/repository/repository.xml" rel="nofollow">https://dl-ssl.google.com/android/repository/repository.xml</a>, reason: Connection timed out: connect" Error for 2 weeks. What shoul I do? Please help...</p>
android
[4]
3,272,398
3,272,399
Python: if error raised i want to stay in script
<p>I'm doing some practice problems from online with python and I have a question about how to stay in a script if an error is raised. For example, I want to read in values from prompt and compare them to a set integer value inside the script. The only problem is that when someone enters something other than a number 'int(value)' (ex. value = 'fs') raises an error and exits the script. I want to have it so if this happens I stay inside the script and ask for another value to be entered at the prompt.</p>
python
[7]
2,797,412
2,797,413
Wordpress > getting full path to my theme's images directory regardless of parent paths
<p>I have a function whose purpose is to list the folders within the images directory of my wordpress theme. It works great when the user has installed wordpress in the root directory of the site. However, it fails if the user has installed wordpress in a folder under the root...</p> <p>$mydir = get_dirs($_SERVER['DOCUMENT_ROOT'].'/wp-content/themes/mytheme/images');</p> <p>This function works fine as long as the wordpress is installed directly into the site's root, such as site.com/index.php</p> <p>However, this path method fails, if the user has installed their blog in a virtual directory. Example: site.com/somedirectory/index.php</p> <p>Can someone help with a better method of determining the path of the $mydir?</p> <p>It would be super simple if I could feed my function with the http address, but my function requires the path to the images directory as a server directory. Anyone know of a way to find the folders under a given directory using the http method instead? For example, I can get a reference to my theme's images directory with...</p> <p>$mydir = get_bloginfo('url').'/wp-content/themes/mytheme/images';</p> <p>However, the function below, will not take a URL, it must be a physical file path to the chosen directory I want to parse. So I either need to replace it with a function that takes a URL or I need to find some way to convert the $mydir function to a physical path, or perhaps some other means.</p> <p>Here is the function that I'm using for parsing the directory and assigning each folder to an array.</p> <pre><code>function get_dirs($path = '.') { $dirs = array(); try { foreach (new DirectoryIterator($path) as $file) { if ($file-&gt;isDir() &amp;&amp; !$file-&gt;isDot()) { $dirs[] = $file-&gt;getFilename(); } } } catch(Exception $e) { //log exception or process silently //just for test echo "There is a problem inside the get_dirs function"; } return $dirs; } </code></pre>
php
[2]
5,115,577
5,115,578
Copy Constructor Doubt
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2685854/why-should-the-copy-constructor-accept-its-parameter-by-reference-in-c">Why should the copy constructor accept its parameter by reference in C++?</a> </p> </blockquote> <p>In wikipedia, it is mentioned that - </p> <p>The following are invalid copy constructors (Reason - copy_from_me is not passed as reference) :</p> <pre><code>X (X copy_from_me); X (const X copy_from_me); </code></pre> <p>because the call to those constructors would require a copy as well, which would result in an infinitely recursive call.</p> <blockquote> <p>Could someone please explain, how it would result in an infinitely recursive call ?</p> </blockquote> <p>Thanks.</p>
c++
[6]
3,778,460
3,778,461
Pass by ref and typecast at the same time
<p>Is there a way to do this in C#? </p> <pre><code>private void Caller() { MyControl c = new MyControl(); Callee(ref c); //Here I want to cast c as Control and pass by ref } private void Callee(ref Control c) { } </code></pre> <hr> <p>In the generics example, how does it infer T = MyControl? Can you please explain? I am a newbie to generics</p>
c#
[0]
1,740,775
1,740,776
ICMP Disable/Blocked:How To Check Internet Connection Using C#
<p>If ICMP Is Blocked/Disabled by Administrator. Is there any way to check the internet connection through C# when ping test is not possible.</p> <p>Thanks in Advance.</p>
c#
[0]
4,960,029
4,960,030
android mysterious app loading
<p>I've discovered that some of the basic apps on my android phone such as email, gallery, videos appear to have been started when the phone was simply lying on my desk doing nothing - even during the early hours of the morning. Does anyone know if this is to be expected and if so why?</p>
android
[4]
4,896,686
4,896,687
How to get MenuItems from Different Android application
<p>I have called "Contacts" app's EditContactActivity from MyApplication. I want to get Contextmenuitems ie ( "Send sms" , "call" , "Edit" , etc ) as menus. So i can use this menu in my application.</p>
android
[4]
5,939,306
5,939,307
How to mask a password in command line
<p>I want to mask a password. I used System.console() but it is not better and sometimes it returns null. Is there any other way to stop echo and mask a password? I am new to java. So please can anyone explain how to do this.</p>
java
[1]
848,735
848,736
Need help with complicated search
<p>I need to search <code>src="http://www.domain.com/wp-content/uploads/2010/12/6a00e54fa8abf788330147e0622c2e970b-800wi.jpg"</code> </p> <p>and get <code>http://www.domain.com/wp-content/uploads/2010/12/</code></p> <p>Since I never know how long the string is I need to get everything up to the last /</p>
php
[2]
900,380
900,381
Is it possible to get the value of an overridden NON static member variable of a parent class?
<p>Is it possible to get the value of an overridden NON static member variable of a parent class?</p> <p>I understand that to get the value of a STATIC member variable you use self::$var1 or ClassName::$var1, but how do you get the value of a NON static member variable?</p> <p>For instance...</p> <pre><code>class One { public $var1 = 'old var'; } class Two extends One { public $var1 = 'new var'; public function getOldVar() { //somehow get old var } } </code></pre> <p>Thanks so much in advance! </p>
php
[2]
1,640,052
1,640,053
Noob question about Android element ID naming
<p>So I have a string in my strings.xml file declared like so:</p> <pre><code>&lt;string name="welcome"&gt;Please hit the menu to begin&lt;/string&gt; </code></pre> <p>And I have a TextView in my main.xml that uses it like so:</p> <pre><code>&lt;TextView android:id="@string/welcome" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/welcome" /&gt; </code></pre> <p>Now, is that the proper way to give a TextView an ID? It seems strange to use a string resource as an ID like that.</p>
android
[4]
2,177,373
2,177,374
Android: Store Class file in Resources?
<p>I am trying to store a saved class binary file in my application's resources. Where should I put it and how can I access it in the application?</p>
android
[4]
2,118,622
2,118,623
How to set up Python for .NET with Python 2.6.1?
<p>The "final" release of Python for .NET (<a href="http://sourceforge.net/project/showfiles.php?group%5Fid=162464&amp;package%5Fid=183296&amp;release%5Fid=537499" rel="nofollow" title="link">link</a>) isn't pre-compiled for Python 2.6. I don't have a problem changing the compilation symbol to PYTHON26 as specified in the docs, the solution rebuilds just fine, but when attempting to import the CLR, I get an error indicating that python26.dll is missing. Anyone know how to build this file? It doesn't seem to be part of the solution, but I might be missing something obvious.</p>
python
[7]
2,596,806
2,596,807
No delay in jQuery statement
<p>I want some characters to appear gradually, so i've built this script. However, the delay seems not to execute at all - i tried to put it to several thousands with no change in result. What do i miss?</p> <pre><code>$(document).ready(function () { var i, d = [500, 300, 600, 1000], t = "String"; $("body") .delay(flashDuration[0]) .animate({ backgroundColor: "#888888" }, d[1]) .animate({ backgroundColor: "#222222" }, d[2]) .animate({ backgroundColor: "#F8ECC2" }, d[3], null, function () { for (i = 0; i &lt; t.length; i++) $("&lt;span&gt;" + t.substr(i, 1) + "&lt;/span&gt;") .addClass("hidden") .delay(i * 2000) /* this delay doesn't execute */ .addClass("visible") .appendTo("#floatingName"); }); }); </code></pre> <p>Please don't bite my head off for d being duration and t being title. I abbreviated the names because every programmer loves cryptic, non-self explanatory, short variable names. Right? Seriously, i tried to avoid wrapping.</p> <p>Also, i tried to post in on jsFiddle <a href="http://jsfiddle.net/Chamster/8XUpL/1/" rel="nofollow">here</a> but the example doesn't even flash the screen, let alone executes the delay properly.</p>
jquery
[5]
2,602,510
2,602,511
Math.round MAX returnable value
<p>Am using Math.round and I am finding that it will not return me any value larger then (2^32/2)-1, but the documentation states it can/will return long values, i.e. 2^64... There a code snippet below.</p> <pre><code>long bTmp = (long)Math.round(4294967296L); System.out.println(bTmp); System.out.println(Long.MAX_VALUE); </code></pre> <p>which output:</p> <pre><code>2147483647 9223372036854775807 </code></pre> <p>Am I missing something?</p>
java
[1]
5,032,472
5,032,473
Making an on/off button with images
<p>I have two images, sound_on.png and sound_off.png. Both have the same height and dimensions.</p> <p>I would like to attach a JavaScript for the following action:</p> <ol> <li>When the pressed images changes from sound_off.png to sound_on.png and the sound plays</li> <li>When the button is pressed again it changes back from sound_on.png to sound_off.png and the sound stops with the onclick command</li> </ol> <p>At the moment I have these lines of code:</p> <pre><code>&lt;a href="#" onClick="playAudio();"&gt;&lt;img src="images/general/sound-on.png" width="40" height="32"&gt;&lt;/a&gt; &lt;a href="#" onClick="stopAudio();"&gt;&lt;img src="images/general/sound-off.png" width="40" height="32"&gt;&lt;/a&gt; </code></pre> <p>What code do I need to make them like the above example?</p> <p>I have this part:</p> <pre><code>&lt;style type="text/css"&gt; .on {background-image:url url(images/general/sound-off.png)); background-repeat:no-repeat;} .off {background-image:url(images/general/sound-on.png); background-repeat:no-repeat;} &lt;/style&gt; &lt;script language="javascript"&gt; function togglestyle(el){if(el.className == "on") {el.className="off";} else {el.className="on";}} &lt;/script&gt; </code></pre> <p>With this DIV for the button:</p> <pre><code>div id="onoff" class="playlist_btn"&gt;&lt;img src="images/general/sound-off.png" width="50 height="50" onclick="togglestyle(onoff)"&gt;&lt;/div&gt; </code></pre> <p>This makes the toggle, but I have no idea so far how to connect the onclick command to get the audio playing and to stop it again.</p> <p>Could it be something like this?</p> <pre><code>function togglestyle(el){if(el.className == "on" onClick="playAudio()") {el.className="off" onClick"stopAudio()";} else {el.className="on";}} </code></pre>
javascript
[3]
2,077,557
2,077,558
unix timestamp conversion results not accurate php
<p>I am trying to convert a unix timestamp into readable text. The timestamp is stored in a database and shown in a table. The problem is the results are not accurate. <hr /> <strong>Code:</strong></p> <pre><code>&lt;td&gt;'.date("F j, Y, g:i a", strtotime($row['expire'])).'&lt;/td&gt; </code></pre> <p><hr /> <strong>database:</strong></p> <p><img src="http://i.stack.imgur.com/xWpiG.png" alt="enter image description here"> <hr /> <strong>Result:</strong></p> <p><img src="http://i.stack.imgur.com/vpbYx.png" alt="enter image description here"></p>
php
[2]
10,952
10,953
Checking if an application is launchable
<p>I have a list of applications, and I want to weed out all the non launchable/non removeable ones. When I run my program on my phone, it gives me all the ones I dont want also, and yes i have:</p> <pre><code>getInstalledApps(false); /* false = no system packages */ </code></pre> <p>Any Ideas?</p>
android
[4]
379,921
379,922
tab menu, delay when clicking through tabs... jquery fix to show loading msg if load time over 1 sec?
<p>I'm wondering if anyone knows a fix for this.</p> <p>I have a tab menu and when you click between tabs sometimes there is a delay in the page opening, - the difference can be from m/s to about half a minute - so i tried to add in a loading message for the pages that seemed to take a while. </p> <p>I thought i had solved it by adding in the message when a tab was clicked </p> <pre><code>jQuery(document).ready(function() { jQuery('#loading').hide(); jQuery('.tabmenu a').click(function(){ jQuery('#loading').show(); }); }); </code></pre> <p>but on pages that previously took about 1 sec to load now take at least 5.</p> <p>What i really need to do is something like</p> <p>if tabmenu clicked and page takes longer than 1 second to change then show 'loading' message.</p> <p>Is it possible to do this? Any help greatly appreciated :)</p> <p>Thanks</p>
jquery
[5]