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 |
---|---|---|---|---|---|
840,375 | 840,376 | Better way to do this in PHP | <p>I currently have my htaccess file set to remove the file type so</p>
<pre><code>www.example.com/home.php
</code></pre>
<p>would become,</p>
<pre><code>www.example.com/home
</code></pre>
<p>I need to compare the url with one that I have saved in the database, I do this by,</p>
<pre><code>if ($_SERVER['QUERY_STRING']) {
$pageURL = str_replace('.php', '?', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']);
}
else {
$pageURL = substr('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'], 0, -4);
}
</code></pre>
<p>When I save the url in the database it gets saved as the current page url after the htaccess file has removed the .php, it is inserted using jquery ajax.</p>
<p>When I come to compare it, I need this to make it match in php as php doesn't take into account the htaccess changes.</p>
<p>Is there a better way to do this?</p>
| php | [2] |
2,126,995 | 2,126,996 | How to make PHP date and time update automatically | <p>I have a script which displays the date and time.</p>
<p>How can I add something to make it update automatically instead of on page refresh.</p>
<p>Here is the script:</p>
<pre><code><?php
$hourdiff = 0; // Replace the 0 with your timezone difference (;
$site = date("l, d F Y g:i a",time() + ($hourdiff * 3600));
echo $site;
?>
</code></pre>
<p>Can anyone help. Thanks. </p>
| php | [2] |
366,063 | 366,064 | PHP file permissions | <p>This question may sound trivial, but it's been giving me trouble. I've written two simple php scripts for a web interface, and they only work with other being given read and execute permissions. I don't understand why the read permission is necessary. Can someone explain or direct me to a reference?</p>
| php | [2] |
5,981,814 | 5,981,815 | Python distutils and replacing strings in code | <p>I often find a need to put paths in my code in order to find data or in some cases tool-specific modules. I've so far always used autotools because of this--it's just so easy to call sed to replace a few strings at build time. However, I'd like to find a more Pythonic way of doing this, i.e. use distutils or some other blessed way of building/installing. I've never managed to find anything relating to this in distutils documentation though so how do other people solve this problem?</p>
| python | [7] |
3,366,462 | 3,366,463 | How to create android themes | <p>My client wants to create themes like this:
<a href="http://mappn.com/community/index.php?topic=42.0" rel="nofollow">http://mappn.com/community/index.php?topic=42.0</a></p>
<p>I have no clue where to start. When I Googled it I just get themes for style/theme for application.</p>
<p>Can anyone suggest where to start learning customizing themes for android phones?</p>
<p>Please share if you find any opensource.</p>
| android | [4] |
613,697 | 613,698 | Android wizard-like (step by step) application | <p>I'd like to build an android step application so I can go back and forth between activities.</p>
<p>I'd like to create a base class for the step manager that includes two buttons to go forward and back, so in the child activities I don't have to recreate those controls every time. The step manager class has to take care of the switching between activities in a precise order and of passing data between them.</p>
<p>I tried to write some code but I can't merge the parent's layout with the child one!</p>
<p><code>
FrameLayout fl = (FrameLayout)this.findViewById(R.id.frame);<br>
LayoutInflater.from(this).inflate(rId, fl, true);
</code></p>
<p>This code is in the parent class (inherited from Activity): </p>
<ul>
<li>the FrameLayout is the place holder for the child-layout controls;</li>
<li>rId is the layout resource ID of a LinearLayout in the child xml layout.</li>
</ul>
<p>I guess that the problem about that code is that I don't call the setContentView of the child layout, so anytime I use the findViewById of a child control I get a null pointer.</p>
<p>What is the best practice to create something like that? </p>
<p>Thanks, Simone.</p>
| android | [4] |
1,902,549 | 1,902,550 | PHP Get last word of url returning blank | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/11075301/php-get-end-string-on-url-between-and">PHP Get end string on url between / and /</a> </p>
</blockquote>
<p>I have this code to get the last part of the url between / and / at the end.</p>
<p>The url is:</p>
<pre><code>http://mydomain.com/category/mobile/
</code></pre>
<p>I need to retrieve "mobile" from it.</p>
<p>The code i'm using is:</p>
<pre><code>$url = trim($url, '/');
//Put it in a variable
$the_category = substr($url, strrpos($url, '/'));
//whats in it?
echo $the_category;
</code></pre>
<p>The above returns nothing ... any ideas?</p>
| php | [2] |
1,878,543 | 1,878,544 | Database connectivity | <p>Please tell me. how can i establish the database connection with the back end of oracle10g express edition with the front end of asp.net?. pls send the source code also</p>
| asp.net | [9] |
3,461,285 | 3,461,286 | Filter through these results? | <p>Say I have the following text:</p>
<p><code>["4294954874;Centhor 702L (1)","4294954873;Lightning DL904 (1)"]</code></p>
<p>I want to return them in an array, for example:</p>
<pre><code>$array = array('Centhor 702L', 'Lightning DL904');
</code></pre>
<p>What would be the best way to do this using PHP?</p>
<p>The stuff on the left and right of the info I need are randomly generated when I grab the response.</p>
| php | [2] |
5,158,812 | 5,158,813 | Hide div while an element appear in the browser | <p>I have a web page with a height more than 1000 pixels. There is an important text which I need to display all the time to a visitor. I placed a 20 pixel high DIV with a fixed property at the top of the page but the content of that DIV appears in the browser available in the middle. I want to hide the top div, but as I scrolled up from the middle div I want to show the top div.</p>
| jquery | [5] |
4,288,935 | 4,288,936 | Android files in intenal storage and local directory | <p>Android gives you getDir (I assume this means I would have myappspace/somedirectory) to create a directory in you application space. But how do you read or write to a file in that directory when android gives you an error if you have the path separator in the openFileOutput/Input call it gives you an error?</p>
| android | [4] |
1,379,558 | 1,379,559 | Hide elements by clicking outside | <p>I have some problems hiding my elements which are in an array. I put all elements to hide in an array which I loop through with <code>.each()</code>. But somehow the elements do not disappear :/</p>
<p>Here is my code:</p>
<pre><code>$('html').bind("click", function(e) {
var hiddenElements = ['#loginContainer'];
$.each(hiddenElements, function(index, value) {
$(value).hide();
});
});
</code></pre>
| jquery | [5] |
5,362,330 | 5,362,331 | homepage url as mysite.com/ rather than mysite.com/index.html | <p>I have a site I want to deploy and as part of the finishing touch, I'd like to have the url in the browser show www.mysite.com/ instead of www.mysite.com/index.html</p>
<p>How is this done?</p>
<p>Thanks. </p>
| asp.net | [9] |
1,016,222 | 1,016,223 | How do I go about implementing Android UI, specifically this gallery? | <p>This question has 2 parts:</p>
<p>1) I'm new to Android development and find implementing the UI on Android quite overwhelming. It would be great help if you could point me to some free UI libraries or give me some advice on how mobile developers go about implementing the UI. Is there some framework of "standard" UI framework which I can use to build simple stuff that aren't directly possible from the Android API? I want to focus more on the content of the app rather than building all the quite common design patterns from scratch.</p>
<p>2) Currently, I'm building an app, which needs to have a gallery. I'm thinking of this</p>
<p><img src="http://i.stack.imgur.com/2AU2o.jpg" alt="Gallery design pattern"></p>
<p>I want to supply a <code>Vector</code> of <code>Photo</code> (which contains URL to the thumbnail and the actual sized image) to this <code>View</code> and get something like that.</p>
<p>Thanks</p>
| android | [4] |
2,570,261 | 2,570,262 | Google maps application in iphone | <p>In my application i added google maps application.It works fine.But in the map UI there is button zoomin and zoomout and also current location button, i want to hide or remove this button is this possible? i have load google map application in my UIWebview using this url @"http://maps.google.com/maps?q=3711.</p>
<p>Can anyone help me ?</p>
<p>Thanks in advance </p>
| iphone | [8] |
1,846,659 | 1,846,660 | Find Control on MasterPage returns nulll | <p>Im trying to access a ModalPopupExtender control and it allways is returning null or object set not set to an intance of an object. I've tried master.Page.FindControl("") and master.FindControl("") and im still not getting the result</p>
<pre><code>MasterPage master = Page.Master as MasterPage;
AjaxControlToolkit.ModalPopupExtender popup = master.Page.FindControl("ModalPopupExtender2") as AjaxControlToolkit.ModalPopupExtender;
</code></pre>
<p>Updated: Cannot change the text of my labels in master page</p>
<pre><code>MasterPage master = Page.Master;
AjaxControlToolkit.ModalPopupExtender popup1 = master.FindControl("ModalPopupExtender1") as AjaxControlToolkit.ModalPopupExtender;
Label lblMessage = master.FindControl("lblMessage") as Label;
lblMessage.Text = msg;
Literal ltrlMessage = master.FindControl("ltrlMessage") as Literal;
ltrlMessage.Text = msg;
Label MessageStatus = master.FindControl("lblMessageStatus") as Label;
MessageStatus.Text = msgStatus;
popup1.Show();
</code></pre>
| asp.net | [9] |
3,725,268 | 3,725,269 | App should not start with its first activity | <p>We have a very large project in android,Its running proper on the device, but when any call aur msg come on the device,The app start again by its first login page.
but it should start by the where it was before coming the call.</p>
<p>What changes should i make in this.</p>
<p>Thanks</p>
| android | [4] |
3,905,041 | 3,905,042 | confuse about three forms of reference | <pre><code> T const&
const T&
T& const //error
</code></pre>
<p>What's the difference of the above three? And if <code>&</code> is <code>*</code>,what will happen?</p>
| c++ | [6] |
4,513,900 | 4,513,901 | General Questions about List | <p>Hi
I have a general question about Lists in C#.
Here is my Code:</p>
<pre><code>public List<string> Example()
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_FailurePredictStatus");
List<string> output = new List<string>();
foreach (ManagementObject queryObj in searcher.Get())
{
output.Add(System.Convert.ToString(queryObj["InstanceName"]));
}
return output;
}
</code></pre>
<p>and now I want to give the first input out</p>
<pre><code>public FormMain()
{
Debug.WriteLine(Example(1));
}
</code></pre>
<p>No overload for method 'output' takes 1 arguments</p>
<p>I hope you can explain me this and sorry for my question, I am an absoltue beginner</p>
<p>Best wishes</p>
| c# | [0] |
2,822,635 | 2,822,636 | android- How to handle the Web service Exception | <p>My application have 3 Relative Layouts and 3 Linear Layouts. Based on the web service response we can fill the relative and linear layout views. When you click on the relative layout then linear layout will be visible that linear layout contains more no.of items(means more views are there like List view). but the problem is only 2 relative layouts are working(means when you click on the relative layout then it will shown the linear layout) and remaining one is not working(that code part is not executed). Suppose we are changing the order(means first you can write the Linear Layout1,Linear layout3 and after Linear layout 2) then LL1 and L3 are working LL2 is not working. How to handle it?</p>
<p>and one more thing i got web service error is "java.lang.IndexOutOfBoundsException".</p>
<p>please can anybody help me.</p>
<p>thanks </p>
| android | [4] |
4,531,227 | 4,531,228 | How to pass textfield values from one view to another view | <p>would you tell me,, what steps i have to add in applications to move values from a view to another when press a button </p>
| iphone | [8] |
1,548,717 | 1,548,718 | Random inside a thread won't work | <p>I'm trying to run a Random method inside a Thread. I need to put this inside a thread because it kept hanging up my main UI Thread. But seems it's not working. Log returns 0 size. I need help, code below.</p>
<pre><code>public class RandomActivity extends Activity implements Runnable {
private TextView random;
Thread thread;
private boolean flagRandom;
private ArrayList<Integer> listRandom;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
thread = new Thread(this);
flagRandom = false;
listRandom = new ArrayList<Integer>();
random = (TextView) findViewById(R.id.txtRandom);
thread.start();
for(int i=0; i<5; i++) {
Log.i("RANDOM", listRandom.get(i).toString());
}
}
@Override
public void run() {
Random rNum = new Random();
while(flagRandom) {
for(int ctr=0; ctr<5; ctr++) {
if(ctr > 0) {
int iRand = rNum.nextInt(5) + 1;
if(listRandom.contains(iRand)) {
ctr--;
} else {
listRandom.add(iRand);
}
} else {
listRandom.add(rNum.nextInt(5) + 1);
}
}
}
}
</code></pre>
<p>}</p>
| android | [4] |
5,707,011 | 5,707,012 | Set variable after function jquery | <p>I want to declare a function, but only run it later on after setting the variables below.</p>
<p>Essentially I am checking the URL and seeing if it matches anything in the menu and then setting that item as selected. I know there are better ways to probably do this, but now I'm determined to find out how to make this work. I have written a function that works on a single item, but I want to run it on both.</p>
<p>Hopefully this makes sense:</p>
<pre><code>var itemOne = $("#side-bar li a");
var itemTwo = $("#navigation ul li a");
$(function() {
function doosomething() {
var url = document.location.href;
// URL of Page
$(someVar).each(function(){
var href = $(this).attr('href');
// URL of Link
if (url.indexOf(href) > -1) {
$(this).parent().addClass('selected');
console.log('yes');
}
else {
console.log('no');
}
});
}
someVar = itemOne,itemTwo
doosomething();
});
</code></pre>
<p>Thanks in advance!</p>
<p>I want to combine this into one.</p>
<pre><code>someVar = itemTwo;
doosomething();
someVar =itemOne;
doosomething();
</code></pre>
<p>Currently I'm just running it like this:</p>
<pre><code>var url = document.location.href;
console.log(url);
$("#side-bar li a").not('li.home-item a').each(function(){
var href = $(this).attr('href');
console.log(href);
if (url.indexOf(href) > -1) {
$(this).parent().addClass('selected');
}
else {
console.log('no');
}
});
</code></pre>
| jquery | [5] |
5,149,428 | 5,149,429 | What to do when javascript is disabled | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2911704/what-do-i-do-if-javascript-is-disabled-by-client">What do i do if javascript is disabled by client?</a> </p>
</blockquote>
<p>In the situation where the client's browser has javascript disabled, are there any standard ways to handle the scenario except telling the client to turn the javascript back on?<br>
Is it a common best practise to design two versions of a web application..one assuming the client browser has javascript, the other assuming that the client browser does not have javascript?<br>
In most of the applications which I have seen, if javascript is not on, nothing will work because we depend on it heavily</p>
| javascript | [3] |
2,755,478 | 2,755,479 | how to make sure a variable is set to a value and it can if tested in catch block | <p>I am writing a proof of concept with a simple requirement where I load an account, make a webservice call to initiate payment and if it is successful update the account balance. </p>
<p>The intention of following code is to make sure some reversal is done if web service call was successful in taking money out of customer' bank but account could not be saved due to concurrency issue. However, I have this strange issue that even if response is successful, the <strong>if test in catch block</strong> returns false and the exception is re thrown? </p>
<p><strong>edit begin:</strong></p>
<p>if <code>response.IsSuccessful</code> is <code>true</code> and <code>ConcurrencyException</code> occurs at <code>accountService.Save(account)</code> line, shouldn't <code>currentStatus</code> be equal to <strong>WEBSERVICE_SUCCESSFUL</strong> ?</p>
<p><strong>edit end:</strong></p>
<p>This is a web application and call to <strong>Process()</strong> is triggered by front end. Am I missing anything obvious? Any help would be really appreciated.</p>
<pre><code>function void Process(Account account, string param1, decimal param2) {
string currentStatus = "START";
try
{
log("Begin web service call");
var response = webservice.Call(param, param2);
log("End web service call");
if(response.IsSuccessful)
{
currentStatus = "WEBSERVICE_SUCCESSFUL";
//update account balance
accountService.Save(account);
}
else
{
// do something else
}
}
catch (ConcurrencyException ex)
{
log("Error concurrency..");
if( currentStatus == "WEBSERVICE_SUCCESSFUL")
//do reversal
else
throw ex;
}
}
</code></pre>
| c# | [0] |
2,190,951 | 2,190,952 | PHP Move Files With Specific Format vs Move All Files | <p>I have these files in /public_html/ directory :</p>
<pre><code>0832.php
1481.php
2853.php
3471.php
index.php
</code></pre>
<p>and I want to move all those <strong>XXXX.php</strong> (always in 4 digits format) to directory /tmp/, except index.php. how to do it with reg-ex and loop?</p>
<p>Alternatively, how about moving all files (including index.php) first to /tmp/ then later on put only index.php back to /public_html/, which one you think is less CPU consuming?</p>
<p>Last thing, I found this tutorial to move file using PHP: <a href="http://www.kavoir.com/2009/04/php-copying-renaming-and-moving-a-file.html" rel="nofollow">http://www.kavoir.com/2009/04/php-copying-renaming-and-moving-a-file.html</a> </p>
<p>But how to move ALL files in a directory?</p>
| php | [2] |
2,368,725 | 2,368,726 | help with navigation for iphone | <p>this is my flow
<strong>navA-> navB->navC</strong> then when user press NavC back button he goes to navA</p>
<p>but when user again press navA he should go to navB but its going on navC i dont know why</p>
<p>in navC i did this</p>
<pre><code>XMLAppDelegate *appDelegate=(XMLAppDelegate*)[UIApplication sharedApplication].delegate;
[self.view removeFromSuperview];
[appDelegate.window addSubview:appDelegate.preLoginNavController.view];
</code></pre>
<p>and in navA i am doing this to go to navB
//<strong>this is preLoginNavController.m</strong>
XMLAppDelegate <em>appDelegate=(XMLAppDelegate</em>)[UIApplication sharedApplication].delegate;</p>
<pre><code> //appDelegate.RootNavController.shouldHasBackButton = YES;
[self.navigationController.view removeFromSuperview];
[appDelegate.window addSubview:appDelegate.navigationController.view];//[navigationController view]
</code></pre>
<p>and in appdidfinish()</p>
<pre><code>[window addSubview:[preLoginNavController view]];
[window makeKeyAndVisible];**strong text**
</code></pre>
<p><strong>Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'</strong> thats why i am using this a</p>
<pre><code>appDelegate.newsNavController.shouldHasBackButton = YES;
[appDelegate.window addSubview:appDelegate.newsNavController.view];
</code></pre>
<p>do i need to push in the mehtod defined bu you or i can use in betwwen while adding subview??</p>
<p>like</p>
<pre><code>AccountApplication* controller = [[AccountApplication alloc] initWithNibName:@"AccountApplication" bundle:nil];
// [self.navigationController pushViewController:controller animated:YES];
// [controller release];
</code></pre>
| iphone | [8] |
4,368,747 | 4,368,748 | How to use Core Data in saving all the details which were stored or displayed in a table view? | <p>I am developing an app which parses an Xml or RSS feeds of a magazine..The thing is I have to include an offline capability,ie save the previous results which were displayed in each cell(similar to the New York times app) and then display the saved ones when there is no network connection..</p>
<p>Please help me with the codewise explanation using Core data as I was suggested to use it for this particular task.</p>
<p>Will be of great help for me..</p>
<p>Looking forward for your replies</p>
<p>Regards and Thanks</p>
<p>Arun</p>
| iphone | [8] |
4,028,828 | 4,028,829 | offline message in chat application C# | <p>Hai. I'm developing an office messenger app just like Network assistant (http://www.gracebyte.com/nassi/). One of the features is broadcasting message to all contacts in network. but i have problem in sending message to offline contact. i mean if there's one (or more) of my contacts is offline, but i still wanna send message, how can i guarantee he'll get my message?</p>
<p>any of you knows the solution?
Oh i develop it using C#.</p>
<p>thank you :)
-ViNa</p>
| c# | [0] |
2,292,955 | 2,292,956 | Generating div,ul,li,a tag combination dynamically using jquery | <p>My Jade!
<a href="https://lh4.googleusercontent.com/-hzRqciA1Tjs/UGmc39ijHuI/AAAAAAAAAFk/0XJzY0ZqU70/s720/App.jpg" rel="nofollow">https://lh4.googleusercontent.com/-hzRqciA1Tjs/UGmc39ijHuI/AAAAAAAAAFk/0XJzY0ZqU70/s720/App.jpg</a></p>
<pre><code>div(data-role='content')
div(class='content-primary')
ul(data-role="listview", data-split-theme='a',data-split-icon='gear')
li(data-theme='a')
a(href="")
div(id='addClientDivId')
a(href='#', data-icon='delete', title=' Delete ')
</code></pre>
<p>I wanna generate the above jade contents dynamically using jquery.
Can anyone help me..???</p>
<p>As i dont have reputation, I have uploaded a image screenshot to picasa.Refer the screenshot. I have tried all the possibilities given below, but couldn get the effects as on the screenshot.</p>
<p>Answer:</p>
<p>I have found solution for my query.</p>
<pre><code>var newContent = '<div data-role="content" data-theme="a" class="content-primary">';
newContent += '<ul data-role="listview" data-split-theme="a" data-inset="true" id="ulId">';
newContent += '<li>';
newContent += '<a href="">';
newContent += '<h4></h4>';
newContent += '<h5></h5>';
newContent += '<a href="" , data-icon="delete">';
newContent += '</a>';
newContent += '</a>';
newContent += '</li>';
newContent += '</ul>';
newContent += '</div>';
$("#addClientDivId").append(newContent).trigger('create');
</code></pre>
| jquery | [5] |
2,968,898 | 2,968,899 | How to write method which will accept variable count of parameters by ref | <p>So, I have the following code</p>
<pre><code>int[] GetIndexes(string columns)
{
...
}
var indexes = GetIndexes("Code|Name|Description");
var codeIndex = indexes[0];
var nameIndex = indexes[1];
var descIndex = indexes[2];
</code></pre>
<p>It is preferred to use it in the next way:</p>
<pre><code>GetIndexes("Code|Name|Description", ref codeIndex, ref nameIndex, ref descIndex);
</code></pre>
<p>Have you any suggestion about it?</p>
| c# | [0] |
3,919,249 | 3,919,250 | How can I make a basic PHP scoreboard? | <p>I have some students in my class and we are working on a project where the students earn a simple point. I am recording their points manually in to a text file on my laptop and then I move that to the schools server so students can view their scores.</p>
<p>The text file is like this:</p>
<pre><code>David:1
John:3
Susan:9
Ricky:12
Liam:3
</code></pre>
<p>and so on. Each line in the text file is like that. I'm not very good with PHP as I'm a novice and I know I need to read these in to an array but then I'm not sure how I would break the score away from the students and sort it so the highest score is on top so that I can then display it on a webpage. I already have quite a large text file so I can't really reformat it. How would I separate these and display them or put them in to an array so I can then display that on a simple HTML page?</p>
<p>I think we are using PHP 5.3.13. Thank you for any assistance.</p>
| php | [2] |
3,932,657 | 3,932,658 | Which android tab supports v4L2 with USB host functionality? | <p>I need to know the names of some android tablets with V4L2 support & host functionality. Suppose if plug in an USB camera.
Can anyone name any tablets with such functionality ?</p>
<p>Thanks a many lot in advance.</p>
| android | [4] |
3,608,874 | 3,608,875 | Android - error when try to test GPS on Emulator | <p>i wanna test a simple brief of using GPS on android. so i write a simple code like this :</p>
<pre><code>public class main extends Activity{
LocationManager mLocationManager;
TextView tv;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.myLocationText);
mLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setPowerRequirement(Criteria.POWER_LOW);
String locationprovider = mLocationManager.getBestProvider(criteria, true);
Location mLocation = mLocationManager.getLastKnownLocation(locationprovider);
tv.setText("Last location lat:" + mLocation.getLatitude() + "long:" + mLocation.getLongitude());
}
</code></pre>
<p>}</p>
<p>also, on AndroidManifest i added uses-permission like this :</p>
<pre><code> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</code></pre>
<p>but when i try to run at android emulator i get Error "Stopped Unexpectedly" and this apps closed. i added some try with DDMS too. but i dont have any idea about this error.</p>
| android | [4] |
3,223,782 | 3,223,783 | Simple GUI for validating username and password | <p>How can I complete the following code for validating a user name and password?</p>
<pre><code>public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LibnValidation().setVisible(true);
boolean result = validation();
if(!result)
{
}
}
private boolean validation() {
throw new UnsupportedOperationException("Not yet implemented");
boolean valid = false;
if(librarian.getText().equals("kani" && jPasswordField1.getPassword().equals("*****")){
valid = true;
}
return valid;
}
});
}
</code></pre>
| java | [1] |
3,783,955 | 3,783,956 | is this possible to create subdirectory in FTP using ftp.MakeDirectory? | <p>I have to create this query to get some answer before i change my code.Pardon me if this question is doesn't make sense to you guys.</p>
<p><strong>Scenario 1:</strong></p>
<pre><code>string path :ftp://1.1.1.1/mpg/test";
FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
requestDir.Credentials = new NetworkCredential("sh","se");
requestDir.Method = WebRequestMethods.Ftp.MakeDirectory;
</code></pre>
<p>Using the same code to create the directory structure to connect my local Filezilla ftp server to do the job---Works Fine.</p>
<p><strong>Scenario 2:</strong>
Used the above code to connect the remote ftp server to do the same job throws exception : Error 550 no file found or no Access.</p>
<p><strong>Question 1</strong> : I have a full permission to read/write for the folder,if its not a permission issue,what else i have to keep it in mind to look for it ?</p>
<p><strong>Question 2</strong>: If i modified my code like
step1: Make"mpg" direcotry first
step2: make"test" directory after that,works fine
is that mean FTP.Makedirectory won't support to create a subdirectory in the main dir ?</p>
<p>If that's the case how it created in my local ftp server ?</p>
<p>Any help appreciated.</p>
<p>Thanks in Advance.</p>
| c# | [0] |
5,184,633 | 5,184,634 | While Loop contines forever to get end of input string | <p>How do I run the while loop until the end of line or null character reached.</p>
<p>Here is my code</p>
<pre><code>#include<iostream>
using namespace std;
main()
{
char input[20];
cout<<"Enter a line: ";
cin>>input;
while(input!='\0')
{
cout<<"This is a text";
}
system("pause");
}
</code></pre>
| c++ | [6] |
5,145,577 | 5,145,578 | Creating files in sub directories in android | <p>Is it possible to create files in subdirectories created under "/data/data/packagename/files/" directory using openFileOutput method in android?
ie there is a sub-directory by name "text" inside the "/data/data/packagename/files/" directory.
I want to use the openFileOutput (String name, int mode) method to write a file eg:sample.txt into this directory....
Is it possible to use openFileOutput method to do it....</p>
<p>Can any one help me on this....</p>
| android | [4] |
3,512,258 | 3,512,259 | Remove everything from a string but numbers, dots and single letters with preg_replace | <p>How to modify this code to remove <strong>everything from a given string exept</strong> <em>numbers</em> (already there) <strong>AND</strong> <em>strings</em>: ".", "k ", "B ", and "M "?</p>
<p>What Im doing is parsing prices given in: 123k, 124.7B, 20M</p>
<pre><code>preg_replace("/\D/", "", "<td>Cost: 20b $, Sell for: 139k $</td>" );
</code></pre>
| php | [2] |
3,074,068 | 3,074,069 | C++ dynamic byte signatures | <p>Is there a good way (or a good lib/class/source file/something) to, at runtime, find a byte signature (using a string of bytes) at a certain address and get a pointer to that address?</p>
<p>I.e. in running memory:</p>
<blockquote>
<p>... 05 AE 6B 24 B1 00 B5 ...</p>
</blockquote>
<p>and at runtime finding the first pattern of <code>AE 6B 24</code> and returning the address of the position?</p>
| c++ | [6] |
4,708,863 | 4,708,864 | jQuery getJSON: Danish letters | <p>Im using jQuery getJSON method to get data from my database via some php code.</p>
<p>Im sending arrays of data from serverside to clientside via the getJSON method. </p>
<p>If a word in this array contains a danish letter (ÆØÅ) getJSON just returns null. I have tried to check the words before i use the getJSON and here there is no problem.</p>
<p>Is there an options in getJSON where i can set charset?</p>
<p>Im using charset ISO-8859-1 on serverside and clientside.</p>
| jquery | [5] |
3,370,489 | 3,370,490 | Is the behavior of "a=(b+n)/++n" defined? | <p>I am wondering if following expression has defined behavior (always equal to "<code>a=n/(n+1); ++n;</code>") in C++?</p>
<pre><code>a=n/++n;
</code></pre>
| c++ | [6] |
884,048 | 884,049 | Drawing half image | <p>Hi all i am having .png image.I want to draw only half of this image.If i call method drawInRect: on image with width being half the size of image,it will still draw the full image
in given rect.So how to draw half image </p>
| iphone | [8] |
930,333 | 930,334 | Quick and easy way to check if all items in a dictionary are empty strings? | <p>I have a dictionary of N items. Their values are strings, but I'm looking for an easy way to detect if they are all empty strings.</p>
<pre><code>{'a': u'', 'b': u'', 'c': u''}
</code></pre>
| python | [7] |
5,887,963 | 5,887,964 | How to clear back stack when Home button is pressed | <p>I created an Home application wich as customized applications that I want to be launched.</p>
<p>The problem is that when I launch an application and then press HOME I want to empty all back stack, so that when I press BACK button dont return to the application.</p>
<p>The actual behaviour is:</p>
<p><strong>HOME >> APP >> (HOME BUTTON PRESSED) >> HOME >> (BACK BUTTON PRESSED) >> APP</strong></p>
<p>The desired behaviour is:</p>
<p><strong>HOME >> APP >> (HOME BUTTON PRESSED) >> HOME >> (BACK BUTTON PRESSED) >> (DO NOTHING!)</strong></p>
<p>Any suggestion?!</p>
| android | [4] |
4,336,964 | 4,336,965 | python -- trying to count the length of the words from a file with dictionaries | <p>SOLVED</p>
<pre><code>def myfunc(filename):
filename=open('hello.txt','r')
lines=filename.readlines()
filename.close()
lengths={}
for line in lines:
for punc in ".,;'!:&?":
line=line.replace(punc," ")
words=line.split()
for word in words:
length=len(word)
if length not in lengths:
lengths[length]=0
lengths[length]+=1
for length,counter in lengths.items():
print(length,counter)
filename.close()
</code></pre>
| python | [7] |
2,597,594 | 2,597,595 | Bizarre Behavior of src attribute on img element in VS2008 inserting [A] characters | <p>With VS2008 SP1 I have a line of code like this in an aspx file:</p>
<pre><code><img src='http://spiurl.appspot.com/<%#DataBinder.Eval(Container.DataItem, "UserName") %>' style='border:0; cursor:pointer;'/>
</code></pre>
<p>This works perfectly. However, if I switch to "Design" mode in the IDE and then back to "Source" mode the characters <strong>[A]</strong> are magically/infuriatingly inserted into the beginning of the src attribute and I end up with:</p>
<pre><code><img src='[A]http://spiurl.appspot.com/<%#DataBinder.Eval(Container.DataItem, "UserName") %>' style='border:0; cursor:pointer;'/>
</code></pre>
<p>...which of course is broken. Has anyone else seen this annoyance before? Do you have a solution?</p>
<p>Update: Actually it appears that this happens on every attempt to save the file.</p>
| asp.net | [9] |
3,167,730 | 3,167,731 | Bad encoding when using on strftime in spanish? | <p>I'm trying to echo the date with strftime but I'm getting bad encoding on utf-8 only characters. (accented characters basically)</p>
<pre><code>setlocale(LC_TIME, 'spanish');
define("CHARSET", "iso-8859-1");
echo strftime("%A, %d de %B",strtotime($row['Date']));
</code></pre>
<p>Is there any problem in this part of the code? Everything is encoded in utf-8 and echoing a 'á' character above it displays the character correctly.</p>
| php | [2] |
118,594 | 118,595 | Java 1.6 - determine symbolic links | <p>In a DirectoryWalker class I want to find out if a File instance is actually a symbolic link to a directory (assuming, the walker walks on UNIX systems). Given, I already know the instance is a directory, would the following be a reliable condition to determine the symbolic link?</p>
<pre><code>File file;
// ...
if (file.getAbsolutePath().equals(file.getCanonicalPath())) {
// real directory ---> do normal stuff
}
else {
// possible symbolic link ---> do link stuff
}
</code></pre>
| java | [1] |
2,281,971 | 2,281,972 | Decoding the encoded Pound symbol in java | <p>we are using the external service to get the data in a CSV format. we are trying to write the data to response so that the csv can be downloadable to client. unfortunately, we are getting the data in the below format. </p>
<pre><code>Amount inc. VAT Balance
£112.83 £0.0
£97.55 £0.0
£15.28 £0.0
</code></pre>
<p>we are unable to decode the content. Is there a way to decode <code>£</code> and display <code>£</code> in java.</p>
<p>Is there any String Utils available to decode the strings.</p>
| java | [1] |
719,956 | 719,957 | utf8/iso-8859-1 encoding i $.ajax() | <p>How to encode/decode utf8 in ajax requests?</p>
<p>My page is encoded in iso-8859-1, but how can you easily encode the data to utf8 when sending and decode again when reveicing the response?</p>
<pre><code>function Ajax(){
var _this = this;
this.url = null;
this.data = null;
this.success = null;
this.global = true;
this.timeout = JSON_TIMEOUT;
this.cache = false;
this.dataType = 'json';
this.type = 'post';
this.send = function(){
var jqxhr = $.ajax({
url : this.url,
data : this.data,
timeout : this.timeout,
cache : this.cache,
dataType : this.dataType,
type : this.type,
global : this.global
}
)
.success(this.success)
.error(function(){
// something
})
.complete(function(){
});
};
}
</code></pre>
| jquery | [5] |
1,330,674 | 1,330,675 | How can I create subclass at run-time to map some properties then cast it back to parent class? | <p>Consider this <code>People</code> class:</p>
<pre><code>public class People
{
public virtual string Name { get; set; }
public virtual ushort Age { get; set; }
}
</code></pre>
<p>I have some third party implementations that can obtain people data but with a little variations. For example, I have a method that is able to retrieve data for <code>StrangePeople</code>:</p>
<pre><code> public class StrangePeople
{
public string Name { get; set; }
public DateTime BirthDate { get; set; }
}
...
StrangePeople someone = GetData<StrangePeople>();
</code></pre>
<p>Due to the amount of classes and variations I trying to found a way to generate a runtime subclass of <code>People</code> that can translate the data so I can cast it back to <code>People</code> later. In other words, with minimum effort generate a subclass like this:</p>
<pre><code>public class StrangePeopleTranslator : People
{
private ushort? _mAge = null;
public override ushort Age
{
get
{
if (_mAge == null)
{
DateTime today = DateTime.Today;
int age = today.Year - BirthDate.Year;
if (BirthDate > today.AddYears(-age)) age--;
_mAge = age;
}
return _mAge.GetValueOrDefault();
}
set
{
_mAge = value;
}
}
public DateTime BirthDate { get; set; }
}
...
People someoneElse = (People)GetData<StrangePeopleTranslator>();
</code></pre>
<p>Maybe the run-time subclass it's bit overkill... I don't know.</p>
| c# | [0] |
4,643,726 | 4,643,727 | tutorial for iphone NSUserDefaults | <p>Is there any tutorial available for state maintanance using <code>NSUserDefaults</code>?</p>
| iphone | [8] |
2,637,836 | 2,637,837 | return type in C# | <p>I have two classes named <strong>ROAD</strong> and <strong>PATH</strong></p>
<pre><code>public class ROAD
{
public string getData()
{
return "Marlton Road";
}
}
public class PATH
{
public string getData()
{
return "Tagore Path";
}
}
</code></pre>
<p>Also i have a function named FETCH() in my Static Void Main</p>
<p>FETCH() contains following code</p>
<pre><code>public returnType FETCH(bool flag)
{
if(flag)
{
ROAD obj=new ROAD();
return obj;
}
else
{
PATH obj=new PATH();
return obj;
}
}
</code></pre>
<p>Now my question is what should be the return type of function FETCH().
Or is there any other way to implement this logic.</p>
| c# | [0] |
5,358,419 | 5,358,420 | Javascript Submit | <p>Hi I have the following script in my form </p>
<pre><code>function pdf() {
var frm = document.getElementById("form1");
frm.action = "http://www.abbysoft.co.uk/index.php";
frm.target="_blank"
frm.submit()
}
</code></pre>
<p>this is called from the following in my form
<code><input class="buttn" type="button" value="Test" onclick="pdf()"</code></p>
<p>The code work up to the frm.submit() but it will not submit </p>
<p>Can anyone offer any advice please ?</p>
| javascript | [3] |
1,053,600 | 1,053,601 | Android Camera in Portrait on SurfaceView | <p>I tried several things to try to get the camera preview to show up in portrait on a <code>SurfaceView</code>. Nothing worked. I am testing on a Droid that has 2.0.1. I tried:</p>
<p>1) forcing the layout to be portrait by: <code>this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);</code></p>
<p>2) using</p>
<pre><code>Camera.Parameters parameters = camera.getParameters();
parameters.set("orientation", "portrait");
parameters.setRotation(90);
camera.setParameters(parameters);
</code></pre>
<p>Is there something else I can try? If this a bug in Android or the phone how can I make sure that this is the case so that I have proof to inform the client?</p>
<p>Thanks,
Prasanna</p>
| android | [4] |
3,225,387 | 3,225,388 | delete db entry using js | <p>i have three file...
1st index.tpl.php
code of this is</p>
<pre><code><td>
<input type="button" name="checkbox" value="delete" onclick="selectAccess('<?php echo __('are you sure you want to delete data')?>','<?php echo $sGroups['id_user']; ?>')">
</td>
</code></pre>
<p>2nd is common.js</p>
<pre><code>function selectAccess(message,AccessId){
var answer = confirm(message)
alert(AccessId);
if (answer)
{
$.ajax({
url: SITE_URL + '/users/delete',
type: 'POST',
data: {
'ID':AccessId
},
success: function(data){
alert(data);
}
});
}
}
</code></pre>
<p>here its not working..... plese advice me where is mistake
thnks...</p>
| php | [2] |
5,087,021 | 5,087,022 | Database not copied in Android 2.3.3 | <p>I write the code of database copy in /data/data path. but it gives this error</p>
<pre><code>sqlite3_open_v2("/data/data/com.mycom.package/databases/My Bookback", &handle, 2, NULL) failed
Caused by: android.database.sqlite.SQLiteException: unable to open database file and copy. 05-23 13:19:46.746: ERROR/AndroidRuntime(9120):
Caused by: android.database.sqlite.SQLiteException: no such table: Details: ,
</code></pre>
| android | [4] |
5,028,977 | 5,028,978 | Can I combine the bind event for two selectors in jQuery? | <p>I have the following:</p>
<pre><code> $('#loginLink')
.bind('click', accessLinkClick);
$('#registerLink')
.bind('click', accessLinkClick);
function accessLinkClick(e) {
e.preventDefault();
$('#registerLink').unbind('click', accessLinkClick);
$('#loginLink').unbind('click', accessLinkClick);
dialog(this);
}
</code></pre>
<p>Is it possible for me to somehow combine the selectors for loginLink and register link so I don't need to specify them twice. I saw how to do this with functions but not events. </p>
| jquery | [5] |
4,862,044 | 4,862,045 | jquery - live and delegate failed here | <p>The following codes worked before but would not work again except I put alert after the ajax call, I've use both delegate & live but it didn't work still.</p>
<pre><code>function getAns(val) {
var value;
value = $("input[name=ans"+val+"]:checked").val();
$.post('ajax.php', {val:value}, function(data) {
alert(data);
});
//only works with this alert
alert('done');
});
</code></pre>
<p>}</p>
| jquery | [5] |
2,703,209 | 2,703,210 | Using MFC Dll in C# | <p>Please give me a complete screenshots from the starting step of how to use MFC Dll in C#?</p>
| c# | [0] |
1,134,589 | 1,134,590 | Feature config class in android library project | <p>I'm using a Config class with a bunch of boolean constants in an android library project, which toggle certain features in the code, and I have many projects that use that library, but need to define their own configs, so a Config file is present in these projects also. The problem is that the build fails, because the library and the project both have a Config.java class. This used to work, but as of ADT 17 the library Config class is not overridden.</p>
<p>How can I solve this problem now?</p>
| android | [4] |
4,279,369 | 4,279,370 | How to get left padding of an image which is aligned center in parent? | <p>I have a RelativeLayout in which there is a imageView center aligned inside a RelativeLayout.</p>
<p>How to get left padding of that image which is aligned center in ?</p>
<p>thanks,
karthik</p>
| android | [4] |
538,452 | 538,453 | PHP fgetcsv error - How can I arrange it? | <p>I am getting the following error:</p>
<p>"Notice: fgetcsv() [function.fgetcsv]: delimiter must be a single character" in my browser</p>
<p>My PHP Code is as follows - can someone rearrange it please?</p>
<pre><code>$fh = fopen('notes.txt', 'r') or die('Unable to open notes.txt');
while(($line = fgetcsv($fh, 0, '||')) !== FALSE)
if ($line[0] == $name) {
echo <<<EOL
My color is $line[2]
EOL;
break; // if there's only ever one '5678' line in the, get out now.
}
fclose($fh);
</code></pre>
| php | [2] |
1,819,645 | 1,819,646 | Reading Data from Text File to a CheckedListBox | <p>Hallo There
was hopng I could ask for some advice.
Which would be the best way to read data from a textFile and adding this to a checkedListBox?</p>
<p>something like this although this doesn't work out properly.</p>
<pre><code>FileStream fs = new FileStream("../../Features.txt", FileMode.Open, FileAccess.Read);
BufferedStream bs = new BufferedStream(fs);
fs.Close();
StreamReader sr = new StreamReader("../../Features.txt");
chkFeatures.Items.Add(sr.ReadToEnd());
sr.Close();
</code></pre>
<p>Regards
Arian</p>
| c# | [0] |
162,811 | 162,812 | How to add an event listener with a callback function that accepts attributes? | <p>And also, how to remove it then?</p>
| javascript | [3] |
4,666,734 | 4,666,735 | Generic DateTime List Comparison in C# | <p>I have a Generic DateTime List</p>
<pre><code>List<DateTime> **PreviousDates** = //Some List of Dates
</code></pre>
<p>Now i want to Get all the Dates in the <strong>PreviousDates</strong> List whose Month and Year equals the GivenDate's Month & Year. no matter what the Day & Time are...</p>
<p>I Tried using List.Contains() method, but it checks all Parts of the Date, i want to check only Month&Year..</p>
<p>Help Me!</p>
<p>Thanks
Pradeep</p>
| c# | [0] |
4,927,666 | 4,927,667 | Do apps created on the lower android versions gets supported in the newer versions? | <p>We are planning to create an android application for our web application. I have noticed that the latest android sdk is 4.0 but many mobiles on market just run on lower versions. If creating an app in lower version is supported in higher versions, which would be the most advisable version of android to start working with?</p>
| android | [4] |
938,040 | 938,041 | Nested Usercontrols and ViewState | <p>I have a UserControlParent that dynamically loads UserControlChild.</p>
<p>In the UserControlChild, I store a value using the ViewState object by doing a </p>
<pre><code>ViewState["count"] = myCount;
</code></pre>
<p>On Postbacks, the ViewState returns a null. Is this because the UserControlChild is being loaded dynamically? If it helps, the UserControlParent is loaded dynamically in the ASPX page as well.</p>
| asp.net | [9] |
5,072,602 | 5,072,603 | Several Large bitmaps within VM memory | <p>I need to load several large bitmaps into memory (to be used on screen at the same time, alpha png's).</p>
<p>I've loaded the bitmaps in efficiently using tutorial: (http://developer.android.com/training/displaying-bitmaps/load-bitmap.html)</p>
<p>My problem is, is that my bitmaps (only 3 of them) are going over the 32MB heap limit on high resolution screens. (silly limit).</p>
<p>What can I do now? Is there anyway of loading bitmaps outside the app assigned memory heap or am I stuck here?</p>
| android | [4] |
3,394 | 3,395 | What is the most Pythonic way to use an empty dictionary as a default argument? | <p>Using default arguments of the form <code>x={}</code> usually does not accomplish the intended purpose in Python, since default arguments are bound when a function is defined, not called.</p>
<p>The convention seems to be to set mutable objects as default arguments with <code>x=None</code> and then check <code>x is None</code> to assign the proper default when the function is called.</p>
<p>So if I would like to cast <code>x</code> to a dictionary that is by default empty, I would use something like the following:</p>
<pre><code>def f(x=None):
x = dict(x) if x is not None else {}
</code></pre>
<p>However, since <code>dict</code> can take any iterable, I could also write this more succinct version:</p>
<pre><code>def f(x=()):
x = dict(x)
</code></pre>
<p>Which of these is the "right" approach?</p>
| python | [7] |
164,979 | 164,980 | Any reason why one would call hide() before show()? | <p>Why would one want to call hide() before show() ? I'd like to know this before i optimize this with method chaining..</p>
<pre><code>function ShowSomething() {
jQuery("something").hide();
jQuery("something").show();
}
</code></pre>
| jquery | [5] |
4,111,876 | 4,111,877 | Replacing width and height in markup with a JS regular expression | <p>I have two JS variables X and Y. In my markup there's a line starting with:</p>
<pre><code><iframe frameborder="0" width="600" height="337" ..
</code></pre>
<p>I want to replace the width's value by X's value and the height's value to Y's value. Could somebody help me with the regular expression to achieve this ?</p>
| javascript | [3] |
5,592,246 | 5,592,247 | Why does my click handler fail after 2 clicks? | <p>My aim is to toggle between two images up and down. </p>
<p>This is what i have, and it works partially. </p>
<p>If this is OK then what am i missing?<br>
When i click two times it stops working....</p>
<p>Here is my code:</p>
<pre><code> $(document).ready(function () {
$(".collapse").click(function () {
$("#box").hide();
$(".collapse").replaceWith('<span class="open"></span>');
$(".open").click(function () {
$("#box").show();
$(".open").replaceWith('<span class="collapse"></span>');
});
});
});
</code></pre>
| jquery | [5] |
5,784,663 | 5,784,664 | Where to create file in android device | <p>I have a requirement that I need to create text file in to my device internal memory and write some data into the file.</p>
<p>For that I am creating file by reading the path "getFileDir()".</p>
<p>This is working fine in most of the devices , but in few devices I am getting "Permission denied" issue while creating file at the above path.</p>
<p>Can anyone please suggest me in which path I have to create a file so that this path accessible in all the devices..??</p>
<p>I am creating file in my onCreate() method of my activity.</p>
<p>I do not want to create file SD card.</p>
| android | [4] |
5,469,106 | 5,469,107 | jquery good practice | <p>Is it good practice to check that element exist before remove it or it is not necessary ?
For example:</p>
<pre><code>if(('#el').length > 0) {
$('#el').remove();
}
</code></pre>
<p>is same as</p>
<pre><code>$('#el').remove();
</code></pre>
| jquery | [5] |
1,084,930 | 1,084,931 | Inbalance of () | <p>For some reason I'm receiving a syntax error for the following line with an imbalance of parenthesis and I don't see the reason.</p>
<pre><code>if(isset($this->uri->segment(3)) AND ((empty($this->uri->segment(3))||($this->uri->segment(3) === FALSE)||(trim($this->uri->segment(3)) == '')))
</code></pre>
| php | [2] |
4,466,385 | 4,466,386 | Autorenewable In-app using MKstorekit? | <p>I have an application in Iphone in which i am trying to implement Autorenewable subscription using MKstorekit4.3.In which i noticed some server codes are there. Is it possible to use this without using the server component.So that by setting own server as nil and review access as nil.can anybody help me with exact mechanism.</p>
| iphone | [8] |
103,880 | 103,881 | Java Command Prompt Exit | <p>I have a short question concerning the Runtime.getRuntime.exec("") command in java.</p>
<p>I am trying to make a tunnel to a gateway computer via SSH:</p>
<pre><code>String tunnel = "C:\\Program Files\\PuTTY\\putty.exe -ssh -X -P " + localPort + " " + tempUsername + "@" + localIP
+ " -pw " + tempPassword + " -L " + tunnelPort + ":" + gatewayName + ":"+gatewayPort;
Runtime.getRuntime().exec(tunnel);
</code></pre>
<p>This bit of code works properly except the annoying fact that a command prompt appears.</p>
<p>Now I tried to exit the prompt after executing the code:</p>
<pre><code>String tunnel = "C:\\Program Files\\PuTTY\\putty.exe -ssh -X -P " + localPort + " " + tempUsername + "@" + localIP
+ " -pw " + tempPassword + " -L " + tunnelPort + ":" + gatewayName + ":"+gatewayPort;
String cmdCommands [] = {tunnel, "exit"};
Runtime.getRuntime().exec(cmdCommands);
</code></pre>
<p>Is it possible to close the command prompt in a similar way like I do or are there better ways? (This code doesnt work)</p>
| java | [1] |
1,654,569 | 1,654,570 | How to get last opened date of an application in android? | <p>I want to get other applications last opened and used date in an android application...</p>
<p>Can anybody help on this?</p>
| android | [4] |
956,460 | 956,461 | how to exclude root node in XML for displaying menu? | <p>I want to attach the xml file data to the menu through the XmlDataSource.
I did that but it display from root node. How to do if do not want root node menu. & all the sub menus in same level. eg File, Edit, View etc. Because not to do so then we get unnecessary one extra level for root level menu.</p>
<p>Regards,
Girish </p>
| asp.net | [9] |
4,942,847 | 4,942,848 | Problem with href url | <p>I'm using a unordered list like a menu, but when I click on an element of the list, the href is being changed rarely. I set the href like this: </p>
<ul>
<li>href="UI/Administracion/Ejemplo.aspx</li>
</ul>
<p>When I click on any element of the list, the href changes his url like this:</p>
<p>UI/Administracion/Ejemplo/UI/Administracion/Ejemplo.aspx</p>
<p>I'm using ASP 3.5 and the app uses master pages.</p>
<p>Any suggestions?</p>
| asp.net | [9] |
2,378,238 | 2,378,239 | How to make any android application for use in different devices as aspect of UI | <p>As i am a new to android and made a small application but that doesn't give same<br>
appearance on different devices<br>
Thanks</p>
| android | [4] |
5,410,975 | 5,410,976 | How to convert a string in hexadecimal string? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3381614/c-convert-string-to-hexadecimal-and-vice-versa">C++ convert string to hexadecimal and vice versa</a> </p>
</blockquote>
<p>Trying this sample code which I found in StackOverflow...</p>
<pre><code>std::string text = "¯"; // AF in HEX ASCII.
std::ostringstream result;
result << std::setw(2) << std::setfill('0') << std::hex << std::uppercase;
std::copy(text.begin(), text.end(), std::ostream_iterator<unsigned int>(result, " "));
</code></pre>
<p>result.str() will be 'FFFFFFAF' instead of just 'AF'</p>
<p>What can I do?</p>
<p>My text can have more than one character, like that: text = '¯ABCÈ'; // AF414243C8
The result after 'convertion' is: FFFFFFAF414243FFFFFFC8.</p>
<p>.</p>
<p>Well, I solved it with a replace... it's not a good practice in this case, but solved.</p>
<pre><code> if(value > 6)
{ //replace
std::string& str = stringlist2[count];
const std::string& from = "FFFFFF";
const std::string& to = "";
size_t j;
for ( ; (j = stringlist2[count].find( from )) != string::npos ; ) {
stringlist2[count].replace( j, from.length(), to );
}
}
</code></pre>
| c++ | [6] |
2,451,083 | 2,451,084 | About the copy constructor and pointers | <p>I'm reading through an example in primer and something which it talks about is not happening. Specifically, any implicit shallow copy is supposed to copy over the address of a pointer, not just the value of what is being pointed to (thus the same memory address). However, each of the pos properties are pointing to two different memory addresses (so I am able to change the value of one without affecting the other). What am I doing wrong?</p>
<p>Header</p>
<pre><code>#include "stdafx.h"
#include <iostream>
class Yak
{
public:
int hour;
char * pos;
const Yak & toz(const Yak & yk);
Yak();
};
</code></pre>
<p>END HEADER</p>
<pre><code>using namespace std;
const Yak & Yak:: toz(const Yak & yk)
{
return *this;
}
Yak::Yak()
{
pos = new char[20];
}
int _tmain(int argc, _TCHAR* argv[])
{
Yak tom;
tom.pos="Hi";
Yak blak = tom.toz(tom);
cout << &blak.pos << endl;
cout << &tom.pos << endl;
system("pause");
return 0;
}
</code></pre>
| c++ | [6] |
3,213,387 | 3,213,388 | How to move images left and right in front or behind another Image Jquery | <p>i have a list of images i need to be able to move them left and right (sortable) in jquery. I know I need to use Child Selector but can someone lead me down the right path to getting this working please.</p>
<p>e.g so say i click id=1 and i want to move it below id="3"</p>
<pre><code> <div id="image_list">
<img src="test0.png" id="1"></img>
<img src="test1.png" id="2"></img>
<img src="test2.png" id="3"></img>
<img src="test3.png" id="4"></img>
</div>
<div id="move_opt">
<div id="left">Move Image Left</div>
<div id="right">Move Image Right</div>
</div>
$('#image_list').live('click', function() {
var img_class = $(this).attr("class");
var img_src = this.src;
$('#img_prop').css("display","block");
$('#pre_img').html("<img src='"+img_src+"'></img>");
});
</code></pre>
<p>Thank you</p>
| jquery | [5] |
1,951,241 | 1,951,242 | php function returns empty string. echo prints the string properly; | <p>I am completely stumped on what appears to be a trivial problem.</p>
<p>I have this function:</p>
<pre><code>function findCategoryNameInTree($id, $tree) {
foreach($tree as $branch) {
if ($branch['category_id'] == $id) {
echo $branch['name'];//works
print_r($branch['name']);//works
//return($branch['name']); //returns nothing
return $branch['name'];//fix this line per feedback still no return value
} else {
if(count($branch['children']) > 0) {
findCategoryNameInTree($id,$branch['children']);
}
}
}
}
</code></pre>
<p>I can't figure out for the life of me why it's not returning anything.</p>
<p>Please help!</p>
<p><strong>Edit</strong>
Here's how I call my function</p>
<pre><code>//what I really want to do
$primgenre = findCategoryNameInTree($cat_id,$category_tree['children']);
//but this doesnt work either
echo $primgenre;
//nor this
print_r($pringenre);
</code></pre>
| php | [2] |
1,286,049 | 1,286,050 | Struct in queue | <p>I have a struct like below:</p>
<pre><code>struct Add
{
public static string url;
public static string password;
public static string fake_path;
public static List<string> upload = new List<string>();
}
</code></pre>
<p>From the form I fill all these vars. And then I need to add this struct to Queue. How to do this?</p>
| c# | [0] |
4,021,734 | 4,021,735 | Problems with deltaTicks combined with high speed in a game loop | <p>My game uses a d = vt calculation for movement of objects where t is the time since the last frame (one frame per loop). </p>
<p>I'm using SDL and the gist of the timing calculation is that I create an instance of a Timer class and start it. I call GetSeconds() when it's needed which returns the difference between when the timer was started and the current time (divided by 1000 because everything is in milliseconds).</p>
<p>Ex:</p>
<pre><code>return (SDL_GetTicks() - m_StartingTicks) / MILLISECONDS_PER_SECOND;
</code></pre>
<p>After each loop the timer is reset. I.e. <code>m_StartingTicks = SDL_GetTicks()</code> However, I recently changed this so that it's only reset <code>if m_StartingTicks is < SDL_GetTicks</code>, but it didn't fix the problem.</p>
<p>This was all hunky dory until I recently wrote a game engine to handle different game states and various other things which are used in my main game loop. This seriously improved performance, but unfortunately each iteration of the game loop is now occuring in less than 1 millisecond so when I pass GetSeconds(), 0 is returned and things on the screen don't move.</p>
<p>The easiest way to handle this is a simple kludge where if <code>SDL_GetTicks() - m_StartingTicks) == 0</code> I change it to a 1 (as in 1 millisecond instead of 0). I don't really like this though, and I'd like to hear any suggestions, fixes, improvements, etc.</p>
<p>If you need more info I'd be happy to offer it.</p>
| c++ | [6] |
4,947,087 | 4,947,088 | How to get remaining rows from table after remove()ing a row | <p>I have some code that should remove the parent row of the clicked td and then return the id's of the other rows to an input box. If i comment out the remove line it all works well, but with the remove call i get an error: </p>
<pre><code>rows is undefined
for (var i=0; i<rows.length; i++) {
$("td.remove").live('click', function(event) {
var element = this;
$(this).parent().remove();
var rows = $(element).parents('table').attr("rows");
answer = '';
for (var i=0; i<rows.length; i++) {
answer += rows[i].id+",";
}
$('#' + $(this).parents('table').attr("title")).val(answer);
});
</code></pre>
<p>How can i get the remaining rows after i have deleted the row i clicked on?</p>
<p>Thanks for any help,</p>
<p>will</p>
| jquery | [5] |
5,619,085 | 5,619,086 | How to return 2 dimension array in C++ | <p>I have a segmentationfault at the line : cout << b[0][0];</p>
<p>Someone can tell me what I should do to fix my code? </p>
<pre><code>#include <iostream>
using namespace std;
int** gettab(int tab[][2]){
return (int**)tab;
}
int main() {
int a[4][2] = {{0, 0}, {1, 0}, {2, 0}, {2, 1}};
int ** b = gettab(a);
cout << b[0][0];
return 0;
}
</code></pre>
| c++ | [6] |
4,214,124 | 4,214,125 | How to align toast in android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2506876/how-to-change-position-of-toast-in-android">how to change position of Toast in android?</a> </p>
</blockquote>
<p>Is there any method to align toast message in application.By default it always appears at the bottom of application.
i did it like this...
Toast.makeText(this, "hello !", Toast.LENGTH_LONG).show();
Thank you </p>
| android | [4] |
269,136 | 269,137 | How to do "hit any key" in python? | <p>How would I do a "hit any key" (or grab a menu option) in Python?</p>
<ul>
<li>raw_input requires you hit return.</li>
<li>Windows msvcrt has getch() and getche().</li>
</ul>
<p>Is there a portable way to do this using the standard libs?</p>
| python | [7] |
3,787,583 | 3,787,584 | Passing values for method | <p>I beginner for programming. So can you please show me how to pass values for your compile() method. </p>
<pre><code>class CL
{
private const string clexe = @"cl.exe";
private const string exe = "Test.exe", file = "test.cpp";
private string args;
public CL(String[] args)
{
this.args = String.Join(" ", args);
this.args += (args.Length > 0 ? " " : "") + "/Fe" + exe + " " + file;
}
public Boolean Compile(String content, ref string errors)
{
//remove any old copies
if (File.Exists(exe))
File.Delete(exe);
if (File.Exists(file))
File.Delete(file);
File.WriteAllText(file, content);
Process proc = new Process();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.FileName = clexe;
proc.StartInfo.Arguments = this.args;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
//errors += proc.StandardError.ReadToEnd();
errors += proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
bool success = File.Exists(exe);
return success;
}
}
</code></pre>
| c# | [0] |
1,760,658 | 1,760,659 | scale-independent pixel | <p>I don't know how it convert to the unit of pixels. For example, if I assign 10sp to my font size on 160 dpi device, how much px of my font size is it ? Or, if I assign 10sp to my font on 240 dpi device, how much px of my font size is it ?</p>
| android | [4] |
3,741,751 | 3,741,752 | How can I change 2.5E7 to a normally formatted number? | <p>How can I change 2.5E7 to 2,500,000.00?</p>
| java | [1] |
117,110 | 117,111 | How to use the value of variable from if/else tree as value of variable for a while loop afterwards | <p>Here is my program code as I have it written so far. It's saying I haven't initialized answer. I want to use the value of answer after the if/else tree executes to convert the number into asterisks.</p>
<pre><code>import java.io.*;
import java.util.*;
public class Project5 {
public static void main(String[] args){
System.out.println("Please enter a formula of this form:operator,operand,operand(ex. add,2,2):");
// wanted to change things but was not sure how far I was allowed to go so I used commas instead of spaces
//was trying to split with a delimiter but kept getting an error [Ljava.lang.String;@55e83f9
Scanner input = new Scanner(System.in);
String formula = input.nextLine();
System.out.println(formula);
String oper = formula.substring(0,3);
System.out.println(oper);
String fnum = formula.substring(4,5);
System.out.println(fnum);
String snum = formula.substring(6,7);
System.out.println(snum);
double freal = Integer.parseInt(fnum);
System.out.println(freal);
double sreal = Integer.parseInt(snum);
double answer;
if (oper.equalsIgnoreCase("add") == true){
answer = freal+sreal;
System.out.println(answer);
}
else if(oper.equalsIgnoreCase("subtract") == true){
answer = freal-sreal;
System.out.println(answer);
}
else if(oper.equalsIgnoreCase("multiply") == true){
answer = freal*sreal;
System.out.println(answer);
}
else if(oper.equalsIgnoreCase("divide") == true){
answer = freal/sreal;
System.out.println(answer);
}
else
System.out.println("not valid.");
while(answer > 0){
System.out.print("*");
answer--;
}
}}
</code></pre>
| java | [1] |
1,595,614 | 1,595,615 | Set the onTouchListener on a background | <p>Is there any possibility to set an onTouchListener on the background which was set by writing <code>android:background="@drawable/xxx"</code> in my <code>.xml</code> file? Maybe I can set one to my <code>RelativeLayout</code> which has this <code>drawable</code> as a background? If not, what is the easiest way to do this? Thanks.</p>
| android | [4] |
1,391,364 | 1,391,365 | Getting location on first boot FC also and random FC's on some devices | <p>I am getting the current location with the following code but this is causing FC if there is no last known location. Also some devices like Motorola atrix crash if they open this activity.</p>
<pre><code>locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000L, 500.0f, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
double lat = location.getLatitude();
double lng = location.getLongitude();
</code></pre>
<p>Is there a better way of getting the current location with out crashing my app?</p>
| android | [4] |
2,387,121 | 2,387,122 | ASP.Net application locks up | <p>FFRS froze reasons</p>
<p>We have ASP.Net 2.0 application. It was running corretly and suddenly get loked up, when I kept opened a member edit page for 20 minutes or so. And after 20 minutes when I cliked on save. It is locked. Not it does not let me login. Niether it opens the login page sometimes.</p>
<p>This has happened twice.</p>
<p>In hosting server architecture we have two app servers and two db servers for fail over purposes.</p>
<p>Your precious help is appreciated!!!</p>
| asp.net | [9] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.