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
3,735,102
3,735,103
Timestamp has Decimal?
<p>I'm using the following code to get a timestamp in Javascript, but it's returning a decimal. When I checked the timestamp with an online converter it's actually correct. I've never seen this format before.</p> <pre><code>var currentTS = new Date().getTime() / 1000; </code></pre> <p>How can I get a whole number and why is it returning a valid timestamp with a decimal?</p> <p>Thanks</p>
javascript
[3]
4,321,522
4,321,523
Error for timeIntervalSinceNow using to pause and resume timer
<p>Using pause timer and resume timer in my code to pause and resume timer. Got error <code>'NSInvalidArgumentException', reason: '-[__NSCFNumber timeIntervalSinceNow]: unrecognized selector sent to instance 0x164590'</code></p> <p>code for pause timer and resume timer</p> <pre><code>-(void)pauseTimer{ pauseStart = [[NSDate dateWithTimeIntervalSinceNow:0] retain]; previousFireDate = [[timer fireDate] retain]; [timer setFireDate:[NSDate distantFuture]]; } -(void)resumeTimer{ float pauseTime = -1*[pauseStart timeIntervalSinceNow]; [timer setFireDate:[previousFireDate initWithTimeInterval:pauseTime sinceDate:previousFireDate]]; [pauseStart release]; [previousFireDate release]; } </code></pre> <p>Using pause and resume timer in play pause toggle button</p> <pre><code>-(void)playpauseAction:(id)sender { if([audioPlayer isPlaying]) { [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected]; [audioPlayer pause]; [self pauseTimer]; } else { [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal]; [audioPlayer play]; [self resumeTimer]; if(isFirstTime == YES) { self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(displayviewsAction:) userInfo:nil repeats:NO]; isFirstTime = NO; } } } </code></pre> <p>Any idea why app terminated and how to fix this.</p> <p>Thanks.</p>
iphone
[8]
825,405
825,406
Cant find the android keytool
<p>I am trying to follow the Android mapping tutorial and got to this part where I had to get an API key <a href="http://code.google.com/android/add-ons/google-apis/mapkey.html#getdebugfingerprint" rel="nofollow">http://code.google.com/android/add-ons/google-apis/mapkey.html#getdebugfingerprint</a></p> <p>I have found my debug.keystore but there does not appear to be a keytool application in the directory:</p> <p><strong>C:\Documents and Settings\tward\.android>ls</strong> adb_usb.ini avd debug.keystore repositories.cfg androidtool.cfg ddms.cfg default.keyset</p> <p>There is also no keytool in this directory:</p> <p><strong>C:\Android\android-sdk-windows\tools>ls</strong> AdbWinApi.dll apkbuilder.bat etc1tool.exe mksdcard.exe AdbWinUsbApi.dll ddms.bat fastboot.exe source.properties Jet dmtracedump.exe hierarchyviewer.bat sqlite3.exe NOTICE.txt draw9patch.bat hprof-conv.exe traceview.bat adb.exe emulator.exe layoutopt.bat zipalign.exe android.bat emulator_NOTICE.txt lib</p> <p>I am using eclipse as my editor and believe that I have downloaded all the latest SDK What am I doing wrong?</p>
android
[4]
4,158,419
4,158,420
how to clear the query string in PHP
<p>How to Clear the Query string.</p> <p>my query string is "index.php?name=sugumar&amp;id=49"</p> <p>using meta tag I redirect the same page. that time the query string values are not cleared. for that I have used. </p> <blockquote> <p>Request.QueryString[1] = string.Empty;</p> </blockquote> <p>but it shows the error. </p> <blockquote> <p>syntax error, unexpected '[' in /home/sugumar</p> </blockquote> <p>Then I used </p> <blockquote> <p>Request.QueryString.Clear();</p> </blockquote> <p>it shows the error</p> <blockquote> <p>Call to undefined function Clear() in /home/sugumar</p> </blockquote> <p>how to solve this problem? I want to clear the query string values before the meta tag redirect the page.</p>
php
[2]
2,343,065
2,343,066
Beginner, trying to setup Python
<p>I'm a PHP programmer, but I want to learn Python. I'm a bit confused with how to actually execute a script. I've created test.py in my web server root, in the file I've written:</p> <pre><code>#!/usr/bin/python import jon.cgi as cgi import jon.fcgi as fcgi print "Content-type: text/html" print "hello world" </code></pre> <p>My server is running Litespeed on CentOS 5, following the tutorial at: <a href="http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:python_fcgi" rel="nofollow">http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed_wiki:python_fcgi</a> I've installed Jon's CGI.</p> <p>But when I navigate to the script in my browser it just prints the full code, as if it's not parsing it. Sorry if I'm asking a stupid question, I would really appreciate any help, thanks.</p>
python
[7]
5,740,759
5,740,760
Create a byte array according to given String In Java
<p>I just need to create a byte array out of the given String.</p> <p>For example, if my String is <code>String ss = "21331UA";</code> then the byte array elements should correspond to them as follows.</p> <pre><code>2 1 3 3 1 U A </code></pre> <p>I could have created it statically as this. <code>byte[] arr = new byte[]{2,1,3,3,1,'U','A'}</code> But have to create this byte array in the runtime dyanamically as this changes time to time. Thats the problem.</p> <p>I just tried as follows and print them, it contains their corresponding ASCII values.<strong>This is not what I want.</strong></p> <pre><code>byte[] arr = ss.getBytes(); for(int i=0; i&lt;arr.length; i++) { System.out.print(arr[i] + " "); } Ans==&gt; 50 49 51 51 49 85 65 </code></pre> <p>Really appreciate any guidance.... Thanks in advance</p>
java
[1]
456,882
456,883
Searching List of Tuples by nth element in Python
<p>So I have a list of tuples, with 3 elements each. Both the second and third elements are ints. For a value n, I need to return all the tuples that contain n as either the second or third element. </p> <p>I'm not entirely sure how to do this, unfortunately. I'm sure it's not too complicated, but although there are some similar questions, I can't find any for this exact problem. Does anyone know how to go about this?</p> <p>Thanks</p>
python
[7]
1,152,341
1,152,342
php header not forwarding ie9
<p>I use the following which works perfectly in all browsers, except ie9</p> <pre><code>$result = mysql_query("SELECT u_id, from users where (id = '$userID')",$db); $item = mysql_fetch_row($result); $how_many = mysql_num_rows($result); // if not a user send to reg if ($how_many &lt; 1){ header("Location: /pages/registration"); } </code></pre> <p>It simply does not forward - the header function does nothing - however, if i change the last block of the code to what is below, it works?!?!</p> <pre><code>if ($how_many &lt; 1){ header("Location: /pages/registration"); // added echo for ie9 echo "&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;here i am "; } </code></pre> <p>I cannot fathom any logical reason for this, am I missing something?</p>
php
[2]
5,497,935
5,497,936
copy and paste the file in swt
<p>I am having a zip file in my E:\temp\file.zip. Now I need to copy the whole zip file and paste it to my desktop and the original zip file should not be deleted. This should be done using java SWT lib.</p> <pre><code>import java.io.*; import javax.swing.*; public class MovingFile { public static void copyStreamToFile() throws IOException { FileOutputStream foutOutput = null; String oldDir = "F:/CAF_UPLOAD_04052011.TXT.zip"; System.out.println(oldDir); String newDir = "F:/New/CAF_UPLOAD_04052011.TXT.zip.zip"; // name the file in destination File f = new File(oldDir); f.renameTo(new File(newDir)); } public static void main(String[] args) throws IOException { copyStreamToFile(); } } </code></pre>
java
[1]
3,173,839
3,173,840
Is there a risk in running file_put_contents() on the same file from different PHP threads?
<p>I know <a href="http://us.php.net/file_put_contents" rel="nofollow">file_put_contents()</a> makes it really easy to append data to a file in PHP. I'd like to try using PHP "<a href="http://www.funkynerd.com/knowledgebase/articles/2" rel="nofollow">threads</a>" to <code>file_put_contents()</code> to the same log file from different PHP threads. Is there a risk in running file_put_contents() on the same file from different PHP threads or will these threads happily block if the file is locked or being accessed by another thread?</p> <p>EDIT: Found <a href="http://stackoverflow.com/questions/4682533/two-users-write-to-a-file-at-the-same-time-php-file-put-contents">a similar question</a> that recommends <a href="http://www.php.net/manual/en/function.flock.php" rel="nofollow">flock()</a>, but the risk question does not seem to be fully addressed. Are these "atomic" write operations?</p>
php
[2]
484,311
484,312
JQuery and radio button help
<p>I have data being imported from a database and I would like to represent that data in a set of radio buttons. If the value in the database is 1 the "customer status" should show the "active" radio button else show the "inactive" button.</p> <p>I don't know much at all about JQuery but am learning day by day so any detailed help offered would be greatly appreciated.</p> <p>I took the main code snippets from my files and am including them here.</p> <p>The interesting thing about the code I am posting is that I can use the buttons to change the data in the database. That works but showing what is in the database isnt.</p> <pre><code>var admCustStatus = $("input[name='admCustStatus']:checked").val(); if (item.field == "admCustStatus") { // ?? radio buttons } &lt;tr&gt; &lt;td class="admMarker"&gt;Active&lt;input type="radio" id="admCustStatusActive" name="admCustStatus" value="1" checked="checked" class="admChkbx"&gt;&lt;/td&gt; &lt;td class="admMarker"&gt;Inactive&lt;input type="radio" id="admCustStatusInactive" name="admCustStatus" value="0" class="admChkbx"&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre>
jquery
[5]
5,687,756
5,687,757
php howto unset static var
<p>i have a function like this. i want reset the $output var first call.</p> <pre><code>function create_tree($tree_array, $reset = TRUE, $ul_class = FALSE) { if($reset) unset($output); // NOT WORK!!! static $output = ''; $class = ''; if ($ul_class) { $class = ' class="' . $ul_class . '"'; } $output .= '&lt;ul' . $class . '&gt;' . PHP_EOL; foreach ($tree_array as $v) { $output .= '&lt;li&gt;&lt;a href="' . site_url_i18n($v['link']) . '"&gt;' . $v['name'] . '&lt;/a&gt;' . PHP_EOL;; if (isset($v['children'])) { create_tree($v['children'], false); } $output .= '&lt;/li&gt;' . PHP_EOL; } $output .= '&lt;/ul&gt;' . PHP_EOL; return $output; } </code></pre>
php
[2]
2,446,714
2,446,715
Is possible to replace an expression with a text in PHP?
<p>For exemple, it's possible to replace</p> <pre><code>{'a1b2,left'} </code></pre> <p>with</p> <pre><code>&lt;img src="a1b2" class="left"/&gt; </code></pre> <p>in Php?</p>
php
[2]
2,397,028
2,397,029
Javascript if number < 10 add a "0"
<p>I made a simple countdown with javascript, here you can see a example:<a href="http://jsfiddle.net/PCwx8/" rel="nofollow">http://jsfiddle.net/PCwx8/</a></p> <p>It simply counts to today midnight. May problem is that i simply want that javascript adds a "0" to the numbers that are minor then 10. I have a idee like :</p> <pre><code>if (i&lt;10) { i="0" + i; } return i; </code></pre> <p>But i dont know if its an integral or simply a number? Thanks, for help, i normally have nothing to do with javascript, so please understand! </p>
javascript
[3]
1,740,330
1,740,331
Access JS object with a key
<p>I can access a value like <code>driver.my_friends["793659690"].name</code> but now I am using it in a loop where <code>key</code> will hold the key.</p> <p><code>driver.my_friends[key].name</code> doesn't work. Says undefined, and <code>driver.my_friends["key"].name</code> will look for a key named key. So how do I use it so that the variable of the variable is evaluated too.</p>
javascript
[3]
3,263,460
3,263,461
Jquery $.post issue
<p>I have below code that reads file name after browse and sends it to another page using POST. if i have alert after $.post, then it works fine. If I remove the alert message, then post is not forwarding the file name to another page. </p> <pre><code>&lt;input type="file" name="fileupload" id="fileupload" value=""&gt; </code></pre> <p>// Jquery code</p> <pre><code>$("#fileupload").change(function() { if ($("#fileupload").val().length &gt; 0) { $.post("ReadExcel.jsp", { filename: $("#fileupload").val(), processId: &lt; %= processId % &gt; }); alert($("#fileupload").val()); // **If I remove this alert, then the code doesn't works** } location.reload(); });​ </code></pre>
jquery
[5]
2,270,733
2,270,734
Liferay Login page redirect
<p>Hi every one i am new to liferay i ve developed my own page and when i click sign-in In main page i want to redirect to my custom page instead going to default home page.. can anyone pls suggest me how to do this where i should redirect it thanks in advance.</p>
java
[1]
82,943
82,944
clear value of text input if checkbox is checked restore value if unchecked using javascript
<p>I have a text field with an image value populated from database. I need to have a checkbox that would clear value when checked and restore value when unchecked.</p> <pre><code>&lt;input type="text" value="/images/sampleimage.jpg" /&gt; Remove this image &lt;input type="checkbox" name="remove"&gt; </code></pre>
javascript
[3]
719,491
719,492
How to get information about mobile service plans?
<p>Is there any way to get information by programming about the mobile service plan like call minutes limit or amount of MB from my internet data plan??</p> <p>Thanks!</p>
android
[4]
4,825,102
4,825,103
Help me with some c++ code
<p>I only want it to update server_record. Dont send any messgaes. What can I remove so it dont say "New record of players online is: 2839". Can I remove everything under query.str("");? I have no idea what char buffer[50]; do. I dont wanna mess anything up. And How can u get current time in c++? I want to insert the current time in the table too. To se when record was set.</p> <pre><code>void Game::checkPlayersRecord() { if(getPlayersOnline() &gt; lastPlayersRecord){ Database* db = Database::instance(); DBQuery query; lastPlayersRecord = getPlayersOnline(); query &lt;&lt; "UPDATE `server_record` SET `record` = " &lt;&lt; lastPlayersRecord &lt;&lt; ";"; db-&gt;executeQuery(query.str()); query.str(""); char buffer[50]; sprintf(buffer, "New record of players online is: %d", lastPlayersRecord); AutoList&lt;Player&gt;::listiterator it = Player::listPlayer.list.begin(); while(it != Player::listPlayer.list.end()){ (*it).second-&gt;sendTextMessage(MSG_EVENT_ADVANCE, buffer); ++it; } } } </code></pre>
c++
[6]
1,963,111
1,963,112
How to make ASPNETDB.mdf appear?
<p>Hi I recently started to learn asp.net.I know that when you drag a login control on the page and a register control asp generates a database called ASPNETDB.mdf.I also know that this database should be in App_Data.For some reason after I added the login control , register control and also selected the authentification type to be from the internet the database is still not showing in App_Data.</p> <p>How can I make it appear?</p> <p>I need it to create a realationship with another table that will hold profile data. </p>
asp.net
[9]
3,650,591
3,650,592
I am converting a working .NET 4.0 application to .NET 3.5 with string.join
<p>I am converting a working .NET 4.0 application to .NET 3.5. Please, help me Here is the code:</p> <pre><code>NameValueCollection qs = new NameValueCollection(); qs["aid"] = "aaa"; qs["fields"] = "1"; qs["aaa"] = "d"; tb.Text = String.Join("&amp;", from item in qs.AllKeys select item + "=" + qs[item]); </code></pre>
c#
[0]
1,791,710
1,791,711
How can I find out when a picture was actually taken in C# running on Vista?
<p>In windows XP "FileInfo.LastWriteTime" will return the date a picture is taken - regardless of how many times the file is moved around in the filesystem.</p> <p>In Vista it instead returns the date that the picture is copied from the camera.</p> <p>How can I find out when a picture is taken in Vista? In windows explorer this field is referred to as "Date Taken".</p>
c#
[0]
3,283,096
3,283,097
Convert Microsoft snp to pdf
<p>Can any body tell me is there any API in Java (1.5) which converts a Microsoft <a href="http://en.wikipedia.org/wiki/SNP_file_format" rel="nofollow">SNP</a> file to PDF format please?</p>
java
[1]
5,291,249
5,291,250
android menu press action for android-sliding-menu-demo
<p>I'm currently using this <a href="https://github.com/gitgrimbo/android-sliding-menu-demo" rel="nofollow">android-sliding-menu-demo</a> as sidemenu for my application. In this project, sidemenu can be only display when press icon at topbar but what I want is to display sidemenu when I press on menu button of android OS. I've already tried with following coding but sidemenu cannot display at all (and import import com.mytestapp.MyHorizontalScrollView.SizeCallback;).</p> <pre><code>public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { new ClickListenerForScrolling(scrollView, menu); } return true; } </code></pre>
android
[4]
1,458,451
1,458,452
Calling a new Form from a separate thread and avoid frozing the form
<p>I am currently creating a chat system. The receiving end of the client side is managed by a separate thread so that when it receives a message from another client, a new Form is loaded bearing the message of the sender. The problem is, the newly loaded form is frozen and is not responding [due to the blocked methods I use (?)]. How can I solve that problem? I am new to C# so please put in the code snippet.</p>
c#
[0]
3,398,886
3,398,887
Is CONSTANT.equals(VARIABLE) faster than VARIABLE.equals(CONSTANT)?
<p>I had an interesting conversation with one of my team mate.</p> <p>Is <code>CONSTANT.equals(VARIABLE)</code> faster than <code>VARIABLE.equals(CONSTANT)</code>in Java?</p> <p>I suspect this to be a false statement. But I am trying to figure out what should be qualitative reasoning behind this?</p> <p>I know in both the cases the performance will not differ to any kind of significant state. But it was a recommendation under BEST PRACTICES which is making me uncomfortable. That's the reason I am looking towards a good reasoning that I want to present with this case. </p> <p>Please HELP </p>
java
[1]
1,173,615
1,173,616
C++ Calling Static Function pointer with Predefined parameters
<p>I have a rather unusual problem... we are tasked with mapping a series of hexadecimal values to function pointers. However, I want to be able to call the function with already predefined parameters. Here is a segment of code that I am trying to get to work:</p> <pre><code>map&lt;short, void(*)(MyClass, MyClass)&gt; mapping = create_map(); map&lt;short, void(*)(MyClass, MyClass)&gt; create_map() { map&lt;short, void(*)(MyClass, MyClass)&gt;&gt; m; m[1] = &amp;function(new MyClass(), new MyClass()); return m; } </code></pre> <p>However, it will only let me put function without parameters into the mapping. How do I store this setup and call it later?</p>
c++
[6]
3,467,075
3,467,076
how to simulate timeout on Ie 8?
<p>one of my user has time out issue on my website - where in my php script takes more than 30 seconds to execute, her IE times out and shows an IE error message.</p> <p>But it never does to me - my IE will continously just wait even if i let my PHP script to sleep for 6 minutes. </p> <p>Is there any way to set the timeout or force my IE to timeout for say in 5 seconds?</p>
php
[2]
2,930,924
2,930,925
How this is code is getting compiled even though we are using a constant which is defined later?
<p>In the following code DEFAULT_CACHE_SIZE is declared later, but it is used to assign a value to String variable before than that, so was curious how is it possible?</p> <pre><code>public class Test { public String getName() { return this.name; } public int getCacheSize() { return this.cacheSize; } public synchronized void setCacheSize(int size) { this.cacheSize = size; System.out.println("Cache size now " + this.cacheSize); } private final String name = "Reginald"; private int cacheSize = DEFAULT_CACHE_SIZE; private static final int DEFAULT_CACHE_SIZE = 200; } </code></pre>
java
[1]
3,971,016
3,971,017
how to initialize static ArrayList<myclass> in one line
<p>i have myclass as</p> <pre><code>myclass(String, String, int); </code></pre> <p>i know about how to add to add to ArrayList in this way:</p> <pre><code>myclass.name = "Name"; myclass.adress = "adress"; myclass.age = age; </code></pre> <p>then add to arrayList like:</p> <pre><code>list.add(myclass); </code></pre> <p>but now i have many object myclass in static form, i want to add</p> <pre><code>ArrayList&lt;myclass&gt; list = new ArrayList&lt;myclass&gt;({"Name","Address", age};.....); </code></pre> <p>can i do like this. thank anyway</p>
java
[1]
4,372,888
4,372,889
Difference between function(){ and function(e){
<p>What is the difference between function(){ and function(e){? All over the web, i have seen in lot of places like,</p> <p><code>$('element').bind(function(){});</code></p> <p>and</p> <p><code>$('element').bind(function(e){});</code>.</p> <p>But can anyone differentiate this clearly? So that i can understand that.</p>
jquery
[5]
1,090,817
1,090,818
Overriding the hardware buttons on Android
<p>Is it possible to override the function of a hardware button programmically on a droid? Specifically, I'd like to be able to override the camera button on my phone programmically. Is this possible?</p>
android
[4]
4,529,410
4,529,411
adding duplicate type of column to a datatable
<p>How can i add same fields for columns in a datatable. I wan to make a datatable which repeate column name of same type multiple times, but dot net dont allow me to add that, but i want to do that hw can i do that?</p> <pre><code>table.Columns.Add("S.NO", typeof(int)); table.Columns.Add("DC", typeof(string)); table.Columns.Add("DC", typeof(string)); table.Columns.Add("DC", typeof(string)); table.Columns.Add("ST", typeof(string)); table.Columns.Add("ST", typeof(string)); table.Columns.Add("AD", typeof(string)); table.Columns.Add("AD", typeof(string)); </code></pre>
asp.net
[9]
1,065,634
1,065,635
jQuery treat hover on two elements as one elements
<p>I have an image map which I have overlaid with some markers in the form of anchors. I currently have a hover trigger on each image map area and the associated anchor - as shown in screen shot <img src="http://i.stack.imgur.com/gMF3C.png" alt="enter image description here"></p> <p>I need to treat these two elements as one, as currently when mouse is moved out of one onto the other it calls <code>.hover()</code> and callback again. I want to call hover callback only when mouse is moved out of either elements.</p>
jquery
[5]
843,828
843,829
Media Formats in Android?
<p>What is the Difference between Encoder and Decoder in <a href="http://developer.android.com/guide/appendix/media-formats.html" rel="nofollow">Supported Media Formats</a> in android? What is the Need of it? Which is the recommended image Format by you?</p>
android
[4]
5,110
5,111
android custom button with default selector
<p>I have a listview in which i have an image and text content getting populated from the java code.</p> <p>I'm unable to get the default orange selector working on the image. The image is placed ontop of button as <code>setBackgroundResource()</code> from Java.</p> <p>Can anyone help me with the same?</p>
android
[4]
5,994,034
5,994,035
Way to shorten jquerycode
<p>I have several modal popup windows which all use the same settings. One of these requires the following code.</p> <pre><code>var $modal = $('#modal') .attr('id', 'modal') .css({zIndex: 3000}); $('#modal-trigger').click(function(evt) { evt.preventDefault(), $('#modal').css("visibility","visible"); $(this).overlay({ effect: 'fade', glossy: true, opacity: 0.8, closeOnClick: true, onShow: function() { $('body').append($modal); }, onHide: function() { $modal.remove(); }, }) }); </code></pre> <p>So making a second one means changing the <em>modal</em> to something else in the following places:</p> <p>var $modal = $('#<strong>modal</strong>')</p> <p>.attr('id', '<strong>modal</strong>')</p> <p>$('<strong>#modal-trigger</strong>').click(function(evt) {</p> <p>$('body').append(<strong>$modal</strong>);</p> <p><strong>$modal</strong>.remove();</p> <p>Is there a way to shorten this, so I do not have to keep adding the full code to achieve this effect?</p>
jquery
[5]
4,149,548
4,149,549
Illegal Cross Thread Operation error
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/606642/help-needed-for-cross-thread-operation-error-in-c-sharp">Help needed for &#39;cross-thread operation error&#39; in C#</a><br> <a href="http://stackoverflow.com/questions/5868783/solve-a-cross-threading-exception-in-winforms">Solve a cross-threading Exception in WinForms</a> </p> </blockquote> <p>I've tried to add progressbar in the foreach-loop</p> <pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { foreach (...) { ... i++; backgroundWorker1.ReportProgress(100 * i / rcount); Thread.Sleep(100); } this.close(); } </code></pre> <p>now i have an Illegal Cross Thread Operation error in <code>this.close();</code> line</p> <p>How can i solve it?</p>
c#
[0]
5,336,849
5,336,850
how to send email in iphone SDK?
<p>how to send email in iphone SDK? any example tutorial to take email address from iphone also?</p>
iphone
[8]
5,670,007
5,670,008
using $this or parent:: to call inherited methods?
<p>Not really a problem, more like curiosity on my part but as an example, say I have a php class:</p> <pre><code>class baseTestMain { protected function testFunction() { echo 'baseTestMain says hi'; } } </code></pre> <p>and another class that extends from that class above:</p> <pre><code>class aSubClass extends baseTestMain { public function doingSomething() { parent::testFunction(); //someextrastuffhere } } </code></pre> <p>Normally, when I want to call a parent method when defining a new method in the subclass I would do the above - <code>parent::methodnamehere()</code> however instead of <code>parent::</code> you can also use <code>$this-&gt;methodname()</code> and the operation would be the same.</p> <pre><code>class aSubClass extends baseTestMain { public function doingSomething() { $this-&gt;testFunction(); //someextrastuffhere } } </code></pre> <p>So what I'm asking is, should I use <code>parent::testFunction();</code> or use <code>$this-&gt;testFunction();</code> ? or is there a difference to it that I've missed? If not, whats your preference or the preferred method?</p> <p>Do note that I am not overriding or extending that function in the subclass, essentially the implementation is carried over from the parent.</p>
php
[2]
417,917
417,918
Get Substring - everything before certain char
<p>I'm trying to figure out the best way to get everything before the - character in a string. Some example strings are below. The length of the string before - varies and can be any length</p> <pre><code>223232-1.jpg 443-2.jpg 34443553-5.jpg </code></pre> <p>so I need the value that's from the start index of 0 to right before -. So the substrings would turn out to be 223232, 443, and 34443553</p>
c#
[0]
3,930,721
3,930,722
Does exit($status) violate the single responsibility principle?
<p>The <a href="http://www.php.net/manual/en/function.exit.php" rel="nofollow">the PHP manual page</a> about the exit construct states:</p> <blockquote> <p>exit — Output a message and terminate the current script</p> </blockquote> <p>Based on that, would it be correct to think that it violates <a href="http://www.codinghorror.com/blog/2007/03/curlys-law-do-one-thing.html" rel="nofollow">the single responsibility principle</a>?</p>
php
[2]
2,107,020
2,107,021
How do I select an input by it's value after a value is entered using jQuery?
<p>See my example below. I'm trying to enter Mike into the input and then hit "remove input" to remove the input from the page. It doesn't seem like the value is updated in the DOM when a user types a value. How can I get around this?</p> <p>Example: <a href="http://jsfiddle.net/ZMSaD/" rel="nofollow">http://jsfiddle.net/ZMSaD/</a></p>
jquery
[5]
1,849,335
1,849,336
Calculating shift hours worked
<p>I'm am trying to calculate the hours for someone based on the number of hours worked and the time period in which they worked.</p> <p>For example: </p> <p>The shift patterns are 07:00 to 15:00 is 'morning', 15:00 to 23:00 is 'afternoons', and 23:00 to 07:00 is 'nights'.</p> <p>Therefore if I started at 08:00 and finished at 17:30, this would mean that I get paid 7 'morning' hours and 2.5 'afternoon' hours.</p>
php
[2]
2,966,115
2,966,116
Difference between androidannotations and droidparts frameworks?
<p>I'm just starting to learn about android, but already have a question:</p> <p><a href="http://droidparts.org/parts/di.html" rel="nofollow">AndroidParts</a> and <a href="https://github.com/excilys/androidannotations/wiki" rel="nofollow">AndroidAnnotations</a> frameworks looks very similar. Which one is better to use?</p>
android
[4]
5,200,713
5,200,714
how to find if a control inherited from a base type?
<p>i want to disable validation controls on some conditions. how can i find that a control is inherited from "BaseValidator"?</p> <p>note all validator controls are inherited from BaseValidator <a href="http://www.startvbdotnet.com/aspsite/controls/validation.aspx" rel="nofollow">(+)</a></p>
asp.net
[9]
2,580,259
2,580,260
Datacall channel implementaion in android
<p>I want to know if datacall channel can be implemented in android. IS it possible to do it in the application level? If so what are the available APIs in android?</p>
android
[4]
4,009,809
4,009,810
How to get rid of the file type when using getName()?
<p>Only doing this because I am lazy. I just wrote a program to list all my music into an excel file.</p> <pre><code> import java.io.*; import org.apache.commons.io.FileUtils; public class NewClass { public static void main( String args[] ) { File folder = new File("C:/Users/Public/Music/OldMusic"); File[] listOfFiles = folder.listFiles(); for (int i = 0; i &lt; listOfFiles.length; i++) { try{ FileUtils.writeStringToFile(new File("test.xls"), listOfFiles[i].getName(), true); BufferedWriter output; output = new BufferedWriter(new FileWriter("test.xls", true)); output.newLine(); output.close(); } catch (IOException e){ } } } } </code></pre> <p>The code works fine, but at the end of every song there is <em>.mp3</em> (i.e.: <em>Metallica - Nothing Else Matters.mp3</em>).</p> <p>Is there a way just to have the Name of the song without the <em>.mp3</em> at the end of it?</p>
java
[1]
1,235,075
1,235,076
java.util.NoSuchElementException No Such Element Exception
<p>New to Java - just trying to get a handle on it. The program is executing as follows:</p> <pre><code>What's your age?23 23 What's your name?Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at king.getName(king.java:25) at king.main(king.java:9) </code></pre> <p>The code it is trying to run is below:</p> <pre><code>import java.util.*; public class king { public static void main(String[] args){ System.out.println(getAge()); System.out.println(getName()); } public static int getAge(){ System.out.print("What's your age?"); Scanner scanner = new Scanner(System.in); String age = scanner.next(); scanner.close(); int numberAge = Integer.parseInt(age); return numberAge; } public static String getName(){ System.out.print("What's your name?"); Scanner newScanner = new Scanner(System.in); String name = newScanner.next(); newScanner.close(); return name; } } </code></pre>
java
[1]
4,169,625
4,169,626
install curl extension fail
<p>I try to install php curl extension in my win xp environment but failed. To follow the manual ,I have copied libeay32.dll and ssleay32.dll into %systemroot%/system32 dir ,the ';' in front of 'extension=php_curl.dll' also has been opened but in the test function phpinfo(), there is still not any clues </p> <p>but the other extensions like php_gd2.dll,php_pdo.dll can be opened or closed without any problems</p> <p>any help would be appreciated</p>
php
[2]
295,404
295,405
jQuery - addClass() mouseover
<p>I have a jQuery effect where if the user mouse over the reply image, the image would change to another image. The problem I am having is that when you mouse over another object, which is set to addClass() for the reply image, this new reply image does not change its image when mouseovered. </p> <p>Demo of my problem: <a href="http://www.sfu.ca/~jca41/stuph/jQueryTest/jQueryTest.html" rel="nofollow">http://www.sfu.ca/~jca41/stuph/jQueryTest/jQueryTest.html</a></p> <pre><code>$(document).ready(function(){ $(".red").mouseover(function() { $(this).css("color","red"); $(this).addClass("reply"); }); $(".red").mouseout(function() { $(this).css("color","black"); $(this).removeClass("reply"); }); $(".reply").mouseover(function() { $(this).css("background-image", "url(reply_h.png)"); }); $(".reply").mouseout(function() { $(this).css("background-image", "url(reply.png)"); }); }); </code></pre>
jquery
[5]
384,795
384,796
JQuery Tabs Custom CSS
<p>I need to apply Custom CSS for jquery tabs.... I have two Jquery tab panels on single View...How to apply diffrent CSS for both Tab panels</p> <p>Css for Selected and hover and default </p> <p>Please give me suggestion</p> <p>Thanks Narasimha</p>
jquery
[5]
3,748,764
3,748,765
What is Difference between using the Scanner class in Java for input and using Strings Args[] with parseint?
<p>What is the difference between the following</p> <pre><code>import java.util.Scanner; //Creating the scanner Scanner input=new Scanner(System.in); System.out.println("Enter the number 1"); int number1=input.nextInt(); </code></pre> <p>vs</p> <pre><code>int number1=parseInt(args[0]); </code></pre>
java
[1]
3,140,522
3,140,523
How should this be achieved? Activity/ActivityGroup or ViewFlipper?
<p>I have a ListView with let's say 5 items. When I click on one of these it automatically start a new activity based on the position of my ListView.</p> <p>Then, in the new activity, it shows like "1 of 5".</p> <p>I have two buttons (back and next) to show 2 of 5 etc, but how should I implement so it loads new content without starting a lot of activites for every "2 of 5", "3 of 5" etc..? It's meant to be done this way so the user don't need to go back to the ListView and then choose the second position..</p> <p>My current code (From the ListView):</p> <pre><code> OnItemClickListener itemListener = new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long rowid) { Intent intent = new Intent().setClass(ctx, Details.class); Bundle b = new Bundle(); b.putInt("id", parent.getPositionForView(v)); intent.putExtras(b); startActivity(intent); } }; </code></pre> <p>and then a piece of code in Details.java:</p> <pre><code> next = (Button)findViewById(R.id.next_button); back = (Button)findViewById(R.id.back_button); Bundle b = getIntent().getExtras(); id = b.getInt("id"); id_header_sum = id+1; String string_id = Integer.toString(id_header_sum); one_of_all.setText(string_id + " of 5"); nextOnClick = new OnClickListener() { public void onClick(View arg0) { if(id_header_sum==30){ } else { } } }; backOnClick = new OnClickListener() { public void onClick(View arg0) { if(id_header_sum==1){ } else { } } }; next.setOnClickListener(nextOnClick); back.setOnClickListener(backOnClick); </code></pre> <p>I don't want to start a single activity for every detail.</p> <p>Please tell me if the question is unclear and thanks in advance!</p>
android
[4]
4,429,777
4,429,778
play a wav file c# code
<p>How can I play a wav file to a another computer? I know i have to send the wav file as a buffer on the out device. Can someone give a short eq in c#?</p>
c#
[0]
571,068
571,069
key value style javascript array`s length keeps being 0
<p>I fill my key value array like this:</p> <pre><code>/** * Callback: Gets invoked by the server when the data returns * * @param {Object} aObject */ function retrieveStringsFromServerCallback(aObject){ for(var i = 0;i &lt; aObject['xml'].strings.appStringsList.length;i++){ var tKey = aObject['xml'].strings.appStringsList[i]["@key"]; var tValue = aObject['xml'].strings.appStringsList[i]['$']; configManager.addStringElement(tKey,tValue); } } </code></pre> <p>Here is the setter of my object</p> <pre><code>/** * @param {string} aKey * @param {string} aValue */ this.addStringElement = function(aKey, aValue){ self.iStringMap[aKey] = aValue; console.log("LENGTH: "+self.iStringMap.length); } </code></pre> <p>I add about 300 key value pairs, according to google chrome inspector, the <code>iStringMap</code> is filled correctly. However the length of the array seems still to be 0. There must be something wrong. Any help much appreciated</p>
javascript
[3]
1,012,135
1,012,136
ASP.NET + QueryString Encoding Problem
<p>I'm passing query string parameter to .aspx page with 'Ñ' character in value. But Request.QueryString returns some other box '[]' character in return. I think this request encoding issue. and I do not want to use that HttpUtility.UrlDecode and HttpUtility.UrlEncode methods.</p> <p>Does anyone know how to solve this?</p>
asp.net
[9]
1,562,813
1,562,814
timer.scheduleAtFixedRate is executed in a second not after delay time
<p>i am using timer like:</p> <pre><code>Timer timer = new Timer(); timer.scheduleAtFixedRate(new CheckWifi(), 0, 50000); // 5 seconds class Wifi extends BroadcastReceiver { protected class CheckWifi extends TimerTask { @Override public void run() { } } </code></pre> <p>but <code>CheckWifi</code> class is executed in a second not after 50 second like is set in <code>scheduleAtFixedRate</code>. Why?</p> <p>Is it better to use <code>Runnable</code> instead of <code>Timer</code>?</p>
android
[4]
4,628,996
4,628,997
Not able to unlock screen in android
<p>I am able to lock a screen in android using Device policy manager. It will lock a screen even when the user is in other applications(Globaly). Same thing i want to do with Unlock. My application unlocks a screen when user locks a screen within my application. But when user locks a screen with other application it is not unlocking screen. </p> <p>I am using proximity sensor to Lock/Unlock screen and registering ProximitySensorEventListener in onPause method for Unlock. It will unlock a screen only within my app.How to do a screen should unlock a screen with any other application (Globaly) ?? plz help me on this issue.</p> <p>Thanks in advance.</p>
android
[4]
5,661,201
5,661,202
how to add the integer values using foreach in php
<p>I just want to know the syntax of adding the quantity using <code>foreach</code>. Any help is greatly appreciable.</p> <p>Here is the code what I do so far:</p> <pre><code>$qproducts = '0'; foreach ($this-&gt;cart-&gt;getProducts() as $product) { $qproducts .= $product['quantity']; } $this-&gt;data['pquantity'] = $qproducts; </code></pre>
php
[2]
5,084,837
5,084,838
How can I check that username contains only english letters, punctuation and digits?
<p>How can I check that username contains only english letters, punctuation symbols and digits?</p> <p>Thank you.</p>
php
[2]
4,915,275
4,915,276
In Java, how to get attribute given the string with its name?
<p>I'm sorry for asking this sort of questions, but I really couldn't find the answer in Google. So say I have a class with <code>private String myColor</code> and I have a string "myColor". Now I want to manipulate the <code>myColor</code> attribute. How can I do that?</p> <p><strong>Edit:</strong> Sorry for an unclear question, I guess the best way is to explain what I need it for. I've got a Swing form and want to use the preferences api to set the values of fields when loading gui. So I can read all the fields and then do <code>outputDirectoryTextField.setText(valueFromPrefsAPI);</code> for each of them, but that seems to be a bit of unneeded coding so I want to have an array(hash?) with the names of fields and loop through them, like this:</p> <pre><code>String[] myTextInputs = {"thisInput", "thatInput"}; for (String inputName : myTextInputs) { String value = prefs.get(inputName, ""); /* some code I'm seeking to find out*/.setText(value); } </code></pre>
java
[1]
2,706,354
2,706,355
Time Consuming to occur error when not able to reach the URL
<p>I have connected to my web service hosted in remote machine using ksoap protocl.But when connection to that url is not reachable it took time to occur exception.Is there any way to set timeout for making a connection in the ksoap.</p> <p>The code i have written is given below.</p> <pre><code>String SOAP_ACTION = "http://VisionEPODWebService/GetProblemAndReasonCodesNew"; String OPERATION_NAME = "GetProblemAndReasonCodesNew"; String WSDL_TARGET_NAMESPACE = "http://VisionEPODWebService/"; String SOAP_ADDRESS = ""; SOAP_ADDRESS = "http://" + serverIPAddress + "/VisionEPODWebService/SystemData.asmx"; SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); request.addProperty("deviceID", deviceId); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS); httpTransport.call(SOAP_ACTION, envelope); Object response = envelope.getResponse(); </code></pre> <p>But I found a method for checking this by as given below</p> <pre><code>if (InetAddress.getByName(server1IPAddress) .isReachable(1000) == false) { Exception exception = null; throw exception; } </code></pre> <p>But it shows error(UnknownHostException) when we specify port number along with the IP address.</p> <p>Will anyone help me. I need either to set time out for the above method or need to check IP reachable along with port number.</p>
android
[4]
4,378,470
4,378,471
what does this mean: var _gaq = _gaq || [];
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/3088098/in-javascript-what-does-it-mean-when-there-is-a-logical-operator-in-a-variable-d">In Javascript, what does it mean when there is a logical operator in a variable declaration?</a><br> <a href="http://stackoverflow.com/questions/2538252/whats-the-javascript-var-gaq-gaq-for">what&rsquo;s the javascript &ldquo;var _gaq = _gaq || []; &rdquo; for ?</a> </p> </blockquote> <p>what does this javascript syntax mean?</p> <pre><code>var _gaq = _gaq || []; </code></pre>
javascript
[3]
371,309
371,310
Search a file that was created
<p>When I create the file and append to it the rest of the information I now want to have the ability to read the text file then display the Month of a birthday thats listed in the file. I want to be able to pull in just the info by birthday. So if I choose month 11 I want to pull in all the data entries that have a birthmonth of 11 by pushing button4.</p> <p>This is what I have so far;</p> <pre><code> private void close_Click(object sender, EventArgs e) { Close(); } private void button1_Click(object sender, EventArgs e) { writetext(); reset(); } public void writetext() { using (TextWriter writer = File.AppendText("filename.txt")) { writer.WriteLine("First name, {0} Lastname, {1} Phone,{2} Day of birth,{3} Month of Birth{4}", textBox1.Text, textBox2.Text, maskedTextBox1.Text, textBox4.Text, textBox3.Text); MessageBox.Show(String.Format("First Name,{0} Lastname, {1} Phone,{2} Day of birth,{3} Month of Birth{4}", textBox1.Text, textBox2.Text, maskedTextBox1.Text, textBox4.Text, textBox3.Text)); } } public void reset() { textBox1.Text = ""; textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; maskedTextBox1.Text = ""; } private void button3_Click(object sender, EventArgs e) { Close(); } private void button2_Click(object sender, EventArgs e) { readfile(); } private void label7_Click(object sender, EventArgs e) { } private void button4_Click(object sender, EventArgs e) { } public void readfile() { string[] lines = File.ReadAllLines("filename.txt"); label6.Text = String.Join(Environment.NewLine, lines); } } } </code></pre>
c#
[0]
5,427,207
5,427,208
How to give input for the double[] array in Java
<p>How do I give input directly, when that function is invoked in another method, especially when that input is a <code>double[]</code> array?</p> <pre><code>public double dotPro1(double[] vectorA, double[] vectorB) { double[] vecPro; vecPro = new double[2]; vecPro[0] = vectorA[0]*vectorB[0]; vecPro[1] = vectorA[1]*vectorB[1]; return vecPro[0] + vecPro[1]; } public double dotPro2(double[] length) { double[] lenPro; lenPro = new double[1]; lenPro[0] = length[0]; return lenPro[0]; } public static double cosine(double a) { double x = Math.cos(Math.toRadians(a)); /*Class c = Class.forName("NaiveStrategy"); Class methodTypes[] = new Class[3]; methodTypes[0] = Double.TYPE; methodTypes[1] = Double.TYPE; methodTypes[2] = Double.TYPE; Method[] m = c.getMethods();*/ NaiveStrategy ns = new NaiveStrategy(); problem--&gt;ns.dotPro1(vectorA[], vectorB[]); problem--&gt;ns.dotPro2(length[]); return 0; } </code></pre> <p>As you can also see my old coding I tried in another way to solve it, but it didn't worked. It's commented out above.</p>
java
[1]
5,063,476
5,063,477
condition with eval {php}
<pre><code>&lt;?php eval("if (1==1){"); echo ('abc'); eval("}"); ?&gt; </code></pre> <p>Then i get a error : Parse error: parse error in C:\wamp\www\test\index.php(2) : eval()'d code on line 1 abc Parse error: parse error in C:\wamp\www\test\index.php(4) : eval()'d code on line 1<br> How to fix?</p>
php
[2]
5,051,259
5,051,260
Renaming a File
<p>In my application there is a file available that<br> Say <strong>one.pdf</strong>. I want to change the file name as <strong>two.pdf</strong> with in the same directory. <br>i tried using java which doesn't Work. </p> <pre><code>File f1=new File("E:\\one.pdf"); File f2=new File("E:\\two.pdf"); f1.renameTo(f2); </code></pre> <p>thanks.</p>
java
[1]
2,494,916
2,494,917
Build Java application from .net perspective
<p>I have been a .net developer for some time now and recently started using java and eclipse.</p> <p>Up until now i've been executing a little test app by right-clicking in Eclipse and "Run As-> Java Application".</p> <p>Everything works fine until i go to try set this up so i can deploy it to another machine.</p> <p>In .Net, it's easy. All the references will be automatically included in the output folders, so all one has to do is take the entire package and move it to another machine and run from there. </p> <p>Does this happen for java? </p> <p>I've been playing around with javac.exe and it's needing quite a bit of information to get this to build. I'm really just trying to find the equivalent of building the project in debug mode so i can avoid setting up ant configurations. </p> <p>Thanks for the ideas</p>
java
[1]
1,427,831
1,427,832
Cycle through array
<p>Supposing I had an array with 4 elements, and I want to cycle through them until a certain condition is met, what would the best way I would have to do so? My idea would be something like:</p> <pre><code>ArrayList&lt;Player&gt; myList = new ArrayList&lt;Player&gt;(); myList.add(new Player("a")); myList.add(new Player("b")); myList.add(new Player("c")); for(int i = 0; i &lt; 3; i++) { if(isGameOver) break; if(i == 2) i = 0; } </code></pre> <p>But I thought that perhaps there was a more elegant solution...</p>
java
[1]
3,816,104
3,816,105
How can I calculate at compiletime in c++
<p>How to calculate some mathematical expression i.e. finding factorial of n; during compiletime in c++ ?</p>
c++
[6]
192,357
192,358
Impersonation in ASP.NET 2.0
<p>Good Day,</p> <p>My web app is set to use Windows Authentication and Impersontation is set to true.</p> <p>I wan't to launch a process using the logged-in user account. However, when I tried to launch notepad.exe, it was run as a NETWORK SERVICE.</p> <p>I've tried different impersonation techniques, but none of them worked.</p> <p>Please help.</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms998351.aspx#paght000023%5Fimpersonatingbyusingwindowsidentity" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms998351.aspx#paght000023_impersonatingbyusingwindowsidentity</a></p>
asp.net
[9]
581,323
581,324
how to prevent multiple clicks on an executable jar
<p>I have an executable jar that runs a Java Swing application with an internal SqlLite db. Users (by mistake) do more than a click on the jar, causing the db lock. I'd like to prevent this behavior. What can I do? thank you very much</p>
java
[1]
1,621,316
1,621,317
How to Map Paths in ASP.NET Non-Form Class File
<p>I've been using the following code in my Web form code-behind classes. I want to use it in my regular .cs files: for example, when making database calls. But when I try to use it outside of a Web form I get the following error when attempting to map with base.Request.ApplicationPath: 'object' does not contain a definition for 'Request'. What would be the simple, correct way to map to the root in a regular .cs class file in a Web Application Project?</p> <pre><code> protected void LogError(string errMsg, string errTrace) { string mailSubject = "oops!"; string mailBody = errMsg + errTrace; System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath); AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings"); // Extract values from the web.config file string toAddress = "me@gmail.com"; string fromAddress = appSettings.Settings["FromEmailAddr"].Value; string emailHost = appSettings.Settings["EmailHost"].Value; mailProvider.SendMail(fromAddress, toAddress, mailSubject, mailBody.ToString()); } </code></pre>
asp.net
[9]
838,873
838,874
Implement the strcmp(str1, str2) function in c#
<p>I have the following homework problem:</p> <blockquote> <p>There are many ways one can implement the strcmp() function.<br> Note that strcmp(str1,str2) returns a negative number if str1 is alphabetically above str2, 0 if both are equal and postiveve if str2 is alphabetically above str1.</p> <p>In it can be implemented in C as follows: </p> </blockquote> <pre><code>int mystrcmp(const char *s1, const char *s2) { while (*s1==*s2) { if(*s1=='\0') return(0); s1++; s2++; } return(*s1-*s2); } </code></pre> <p>So now I want to implement it in C# without using any of the built in methods of .NET. How can I accomplish this?</p>
c#
[0]
3,000,126
3,000,127
python first web application - where
<p>I am rookie in python - have experience in PHP</p> <p>my service provider (Bluehost) say that python 2.6 is available, however I am not able to run any script (basic hello word) on it - probably because I try do it PHP way. create a script.php file and place the link to it in browser... :)</p> <p>Where I can find explanation for dummy like me what I should do with file script.py (hello world inside) in order to be executed and displayed in browser, I am guessing that compilation could be required </p> <p>thank you</p> <p>Bensiu</p>
python
[7]
3,441,080
3,441,081
How to pass a class instance dynamically?
<p>What is wrong with the following android java code</p> <pre><code>Class&lt;?&gt; c = Class.forName(PACKAGENAME+"."+className); Constructor&lt;?&gt; cons = c.getConstructor(String.class); Object object = cons.newInstance(result); </code></pre> <p>i want it to call a constructor of one parameter. </p>
java
[1]
5,611,684
5,611,685
Is there a function like "bcadd" except it performs multiplication?
<p>I'm hoping to do some math operations on numbers being represented as strings. So far, I haven't found anything that could do multiplication.</p> <p>Thanks!</p>
php
[2]
5,964,886
5,964,887
setTimeout() doesn't allow me to pass text values
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1190642/how-can-i-pass-a-parameter-to-a-settimeout-callback">How can I pass a parameter to a setTimeout() callback?</a><br> <a href="http://stackoverflow.com/questions/6081560/is-there-ever-a-good-reason-to-pass-a-string-to-settimeout">Is there ever a good reason to pass a string to setTimeout?</a> </p> </blockquote> <p>I want to call a function <code>loadPHPQuote(code)</code> after 1 second. And want to pass the parameter called <strong>code</strong> which is containing both numbers and text characters. But <code>setTimeout()</code> wasn't work if the code contain a character it is OK with only numbers. </p> <p>Here is my code </p> <pre><code>setTimeout('loadPHPQuote('+code+')',1000); </code></pre> <p>Is there anyone who can help me with this please.....?</p>
javascript
[3]
3,959,837
3,959,838
show timer in label
<p>As in most games i hv seen the timer in a format "01:05"</p> <p>I m trying to implement a timer, and on reset i need to reset the timer to "00:00".</p> <p>This timer value should be in label.</p> <p>How to create a timer which is incrementing? like 00:00---00:01---00:02..........somthing like dat.</p> <p>suggestions</p> <p>regards</p>
iphone
[8]
1,777,694
1,777,695
jquery to change image src of current row only
<p>I have a table with multiple rows that all have the same class. When an image is clicked, there's a db call then returning json. I have everything working correctly but when I click the image, ALL in the table change. I would only like the current row image to be affected.</p> <p>Example Table:</p> <pre><code>&lt;tr class="changerow"&gt; &lt;td&gt;&lt;a href="" class="hide"&gt;&lt;img src="image.png" class="someimage" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="" class="hide"&gt;&lt;img src="image.png" class="someimage" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="" class="hide"&gt;&lt;img src="image.png" class="someimage" /&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Jquery:</p> <pre><code>$('.hide').live('click',function(){ var row=$(this); $('.someimage').attr("src","newimage.png"); }); </code></pre> <p>So, I know I need to somehow identify the current row and create the variable "row". Not exactly sure how to do this. Was thinking using row.parents('.changerow') or something like that. Help please :) Thanks!</p>
jquery
[5]
297,258
297,259
How to force close my Android application?
<p>Well apparently my android application doesnt close when I finish the activity so it there a way to force close it including any activity in my app that could be opened?</p>
android
[4]
5,845,422
5,845,423
reuse function logic in a const expression
<p>I think my question is, is there anyway to emulate the behaviour that we'll gain from C++0x's <code>constexpr</code> keyword with the current C++ standard (that is if I understand what <code>constexpr</code> is supposed to do correctly).</p> <p>To be more clear, there are times when it is useful to calculate a value at compile time but it is also useful to be able to calculate it at runtime too, for e.g. if we want to calculate powers, we could use the code below.</p> <pre><code>template&lt;int X, unsigned int Y&gt; struct xPowerY_const { static const int value = X*xPowerY_const&lt;X,Y-1&gt;::value; }; template&lt;int X&gt; struct xPowerY_const&lt;X, 1&gt; { static const int value = X; }; int xPowerY(int x, unsigned int y) { return (y==1) ? x : x*xPowerY(x,y-1); } </code></pre> <p>This is a simple example but in more complicated cases being able to reuse the code would be helpful. Even if, for runtime performance, the recursive nature of the function is suboptimal and a better algorithm could be devised it would be useful for testing the logic if the templated version could be expressed in a function, as I can't see a reasonable method of testing the validity of the constant template method in a wide range of cases (although perhaps there is one and i just can't see it, and perhaps that's another question).</p> <p>Thanks.</p> <p><strong>Edit</strong> Forgot to mention, I don't want to <code>#define</code></p> <p><strong>Edit2</strong> Also my code above is wrong, it doesn't deal with x^0, but that doesn't affect the question.</p>
c++
[6]
4,930,525
4,930,526
Tabletool Icon Removes Select entries from toolbar
<p>Hi I am using below code to display tabletool in datatable, everythings work perfectly but tabletool icons remove Select entry icon, any idea how can i display both in same div.</p> <pre><code> $(document).ready(function () { $('#tblOscarNominees').dataTable({ "bJQueryUI": true, "sPaginationType": "full_numbers", "sDom": '&lt;"H"Tfr&gt;t&lt;"F"ip&gt;', "oTableTools": { "sSwfPath": "../DataTables/media/swf/copy_csv_xls_pdf.swf" } }); </code></pre> <p>Thanks in advance</p>
asp.net
[9]
704,059
704,060
Question about focus and activites on Android
<p>I have a chat application here that uses a handler and a runnable to frequently poll for updates. On receiving an update as HTML, it adds this content to the TextView in the main activity.</p> <p>Now, I've noticed that when the activity loses focus and I use other applications/view the home screen, the runnable keeps going on and when I re-open the application, I see the TextView with the updated content.</p> <p>Is this considered unsafe and should I build a service to do this, or is it fine to modify the UI when it's unfocused like that?</p>
android
[4]
455,281
455,282
jQuery backgroundPostion and animate can't only get the Y
<p>I have a problem. I have this 3060 px wide image as my background-image, and when I press a menu link I want to 'slide' the background to the right or left, but when I'm doing this I can only get it to use the X. If I use backgroundPositionX, it doesn't do anything. When I use backgroundPosition, though, I can only provide 1 parameter. And I only want to do something to the X side not the Y.</p> <p>The code I have at the moment sets the Y to 50% automatically, and this is not wanted.</p> <pre><code> function move(space) { image = 3060; bodyWidth = $('body').width(); offset = 900 * space; if(image - offset &lt; bodyWidth) offset = image - bodyWidth - 15; console.log(offset); console.log(bodyWidth); $('body').animate({ backgroundPosition: -offset }, 5000, function() { console.log("animate complete"); }); //$('body').css('backgroundPosition', '-'+offset+'px 0px'); } </code></pre>
jquery
[5]
4,534,346
4,534,347
Handling different datatypes in a single structure
<p>I need to send some information on a VxWorks message queue. The information to be sent is decided at runtime and may be of different data types. I am using a structure for this - </p> <pre><code>struct structData { char m_chType; // variable to indicate the data type - long, float or string long m_lData; // variable to hold long value float m_fData; // variable to hold float value string m_strData; // variable to hold string value }; </code></pre> <p>I am currently sending an array of structData over the message queue. </p> <pre><code>structData arrStruct[MAX_SIZE]; </code></pre> <p>The problem here is that only one variable in the structure is useful at a time, the other two are useless. The message queue is therefore unneccessarily overloaded. I can't use unions because the datatype and the value are required. I tried using templates, but it doesn't solve the problem.I can only send an array of structures of one datatype at a time.</p> <pre><code>template &lt;typename T&gt; struct structData { char m_chType; T m_Data; } structData&lt;int&gt; arrStruct[MAX_SIZE]; </code></pre> <p>Is there a standard way to hold such information?</p>
c++
[6]
4,611,912
4,611,913
Is it possible to do all these on an Android phone?
<p>I am wondering is it possible to do all these on an Android phone? Example, Samsung Galaxy S phone</p> <ol> <li>To automatically launch a video clip upon phone start up i.e. from off position or phone ‘reboot’/’restart’</li> <li>To run the video clip while the phone is idling</li> <li>To launch to a particular wap site when interrupted</li> <li>To restrict user from going to other portal other than the 3 steps above</li> <li>To restrict user from running other application on the phone.</li> </ol>
android
[4]
3,451,824
3,451,825
Change the name of the radiobutton in the gridview while render
<p>After render group name comes in the name attribute with different name for each radiobutton in the gridview.</p> <p>I tried to set all the names as same. But when we see the source in the browser it is unique.</p> <p>How to change the name for all the radiobutton in the gridview as same.</p> <pre><code>protected override void Render(HtmlTextWriter writer) { System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); base.Render(htw); htw.Close(); string h = sw.ToString(); RadioButton first = (RadioButton)gvAddOption.Rows[0].Cells[3].FindControl("rblValue"); string uniqGroupName = first.UniqueID; uniqGroupName = uniqGroupName.Replace(first.ID, first.GroupName); foreach (GridViewRow row in gvAddOption.Rows) { RadioButton val = (RadioButton)row.Cells[3].FindControl("rblValue"); string eachGroupName = val.UniqueID; eachGroupName = eachGroupName.Replace(val.ID, val.GroupName); //h.Replace("name=\"" + eachGroupName + "\"", "name=\"" + uniqGroupName + "\""); h.Replace(eachGroupName, uniqGroupName); } writer.Write(h); } </code></pre> <p>Thanks.</p>
asp.net
[9]
2,000,859
2,000,860
Clearing value before submitting form (not canceling submit)
<p>I want to clear my default value in two input fields before submitting them. But this don’t work…</p> <pre><code>&lt;form action="page.html" id="myForm"&gt; &lt;input type="text" value="Firstname" name="firstname" id="firstname"&gt; &lt;input type="text" value="Lastname" name="lastname" id="lastname"&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;script&gt; $(document).ready(function() { $("myForm").submit(function() { if($('#firstname').val() == "Firstname") $('#firstname').val() = ""; if($('#lastname').val() == "Lastname") $('#lastname').val() = ""; return true; }); }); &lt;/script&gt; </code></pre> <p>I don’t want to clear them both on focus. I cant use html5.</p>
jquery
[5]
3,198,869
3,198,870
SendInput putting the system to sleep
<p>I'm trying to figure out the proper use of the SendInput function so I can directly manipulate the cursor on the screen, so for a basic test to see how things work, I made this short snippet that should move the cursor 10 pixels to the right. In theory.</p> <pre><code>#include &lt;windows.h&gt; #include &lt;winable.h&gt; int main() { INPUT joyInput; joyInput.type = INPUT_MOUSE; joyInput.mi.dx = 10; joyInput.mi.dwFlags = MOUSEEVENTF_MOVE; SendInput(1, &amp;joyInput, sizeof(INPUT)); return 0; } </code></pre> <p>However, in practice, the SendInput function is either putting my computer to sleep, or at least shutting off my monitors, which is certainly an unwanted effect! Commenting out that line prevents the issue from happening, but obviously I need it to perform the task. What am I doing wrong? </p>
c++
[6]
3,927,426
3,927,427
Changes being made to an object in Java
<p>I have created a Compound class that holds the number of Carbon, Hydrogen, Oxygen, Nitrogen and it's bond count. I have a stack that holds these objects. </p> <p>Initially the stack will start off at empty and I will pop that. Then I will apply addHydrogen function to it so it's Hydrogen will = 1, Oxygen=0, Nitrogen=0 and Carbon=0. </p> <p>I then want to take the same object and apply the addCarbon function so that Hydogren will = 0, Oxygen=0, Nitrogren=0 and Carbon=1. </p> <p>How can I write my program so I can use the same object but not with the changes I made from adding the Hydrogen? I know I could use some if cases initially but I don't think it will work because I will eventually start with a compound that has hydrogen=2, oxygen=2, Nitrogren=0, Carbon=1.</p> <p>*I didn't include my constructors in the code, they just initialize everything to 0. </p> <pre><code>class compound { int Hydrogen; int Carbon; int Nitrogen; int Oxygen; int bond; public void addHydrogen(compound comp) { Hydrogen++; } public void addCarbon(compound comp) { Carbon++; } } public static void main(String[] args) { Compound a= new Compound(); a.addHydrogen(a); a.addCarbon(a); } </code></pre>
java
[1]
2,065,072
2,065,073
How to get the Information of the Music track playing on a android device?
<p>I want to get the Information of the Music track playing on a android device? Is there any android powered api available for this?</p> <p>Or do I have to write a plugin for respective android media players?</p>
android
[4]
5,121,691
5,121,692
jquery set value of div
<p>I have this div:</p> <pre><code> &lt;div style="height:100px; width:100px" class="total-title"&gt; first text &lt;/div&gt; </code></pre> <p>and I have a jquery statement to change its value:</p> <pre><code> $('div.total-title').html('test'); </code></pre> <p>But it doesn't work.</p>
jquery
[5]
3,934,207
3,934,208
Pointer to function won't compile
<pre><code>//mediafactory.h class MediaFactory{ public: typedef Media* (*funPointer)(); funPointer somePointer; } //mediafactory.cpp Media* MediaFactory::returnMedia(){ } </code></pre> <p>when I try to do</p> <pre><code>somePointer = returnMedia; </code></pre> <p>I get this error:</p> <pre><code>1 IntelliSense: a value of type "Media *(MediaFactory::*)()" cannot be assigned to an entity of type "MediaFactory::funPointer" c:\Users\...\mediafactory.cpp 37 </code></pre> <p>However, if i change the function to the code below, it will compile and work</p> <pre><code>Media* returnMedia(){ //without scope } </code></pre>
c++
[6]
2,760,768
2,760,769
Javascript contains statement
<p>I'm trying check a field in a database to see if it does not contain either "UK_CONTACTS or a blank. If it is either of these conditions I want to copy the that field to another field. I am very very new at this and have come up with the following and have written in text "does not contain" as I don't know the correct syntax for javascript.</p> <pre><code>function getdbasename(){ var dbasedata = document.forms[0]._dbase_name.value; } If (dbasedata does not contain "UK_CONTACTS" || dbasedata does not contain " ") { _area.value = _dbase_name.value; } </code></pre> <p>Probably miles out but it's my best shot.</p>
javascript
[3]
3,805,879
3,805,880
character counter in 2D array
<p>I tried to create a 2D array and place four <code>X</code> in the same column. I created a loop for detecting and counting the number of <code>X</code>s but it doesn't work.</p> <pre><code> var creatematrix = function (nbRang, nbColumn) { var result = Array(nbRang); for (var i=0; i&lt;nbRang; i++) { result[i] = Array(nbColumn); } return result; }; var m = creatematrix(2, 6); m[1][2] = "X"; m[1][3] = "X"; m[1][4] = "X"; m[1][5] = "X"; var sumX = 0 for(var k = 0; k &lt; 6 ; k++){ if(m[1][k]== "X"){ sumX += 1; }else if(sumX == 4){ alert("player won"); } } </code></pre>
javascript
[3]
4,489,626
4,489,627
How do I iterate over a Python dictionary, ordered by values?
<p>I've got a dictionary like:</p> <pre><code>{ 'a': 6, 'b': 1, 'c': 2 } </code></pre> <p>I'd like to iterate over it <em>by value</em>, not by key. In other words:</p> <pre><code>(b, 1) (c, 2) (a, 6) </code></pre> <p>What's the most straightforward way?</p>
python
[7]
5,382,683
5,382,684
How to disable/enable all children on LinearLayout in Android
<p>Is there way by programming that all the children of a certain layout? </p> <p>For example i have this layout with two children: </p> <pre><code>&lt;LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout1" android:layout_width="fill_parent"&gt; &lt;SeekBar android:layout_height="wrap_content" android:id="@+id/seekBar1" android:layout_weight="1" android:layout_width="fill_parent"&gt;&lt;/SeekBar&gt; &lt;TextView android:id="@+id/textView2" android:text="TextView" android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_height="wrap_content"&gt;&lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>and i want to do something like:</p> <pre><code>LinearLayout myLayout = (LinearLayout) findViewById(R.id.linearLayout1); myLayout.setEnabled(false); </code></pre> <p>In order to disable the two textviews.</p> <p>Any idea how?</p>
android
[4]