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
4,795,427
4,795,428
The name 'grdViewPersonnel' does not exist in the current context
<p>I'm getting this error: The name 'grdViewPersonnel' does not exist in the current context</p> <pre><code>public partial class frmViewPersonnel : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // Declare the DataSet dsPersonnel myDataSet = new dsPersonnel(); // Fill the dataset with what is returned from the function myDataSet = clsDataLayer.GetPersonnel(Server.MapPath("PayrollSystem_DB.mdb")); // Set the DataGrid to the DataSource based on the table grdViewPersonnel.DataSource = myDataSet.Tables["tblPersonnel"]; // Bind the DataGrid grdViewPersonnel.DataBind(); } } } </code></pre>
c#
[0]
4,619,173
4,619,174
read XML using LINQ
<p>I am newbie to LINQ. I am trying to read the following node and element values from XML using LINQ. </p> <p>DATA -- msgid and msgtime PTP -- percentage CONT1 -- get "url" value if the "type" = "RIGHT"</p> <p>Please let me know.</p> <pre><code>&lt;DATA msgid="02123" msgtime="2008-02-29 15:30:02.123"&gt; &lt;PTP number="67" pert="READ" percentage="95" pertime="2008-02-29 15:30:02.123"&gt; &lt;Images&gt; &lt;Image view="w1" type="IMAGE" percentage="85" distance="0" url="00002_tyd.jpg" /&gt; &lt;/Images&gt; &lt;/PTP&gt; &lt;CHAS1 sequence="1" number="58019" percentage="95" pertime="2008-02-29 15:30:02.123"&gt; &lt;Images&gt; &lt;Image view="c1" type="WRONG" percentage="85" url="00002_ssj.jpg" /&gt; &lt;Image view="c2" type="RIGHT" percentage="85" url="00003_ssj.jpg" /&gt; &lt;/Images&gt; &lt;CONT1 number="58011" percentage="95" pertime="2008-02-29 15:30:02.123"&gt; &lt;Images&gt; &lt;Image view="c1" type="WRONG" percentage="85" url="00002_csj.jpg" /&gt; &lt;Image view="c2" type="RIGHT" percentage="85" url="00003_csj.jpg" /&gt; &lt;/Images&gt; &lt;/CONT1&gt; &lt;/CHAS1&gt; &lt;/DATA&gt; </code></pre>
c#
[0]
2,703,436
2,703,437
5 Different Times in PHP
<p>I need to have 5 vars like this:</p> <pre><code>$time1 = "The time now -5 minutes"; $time2 = "The time now -10 minutes"; $time3 = "The time now -20 minutes"; $time4 = "The time now -30 minutes"; $time5 = "The time now -40 minutes"; </code></pre> <p>So assuming it's 9 AM, $time1 should be "8:55 AM"</p> <p>It would be so great if anyone could help me out with this :)</p> <p>Thanks in advance for every hint,</p> <p>Camillo</p>
php
[2]
1,108,277
1,108,278
we should have the ability to add/remove/hide columns on listing page
<p>in php,there is a simple listing page.in listing page we can not display all the columns from database.i want to give functionality of add/remove/hide columns.</p>
php
[2]
592,539
592,540
Cannot call method 'reload' of undefined jQuery error
<p>My jQuery keeps chucking this error up - 'Cannot call method 'reload' of undefined'. </p> <p>I basically want the parent page to reload after 8 Seconds (this is synced to refresh once the colorbox closes)</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $('#success').trigger('click'); }); var t=setTimeout(parent.$.fn.colorbox.close,8000); var s=setTimeout(parent.location.reload(),8000); &lt;/script&gt; </code></pre> <p>Many thanks in advance.</p>
jquery
[5]
695,085
695,086
C++ null string
<p>I have a function in a C++ program returning a <code>string</code>. On certain conditions, e.g. if the function encounters an error or so, I want to return a special value telling the caller that something has gone wrong.</p> <p>I could basically just return an empty string <code>""</code>, but the function does need the empty string as normal return value.</p> <ul> <li>How can I accomplish this?</li> <li>Do I have do create a special data structure that for my function that holds a bool if the function was successfully run and a string containing the actual return value?</li> </ul>
c++
[6]
1,456,318
1,456,319
How can I format Java code in word document
<p>I need to write a report which may contain some Java code pieces. I need the code to appear colored and line numbered. How can I do this ?</p>
java
[1]
2,588,444
2,588,445
Error with class
<p>I have a webview which has this class as webviewclient. This is to make links to pages open in the webview, and links to downloadable files open with the default browser. Here it is:</p> <pre><code>class LinkWebView extends WebViewClient { public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("/WS/") | url.contains("/Francesco/") | url.contains("/Gabriele/")) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); ClubCiprianisActivity cca = new ClubCiprianisActivity(); cca.comincia(intent); } catch (Exception ex) { ClubCiprianisActivity cca = new ClubCiprianisActivity(); cca.tostizza(ex.getMessage()); } } else { view.loadUrl(url); } return true; } </code></pre> <p>}</p> <p>this webview will load only urls from a specific website so the conditional to choose wheter to open the link in the webview or in the default browser is correct for that website.</p> <p>ClubCiprianisActivity is the only activity shown in my application, with the webview and all the rest.</p> <p>method comincia of ClubCiprianisActivity is this:</p> <pre><code>public void comincia(Intent intent) { startActivity(intent); } </code></pre> <p>I had to make it because Eclipse doesn't recognize the method startActivity in the webviewclient class. tostizza is just showing a Toast because I can't do that either in the webviewclient class. My problem is that when I open al link to a webpage it opens normally, but when I try to open a downloadable link, going into the shouldoverride... I get an error.</p>
android
[4]
3,181,667
3,181,668
Android: Preference default Value
<p>I have a problem. I have 3 - 4 Activities. One of those is main and a second one is Preference Screen. I have a preference screen with different Preferences like ListPreference etc that have default values. How can i activate default Value of Settings when I start my project ? Because they activated only when I start Settings Activity. Shortly: I need to use default value in main activity without passing Settings Activity.</p>
android
[4]
4,333,453
4,333,454
python re string starting with
<p>In the following string how to say that the line is starting with a digit or ending with a number or many</p> <pre><code>line="He is a German called Mayer12345" re.compile(r".*\d+\w$") line="12He is a German called Mayer" re.compile(r"^\d+\w .*") </code></pre>
python
[7]
3,716,717
3,716,718
How to replace carriage return
<p>I have a variable (<code>$myClass[0]-&gt;comment;</code>) that has carriage return in it. I want to replace all the carriage return in that variable with "<code>\n</code>" how can I do that.<br> below may help a bit </p> <pre><code>$myClass[0]-&gt;comment; </code></pre> <p>Here is some output </p> <pre><code>&lt;?php $test = explode(chr(13),$myClass[0]-&gt;comment ); var_dump($test); ?&gt; </code></pre> <p>OUTPUT </p> <pre><code>array 0 =&gt; string '12' (length=2) 1 =&gt; string ' ' (length=1) 2 =&gt; string ' 22' (length=3) </code></pre> <p>All I want is <code>\n</code> instead of carriage return.</p>
php
[2]
5,423,187
5,423,188
function calls between classes
<p>Can anyone please tell me what r we actually meaning by the following statement (I encountered it in one of my tutorials)</p> <pre><code>String s1 = Utilities.gets1(UtilityConstants.MY_SEVICE_NAME); </code></pre> <p>I have found that <code>Utilities.java</code> , <code>UtilityConstants.java</code> files do exist in the project.</p> <p>I know with this vague little information it is difficult for you to convey the proper meaning.</p> <p>But can you please make clear what sort of call is that?</p>
java
[1]
98,205
98,206
Spreadsheet_Excel_Writer get file content
<p>I need to attach an XLS-file to e-mail via PHP. The Problem is - <code>Spreadsheet_Excel_Writer</code> send a HTTP Header to a browser an then the content. <code>Spreadsheet_Excel_Writer</code> API has no any functions like <code>get_content</code> to become the file content directly. I don't want to save the file first, I just want to jump this step over, saving the content directly as attachment. Any ideas?</p> <p>Thx a lot.</p>
php
[2]
792,407
792,408
Deleting Symbolic Links in PHP
<p>What is the proper way to delete symbolic links, preserving what they link to? What is the proper way to delete what they link to? Which would <a href="http://php.net/manual/en/function.unlink.php" rel="nofollow">unlink</a> do? There seems to be some <a href="https://bugs.php.net/bug.php?id=52176" rel="nofollow">ambiguity</a>.</p> <p>Through a little testing, symbolic links respond to <a href="http://php.net/manual/en/function.is-file.php" rel="nofollow">is_file</a> and <a href="http://php.net/manual/en/function.is-dir.php" rel="nofollow">is_dir</a> according to what they point to, as well as returning <code>true</code> to <a href="http://php.net/manual/en/function.is-link.php" rel="nofollow">is_link</a>.</p>
php
[2]
220,530
220,531
already an open DataReader associated with this Command which must be closed first
<p>when i am trying to execute the code it is showing the above error.</p> <pre><code>try { com.CommandText = "select * from Export"; com.ExecuteReader(); data_mode = "Export"; com.CommandText = "Insert INTO [" + New_access_file + "]." + data_mode + " select * FROM ExportDATA"; com.ExecuteNonQuery(); } catch { data_mode = "Export"; com.CommandText = "SELECT * INTO [" + New_access_file + "]." + data_mode + " FROM ExportDATA"; com.ExecuteReader(); } </code></pre>
c#
[0]
4,585,476
4,585,477
How do I get a list of all the assemblies I can reference on my machine?
<p>To add a new .NET reference to your project in Visual Studio you just click "Add reference..." on References of the current project, switch to the ".NET" tab and go for it.</p> <p>Now, is there a way to get this list programmatically?</p>
c#
[0]
137,246
137,247
Java Reflection List Iterate
<pre><code>private static Void createTbody(List object) { Iterator hritr = object.iterator(); while(hritr.hasNext()) { UserDto users = (UserDto)hritr.next(); users.userId; users.userName; } } </code></pre> <p>DtoClass::</p> <p>UserDto</p> <pre><code>public class UserDto { public String userName; public String userId; } </code></pre> <p>In the above code i dont have any problem...</p> <p>put in my <code>createTbody</code> function i dont know the <code>UserDto</code> Class at compile time...It should dynamic class.This class name i will get through reflection.</p> <pre><code>UserDto users = (UserDto)hritr.next(); </code></pre> <p>Why because is, <code>private static Void createTbody(List object)</code> object may contain List of <code>CustomerDto</code>,<code>UserDto</code>etc...</p>
java
[1]
2,351,422
2,351,423
checking jquery slideup status?
<p>I'm just curious if I should check the current status of my div tag before I call the slideup method. Here is what I'm currently calling:</p> <pre><code> if(parseInt(msg.status)==1) { window.location=msg.txt; } else if(parseInt(msg.status)==0) { // Is it an issue that by default I first call the slideup method // regardless of it's state? $('#notify').slideUp('fast', function() { $('#notify').html(msg.txt).slideDown(); }); } </code></pre> <p>Everything works fine, but I was just curious if this is "bad" practice or not.</p>
jquery
[5]
1,045,858
1,045,859
How to call android application from javascript
<p>I want to call android application from JavaScript.</p>
android
[4]
4,892,897
4,892,898
Syntax error caused by <%@ Page Language="c#"%> ? ASP.Net
<p>Is this invalid to put in an aspx file? I have some static aspx pages and I want to add a bit of C# to one of them. How can I do this?</p> <p>I figured just adding </p> <pre><code>&lt;%@ Page Language="c#"%&gt; </code></pre> <p>and then using &lt;% %> to put a bit of C# goodness in there, but it says Syntax Error. with a blue wavy line over this code.</p>
asp.net
[9]
4,274,514
4,274,515
Extract List of object from another List of objects
<p>I have a <code>List&lt;User&gt; users</code>, where class<code>User</code> has one property <code>username</code>. I also have another<code>List&lt;User&gt; activeUsers</code>. Let <code>users = activeUsers + inactiveUsers</code>. Now I want to extract <code>inactiveUsers</code> from <code>users</code> based on <code>username</code> property. I solved this problem using two for-loops. I think this is not efficient way. so if anyone know how it can be done efficiently please let me know.</p> <p>e.g. I have activeUsers[1,3] and users[1,2,3,4] and want to build inactiveUsers[2,4].</p>
java
[1]
4,113,964
4,113,965
Using jQuery to find the number of TR elements in a given table
<p>I have seen several examples on how to find children, etc but for some reason I can't get this one right ... any help from the SO community?</p> <p>The below is my current "attempt" in code --</p> <p>var trCount = $("#table > tr").size();</p>
jquery
[5]
3,568,685
3,568,686
Java String to int binary number conversion
<p>I'm trying to convert Strings of user input into int. No problem with that, i'm using the following code:</p> <pre><code>c = sc.next(); while(!c.contains("#")){ i = Integer.parseInt(c); input.add(c); c= sc.next(); } </code></pre> <p>(this is just the part of the code that does the conversion, the scanner part is working)</p> <p>The only problem is that the input are binary numbers, so when the input is, for example "00111", the convert gives me "111" and i can't lose those 0's. How can i convert the user input into the number without losing the zeros to the left?</p>
java
[1]
4,015,938
4,015,939
Java - Heap memory
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/1596009/java-lang-outofmemoryerror-java-heap-space">java.lang.OutOfMemoryError: Java heap space</a><br> <a href="http://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap-s">How to deal with &ldquo;java.lang.OutOfMemoryError: Java heap space&rdquo; error (64MB heap size)</a> </p> </blockquote> <p>Could you please tell me how could I increase the java internal heap memory?</p>
java
[1]
4,073,188
4,073,189
SFTP implementation in C++ for Windows Platform
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/360259/sftp-c-library">SFTP C++ library?</a> </p> </blockquote> <p>Hi Everyone, Presently i am using FTP for server side file transfer, but due to requirement now i have to implement SFTP instead of FTP in windows platform using C++ Language. Can anyone help me out??</p>
c++
[6]
895,845
895,846
Skip age checks for html parsing
<p>I'm using something like this:</p> <pre><code>HttpClient client = new DefaultHttpClient(); HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); InputStream in = response.getEntity().getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line = null; while ((line = reader.readLine()) != null) { str.append(line); } </code></pre> <p>to get the source code of particular website. My problem is that some pages have age checking, is there anyway to bypass this? or inject javascript code?</p> <p>Thank you</p>
android
[4]
5,837,355
5,837,356
Package naming uniqueness for applications?
<p>When creating an android app, we need to supply a package name in the manifest.</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.me.foo"&gt; </code></pre> <p>I believe this uniquely identifies an application, such that we can't upload an app to marketplace if another app already exists with the same package name.</p> <p>Is it possible to extend a package name though without collision? For example:</p> <pre><code>package="com.me.foo" package="com.me.foo.grok" </code></pre> <p>Will the second application be accepted by the marketplace, even though it's a substring of the first package name? </p> <p>Thanks</p>
android
[4]
1,077,071
1,077,072
how to remove a button dynamically in C#?
<p>i have added a <code>button</code> and number of <code>textBox</code> dynamically in my C# winform app. how can i remove them dynamically? specially if i have number of same controls?</p>
c#
[0]
2,599,457
2,599,458
How to set single image and use to all the android devices?
<p>I have to use a image in the top of my app as header image and the orientation is set horizontal as fix, as a newbie the problem that m facing is that I have to run the app to all major devices (240x320, 320x480, 480x800, 600x1024, 720x1280, 800x1280). So how can I fix? Any help will really be appreciated. Thanks</p>
android
[4]
3,242,272
3,242,273
getIntent() and subclass of Intent
<p>I wrote a class MyIntent which extends Intent. and then i use an instance of MyIntent to invoke startActivity(MyIntent).</p> <pre><code>MyIntent i=new MyIntent(this,NewActivity.class); </code></pre> <p>the constructor is:</p> <pre><code>public MyIntent(Context context,Class&lt;?&gt; cls){ super(context,cls); putExtra(var1,var2); //other codes ((Activity)context).startActivity(this); } </code></pre> <p>however,when i call getIntent() in the new started activity the returned value of getIntent() is an Intent not MyIntent,that is</p> <pre><code>getIntent() instanceof Intent // true; getIntent() instanceof MyIntent // false; </code></pre> <p>when i try (MyIntent)getIntent() the system throws me ClassCastException.How so? </p>
android
[4]
4,716,887
4,716,888
Python map function, passing by reference/value?
<p>I have a question about the <code>map</code> function in Python.</p> <p>From what I understand, the function does not mutate the list it's operating on, but rather create a new one and return it. Is this correct ?</p> <p>Additionally, I have the following piece of code</p> <pre><code>def reflect(p,dir): if(dir == 'X'): func = lambda (a,b) : (a * -1, b) else: func = lambda (a,b) : (a, b * -1) p = map(func,p) print 'got', p </code></pre> <p><code>points</code> is an array of tuples such as: <code>[(1, 1), (-1, 1), (-1, -1), (1, -1)]</code></p> <p>If I call the above function in such a manner:</p> <pre><code>print points reflect(points,'X') print points </code></pre> <p>the list <code>points</code> does not change. Inside the function though, the print function properly prints what I want.</p> <p>Could someone maybe point me in some direction where I could learn how all this passing by value / reference etc works in python, and how I could fix the above ? Or maybe I'm trying too hard to emulate Haskell in python...</p> <p>Thanks</p> <p>edit:</p> <p>Say instead of <code>p = map(func,p)</code> I do </p> <pre><code>for i in range(len(p)): p[i] = func(p[i]) </code></pre> <p>The value of the list is updated outside of the function, as if working by reference. Ugh, hope this is clear :S</p>
python
[7]
1,302,548
1,302,549
Using interfaces in java..Newb question
<p>Suppose there in an interface Displaceable and a class Circle which implements Displaceable. Displaceable has a method named move() which of course is implemented in Circle.</p> <p>What would happen in the following scenario?</p> <pre><code>Circle a = new Circle(..); Displaceable b = a; b.move() </code></pre> <p>Would the object refer to the Circle's move method?</p>
java
[1]
2,857,400
2,857,401
Changing string daily
<p>I am making a daily Bible verse widget. I am working on making a string array with 236 different verses. I need the app to change the verse daily. I actually wanted to start on the string named 1 and go down the list in order. Is this possible or do I need to randomly call the strings?</p>
android
[4]
2,150,335
2,150,336
Check is textview is ellipsize in android
<p>I have <code>TextView</code> with width as <code>wrap content</code>. In this <code>TextView</code> I set text, but text is not of the same length every time. When text is very long I use single line true and <code>ellipsize</code>: end. But now I have a problem. I want to set Visibility of other layout but that depends on the length my text. If text is too long to fit in the screen I want to setVisible true, but when text is short and when I don't need ellipsize, I want to set visibility false. So I need to check status of my TextView. When its ellipsize I want to <code>setVisible</code> true, when its not <code>setVisible</code> false. How I can do that. This is what I got:</p> <pre><code>tvAle.post(new Runnable() { @Override public void run() { int lineCount = tvAle.getLineCount(); Paint paint = new Paint(); paint.setTextSize(tvAle.getTextSize()); final float size = paint.measureText(tvAle.getText().toString()); Log.v("a", ""+size+" "+tvAle.getWidth()); if ((int)size &gt; (tvAle.getWidth()+10)) { allergiesLayout.setVisibility(View.VISIBLE); } else allergiesLayout.setVisibility(View.GONE); } </code></pre> <p>but this solution doesn't work.</p>
android
[4]
3,346,452
3,346,453
Should we strictly adhere set/get rule
<p>When I have a public exposed class, I usually make its member variables private, together with public accessors and mutators (I try to avoid mutators if possible to make my class immutable). </p> <p>For example, </p> <pre><code>public class Point { private final int x; private final int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getX() { return x; } public int getY() { return y; } } </code></pre> <p>If the class is for private usage, I will usually</p> <pre><code>private static class Point { public final int x; public final int y; public Point(int x, int y) { this.x = x; this.y = y; } } </code></pre> <p>As I find the 2nd way is much more convenient for me. Less cumbersome and less typing, although a good IDE may help.</p> <p>I was wondering, if I have a class for public consumption, is it good that I am using the 2nd approach? (By ensuring my public exposed field will be immutable). </p> <p>Any shortcoming out from it? Although it seems to violate OOP encapsulation theory, I didn't see a real harm from practical point of view.</p>
java
[1]
1,092,430
1,092,431
Can anyone suggest excellent article of working of HEADERS,COOKIES & SESSIONS besides PHP manual?
<p>I need excellent article of working of HEADERS,COOKIES &amp; SESSIONS besides PHP manual.</p>
php
[2]
1,562,430
1,562,431
Structure for a test suite
<p>In the below mentioned directory structure i am trying to build a python platform for a test module.The code resides in the directory /opt/site which is included in the python path.</p> <p>In the /opt/site directory i also have a <code>__init__</code> file and another file as suite.py along with directories dir1,dir2</p> <p>In dir1,dir2 directories i have the following files <code>__init__</code> and execute.py</p> <p>My question is that what should be the code on suite.py such that if i mention dir1 in suite.py dir1/execute.py should be executed and if dir2 is mentioned dir2/execute.py should be executed or if both are mentioned then dir1/execute.py and dir2/execute.py should be executed</p> <p>Also how to call particular functions in dir1/execute.py from suite.py</p> <p>can any one let me know how to achieve this</p>
python
[7]
4,656,417
4,656,418
On click, generating a file and presenting a Save As dialog box: How to control the default file name
<p>I would like to generate a pdf file when the user clicks on it, an not before. Then after the doc is generated, ideally, I would like to give the user the option to either view the document or download it. If they choose to download, I'd like to display the Save As file dialog box with an appropriate default file name. If they choose to view, I'd like to view the document in a new window regardless of the users local settings for a PDF extension (I'm not sure if a user can control whether a pdf is opened in a new window or now like they can for MS Office file extensions.)</p> <p>The following code generates the doc and presents the user with a dialog box to save, but the default dialog is the name of the web page(e.g. WebPageName.pdf) rather than a default file name that I would prefer.</p> <p>Is there a way to control what the default file name that is used to prefilled the Save As Dialog box?</p> <p>I'm not sure how to get all this functionality in one link.</p> <pre><code>Protected Sub imgPdf_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) SessionVariables.ChinaVisaId = New SqlInt32(CType(CType(sender, ImageButton).CommandArgument, Integer)) Dim TargetChinaVisa As ChinaVisa = _Order.ChinaVisas.ItemById(SessionVariables.ChinaVisaId) Dim DocName As String = TargetChinaVisa.ReferenceNumber &amp; ".pdf" Dim PdfPath As String = Server.MapPath("~/Files/") &amp; DocName Dim RelativePath As String = "~/Files/" &amp; DocName Dim AbsolutePath As String = "http://" &amp; _SiteName &amp; "/Files/" &amp; DocName Dim MyPDF As New ChinaVisaPdf(TargetChinaVisa) MyPDF.SaveAsPdf(PdfPath) Server.Transfer(RelativePath) End Subs </code></pre> <p>Side question: When opening a doc in a new window, I assume that that has to be done with client side code and an absolute path?</p>
asp.net
[9]
562,526
562,527
How to terminate program?
<p>How would you make a Java program terminate itself when 'ESCAPE' is pressed? I have tried this:</p> <pre><code> public class Main { public static final int i = 12; public static void Exit(KeyEvent e) { if (e.getKeyCode() == 27) { System.exit(0); System.out.println("Closing"); } } public static void main (String args[]) { while(i &lt;= 0) { Exit(null); } } } </code></pre> <p>However, it does not appear to work. Any suggestions?</p>
java
[1]
5,859,959
5,859,960
adding trailing zeros to php string if not in format
<p>Have a text box which get data for price. If someone enter something like "3." i want to get it converted to "3.0" i cannot append "0" simply in the end because then if it is "100" gets converted to "1000"</p> <p>Also is_numeric("3.") returns 1.</p> <p>Whats the possible way round? </p>
php
[2]
2,975,206
2,975,207
loading js file within js
<p>i have code like this: <a href="http://stackoverflow.com/questions/1618351/loading-js-files-dynamically-via-another-js-file">loading js files dynamically via another js file?</a> but it fails to recognize the object within.</p> <p>ie. content of cCB.js</p> <pre><code>cCB = { map: {}, ... } </code></pre> <p>etc.</p> <p>using:</p> <pre><code>function jsinclude(file) { var script = document.createElement('script'); script.src = file; script.type = 'text/javascript'; script.defer = false; document.getElementsByTagName('head').item(0).appendChild(script); } </code></pre> <p>with the calling code:</p> <pre><code>jsinclude('/js/cCB.js'); </code></pre> <p>produces in my html head</p> <pre><code>&lt;script src="/js/cCB.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>but at the first call to a var within that object:</p> <pre><code>cCB.map = new google.maps.Map(document.getElementById('map'), myOptions); </code></pre> <p>i get error:</p> <pre><code>referenceError: can't find variable cCB </code></pre> <p>======== have I missed something silly here? I have searched already (hence the link) but have no answer</p>
javascript
[3]
3,926,764
3,926,765
jQuery - sort DIVs by className
<p>I have a list of DIVs, like this :</p> <pre><code>&lt;div id="list"&gt; &lt;div class="cat1-4.2"&gt;&lt;div&gt;4&lt;/div&gt;&lt;/div&gt; &lt;div class="cat3-3.3"&gt;&lt;div&gt;3&lt;/div&gt;&lt;/div&gt; &lt;div class="cat2-5.1"&gt;&lt;div&gt;5&lt;/div&gt;&lt;/div&gt; &lt;div class="cat3-1.5"&gt;&lt;div&gt;1&lt;/div&gt;&lt;/div&gt; &lt;div class="cat3-2.4"&gt;&lt;div&gt;2&lt;/div&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>and I want to sort them, using jQuery</p> <p>Server-side, I can define the wanted order, and include this order in the class names :</p> <p>catX-<strong>4.2</strong></p> <p>I want to be able to call either the first order (in my example this DIV will be in the 4th position), or the second order (it will be in the 2nd position) : that explains the "4.2"</p> <p>So if I call <code>OrderDIV(1)</code> I will have this :</p> <pre><code>1 2 3 4 5 </code></pre> <p>and if I call <code>OrderDIV(2)</code> I will have this :</p> <pre><code>5 4 3 2 1 </code></pre> <p>(I will need to add more orders, like : catX-4.2.5.6.2)</p> <p>Thank you VERY MUCH for your help!</p>
jquery
[5]
1,782,154
1,782,155
Restrict the values in an arraylist?
<p>If my list can contain values of 1 or 2 in it and I get the list at runtime and it isn't possible for me to modify it then what's the best way to check and report an error if it does contain any other values ? Do I need to examine each and every element against values of 1 and 2 to make sure no other values are contained in the list. </p>
java
[1]
2,053,136
2,053,137
How to implement a simple prioritized listener pattern in JavaScript
<p>I have an event/listener manager that has this function:</p> <pre><code> var addListener = function(event, listener) { myListeners[event].push(listener); //assume this code works } </code></pre> <p>But now I need to change it so that it looks like this:</p> <pre><code> var addListener = function(event, listener, fireFirst) { if(fireFirst) { myListenersToFireFirst[event].push(listener); } else { myListenersToFireSecond[event].push(listener); } } </code></pre> <p>This is so that when the <code>fireEvent</code> function is called, it will fire the listeners in the <code>myListenersToFireFirst</code> array first, then the listeners in the second array.</p> <p>So it will look something like this:</p> <pre><code> var fireEvent = function(event) { var firstListeners = myListenersToFireFirst[event]; //for each listener in firstListeners, call `apply` on it var secondListeners = myListenersToFireSecond[event]; //for each listener in secondListeners, call `apply` on it } </code></pre> <p>Is this the best way to accomplish this in JavaScript? Is there a more elegant way of achieving this priority list of listener-event firing?</p>
javascript
[3]
1,374,429
1,374,430
Callback to parent thread from child thread
<p>I've got a parent thread. It's job is to queue request and init child thread. Child thread is supposed to get data from web service and callback to parent thread. Parent thread process data and start another child thread. The problem is that everything which is inside callback method is handled by the child thread not the parent thread. Is there a way to handle callback by parent thread? In other words the child thread finishes right after calling the callback method without processing it. </p>
java
[1]
4,145,862
4,145,863
Non-const reference may only be bound to an lvalue
<p>Could someone please explain how to simulate this error? and also what this complains about.</p> <blockquote> <p>"A non-const reference may only be bound to an lvalue" in C++</p> </blockquote>
c++
[6]
981,913
981,914
is it possible to refactor this into a single method
<p>I have a bunch of methods that look like these two:</p> <pre><code> public void SourceInfo_Get() { MethodInfo mi = pFBlock.SourceInfo.GetType().GetMethod("SendGet"); if (mi != null) { ParameterInfo[] piArr = mi.GetParameters(); if (piArr.Length == 0) { mi.Invoke(pFBlock.SourceInfo, new object[0]); } } } public void SourceAvailable_Get() { MethodInfo mi = pFBlock.SourceAvailable.GetType().GetMethod("SendGet"); if (mi != null) { ParameterInfo[] piArr = mi.GetParameters(); if (piArr.Length == 0) { mi.Invoke(pFBlock.SourceAvailable, new object[0]); } } } </code></pre> <p>I have one method for each property in my pFBlock object. with so little changing between methods I feel like there should be a better way to do this, but I can't think of any. I'm using VS 2005.</p>
c#
[0]
5,317,455
5,317,456
Problem with Master pages event order
<p>I have a simple setup with the master page housing some controls used by all child pages.</p> <p>I found when moving to new pages the master page page loads event fires as a non post back and read the solution was to store it's current values somewhere for retrieval. Ok all done.</p> <p>The child page uses these values to run a report. When I switch to a new report, all is well. If I change the values in the master page the master page and the sub page load events fire. </p> <p>The load event for the sub page fires first, picks up the values from the master page which are still the old values and then finally the master page events fire and all the new values are stored. The report hasn't changed as it still ran from the old values.</p> <p>I can't really see a way around this. All you ever hear is that master pages are a saving grace but I swear i've never jumped through so many hoops to get a page to load correctly.</p> <p>And now this!</p> <p>Anyone see a plan to resolve it?</p>
asp.net
[9]
3,217,855
3,217,856
Got "Index out of bounds" Error on List.Add() in c#
<p>Here is the code</p> <pre><code>List&lt;string&gt; something = new List&lt;string&gt;(); Parallel.ForEach(anotherList, r =&gt; { .. do some work something.Add(somedata); }); </code></pre> <p>I get the <code>Index out of bounds</code> error around 1 time per hundred run. Is there anyway to prevent the conflict (I assume) caused by threading?</p>
c#
[0]
1,156,077
1,156,078
How can I use Equals or hashcode in my following program
<p>I want to fetch the details of manager from manager class if at run time I give kinid of employee from the employee class. How can I do this using Equals or Hashcode?</p> <pre><code>public class employee { public string empname { get; set;} public string location { get; set; } public int kinid { get; set; } public double magkin { get; set; } } public class manager { public string magname { get; set; } public double magkin { get; set; } } Dictionary&lt;employee, manager&gt; relation = new Dictionary&lt;employee, manager&gt;(); </code></pre>
c#
[0]
5,408,580
5,408,581
Search contact by phone number
<p>In my app, user writes a phone number, and I want to find the contact name with that phone number?</p> <p>I usually search the contacts like this:<br> <code> Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); </code></p> <p>But I do this to access all contacts... In this app I only want to get the contact name of the given phone number... How can I restrict the query?</p> <p>Or do I have to go trough all contacts and see if any has the given phone number? But I believe that this can be very slow this way...</p>
android
[4]
2,148,873
2,148,874
Trying to extract specfic data with split
<p>i have this txt file name contacts.txt that contains this:</p> <pre><code>kate|female|kathryn bailey beckinsale|26-jul-1973|#23 underworld drive|(621) 142-7827|kate@lycans.net jessica|female|jessica claire biel|03-mar-1982|27 texas avenue|(53)2344223|jbiel@yahoo.com johnny|male|john christopher depp ii|09-jun-1963|711 pirate road|(773) 476-6634|jspaw@piratebay.org </code></pre> <p>my script is this:</p> <pre><code>function syncText() { var xhr = new XMLHttpRequest(); xhr.open("get", "data/contacts.txt", false); xhr.send(null); if (xhr.status == 200) { var data = xhr.responseText; var items = data.split("|"); items.sort(); var div = document.getElementById("header2"); for (var i = 0; i &lt; items.length; i++) { var p = document.createElement("p"); var text = document.createTextNode(items[i]); p.appendChild(text); div.appendChild(p); } } else { alert("data retrieval failed..."); } } </code></pre> <p>The HTML is this:</p> <pre><code>&lt;div id="header2"&gt; &lt;button onclick="syncText()"&gt;Load&lt;/button&gt; &lt;/div&gt;` </code></pre> <p>i only want to retreive kat, jessica, johnny.. please help me</p>
javascript
[3]
939,416
939,417
Stopping the registarion on invalid input:JavaScript
<p>I have a registration form with date of birth as one of the fields, I have written a function for future date which has to be invalid. But when the user puts a future date it still submits the form, although alert is being made to the user.</p> <p>This is the function for alert, and its working fine.</p> <pre><code>var user_birth_year=document.getElementById("birth_year").value; var user_birth_month=document.getElementById("birth_month").value; var user_birth_day=document.getElementById("birth_day").value; var userDate = new Date(user_birth_year,user_birth_month-1,user_birth_day); var currentDate = new Date(); var res="Invalid date"; if(currentDate.getTime() &lt; userDate.getTime() ) { document.getElementById('registererror').innerHTML = "&lt;span class='errorMsg'&gt;"+res+"&lt;/span&gt;"; document.getElementById('registererror').style.display = 'block'; } else { document.getElementById('registererror').style.display = 'none'; } </code></pre>
javascript
[3]
4,575,407
4,575,408
Converting vb.net into a web application
<p>I have written a desktop application in vb.net. Now I need to convert it into a web application in asp.net. Can you please suggest how I might proceed?</p>
asp.net
[9]
3,845,308
3,845,309
Best way to replace image buttons in jquery
<p>Below I have an image button:</p> <pre><code>&lt;table id="question"&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;a onclick="return plusbutton();"&gt; &lt;img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/&gt; &lt;/a&gt; &lt;span id="plussignmsg"&gt;(Click Plus Sign to look up Previous Questions)&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Now what I want to do is by using jquery I want to hide the current image <code>Images/plussign.jpg</code> and replace with another image <code>Images/plussigndisabled.jpg</code> in the if statement below:</p> <pre><code>if (qnum == &lt;?php echo (int)$_SESSION['textQuestion']; ?&gt;) { } </code></pre> <p>And then in the document ready function I want it to replace the <code>Images/plussigndisabled.jpg</code> with <code>Images/plussign.jpg</code></p> <p>I want to know what is the best way to achieve this in jquery?</p> <p>UPDATE:</p> <p>Below is what I tried:</p> <pre><code>var x = "&lt;img src='Images/plussigndisabled.jpg' width='30' height='30' alt='Look Up Previous Question' class='plusimage' name='plusbuttonrow'/&gt;&lt;span id='plussignmsg'&gt;(Click Plus Sign to look &lt;br/&gt; up Previous Questions)&lt;/span&gt;" ; if (qnum == &lt;?php echo (int)$_SESSION['textQuestion']; ?&gt;) { $('#plus th').html($(x)); $("#showGridId").unbind('click').click(function (event) { event.preventDefault(); return false; }).css('color', '#BBBBBB'); } </code></pre> <p>Thanks</p>
jquery
[5]
1,378,298
1,378,299
how to convert object into string in php
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/28098/php-tostring-equivalent">PHP ToString() equivalent</a> </p> </blockquote> <p>how to convert object into string in php</p> <p>Actually i am dealing with web service APIs.i want to use output of one API as a input for another API. when i am trying to do this i got error like this:Catchable fatal error: Object of class std could not be converted to string in C:\ ...</p> <p>this is the output of first API::stdClass Object ( [document_number] => 10ba60 ) now i want only that number to use as input for 2nd AP</p> <p>print_r and _string() both are not working in my case</p>
php
[2]
2,677,832
2,677,833
android ICS left caret resource
<p>The new Android design docs mention use of an Up caret: <a href="http://developer.android.com/design/patterns/actionbar.html" rel="nofollow">http://developer.android.com/design/patterns/actionbar.html</a></p> <p>The up caret seems to be proper for navigation throughout Android - is there a proper way to add this caret? It seems unintuitive that I should just modify the icon image to include it.</p> <p>Any help would be much appreciated!</p>
android
[4]
3,482,119
3,482,120
How to Get Contact name, number and emai ID from a list of contacts?
<p>I am new to android ,I need to get the details of my contacts, but the details include only 3 </p> <ol> <li><p>Contact name</p></li> <li><p>contact number and </p></li> <li><p>Email ID</p></li> </ol> <p>when I press a Button it will show these 3 details of my all contacts</p> <p>I am using android Eclair version 2.1. Any solution ?</p>
android
[4]
738,104
738,105
how to detect if div is hidden by javascript
<p>I have a DIV, that is sometimes hidden, and in this case I don't want that google adds appear/are loaded at all inside this DIV.</p> <p>What is the best practice to make such a check with javascript?</p>
javascript
[3]
631,910
631,911
can i use same id's for 2 elements which requires same validations in javascript?
<p>I'm working on a web project which has lots of tables. Do I need to write a separate function for each of the cells in the table for validation? Can i some how reduce the code?</p>
javascript
[3]
4,714,858
4,714,859
Get element with a certain value in a stringified data attribute
<p>Example:</p> <pre><code>&lt;div data-object="{ 'foo' : 123 }"&gt;&lt;/div&gt; &lt;div data-object="{ 'foo' : 456 }"&gt;&lt;/div&gt; </code></pre> <p>What would be the fastest way to find the div with foo value 123? At the moment im looping through the divs, converting the stringified object to a js object and check if the foo value is equal to 123? Can this be done without a loop? Thanks</p>
jquery
[5]
4,586,284
4,586,285
removing trailing space at the end of a word?
<p>How do I remove a space at the end of a word and not from the middle of the word?</p>
php
[2]
4,859,283
4,859,284
How to append no. of bytes to a byte array?
<p>I am doing a project in 'Steganography' in which I want to encrypt the contents of file using 'Blowfish' algorithm and then want to embed the encrypted text in the image and do the reverse procedure for extracting the image.<br> The 'update' method from class 'Cipher' encrypts only some no. of bytes but, here I want all the bytes(encrypted contents) of the file in only one array. Same is the case with 'update' method in decryption. This array later will be passed to a method in which I embed the text in the image and extract when required.So what can be the better approach towards this problem?<br> Thank you.</p>
java
[1]
2,191,551
2,191,552
UIBarButtonItem with custom action won't execute it
<p>Well, figuring such thing was easy, I decided to get a custom action executed by my <code>UIBarButtonItem</code> once it's pressed. Here's the code:</p> <pre><code> UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"GET BACK!!!" style:UIBarButtonItemStylePlain target:self action:@selector(test)]; self.navigationItem.backBarButtonItem = backButton; [backButton release]; [self.navigationController pushViewController:appsViewController animated:YES]; </code></pre> <p>Yet, even without adding any custom views, <code>-test</code> isn't called at all (although the title change is applied).</p> <p>As you can see, I'm applying these changes to the item right before I push the new view controller (else the title change wouldn't even work).</p> <p>I've searched a lot for an answer to this, but the only trouble people seem to be having is it not replying to an action once it has a custom view. So; what am I doing wrong?</p>
iphone
[8]
4,096,420
4,096,421
Object-Oriented Programming
<p>I am new to C#. I have a Persons class with this function: </p> <pre><code>public virtual void InputPerson(Persons P) { P.ID = int.Parse(Console.ReadLine()); Console.WriteLine("Titel:"); P.Titel = Console.ReadLine(); Console.WriteLine("Name:"); P.Name = Console.ReadLine(); Console.WriteLine("Surname:"); P.Surname = Console.ReadLine(); } </code></pre> <p>And I have a User class that inherits form this Persons class. I now need to create a InputUser function in the User class that makes use of this InputPerson function in the Persons class without rewriting all the code from the InputPerson function to the InputUser function. Here is my code from the InputUser function:</p> <pre><code>public override void InputPerson(User U) { Console.WriteLine("Please enter a Customer:"); Console.WriteLine("Customer ID:"); base.InputPerson; Console.WriteLine("Telephone Number:"); U.Telephone = int.Parse(Console.ReadLine()); Console.WriteLine(); } </code></pre> <p>This InputUser code gives me a error stating: </p> <pre><code>'UserCustomerNotes.User.InputPerson(UserCustomerNotes.User)': no suitable method found to override </code></pre> <p>Can anyone please help?</p> <p>Thanks in advance</p>
c#
[0]
2,664,297
2,664,298
How many ways to create a web service
<p>I want to know how many ways i can create a web service in .Net and how? and what are the important part in this and what the [] this bracket meaning in the web service, also how can i debug web service? and how can i call web service from ajax and what are the complexity in web services? Would some body please elaborate me on this, i am in really in dire need to understand these points.. and i am seeking help from you knowledgeable people, please explin me in brif nd possible then put appropriate links also....</p>
asp.net
[9]
1,281,187
1,281,188
not able to run video from server on iOS 4.1
<p>I have been trying to run a video from my app in iOS 4.1 but haven't met with success. Material everywhere give code for iOS 3.2 but not for the higher versions. Please help , I would be grateful to you. This is my code below:</p> <pre><code>-(IBAction)pressButton:(id)sender { NSString *urlString = [NSString stringWithFormat:@"http://www.itc.virginia.edu/network/videotest/when-sm.mov"]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:urlString]; moviePlayer.scalingMode = MPMovieScalingModeAspectFill; [moviePlayer play]; MPMoviePlayerViewController *movieViewPlayer = [[MPMoviePlayerViewController alloc]initWithContentURL:urlString]; [self presentMoviePlayerViewControllerAnimated:movieViewPlayer]; } </code></pre>
iphone
[8]
2,348,722
2,348,723
How to convert text into URL syntax on Python?
<p>I want to convert python str to URL syntax.</p> <p>For example</p> <pre><code>&gt;&gt;&gt; u'한글'.encode('utf-8') '\xed\x95\x9c\xea\xb8\x80' to '%ed%95%9c%ea%b8%80' </code></pre> <p>Thanks in advance.</p>
python
[7]
5,451,320
5,451,321
Is it possible to redefine the JavaScript print function?
<p>I am running JavaScript inside a Java application and have a gui terminal where I can print things by calling:</p> <pre><code>js.say("foo") </code></pre> <p>(js is an imported Java object, so yea I am running on the JVM). Now, I would like to redefine a:</p> <pre><code>print("foo") </code></pre> <p>call into a call to <code>js.say("foo")</code>. I can do:</p> <pre><code>&gt; b = function(s) {js.say(s)} sun.org.mozilla.javascript.internal.InterpretedFunction@39ffbc2e &gt; b("wee") wee </code></pre> <p>But when I do:</p> <pre><code>&gt; print = function(s) {js.say(s)} sun.org.mozilla.javascript.internal.InterpretedFunction@6a7c8bd &gt; print("wee") </code></pre> <p>It seems I am not calling the new print function but the same old one if you get my drift. Is there a way to do what I am trying to do or am I doing something fundamentally wrong here?</p>
javascript
[3]
2,567,689
2,567,690
Beginner question about getting reference to cin
<p>I'm having problems wrapping my head around this. I have a function</p> <pre><code>void foo(istream&amp; input) { input = cin; } </code></pre> <p>This fails (I'm assuming because cin isn't supposed to be "copyable".</p> <p>however, this works</p> <pre><code>void foo(istream&amp; input) { istream&amp; baz = cin; } </code></pre> <p>Is there a reason that I can get a reference to cin in baz but I cannot assign it to input?</p> <p>Thanks</p>
c++
[6]
4,878,126
4,878,127
Getting User Credentials Windows Authenication
<p>If a user has signed into their computer and are connected to an intranet, is there a way to grab the users crendtials and authentication them in asp.net? What specific code would do this?</p>
asp.net
[9]
3,235,906
3,235,907
jquery get attribute value when property is not set
<p>I simply want to get the current value of a field's attribute.</p> <p>This field has a default value like:</p> <pre><code>&lt;input validation="defaultValue" /&gt; </code></pre> <p>When i want to get the validation attribute, i don't know if it has been updated before or if this is still the default value.</p> <p>So the property get with <code>prop()</code> return <code>undefined</code> when the property is not set (not yet updated), and the <code>attr()</code> method return always the default value (that's not true actually for maintainability but that will be in the future).</p> <p>Is there a method that check:</p> <p>if property is set => return property else return attribute</p> <p>Thanks</p>
jquery
[5]
495,128
495,129
Synchronizing on synchronized collections-> performance issue
<p>Based on the answers below : It is Still not clear to me: What does the synchronized construct on the concurrentMap do, if anything. i.e. in the case of a concurrentmap, what is the difference if any between synchronized(map) versus non synchronizing. <b><i>I am not interested in the correctness or believed goodness of the solution</i></b>. Just an answer to the question: Q:What is the difference between synchronizing on a concurrentmap and not synchronizing on the same? Specifically with regard to performance.. will suffice. Nothing more please.<br> I am only interested in what happens and no supplementary advice.</p> <p>I have a theoretical question which I am having a bit of a mental problem resolving: Assume I have a Concurrent Collection class say=>ConcurrentHashMap map;</p> <p>Assume I have three methods:</p> <pre><code>method1: synchronized(map){ doSomethingWithThemap(); //Assume put integers 1.. 1000000 } method2:doSomethingWithThemap(); //Note it is not synchronized method3:doSomethingElseWithThemap(); //Assume put integers 2000000.. 3000000 </code></pre> <p>Now assume 2 TestCases:</p> <hr> <ul> <li>TestCase1: Spawn two threads A &amp; B. A calls method1 and B calls method3.</li> <li>TestCase2: Spawn two threads A' &amp; B'. A' calls method2 and B' calls method3.</li> </ul> <p>From a performance point of view I would expect TestCase2 to win, since from what I understand, in TestCase1 B cannot add to the map, albeit concurrent, since the synchronized block will hold the lock on the map, and this is not the case in TestCase2.</p> <p>My Unit Tests DO NOT validate this hypothesis.</p> <p>Q: What am I missing here. i.e. Given a synchronized block on a concurrentcollection is performance impacted at all? </p>
java
[1]
4,423,335
4,423,336
AlarmManager launching multiple times
<p>I am using this code to create an Alarm in a activity that can be launched by the user.</p> <p>The Alarm sends an intent that launches a broadcast reciever and then a service.</p> <pre><code>private void setGameAlerts(){ //Setting alarm to fire off NEW_GAME intent every 24 hours. String alarm = Context.ALARM_SERVICE; Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 8); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND,0); calendar.set(Calendar.MILLISECOND, 0); AlarmManager am = (AlarmManager)getActivity().getSystemService(alarm); Intent intent = new Intent("NEW_ITEM"); PendingIntent sender = PendingIntent.getBroadcast(getActivity(), 0, intent, 0); am.setRepeating(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis() , AlarmManager.INTERVAL_DAY, sender); Log.e("RELEASE LIST", "ALARM Set For 1 day from " + calendar.getTimeInMillis()); </code></pre> <p>For some reason EVERYTIME the activity is launched it Automatically sends this intent and the service is launched. is there something wrong with my code that is causing this to happen other than the alarm going off everyday at 8 oclock? </p>
android
[4]
4,992,734
4,992,735
Why python does not allow hyphens
<p>I have always wondered why can't we use hyphens in between function names and variable names in python</p> <p>Having tried functional programming languages like Lisp and Clojure, where hyphens are allowed. Why python doesn't do that.</p> <pre><code># This won't work -- SyntaxError def is-even(num): return num % 2 # This will work def is_even(num): return num % 2 </code></pre> <p>I am sure Sir Guido must have done this because of some reasons. I googled but couldn't manage to find the answer. Can anyone please throw some light on this?</p>
python
[7]
5,837,160
5,837,161
How do i know id of ListView item on OnItemUpdated?
<p>I have suppliers table with id int value for each supplier. I'm trying to edit columns of this table inside of ListView.</p> <p>i'm trying to access e arg but it doesn't have any data on id of the row i'm trying to update?</p>
asp.net
[9]
5,937,201
5,937,202
Jquery div slide across page
<p><a href="http://jsfiddle.net/sQqzZ/" rel="nofollow">http://jsfiddle.net/sQqzZ/</a></p> <p>please help I'm no good with JS I tried copying and pasting these into documents but all I got was and error msg that $ is not defined. This is probably and easy fix but I'm in the dark. Could you just paste how the JS should be on here? </p>
jquery
[5]
6,031,123
6,031,124
Jquery mask for number and letter
<p>I'd like check via jquery a string, thi string can begin by "P" or "M" and after that some number, sample P1456598, M124, P47, M798664645</p> <p>Any idea ?</p> <p>Thanks,</p>
jquery
[5]
1,930,227
1,930,228
Executing program with an DAT file and input
<p>How am I able to execute my C++ program together with a .DAT file and an input?</p> <p>For example: <code>./program.exe file.dat 5</code></p> <p>Example of multiple command lines in file.dat:</p> <pre><code>addpeer 12130 removepeer 13820 </code></pre>
c++
[6]
4,698,560
4,698,561
is it possible to implement Java arrays without ever using the special array token [ ]
<p>This is a Java style question. The brackets empty declare an array reference. With the 'new' keyword, they instantiate. Without the 'new' keyword, they index. </p> <pre><code>char[] myArray = new char[100]; output.format("%c\n", myArray[43]); </code></pre> <p>Of these uses of the brackets, the first case is an anomaly since it uses a special token to declare and does not look like a normal Java reserved word or Java identifier and has no number between the brackets. Is there an alternative that avoids this anomalous case?</p> <p>Edit: Why might this matter? Arrays might be faster or use less memory than collections classes.</p>
java
[1]
2,702,366
2,702,367
Counting item number in Python 'for'?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2894323/for-x-in-y-type-iteration-in-python-can-i-find-out-what-iteration-im-currentl">for x in y, type iteration in python. Can I find out what iteration I&#39;m currently on?</a><br> <a href="http://stackoverflow.com/questions/8590810/iteration-count-in-python">Iteration count in python?</a> </p> </blockquote> <p>Kind of hard to explain, but when I run something like this:</p> <pre><code>fruits = ['apple', 'orange', 'banana', 'strawberry', 'kiwi'] for fruit in fruits: print fruit.capitalize() </code></pre> <p>It gives me this, as expected:</p> <pre><code>Apple Orange Banana Strawberry Kiwi </code></pre> <p>How would I edit that code so that it would "count" the amount of times it's performing the <code>for</code>, and print this?</p> <pre><code>1 Apple 2 Orange 3 Banana 4 Strawberry 5 Kiwi </code></pre>
python
[7]
2,655,104
2,655,105
java pass by value example help me to understand
<p>I have the following code </p> <pre><code>class sample { public void update(List l) { l = null; } public static void main (String[] args) { List m = new ArrayList(); m.add("suresh"); m.add("sankar"); new sample().update(m); System.out.println(m); } } </code></pre> <p>The answer will be {["suresh,"sankar"]}. The <code>m</code> is a pointer to the arraylist object, it contains an memory address value (for ex consider 0xf34 ). when we pass m to update method ,the local variable l will be set to 0xf34 that points to arraylist object in memory .when we set null to this variable l , the memory address replaces the arraylist with null ,hence the variable m should also refer null.am i right.please help.</p>
java
[1]
3,330,466
3,330,467
How to give name of MainWindow.xib file in plist file at run time?
<p>I want to give the name of MainWindow.xib file in plist file through code, How I can achieve this, any idea?</p>
iphone
[8]
3,930,265
3,930,266
Facebook Comment Integration
<p>I have integrated the facebook comment module. When first time I am loading a page with ajax and showing it in popup box then its showing list of comment for specifying url. After closing the popup window I am clicking again to show the same popup or for other url then its not showing facebook comment second time. Can any one tell that what is the problem and how to make it proper working.?</p>
php
[2]
342,858
342,859
How to place Relative layout at bottom of screen(or linear layout).?
<p>I have following in xml</p> <p> </p> <p>I wanna put the second linear layout at the bottom of the screen. How will i do? I have set the property of second Relative layout to bottom but still not showing at bottom..</p> <p>**</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent" android:layout_width="fill_parent"&gt; &lt;RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:id="@+id/RelativeLayout02" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="bottom"&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>** Thanx in advance </p>
android
[4]
3,423,486
3,423,487
Issue with generic types of ArrayList and interface inheritence
<p>I'm having trouble understanding why the following doesn't work and I'm sure the answer is related to something basic I am not understanding and I'm driving myself nuts and hope someone can help.</p> <p>I understand about using interfaces in an ArrayList such that if I have:</p> <pre><code>public interface Weapon { ... } public class Gun implements Weapon { ...} public class Knife implements Weapon { ... } </code></pre> <p>you can then insert anything that implements Weapon into the an array of weapons:</p> <pre><code>ArrayList&lt;Weapon&gt; collection = new ArrayList&lt;Weapon&gt;; collection.add(new Gun()); collection.add(new Knife(); </code></pre> <p>and that's fantastic. I get that, but what is confusing me is the understanding of why <code>ArrayList&lt;Gun&gt;</code> isn't compatible with <code>ArrayList&lt;Weapon&gt;</code> in other ways. To illustrate, the following is legal:</p> <pre><code>public void interfaceIsTheArgument(Weapon w) { ... } ... interfaceIsTheArgument(new Gun()); interfaceIsTheArgument(new Knife()); </code></pre> <p>but the following is not:</p> <pre><code>public void interfaceIsTheArgument(ArrayList&lt;Weapon&gt; w) { ... } ... interfaceIsTheArgument(new ArrayList&lt;Gun&gt;()); interfaceIsTheArgument(new ArrayList&lt;Knife&gt;()); </code></pre> <p>because the last function call reports that the method isn't applicable for its arguments. </p> <p>My question is why if the method knows it tasks an ArrayList with an interface as the generic type, why isn't it okay to pass in an array list of knifes in that last statement?</p>
java
[1]
4,901,799
4,901,800
how do display the another set of menu-items by selecting particular menu from menu list?
<p>In my application I am having 3 menu like options,setting and favorites. In that If I press 'favorites' means it should display another set of (new)menu and I want to hide the previous set of (old)menu. IS it possible with android? If anyone knows, help me please.</p>
android
[4]
5,958,033
5,958,034
Python: Are Two Lists Equal
<p>I'm looking for an easy (and quick) way to determine if two lists contain the same elements:</p> <p>example:</p> <pre><code>['one', 'two', 'three'] == ['one', 'two', 'three'] : true ['one', 'two', 'three'] == ['one', 'three', 'two'] : true ['one', 'two', 'three'] == ['one', 'two', 'three', 'three'] : false ['one', 'two', 'three'] == ['one', 'two', 'three', 'four'] : false ['one', 'two', 'three'] == ['one', 'two', 'four'] : false ['one', 'two', 'three'] == ['one'] : false </code></pre> <p>I'm hoping to do this w/out doing a map</p> <p>My python skills are nascent at best so I'm hoping theres' a tight way of doing this.</p> <p>Thanks,</p> <p>Paul</p>
python
[7]
5,816,642
5,816,643
Is there any way to make a date object in 12 hour mode in javascript
<p>Hii,</p> <p>I have to make date time in 12hr mode i.e. 23 January 2010 1:30 PM in java script</p>
javascript
[3]
4,554,867
4,554,868
ASP.NET disappear message after a while
<p>On a page I display a message against button click.Message is a Label control. My problem is that once button is clicked message appear but it should automatically disappear after 3 seconds of time. I am working on ASP.NET in .NET framework 4.0</p> <p>Thanks</p>
asp.net
[9]
362,121
362,122
translate sql data into c# objects
<p>I'm retrieving a group of customers and orders from sql, what's the best way to translate this into a list Customer objects and their orders?</p> <pre><code>public class Customer { public List&lt;Order&gt; Orders { get; set; } } public class Order { ... } </code></pre>
c#
[0]
5,405,058
5,405,059
very simple javascript image load question
<p>Very new to javascript here folks, so forgive the newbie question. </p> <p>I want to load a very simple and small image with javascript. Can I do an that is triggered by an onload? </p> <p>Note: The reason for this is I have a section of a website that requires javascript to work properly. I want to have a little green circle to show a user that they have javascript installed.</p>
javascript
[3]
6,009,797
6,009,798
Service and Activity process
<p>I have an service with one activity , I want to have different process for service than activity , I have did it with :</p> <pre><code>android:process=":MA_TEST" </code></pre> <p>but there is a problem </p> <p>in task manager , if I end my activity , It will closes service automatically , I want my service works really on different process than activity .</p> <p>Also How can I hide my activity from task manager ?</p> <p>thanks.</p>
android
[4]
3,669,259
3,669,260
Android Instagram
<p>please help! I want share my photo into Instagram. I use Intent for sharing, but I don't need at all list in Share, such as - Facebook, Instagram, Gmail, Bluetoth... etc. I need only Instagram. I want share photo into Instagram by only onclickListener. How can do it? thanks.</p>
android
[4]
5,591,910
5,591,911
What is the best way to initialize a JavaScript Date to midnight?
<p>What is the simplest way to obtain an instance of new Date() but set the time at midnight?</p>
javascript
[3]
2,153,545
2,153,546
Faster Javascript text replace
<p>Given the following javascript (jquery)</p> <pre><code> $("#username").keyup(function () { selected.username = $("#username").val(); var url = selected.protocol + (selected.prepend == true ? selected.username : selected.url) + "/" + (selected.prepend == true ? selected.url : selected.username); $("#identifier").val(url); }); </code></pre> <p>This code basically reads a textbox (username), and when it is typed into, it reconstructs the url that is being displayed in another textbox (identifier).</p> <p>This works fine - there are no problems with its functionality. However it feels 'slow' and 'sluggish'. Is there a cleaner/faster way to accomplish this task?</p> <p>Here is the HTML as requested.</p> <pre><code>&lt;fieldset class="identifier delta"&gt; &lt;form action="/authenticate/openid" method="post" target="_top" &gt; &lt;input type="text" class="openid" id="identifier" name="identifier" readonly="readonly" /&gt; &lt;input type='text' id='username' name='username' class="left" style='display: none;'/&gt; &lt;input type="submit" value="Login" style="height: 32px; padding-top: 1px; margin-right: 0px;" class="login right" /&gt; &lt;/form&gt; &lt;/fieldset&gt; </code></pre> <p>The identifier textbox just has a value set based on the hyperlink anchor of a button. </p>
jquery
[5]
5,863,176
5,863,177
Adapter getView() called systematically after closing a Dialog
<p>My activity contains a ListView. When I open a dialog (a custom dialog that enherits from Dialog), getView() of the adapter gets called systematically, so there must be a notifyDataSetChanged called somewhere. I dont want my list to be refreshed everytime I close the dialog. How can I prevent this?</p>
android
[4]
4,217,594
4,217,595
finfo path not found
<p>I'm on 5.3.1 and after reading the docs, I see that fileinfo is included and that pecl is no longer required. I an however getting:</p> <blockquote> <p>finfo_file(): File or path not found</p> </blockquote> <p>I'm not sure what it's looking for. I've enabled the extension in the ini file and attempted to run the example from the PHP site:</p> <pre><code>$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension foreach (glob("*") as $filename) { echo finfo_file($finfo, $filename) . "\n"; } finfo_close($finfo); </code></pre> <p>Can someone tell me what file I need?</p>
php
[2]
3,704,406
3,704,407
how to change text color of tabs when pressed (currentTab)?
<p>In my seTabColor() I'm setting the color of the title text to Gray. I want to change it to white when pressed. How can I do it?</p> <pre><code>public void setTabColor(TabHost tabHost) { for(int i = 0; i&lt;tabHost.getTabWidget().getChildCount(); i++) { // tabHost.getTabWidget().getChildAt(i).setBackgroundResource(r[i]); tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.BLACK); TextView t = (TextView) getTabWidget().getChildAt(i).findViewById(android.R.id.title); t.setTextSize(9 * getResources().getDisplayMetrics().density); // tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = 58; // tabHost.getTabWidget().getChildAt(i).().height = 58; TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); tv.setTextColor(Color.GRAY); </code></pre> <p>}</p> <p>I wanna do something like: <code>tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab())...</code> </p> <p>But im not sure how to use that to conditionally change the text color. </p>
android
[4]
5,755,956
5,755,957
LiveJournal website interface authentication
<p>I need to add livejournal support to an application. I'm a bit confused about authentication means.</p> <p>They're using xml-rpc which gives me an opportunity to send requests to their server, however I think that users won't type in their account details in my custom authentication form so easily - I mean I wouldn't trust just every custom form. Is there any option to authenticate user through the site interface ? If so, will it be possible to retrieve auth token in order to send "post an entry" and similar requests ?</p> <p>Thanks.</p>
android
[4]