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 |
|---|---|---|---|---|---|
803,239 | 803,240 | How to take formatted input from ifstream | <p>I have a text file with a set of names formatted in the following way:</p>
<pre><code>"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH"
</code></pre>
<p>and so on. I want to open the file using <em>ifstream</em> and read the names into a string array (without quotes, commas). I somehow managed to do it by checking the input stream character by character. Is there an easier way to take this formatted input?</p>
<p>EDIT:
I heard that you can use something like
fscanf (f, "\"%[a-zA-Z]\",", str);
in C, but is there such a method for ifstream?</p>
| c++ | [6] |
1,964,844 | 1,964,845 | Finding account nature of a contact group? | <p>I am developing an application in which it is required to find the nature of a contact group means whether it is google group , phone group or sim group. How to find it.Please suggest me how to do it.
Thanks in advance.</p>
| android | [4] |
5,373,595 | 5,373,596 | Why do I get duplicate define although using require_once()? | <p>My defs.php has a define that I need, and although I used require_once for it, when I try to access defs.php, I get a series of duplicates as if the defs.php was already called before.
On the other hand, if I don't call it, I get undefined <code>use of undefined constant</code>...</p>
<p>Any ideas? </p>
<p>Thanks!</p>
| php | [2] |
1,997,660 | 1,997,661 | webpage not loading javascript script | <p>so, I have this webpage here [ <a href="http://saikonet.org" rel="nofollow">http://saikonet.org</a> ] and it's not loading the tipsy script. If you go into the source, it's on line 11. Now, the strange part is all the other scripts are loading fine, and if you click on the tipsy script link, it's loads fine in browser, so syntax and filepath are both fine. even stranger is that is was working completely fine last time I checked.. it just stopped working all the sudden. I'm not sure how to proceed..</p>
<p>(and btw, the way I checked whether it's loading or not was via the script tab in chromium's 'inspect element')</p>
| javascript | [3] |
399,354 | 399,355 | The linked program is no longer installed Toast message on click of android market app on HTC-Evo(Sprint) | <p><img src="http://i.stack.imgur.com/GgV3g.png" alt="enter image description here">The linked program is no longer installed Toast message on click of android market app </p>
| android | [4] |
5,909,016 | 5,909,017 | Disabling event handler for link inside UL | <p>I have a LI element to which I have added a "Toggle" event handler</p>
<pre><code>$("#myUL li").toggle {}
</code></pre>
<p>Inside the LI there is an anchor (link) element:</p>
<pre><code><ul id ="myUL">
<li>Click anywhere to initiate toggle handler <a href="/">(Except here)</a></li>
</ul>
</code></pre>
<p>How can I tell jQuery not to initiate the Toggle event if the user clicks on the link which is inside the UL, but to do initiate the event if the user clicks anywhere inside the UL beside that link?</p>
<p>Thank</p>
<p>Joel</p>
| jquery | [5] |
5,480,576 | 5,480,577 | absolute addressing - relocations | <p>so I upgrade to Snow Leopard and XCode 3.2.3 / SDK4</p>
<p>now my project won't compile:</p>
<p>ld: absolute addressing (perhaps -mdynamic-no-pic) used in -[MyAppDelegate applicationDidFinishLaunching:] from /Users/ade/Documents/XCodeprojects/MyApp/build/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv6/MyAppDelegate.o not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs</p>
<p>Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1</p>
<p>any help or advice would be greatly appreciated...</p>
<p>ade.</p>
| iphone | [8] |
3,669,597 | 3,669,598 | simple Jquery animation don't work Works on Jsfiddle | <p>Are going crazy about this now...</p>
<p>I'm trying to get an animation that work on jsFiddle to work local/ftp but nothing happens.</p>
<p>I have include ALL this library's </p>
<pre><code><link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</code></pre>
<p>I can run an animation that has the function <code>$(this).hide(</code> ... but as i told, not the animate func.</p>
<p>This is the script I'm using. </p>
<pre><code>$(".wrapper").mouseenter( function() {
$(this).animate({
left: -1*$(".leftbox").width()
}, 500);
});
$(".wrapper").mouseleave( function() {
$(this).animate({
left: "0px"
}, 500);
});
</code></pre>
<p>And here is the jsFiddle that I'm copy-paste into my index page. not changing anything.
<a href="http://jsfiddle.net/ewNpL/1/" rel="nofollow">http://jsfiddle.net/ewNpL/1/</a></p>
| jquery | [5] |
899,860 | 899,861 | How to integrate admobs to android apps? | <p>I have to ingrate admobs to android apps. i have alredy create aaccount on admobs. i dont have any idea about how to get appid, publisherid. How many id want to my apps? how to create it ?</p>
<p>Thanks in advance</p>
| android | [4] |
4,077,766 | 4,077,767 | Map a link with a function | <p>Suppose I have a link and a function as below, how can I map this link with the function?</p>
<p>As a result, user click on the link "remove user" will execute the function "remove_user</p>
<pre><code><a href="xxx">remove all compare items</a>
functio remove_user() {
return mysql_query("DELETE * FROM compre_items");
}
</code></pre>
| php | [2] |
2,962,190 | 2,962,191 | how to select the parent field using jquery | <p>my main file is</p>
<pre><code><div id="man">
//some content
<div id="one">
//some content
<div id="two">
//some content
<div id="three">
//some content
<div id="four">
<a title="to delete">delete</a>
<a title="to reset">reset</a>
<a title="to change">change</a>
</div>...// all div ends...
<div id="woman">
//some content
<div id="one">
//some content
<div id="two">
//some content
<div id="three">
//some content
<div id="four">
<a title="to delete">delete</a>
<a title="to reset">reset</a>
<a title="to change">change</a>
</div>...// all div ends...
</code></pre>
<p>and the jquery is -</p>
<pre><code>$("document").ready(function(){
$("a:contains(delete)").click(function(){
alert($(this).parent().parent().parent().parent().parent().attr("id"))
})
})
</code></pre>
<p>is there any another way to find the top parent instead of using this...??</p>
| jquery | [5] |
1,348,552 | 1,348,553 | JQUERY string --> variable | <p>In the html, I have a select with some options with values "a", "b", "c"</p>
<p>I retrieve whatever the user chooses using</p>
<pre><code>function getOp(){
return $("select[name = 'choices'] option:selected").val();
}
</code></pre>
<p>Let's say they chose <code>a</code></p>
<p>I have a <code>var x = getOp();</code> but now <code>x</code> is a string <code>"a"</code>. However, I want to be able to use <code>x</code> to call another (already set) variable called <code>a</code>.</p>
<p>When I do things with <code>x</code> now, <code>x</code> functions as a string as opposed to another variable. How can I link my <code>x</code> to my <code>a</code> variable?</p>
| jquery | [5] |
4,497,819 | 4,497,820 | Is there any way to represent any number as sum of 4 squares? | <p>Is there any way to represent any number as sum of 4 squares.</p>
<p>For example 29 can be represented as 5^2+2^2+0^2+0^2</p>
<p>I tried the following code but some numbers giving 5terms for example 23 as 4^2+2^2+1^2+1^2+1^2</p>
<p>the code i tried is :</p>
<pre><code> x=0;
while(num!=0){
x=(int)Math.floor(Math.sqrt(num));
num=num-(x*x);
}
</code></pre>
| java | [1] |
1,590,869 | 1,590,870 | Iterable Sum in Java? | <p>Is there a library that does this:</p>
<pre><code>public class Iterables{
private Iterables() {}
public static <T> int sum(Iterable<T> iterable, Func<T, Integer> func) {
int result = 0;
for (T item : iterable)
result += func.run(item);
return result;
}
}
public interface Func<TInput, TOutput> {
TOutput run(TInput input);
}
</code></pre>
| java | [1] |
3,161,826 | 3,161,827 | Are Python serial write and socket send commands blocking? | <p>I am running an into an issue with my python SocketServer application which seems to be blocking some threads intermittently. I am guessing this could be because of a network outage and somehow the write buffer is overrun and the write is blocked after that.</p>
<p>These are my questions
1) When I do a write on a serial port and the write buffer is full what happens?
2) When the socket send buffer is full will the send block until there is space in the buffer to write?</p>
<p>My Socket server is non-blocking but I want to know what happens in case of a buffer overrun.</p>
| python | [7] |
4,886,477 | 4,886,478 | Not Able Play an video through VideoView API | <p>I am trying to play <a href="http://110.234.149.86/vedios/sw.mp4" rel="nofollow">this video</a> through VideoView.My code is below.</p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView vv =(VideoView)findViewById(R.id.videoView1);
vv.setVideoURI(Uri.parse("http://110.234.149.86/vedios/sw.mp4"));
vv.start();
vv.setMediaController(new MediaController(this));
vv.requestFocus();
}
</code></pre>
<p>It says it cannot play the video. Can anyone help me?</p>
<p>Thanks!</p>
| android | [4] |
2,781,810 | 2,781,811 | Is there a built in function in PHP to compare a variable with many variables in an array? | <pre><code>$numbers = array('1','2','3','4');
$number = '1';
</code></pre>
<p>Is there any way to compare all numbers with a number to see if some of the values is equal to $number?</p>
| php | [2] |
3,046,743 | 3,046,744 | How to Get audio file from the project | <p>i m not getting sound in iphone here is my code</p>
<pre><code>NSString *filepath=[[NSBundle mainBundle]pathForResource:@"horror (2)" ofType:@"mp3" ];
NSLog(@"filepath=%@",filepath);
url=[[NSURL alloc]initFileURLWithPath:filepath ];
NSLog(@"url==%@",url);
audioplayer=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil ];
[self.audioplayer prepareToPlay];
self.audioplayer.currentTime=0;
[self.audioplayer play];
audioplayer.numberOfLoops=-1;
</code></pre>
| iphone | [8] |
1,957,862 | 1,957,863 | How to implement gallery swiping with dots under | <p>How to implement gallery swiping with dots under? I need to show indicator of the current image.</p>
| android | [4] |
5,495,035 | 5,495,036 | Java array of ArrayList - strange goings on? | <p>I've been pulling my hair out with this all day. Probably a newb error of some sort, but I can't get my head around it.</p>
<p>It started out more complicated, but I've simplified it to:</p>
<pre><code>public class Main {
static ArrayList<Selection>[] a = new ArrayList[2];
public static void main(String[] args) {
// Initialise the Selection ArrayList
for (int i=0; i < a.length; i++) {
a[i] = new ArrayList<Selection>();
}
callTest();
}
public static void callTest () {
a[0].add(new Selection(true));
a[1].add(new Selection(false));
System.out.println(a[0].get(0).getTF());
System.out.println(a[1].get(0).getTF());
}
}
class Selection {
private static boolean trueFalse;
public Selection (boolean iTF) {
trueFalse = iTF;
}
public boolean getTF () {
return trueFalse;
}
}
</code></pre>
<p>Running the program will return:</p>
<pre><code>false
false
</code></pre>
<p>instead of the expected (at least to me):</p>
<pre><code>true
false
</code></pre>
<p>Can someone please shed some light on this? It appears that whenever the value held in a Selection object is altered, ALL the Selection objects are altered, even though they have a different object reference. Have I done something silly?</p>
| java | [1] |
2,181,523 | 2,181,524 | Visual effects with video recording | <p>Hi
I am looking forward to get some visual effects will recording video but unable to get any help from any where. It would be great if any one now how to do this. I am stuck in this from long time.</p>
<p>Thanks in Advance.</p>
| iphone | [8] |
4,449,392 | 4,449,393 | c# why wont this display to label | <p>I want to be able to display balance to label and my code is not working. This is code I got so far:</p>
<pre><code>SqlDataReader readdata;
{
sqlCommandbalance.Connection.Open();
sqlCommandbalance.Parameters["@accountID"].Value = show.accoundID;
readdata = sqlCommandbalance.ExecuteReader();
string balanceDB = null;
while (readdata.Read())
{
balanceDB = readdata["balance"].ToString();
}
sqlCommandbalance.Connection.Close();
balanceShow.Text += " " + balanceDB.ToString();
}
</code></pre>
<p>On this line - <code>balanceShow.Text += " " + balanceDB.ToString();</code> got a error saying Object reference not set to an instance of an object.</p>
| c# | [0] |
2,769,872 | 2,769,873 | charCodeAt to return correct code for custom charcodes | <p>Would this be good way to return correct code for custom charcodes</p>
<pre><code>String.prototype._charCodeAt = String.prototype.charCodeAt;
String.prototype.charCodeAt = function( i , keycodes ) {
if( keycodes !== 'undefined' ) {
for( var j = 0; j < keycodes.length; j++ ) {
if( this[i] === keycodes[j].char ) {
return keycodes[j].code;
}
}
} else {
return this._charCodeAt( i );
}
}
</code></pre>
<p>Keycodes is array where values stored like this</p>
<pre><code>[
...
{ "char" : "ä" , "code" : 132 },
{ "char" : "à" , "code" : 133 },
{ "char" : "å" , "code" : 134 },
...
];
</code></pre>
<p>By default the javascript returns wrong values for the "special characters".<br>
Is this code sufficient for this?</p>
| javascript | [3] |
5,204,088 | 5,204,089 | Java nested classes- under the hood? | <p>I have a couple of questions relating to nested classes within Java.</p>
<ul>
<li><p>How do nested classes appear "under the hood", with regards to memory allocations?</p></li>
<li><p>You cannot declare a static variable within a nested class (I think the exact error was that static attributes can only be declared at the top level class). Why is this and what other restrictions are there for nested classes?</p></li>
</ul>
<p>If possible, please say whether your answer is Java-specific, or whether C++ also follows the same rules?</p>
| java | [1] |
4,393,460 | 4,393,461 | More elegant way to update index into circular list? | <p>I have a list of questions that the user will iterate through, they can start at any question, but they do have a order to them, so in order to do this I just maintain an index into the array and increment it like so:</p>
<pre><code>CurrentQuestion = (++CurrentQuestion < questions.Length) ? CurrentQuestion : 0;
</code></pre>
<p>It isn't necessarily obvious what is happening here, is there a more elegant way to do this?</p>
| c# | [0] |
4,179,231 | 4,179,232 | [PHP]: Error -> Too few arguments in sprintf(); | <p>This line is giving error: "Too few arguments". What is the problem?</p>
<pre><code>$InsertQuery = sprintf("INSERT INTO listing (ldate, places, company, designation, projectdetails, desiredcandidate, hrname, hrcontact, email) VALUES (DATE_FORMAT(%s,'%Y %m %d),%s,%s,%s,%s,%s,%s,%s,%s)", $ldate,$places,$company,$designation, htmlentities($projectdetails), htmlentities($desiredcandidate),$hrname,$hrcontact,$email);
</code></pre>
| php | [2] |
2,830,147 | 2,830,148 | Break statement in Python | <p>I am trying to break out of a for loop, but for some reason the following doesn't work as expected:</p>
<pre><code>for out in dbOutPut:
case_id = out['case_id']
string = out['subject']
vectorspace = create_vector_space_model(case_id, string, tfidf_dict)
vectorspace_list.append(vectorspace)
case_id_list.append(case_id)
print len(case_id_list)
if len(case_id_list) >= kcount:
print "true"
break
</code></pre>
<p>It just keeps iterating untill the end of <code>dbOutput</code>. What am I doing wrong?</p>
| python | [7] |
488,585 | 488,586 | A good way to release fixtures | <p>Hey, my problem is as follows,
I am trying to create code where a set of sporting fixtures are created with dates on.
Say I have 8 teams, with 7 rounds of fixtures.</p>
<p>I have generated the fixtures, but want to add a date generation on them.
So if i had 7 rounds, I would put 28 days and it would make each round 4 days from now, 8 days from now, etc.</p>
<p>What would be the best way to go about doing this?
Thanks</p>
| php | [2] |
3,408,308 | 3,408,309 | const error message | <p>hi
what does this error message mean :
error C2662: 'addDoctor' : cannot convert 'this' pointer from 'const class Clinic' to 'class Clinic &'
I'm not using const though</p>
<p>sorry,but this is my first time posting experience</p>
<p>Clinic.h</p>
<pre><code>class Clinic{
public:
Clinic();
int addDoctor(Doctor*);
private:
Doctor doctors[10];
int d;
};
</code></pre>
<p>Clinic.cpp</p>
<pre><code>Clinic::Clinic()
{d=-1;}
int Clinic::addDoctor(Doctor *x)
{d++;doctors[d]=x;return d;}
</code></pre>
| c++ | [6] |
4,535,020 | 4,535,021 | Converting month name to month number using JavaScript | <p>Is there a a better solution than what I have below to convert a month name to a month number using JavaScript or PHP?</p>
<p>I did like this:</p>
<pre><code>$monNum = date('n',strtotime($staff->curMonth));
</code></pre>
| javascript | [3] |
4,003,407 | 4,003,408 | Cant access global variable in function | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/894990/cant-access-global-variables-inside-a-usort-function">can't access global variables inside a usort function?</a> </p>
</blockquote>
<p>I've experienced this problem more then one time now, and I this time I couldnt figure out how to get around it.</p>
<pre><code>$testing = "hej";
function compare($b, $a)
{
global $testing;
echo '<script>alert(\'>'.$testing.'<\');</script>';
}
</code></pre>
<p>Why does this not show a alertbox with ">hej<", for me it shows "><".</p>
<p>Also, this is a function that is call from <code>uasort</code> as second parameter.</p>
| php | [2] |
1,756,663 | 1,756,664 | Remove unwanted id for a control when declared in asp:content in ASP.NET | <p>Consider sample piece of code in asp.net which has a master page associated with it</p>
<pre><code><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderA" Runat="Server" >
<asp:TextBox ID="TextBoxB" runat="server" CausesValidation="True" Height="96px" Width="426px" />
</asp:Content>
</code></pre>
<p>When the page is rendered in browser id generated for textbox with id "TextBoxB" is</p>
<pre><code>ctl00_ContentPlaceHolderA_TextBoxB
</code></pre>
<p>Below is the equivalent html code.</p>
<pre><code> <input name="ctl00$ContentPlaceHolderA$TextBoxB" type="text" id="ctl00_ContentPlaceHolderA_TextBoxB" style="height:96px;width:426px;" />
</code></pre>
<p>Is it possible to have same id of TextBoxB in both HTML and aspx page.</p>
<p>Thanks in Advance.</p>
| asp.net | [9] |
5,685,069 | 5,685,070 | send .doc file as an attachment to mail | <p>i want to send a .doc file as an attachment via email.</p>
<p>i am using the code below:</p>
<pre><code>final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(
android.content.Intent.EXTRA_SUBJECT,
"Song Pad.");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Please see the attached document.");
final File file = new File(dirPath + "/" + filename
+ ".doc");
emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://" + file.getAbsolutePath()));
MainActivity.this.startActivity(Intent.createChooser(
emailIntent, "Send Email..."));
</code></pre>
<p>the attachment goes successfully to email but when i open it on device it shows message</p>
<p><strong>Unable to find viewer for plain/text</strong>.</p>
<p>on the other hand when i send doc file not via my app then it opens perfectly.</p>
<p>please guide . i think there is little mistake..
thanks..</p>
| android | [4] |
3,900,231 | 3,900,232 | android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 5 | <p>plz help me i face this problem</p>
<p>my code is</p>
<pre><code>`final Cursor curr = dbhelper.getdatatomanagedata();
startManagingCursor(curr);
Integer colid = curr.getInt(0);
String colans = curr.getString(1);
objansMap = new HashMap<Integer, String>();
if (curr!=null)
{
curr.moveToFirst();
while(!curr.isAfterLast())
{
objansMap.put(colid, colans);
curr.moveToNext();
}}
</code></pre>
| android | [4] |
4,437,795 | 4,437,796 | How to unit test an helper function that use HTTPConnection | <p>I have written a <strong>helper function</strong> that can retrieve content from a url. This function can also parse a <code>Map</code> of parameters and feed a url or a body on request depending on <code>GET</code> or <code>POST</code> method. Let's say this function also do other things (change headers, cookies etc...). How can I test this function against an http(s) server ? How to simulate a fake servlet that will answer to the request made by this function ?
I've seen that we can use mock object, or other library that are specialized in servlet unit testing. But it doesn't seem to fit my needs as I trully need to test the request and its answer without changing the function content.</p>
| java | [1] |
3,774,926 | 3,774,927 | php newline not working | <p>For some reason i cant get the carriage return to appear on the web page. When i view source code it is fine.<br>
I have tried various iterations of \n but it is kicking my butt.</p>
<pre><code><?php
/* Define string */
$greeting = "Greeting Professor Falken.";
$question1 = "Would you like to play a Game?";
print "$greeting \n ";
print "$question1";
?>
</code></pre>
| php | [2] |
1,580,312 | 1,580,313 | Problems with my PHP script - newbie fails? | <p>Hey Guys I have a Problem with my PHP Script it doesn't work ...
I don't know why it doesn't work or which skills I have to improove.</p>
<p>I would be thankfull for help</p>
<p>The Code is here : <a href="http://pastebin.com/gkFBEJS0" rel="nofollow">http://pastebin.com/gkFBEJS0</a></p>
<p>Thanks a loot
Chris</p>
| php | [2] |
3,271,178 | 3,271,179 | iPhone audio analysis | <p>I'm looking into developing an iPhone app that will potentially involve a "simple" analysis of audio it is receiving from the standard phone mic. Specifically, I am interested in the highs and lows the mic pics up, and really everything in between is irrelevant to me. <br><br>Is there an app that does this already (just so I can see what its capable of)? And where should I look to get started on such code?<br><br> Thanks for your help.</p>
| iphone | [8] |
3,104,409 | 3,104,410 | PHP forcing a specific set of numbers | <p>Im writing a script at the moment which requires the layout to be formatted into <code>3 numbers ( 000 )</code> .... When i return my SQL, the results i get could be '1', could be '100', could be '50' it could be anywhere between 0 and 999 .... How can i always get it to return as a 3 number layout.</p>
<p>For instance, if the result returns 1 it need to read 001, if it returns 50 it needs to read 050 and so on.</p>
| php | [2] |
4,340,952 | 4,340,953 | Error to remove text from text function in jquery | <p>I want to remove the text. I'm using the following function.</p>
<pre><code> var ta=$('title', item).text();
</code></pre>
<p>The out put of this is "Cases That Charge On-The-Go(video)".
I want to remove the "(video)" from the text. plz let me know ho</p>
| jquery | [5] |
5,582,188 | 5,582,189 | One android app to control another app | <p>I currently have an android app in the market which has a free and pro version of the app. The pro app doesn't provide any functionality it is just an unlock app which enables extra features from within the pro app. </p>
<p>What I want to be able to is to allow the user from the free app to enable SMS messaging that when a certain message arrives it wipes the content of the free app. However, I do not want to enable the SMS permission on the free as this may put people off as it is a password app, so what I want to do is the following:</p>
<ol>
<li>The user, from the free app enables the sms check</li>
<li>The pro app has permission to check SMS messages and if the app settings from the free app enables this sms check, then the pro app checks for when a message arrives with particular criteria</li>
<li>If the pro app finds the matching critera, then the pro triggers the free app to remove all content of the app, i.e. all data within the apps preferences and database.</li>
</ol>
<p>Is this possible and if so how could it be done, couldn't find anything on Google, probably using the incorrect keywords!</p>
| android | [4] |
2,269,502 | 2,269,503 | Detect long press on "virtual" back-key | <p>havent found a solution yet.
I want to detect a long press on the "virtual" back-key, the one you find at the galaxy s2 for example.</p>
<p>I tried to detect the onKeyDown-events (which works) when the user presses the button and the onKeyUp-events when the user leaves the button but the virtual key is firing onKeyUp-events all the time.</p>
<p>I also tried to override the onKeyLongPress-method but this havent helped.</p>
<pre><code> @Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
mBackKeyDownTime = event.getEventTime();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_BACK)
{
mBackKeyUpTime = event.getEventTime();
final long delta = mBackKeyUpTime - mBackKeyDownTime;
return true;
}
return super.onKeyUp(keyCode, event);
}
</code></pre>
| android | [4] |
5,806,258 | 5,806,259 | run JavaScript without UIWebView | <p>is it possible to run JavaScript in objective-c without using UIWebView ? i ask for this because i need to get the part of html data created by JavaScript when the web page loaded .the html source look like this </p>
<pre><code><table dir = "rtl .......">
<tbody>
<script src = "get.aspx?type=js&file=ajax&rev=3"......>
<script language = "JavaScript" src = "get.aspx?type=js&file=mc&rev=6"></script>
<script>..</script>
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
<tr>..</tr>
</code></pre>
<p>all < tr> after < script>..< /script> tag are created at runtime.i can't see them when i download the html source with NSURLConnection.hope some body help me.</p>
| iphone | [8] |
1,177,598 | 1,177,599 | Why does Java Compiler refuse to compile this? | <p>Why does Java Compiler raise "The local variable s may not have been initialized" in the finally block. I can not figure out in which flow of code, <strong>s</strong> remains un-initialized.</p>
<pre><code> public static void test() {
String s;
try {
s = "abc";
} catch (Throwable e) {
s = "throwable";
} finally {
System.out.println(s.getClass()); //---->(The local variable s may not have been initialized)
}
}
</code></pre>
| java | [1] |
5,437,030 | 5,437,031 | future in iphone development? | <p>i have done btech,nw i am searching job but one big question arise me in front of me several times that as a <strong>iphone developer</strong> i can survive or not ? i learned nowdays iphone development but my seniors said to me after learn iphone development you become miniority developer why dont you start from java or .net or php plateform. but i feel my future safe in i phone developer?m i right or not ?i am totally confused?please help me and give valuable suggestions</p>
| iphone | [8] |
2,893,359 | 2,893,360 | How to append string representation of a specified object to a instance | <p>I have a code like this:</p>
<pre><code>StringBuilder systemCondition = new StringBuilder();
systemCondition.Append("^(");
systemCondition.Append(Regex.Escape(this.Class));
systemCondition.Append(" : ");
systemCondition.Append(Regex.Escape(this.Instance));
systemCondition.Append(")$");
m_afc.QualifiedInstanceFilter = systemCondition.ToString();
</code></pre>
<p>Can any body tell me whats wrong here?
Then what about this code </p>
| c# | [0] |
2,085,511 | 2,085,512 | Getting correspoding enum key for the value passed | <pre><code>var StateValue = {
Unknown: 0,
AL: 1,
AK: 2,
AZ: 3,
AR: 4,
CA: 5,
CO: 6,
CT: 7,
DE: 8,
},
</code></pre>
<p>Now if i pass 8 i need the value DE to be printed. How can i do this. </p>
| javascript | [3] |
2,425,377 | 2,425,378 | lat long android GPS location on screen android | <p>Latitud , Longitud in the gps in a string so i will be able to send each change position to my python server with my new location using the open socket !! so any help to save this latitud and longitud !! here is my code</p>
<pre><code>package letget.h;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;
public class letget extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* Use the LocationManager class to obtain GPS locations */
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
}
/* Class My Location Listener */
public class MyLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
String Text = "My current location is: " +
"Latitud ="+ loc.getLatitude() +
"Longitud =" + loc.getLongitude();
Toast.makeText( getApplicationContext(),
Text,
Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderDisabled(String provider)
{
Toast.makeText( getApplicationContext(),
"Gps Disabled",
Toast.LENGTH_SHORT ).show();
}
@Override
public void onProviderEnabled(String provider)
{
Toast.makeText( getApplicationContext(),
"Gps Enabled",
Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}/* End of Class MyLocationListener */
}/* End of UseGps Activity*/
</code></pre>
| android | [4] |
4,344,941 | 4,344,942 | How To Put Data At Run Time In a Table i.e Table Also Create At The Run Time? | <p>i am trying to put data as a summery in my application from data table in a label but i want to put data in a table inspite of label such that table also create a t run time wile my code is putting data ina label at run time .. .</p>
<pre><code> for (int m = 0; m < dtGroupedByDate.Rows.Count; m++)
{
Label Date = new Label();
Date.Text = dtGroupedByDate.Rows[m][0].ToString();
Date.Style["margin-left"] = (m > 0) ? "20px" : "0px";
this.Controls.Add(Date);
Label PowerSum = new Label();
PowerSum.Text = dtGroupedByDate.Rows[m][1].ToString();
PowerSum.Style["margin-left"] = "20px";
this.Controls.Add(PowerSum);
}
</code></pre>
<p>Hopes for your suggestions...
Regards,</p>
| c# | [0] |
5,515,308 | 5,515,309 | how to hide other application from my application from list of apps android | <p>Could anybody please help me find a way to hide other application from my application. I'm retrieving a list of apps installed with check boxes and when I check some apps, those should be hidden from the application list in emulator. I've searched in google but I couldn't find it. I am waiting for help....
Thanks, </p>
| android | [4] |
1,339,422 | 1,339,423 | How to get the values of a dynamic textbox | <p>I have added some dynamic textboxes upon a button click. I need the values in the click event of another button click. How can I achieve that?</p>
| asp.net | [9] |
1,859,392 | 1,859,393 | g++ cannot find the correct copy constructor when doing copy initialization | <p>With the following code:</p>
<pre><code>class B{};
class A{
public:
A(B& b);
A(const A& a);
};
A::A(B& b){
}
A::A(A& a){
}
int main(){
B b;
A a = b;
}
</code></pre>
<p>no matching function call to 'A::A(A)'</p>
<p>I looked up some references, and thought it might caused by the Return Value Optimization (RVO), so I tried to disable the optimization by the -fno-elide-constructor option. Problem still remains. </p>
| c++ | [6] |
1,362,377 | 1,362,378 | How to use the -> in PHP | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1234196/what-does-this-php-construct-mean-html-redirecturl">What does this php construct mean: $html->redirect(“URL”)?</a> </p>
</blockquote>
<p>Hi, I've been looking for what this operator "->" does, but I can't seem to find a reference to it, only people using it in come and I can't make out what its doing, an explanation would be appreciated.</p>
| php | [2] |
541,170 | 541,171 | Delegate definition in C# | <p>Assuming I have the following delegate:</p>
<pre><code>public delegate int TestD(int p);
</code></pre>
<p>Is there any difference between</p>
<pre><code>TestD del = MyMethod;
</code></pre>
<p>and </p>
<pre><code>TestD del = new TestD(MyMethod);
</code></pre>
| c# | [0] |
252,745 | 252,746 | jquery autocomplete() is not working | <pre><code><link rel="stylesheet" type="text/css" href="jquery-ui-1.8.2.custom.css" />
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script>
<body>
Search: <input id="example" />
</body>
<script>
$(document).ready(function(){
var data = "Core Selectors Attributes Traversing Manipulation CSS Events Effects Ajax Utilities".split(" ");
$("#example").autocomplete(data);
});
</script>
</code></pre>
| jquery | [5] |
2,941,750 | 2,941,751 | which version of the code below is right? | <p>Hi I found this function in a utilities code file:</p>
<p><strong>Version 1:</strong></p>
<pre><code>public static bool IsValidLong(string strLong)
{
bool result = true;
try
{
long tmp = long.Parse(strLong);
}
catch (Exception ex)
{
result = false;
}
return result;
}
</code></pre>
<p>I want to replace this (and validators for other types) with following:</p>
<p><strong>Version 2:</strong></p>
<pre><code>public static bool IsValidLong(string strLong)
{
long l;
return long.TryParse(strLong, out l);
}
</code></pre>
<p>which version is better and why?</p>
| c# | [0] |
1,991,091 | 1,991,092 | changing a link url with javascript | <p>This is a javascript menu for a website I'm updating. I want to add a dynamic link (id=IT-LINK) to link to the Italian version of the site. But the URL needs to change depending on which page the viewer is on. Can someone please tell me how to do it!? I'm very new to javascript and am learning by myself. Thanks, Cataldo</p>
<pre><code>window.onload = uline;
var pagename = document.getElementById("TAG").getAttribute("data-name");
function uline()
{
if (pagename == 'HOME' )
document.getElementById(pagename).style.color="#ffffff";
else
document.getElementById(pagename).style.textDecoration="underline";
}
document.write('<DIV CLASS=RIGHT><B>');
document.write('<a href=\"+link+'\" id=IT-LINK >ITALIANO</a> &nbsp;&nbsp;&nbsp;');
document.write('<br><br>');
document.write('<a href="news.html" id=NEWSLETTER >NEWSLETTER</a> &nbsp;&nbsp;&nbsp;');
document.write('<a href="prodotti.html" id=PRODUCTS >PRODUCTS</a> &nbsp;&nbsp;&nbsp;');
document.write('<a href="bio.html" id=BIO >PHILOSOPHY/BIOG</a> &nbsp;&nbsp;&nbsp;');
document.write('<a href="contatti.html" id=CONTACTS >CONTACTS</a> &nbsp;&nbsp;&nbsp;');
document.write('<a href="home.html" id=HOME >HOME</a>');
document.write('</B></DIV>');
</code></pre>
| javascript | [3] |
3,347,972 | 3,347,973 | Python pyodbc settings | <p>I am looking at a system that is using PyODBC and FreeTDS with a connection similar to the following:</p>
<pre><code>cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=srv;DATABASE=dbtable;UID=uid;PWD=pwd')
</code></pre>
<p>I was wondering if after this connection is made, if it is possible to view the settings that are actually used. We dont currently have access to look at the configuration files</p>
<p>Thanks,</p>
<p>JJ</p>
| python | [7] |
3,925,832 | 3,925,833 | bind and live not working | <p>(the input value is filled with 'a' 'links' but after the links are generated (inside another div ) thei do no act on hover)
i have this:</p>
<pre><code><a href="#">This works</a><br><br>
<input class="input" type="text" style="width:400px;" value=" <a href='#'>This works...NOT</a> "/><br>
<div id="test"></div>
</code></pre>
<p>and this jquery:</p>
<pre><code>$('a').hover(function() {
$(this).css('color', '#f00');
},function(){
$(this).css('color', '#000');
});
$(".input").bind('keyup', function() {
$('#test').html(this.value);
});
</code></pre>
<p>i tried wit bind and live, but the link created inside a input and copyed to a div - no changes color on hover. Please help</p>
| jquery | [5] |
2,204,326 | 2,204,327 | caesar cipher Simple Encryption code in python | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1538935/caesars-cipher-using-python-could-use-a-little-help">Caesar's Cipher using python, could use a little help</a> </p>
</blockquote>
<pre><code>def affine (a, b):
for i in range(26):
print chr(i+65) + ": " + chr (((a*i+b)%26)+65)
</code></pre>
<p>This is something I have come across. How can I use this with a message "Hello world" and encrypt it?</p>
<p>And also how to Decrypt a message?</p>
| python | [7] |
4,121,393 | 4,121,394 | jQuery show element one time on multiple clicks | <p>The link below calls the DeleteUser function and displays the message below. When the link is clicked again, the message repeats, and continues to do so each time the link is clicked. Is there a way to stop this behavior? I have tried to hide the link after it is clicked once, but the element remains, so when another link that shares this message box is clicked, the first message is still displayed.</p>
<pre><code><a href="#" onclick="DeleteUser('{id}','{deleting}')">Delete User</a>
function DeleteUser(id, deleting){
var message = "<h1>Are you sure? All records associated with this user will be deleted also.</h1>";
$('#managermsg').append(message);
$('#managermsg').fadeIn(500);
$("#usermanager").slideToggle("slow");
};
</code></pre>
| jquery | [5] |
4,718,926 | 4,718,927 | When using Pick_Contact, after i choose a Contact it open ups Android Market | <p>help please</p>
<p>here is my code on onClick</p>
<pre><code> if(v.getId()==R.id.btnContacts)
{
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
</code></pre>
<p>here is my code on onActivityResult</p>
<pre><code> if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = managedQuery(contactData, null, null, null, null);
if (c.moveToFirst()) {
String id =
c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts._ID));
String hasPhone =
c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if (hasPhone.equalsIgnoreCase("1")) {
Cursor phones = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ id,
null, null);
phones.moveToFirst();
String cNumber = phones.getString(phones.getColumnIndex("data1"));
TextView txtPhoneNo = (TextView) findViewById(R.id.txt_PhoneNo);
txtPhoneNo.setText(cNumber);
c.close();
</code></pre>
<p>i dont know what's happening have tried a dozen solutions but its still the same, im running this in my Galaxy Tab</p>
| android | [4] |
1,831,267 | 1,831,268 | How to change string to date in Java | <p>i need to to convert an string to date format in java i have an string that i get from torrent file </p>
<pre><code>the string is like 1278622088
</code></pre>
| java | [1] |
5,396,090 | 5,396,091 | Import Python file from within executing script | <p>I am attempting to import a python file(called test.py that resides in the parent directory) from within the currently executing python file(I'll call it a.py). All my directories involved have a file in it called init.py(with 2 underscores each side of init)</p>
<p><strong>My Problem:</strong> When I attempt to import the desired file I get the following error</p>
<blockquote>
<p>Attempted relative import in non-package</p>
</blockquote>
<p>My code inside a.py:</p>
<pre><code>try:
from .linkIO can_follow # error occurs here
except Exception,e:
print e
print success
</code></pre>
<p>Note: I know that if I were to create a file called b.py and import a.py(which in itself imports the desired python file) it all works, so whats going wrong?</p>
<p>For eg:</p>
<p>b.py:</p>
<pre><code>import a
print "success 2"
</code></pre>
| python | [7] |
4,618,607 | 4,618,608 | Need help with returning a 2D array C++, please | <p>I'm trying to create an array and pass it to functions, which then return it, but I don't know the correct way of returning.
I've been looking around tutorials and trying stuff out, but haven't managed to solve this.
I'm new to C++ and thought it would be similar to Java, but apparently it isn't.</p>
<p>This is where I've gotten:</p>
<pre><code>class MainClass {
public:
static int countLetterCombinations(string array[], int numberOfWords) {
// Code
return totalCombos;
}
// This is the function I'm having trouble with.
static string** sortCombos(string combinations[][3]) {
// Do something
return combinations; // This gives converting error.
}
};
int main() {
// Code
int numberOfCombinations = MainClass::countLetterCombinations(words, numberOfWords);
string combinations[numberOfCombinations][3];
combinations = MainClass::sortCombos(combinations);
// Further code
}
</code></pre>
<p>Anyone know how to fix this?</p>
| c++ | [6] |
3,100,978 | 3,100,979 | Array operations? | <p>I want to know if there is something similar to (input==(letters[i]-'c')) that i can use. I know what i type doesn't make sense but i'm trying to create something similar to that. If the user's input is anything in the array but c, then it displays the first message, else if it is c, then it displays the second message. I just want to somehow temporarily exclude c from the array and have the program check all other elements...</p>
<pre><code>char []letters={'a','b','c','d'};
//input is user input
for(int i=0;i<letters.length<;i++)
if(input==(letters[i]-'c'))
{
system.out.print("input might be a,b,d but not c");
}
else if(input=='c')
{
system.out.print("input is c");
break;
}
</code></pre>
| java | [1] |
3,642,216 | 3,642,217 | how can i make php alert pop ups just like in javascript | <p>i need a pop up window which asks me before proceeding to next like <strong>alert</strong> in <strong>javascript</strong>.</p>
<p>Is any built in facility in PHP like that.</p>
| php | [2] |
2,539,699 | 2,539,700 | How to make a web browser bot? | <p>I have searched this site and other sites for an answer that would help me but I just can't get the codes I come across to work for me.</p>
<p>First let me explain how my program works and where I am at with it, then let me explain what I am trying to do but can't get it to work.</p>
<p>1st: I have Form1 as a login to a website. You enter the Username and Password that you would use to log into that website and you can also have it log you in automatically and have it remember your login information.</p>
<p>2nd: After you login, Form3 opens up (Form2 is the about me), You have a web browser and a button below (there will be more buttons below the browser but first i have to get this button working.)</p>
<p>3rd: The problem is that when I click the button I have it go to a web address and then I want it to hire my offensive and deffensive troops and then click submit (the hire troops buttons and submit button are on the website.) The hire troops is a text field on the website and next to it there is a max offense and max deffense button. Now what I want it to do is click the Max offense and then click the Max deffense button and the click the submit button.</p>
| c# | [0] |
1,243,147 | 1,243,148 | Does the code below use command pattern | <p>I have a very basic question about the command pattern. Supose, I have an interface like</p>
<pre><code>public interface Task {
public void execute();
}
</code></pre>
<p>and some class implementing the interface Task</p>
<pre><code>class SomeClass implements Task {
public void execute() {
//do something
}
class Test {
public static void main(String[] args) {
Task task = new SomeClass();
task.execute();
}
}
</code></pre>
| java | [1] |
3,860,791 | 3,860,792 | Removing windows close button in jQuery dialog | <p>I want to remove the window close button provided by jQuery.</p>
<pre><code>$(function () {
$('form').submit(function () {
$("#popUp").dialog({
modal: true,
minWidth: 700
});
$('div').close({ onload: function () {
$('#popUp').remove();
}
});
});
});
</code></pre>
<p>This code does not work. How can I remove the close button?</p>
| jquery | [5] |
241,971 | 241,972 | Turning an integer into random string and back again | <p>what I'm wanting is to convert an integer into a string. For example, 123456789 may become 8GFsah93r ... you know like Youtube, Pastebin and what not. I then want to convert it back.</p>
<p>I'm working with large integers, for example: 131569877435989900</p>
<p>Take a look at this link: <a href="http://codepad.viper-7.com/wHKOMi" rel="nofollow">http://codepad.viper-7.com/wHKOMi</a></p>
<p>This is my attempt using a function I found on the web, obviously... it's not correctly converting back to integer. I'm needing something that does this realiably.</p>
<p>Thanks</p>
| php | [2] |
1,723,613 | 1,723,614 | event.preventDefault(); when trigger is parent div not link? | <p>I have a div as a trigger for some jQuery. The div contains a link. Sometimes clicking the div will also mean clicking the link and I need to stop the link's behaviour. </p>
<p>I believe this can be done with event.preventDefault(); but the following doesn't work in IE8. Im assuming this is because the trigger is a parent div not the actual link, but how do I fix this? Thanks </p>
<pre><code>$('div#myDiv').click(function(){
event.preventDefault();
//other js here
});
<div id="myDiv">
<a href="#">Link</a>
</div>
</code></pre>
| jquery | [5] |
3,283,875 | 3,283,876 | Send song title to spotify to start playing from android app | <p>Is there any way to send a song title to the spotify app from my app so that it will start playing the song through spotify?</p>
<p>I tried using the bellow code i found in another code but nothing happens.</p>
<pre><code>Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setComponent(new ComponentName("com.spotify.mobile.android.ui", "com.spotify.mobile.android.ui.Launcher"));
intent.putExtra(SearchManager.QUERY, "michael jackson smooth criminal");
</code></pre>
<p>I know shazam is able to do this.</p>
| android | [4] |
1,687,701 | 1,687,702 | How to get multiple list of tabs on clicking a tab? | <p>I am trying to implement the application that shows tabactivity of five tabs like <code>Tab 1</code>, <code>Tab 2</code>,<code>More</code>,<code>Tab 3</code>,<code>Tab 4</code>, likewise.</p>
<p>By clicking on the <code>More</code> tab it should display me list of remaining tabs above the <code>More</code> tab. I'm not getting how to implement this or whether this could be achieved. If anybody has idea for this please suggest me.</p>
<p><img src="http://i.stack.imgur.com/HNP4W.png" alt="row view"></p>
<p>On the "More" tab it should display rest of the tabs above the "More" tab</p>
| android | [4] |
308,943 | 308,944 | Label text not updated | <p>I have a Windows Form with a status bar which shows the current state of application.
I have a class named AppState with update the Label in the status bar and in dispose it changes the state back to "Ready".</p>
<p>In code when I do an operation like:</p>
<pre><code>using (AppState state = new AppState("Processing..."))
{
//Do some work that take some seconds
}
</code></pre>
<p>But the label remains the same. I am not getting any exceptions. The label text is updated but on UI it keeps on showing previous value. Am I missing anything here?</p>
<p>santosc you are right, thats the only thing I am doing. Here is the AppState code</p>
<pre><code>public class AppState : IDisposable
{
static string Default = "Ready";
public AppState(string status)
{
Form.StatusLabel.Text = status;
}
public void Dispose()
{
Form.StatusLabel.Text = Default;
}
}
</code></pre>
| c# | [0] |
2,933,167 | 2,933,168 | British Date Formatting in PHP | <pre><code><?php
$firstdate = '2011-11-16';
$sample = date("d-m-Y", strtotime($firstdate));
echo $sample;
?>
</code></pre>
<p>I have a column in a table with date in this format 2011-11-16
But I need it in reverse, so I've used the following code.</p>
<p>The problem is that when the date is 0000-00-00, it prints 01-01-1970.
Is there a way of making it print 00-00-0000 instead? Please note that I'm looking to reverse it to British format. 00-00-0000.</p>
<p>Thanks</p>
| php | [2] |
153,431 | 153,432 | Writing a login screen like default android pattern lock | <p>I want to write a login screen for my new app like android's default pattern lock. Is there a way to do this? Is there any library to help doing this?</p>
<p>Thanks in advance.</p>
| android | [4] |
2,887,739 | 2,887,740 | real time output in php | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5763796/how-to-make-for-loop-real-time-in-php">How to make For Loop Real Time in PHP</a> </p>
</blockquote>
<p>I think when we run php script,web server wait until end of script and after that will return output. for example if following script doesn't have output.</p>
<pre><code>set_time_limit(0);
$i = 0;
while(1) {
$i++;
if ($i%10 == 0)
echo 'Salam';
}
</code></pre>
<p>How can I have real time output?I mean the script is not ended yet,but it echoed somethings.</p>
| php | [2] |
318,429 | 318,430 | Deprecated methods in java | <p>If a method is deprecated in Java there will be a another best way to have same functionality, right?</p>
<pre><code>Date date = new Date();
date.getHours()
</code></pre>
<p>If <code>getHours()</code> is deprecated then what is the best way to get date using only the Date class?</p>
| java | [1] |
4,070,069 | 4,070,070 | else if in Python 2.7 | <p>The purpose of this code isn't important,but I'm getting an indentation error. They are usually really obvious fixes, but in this case I don't see why the error comes up.</p>
<pre><code>group=0
for i in range(0,len(line)):
for j in range(0,len(both)):
if both[j]==line[i]:
elif both[j]==line[i]-1:
group+=1
</code></pre>
| python | [7] |
2,957,347 | 2,957,348 | deleting memory allocated in static function in C++ | <p>I have C++ class as follows</p>
<pre><code>class anotherClass;
class myClass {
private:
myClass() {}
~myClass() {}
typedef std::map<string, anotherClass* > stringToClass;
static stringToClass s_stringToClass;
public:
static anotherClass* getStringToclass(string name);
};
</code></pre>
<p>in above class for getStringToClass defintion is as follows</p>
<pre><code>anotherClass* myClass::getStringToClass(string name) {
stringToClass::iterator iter;
iter = s_stringToClass.find(name);
if(iter == s_stringToClass.end()) {
typedef stringToClass::value_type stringToClassPair;
anotherClass* pothClass = new anotherClass();
s_stringToClass.insert(stringToClassPair(name, pothClass));
return pothClass;
}
else {
return iter->second;
}
}
</code></pre>
<p>now my question is we are allocating memory in static function as defined above. How can we delete memory? Can we delete memory in destructor, as destructor is not static?</p>
<p>Thanks for the help.</p>
| c++ | [6] |
825,814 | 825,815 | JavaScript: How can i set a variable in a string | <p>I would like to set attributes on all elements that id starts with "id-" followed by a number [e.g. id="id-0", id="id-1) and so on]. I thought about something like this:</p>
<pre><code><script type="text/javascript" >
function Prepare() {
var = 0
while(document.getElementById("id-{var}")) {
document.getElementById("id-{var}").setAttribute("rows", "60");
var += 1
}
</script>
</code></pre>
<p>How can i set a var like this in JavaScript?</p>
| javascript | [3] |
914,684 | 914,685 | How to do a mail merge from a SP List to a word doc? | <p>Is there a simple way to do this? Basically I would have a list that contains a bunch of customer information and I would like to merge each list item to a specific word doc and insert each document into a library.</p>
<p>I've found a few things online but they seem unnecessarily complex...</p>
| asp.net | [9] |
4,258,015 | 4,258,016 | How to get authentication to access google services with android? | <p>In my application I am interfacing with google services such as calendar and documents. For testing I have just been providing a user name and password to access services as follows...</p>
<pre><code>myService.setUserCredentials(username,password);
</code></pre>
<p>This method, at least how I'm implementing it, requires that I request the username and password for each session, which obviously is not practical. I would prefer not to save the username or password in long term storage. I know there is an account manager class in the SDK, but am unsure of proper implementation. My question is, what is the most secure and user friendly method for accessing google services from within the application? Thanks.</p>
| android | [4] |
846,459 | 846,460 | Javascript replace with part of match? | <p>I'm looking over <code>replace()</code> examples and I'm not exactly sure the best way to do this:</p>
<p>Say I have a string something like </p>
<pre><code>{G}{J}{L}...
</code></pre>
<p>What's the best way to use <code>string.replace()</code> to change the inner and outer brackets but leave the letter inside them? Do I need to do separate matches for the outer and inner brackets or is it possible/faster to do it in a single statement?</p>
<p>I see that <code>$</code> can get the whole match and I guess I could remove the first and last characters and replace them after but that seems slow.</p>
| javascript | [3] |
167,542 | 167,543 | What's the difference of different location of "using statement"? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/125319/should-usings-be-inside-or-outside-the-namespace">Should Usings be inside or outside the namespace</a> </p>
</blockquote>
<p>Hi, friends,</p>
<p>What's the difference between the following 2 code snippets? The using statement is located differently.</p>
<pre><code>namespace CodedUITest
{
using System;
}
</code></pre>
<p>and</p>
<pre><code>using System;
namespace CodedUITest
{
}
</code></pre>
<p>Thanks!</p>
| c# | [0] |
2,476,577 | 2,476,578 | I want to compare two time values in the format of HR:MIN:SEC. of the type string in c#? | <p>Following is a code that a did in comparison between dates. Is it possible to use that code for strings also. OR Is there any sol?</p>
<pre><code> protected void Button1_Click(object sender, EventArgs e)
{
int uid = Convert.ToInt32(dlFaculty.SelectedValue);
string starttime = Convert.ToString((Convert.ToInt32(dlHour.SelectedItem.Text)) + ":" + (Convert.ToInt32(dlMinute.SelectedItem.Text)) + " " + dlAMPM.SelectedItem.Text);
string endtime = Convert.ToString((Convert.ToInt32(dlHour1.SelectedItem.Text)) + ":" + (Convert.ToInt32(dlMinute1.SelectedItem.Text)) + " " + dlAMPM1.SelectedItem.Text);
DateTime startdate = Convert.ToDateTime(txtStartDate.Text);
DateTime enddate = Convert.ToDateTime(txtEndDate.Text);
DataTable oTable = new DataTable();
Boolean flag = true;
string SQL = "select startdate,enddate from BatchMaster where usermasterid=" + uid + " AND starttime='" + starttime + "' AND endtime='" + endtime + "'";
oTable = DbHelper.ExecuteTable(DbHelper.CONSTRING, CommandType.Text, SQL, null);
//coursemasterid = 0;
//string s = subjectsid;
if (oTable.Rows.Count > 0)
{
DataRow dr = oTable.Rows[0];
if ((Convert.ToDateTime(dr["startdate"]) <= startdate && Convert.ToDateTime(dr["enddate"]) >= startdate) || (Convert.ToDateTime(dr["startdate"]) <= enddate && Convert.ToDateTime(dr["enddate"]) >= enddate))
{
//lblavailability.Visible = true;
flag = false;
// lblavailability.Text = "Not Available.";
}
lblavailability.Visible = true;
if (flag == true)
{
lblavailability.CssClass = "textgreen";
lblavailability.Text = "Available.";
}
else
{
lblavailability.CssClass = "errorbold";
lblavailability.Text = "Not Available.";
}
}
else
{
lblavailability.CssClass = "textgreen";
lblavailability.Visible = true;
lblavailability.Text = "Available.";
}
}
</code></pre>
| c# | [0] |
683,566 | 683,567 | How to make a clickable link based on users login details | <p>I have created a login system (with help from people on this site) that redirects a logged in user to several pages that only they have access to based on their login information. When navigating the site they will also have access to other pages that all logged in users have access to.</p>
<p>This information is in a msql database and uses php redirect. The system has a small area to show a logged in users name and a logout option. Using sessions this is shown on whatever page the user views whether it is their personal page or a general page open to any logged in user. What I would like to do is to create a “go back to personal page” link (in the same panel as the logout and user name) so whoever is logged in will have a quick link back to their personal page.</p>
<p>I am quite new to PHP and I am sure there is a very simple way to uses the login information and the redirect function to create a clickable text link to achieve this but I have not found a way to do this. I would appreciate help from anyone who could point me in the right direction.</p>
| php | [2] |
3,534,936 | 3,534,937 | Use jQuery to match current URL to herf in a UL and add class if matched | <p>I have a dynamically created UL. I want to use jQuery to use the current URL, search through a specified UL and find any li with a matching href. If one is found then add the class "current_page".</p>
<p>I came up with this but it doesn't seem to do the trick.</p>
<pre><code>$(document).ready(function() {
$("ul.nav_cat_archiveli").find("a[href='"+window.location.pathname+"']").each(function() {
$(this).addClass("current_page");
});
});
</code></pre>
| jquery | [5] |
6,027,539 | 6,027,540 | Application crashes when user presses Back Button | <p>Good day all, First of all, maybe i went about this the wrong way in the first place. Situation is, i have a listview that when an item is clicked, it creates an intent and calls startActivityForResult() to another activity, to be able to edit the entries in the row. and that other activity after editing the required values, returns back to the calling activity, when the user clicks on a save button. The activity then uses the row Id to update the item.My problem now is that, if the user presses the BACK button instead, the application crashes. i have been looking around and see solutions like using Shared Preferences or onSavedInstanceState(), but i don't know where exactly i should be putting the code? Any help as usual, will be greatly appreciated. Thank you.</p>
<p>p.s: when i look at logcat, its gives a NullPointerException for this line in onActivityResult. </p>
<pre><code> Bundle result = data.getExtras();
</code></pre>
| android | [4] |
5,106,291 | 5,106,292 | Use `object` to instantiate custom class | <p>here is my haha class</p>
<pre><code>class haha(object):
def theprint(self):
print "i am here"
>>> haha().theprint()
i am here
>>> haha(object).theprint()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object.__new__() takes no parameters
</code></pre>
<p>why <code>haha(object).theprint()</code> get wrong output?</p>
| python | [7] |
4,718,916 | 4,718,917 | Preference UI Components without PrefernceActivity | <p>Is there a way to use the ui Components from the preference package without a PreferenceActivity?</p>
<p>I have to build a lot of settingsviews, and i cant use sharedprefernces.</p>
<p>Do i Have to build this all by hand?</p>
<p>Vino</p>
| android | [4] |
4,218,015 | 4,218,016 | exit(); die(); return false; | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1795025/what-are-the-differences-in-die-and-exit-in-php">what are the differences in die() and exit() in PHP?</a> </p>
</blockquote>
<p>I guess the main question is what is the difference between the 3 exactly?</p>
<p>What is the correct semantic usage for each one of these?</p>
<p>From what I see <code>return false;</code> can discontinue a function whereas <code>die();</code> and <code>exit();</code> will prevent any further code running <em>at all</em>.</p>
<p>Is this correct?</p>
| php | [2] |
5,477,353 | 5,477,354 | Android AutoCompleteTextView | <p>When I type <code>a</code> on EditText, I want to let <code>add</code>、<code>acer</code>、...show in the drop down menu. I know it can complete with <strong>AutoCompleteTextView</strong>. But I want it also show <code>bat</code>、<code>cat</code>..., the string <code>a</code> is in a word, not in the front.</p>
| android | [4] |
4,198,752 | 4,198,753 | How to shrink a text output in python | <p>Hi
I have a program in python which upon running displays an output on a single page. But when I print the output to an A4 size page the output does not fit on to a page, and gets distorted. Is there a way I could shrink my output or adjust the font size of my output, and print it on to a single page?</p>
| python | [7] |
2,419,430 | 2,419,431 | Jquery compatability issue 1.4 - 1.6 | <p>Im running two scripts, one that only works using jQuery 1.4 and another that needs 1.6 to work correctly. I'm sure there is some obvious (to someone who knows) synatx change or something in between the versions but I cannot figure it out.</p>
<p>This is the 1.4 script: <a href="http://demo.marcofolio.net/slot_machine/" rel="nofollow">http://demo.marcofolio.net/slot_machine/</a> and if you view the demo there are two bits JS files in the source. The other script that needs 1.6 is the jQuery isotope plugin: <a href="http://isotope.metafizzy.co" rel="nofollow">http://isotope.metafizzy.co</a>. So i guess i'm asking how to make the 1.4 script 1.6 compatible.</p>
<p>Thanks in advance.</p>
| jquery | [5] |
4,743,434 | 4,743,435 | Cannot get Jquery .ajax or .load to execute scripts | <p>Here's test.html :</p>
<pre><code><html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<script language=javascript>
$(document).ready(function() {
$("button").click( function() {
$.ajax({
url : "http://localhost:101/test2.html",
dataType : "html",
success: function(data){ alert(data); $("div").html(data); }
});
});
});
/*
$(document).ready(function() {
$.ajax({
url : "http://localhost:101/Scripts/testscript.js",
dataType : "script"
//success: function(data){ $("#inner-main").html(data); }
});
});
*/
</script>
<button> bleh </button>
<div> </div>
</body>
</html>
</code></pre>
<p>Here's test2.html :</p>
<pre><code><script type=javascript>
alert("lock and load, outside!");
$(document).ready(function () {
alert("lock and load!");
});
</script>
<p>Hello, world </p>
</code></pre>
<p>I cannot get test1 to load test2 and execute scripts in it.
I do get < p > (Hello World) to display in the div. The scripts though, do not execute.
The only alert I see is from the function called on success.</p>
<p>What am I doing wrong ?</p>
<p>The URL to test1.html is <a href="http://localhost:101/test1.html" rel="nofollow">http://localhost:101/test1.html</a></p>
| jquery | [5] |
1,361,409 | 1,361,410 | What does this -> ~T() do? | <p>Can anyone explain what this code extract is doing? My first guess was that <code>d()</code> calls the destructor of itself but then I wondered why you couldn't just call the destructor of <code>T</code> yourself.</p>
<pre><code>class T
{
void d()
{
this -> ~T();
}
}
</code></pre>
<p>Thank you in advance.</p>
| c++ | [6] |
1,115,053 | 1,115,054 | Learning python though short tasks and coding competions | <p>I recall seeing a website about learning python that consisted of small tasks with interactive examples and a score board where you could rank.</p>
<p>What was it?</p>
<p>There was also a javascript section. </p>
| python | [7] |
3,628,449 | 3,628,450 | Chat Server - client/server chat Java homework | <p>My chat room program. I have 2 packages, 1 for Client & other for Server. Run Server program, fill the PortField and click button Start Server, window program is stuck, i cant do anything on it, but Server still work, Clients still connect and chat.</p>
<pre><code>private void btnOpenActionPerformed(java.awt.event.ActionEvent evt) {
int port = Integer.parseInt(txtPort.getText());
go(port);
}
private void go(int port){
try {
listUser = new Hashtable<String, ClientConnect>();
server = new ServerSocket(port);
txaStatus.append("Server is started\n");
txaStatus.append("IP Server : "+InetAddress.getLocalHost().getHostAddress()+"\n");
txaStatus.append("Port : " + port + "\n");
while(true){
client = server.accept();
new ClientConnect(this,client);//class ClientConnect for DataOutPut & DataInput Client <=> Server
}
} catch (IOException e) {
txaStatus.append("Server cannot start\n");
JOptionPane.showMessageDialog(this,"Port busy","warning",JOptionPane.WARNING_MESSAGE);
System.exit(0);
}
}
</code></pre>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.