Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,837,721
2,837,722
Stripping $ from php values
<p>I have a form where users can enter the amount they spend on their phone bill and then I tell them how much they could save if they switched to vonage, skype etc. </p> <p>I pass the value "$monthlybill" in the url and then do some math to it. The problem is that if the user writes "$5" instead of "5" in the form, it breaks and is not recognized as a number. How do i strip out the dollar sign from a value?</p>
php
[2]
4,918,067
4,918,068
Create a List that contain each Line of a File
<p>I'm trying to open a file and afterwards create a list with each line read from the file.</p> <pre><code> i=0 List=[""] for Line in inFile: List[i]=Line.split(",") i+=1 print List </code></pre> <p>But this sample code gives me an error because of the i+=1 saying that index is out of range. What's my problem here? How can I write the code in order to increment my list with every new Line in the InFile?</p>
python
[7]
647,749
647,750
How to sort 3D array in c#, with each row is specific to one entry if 1D array?
<p>Please guide me as how to sort an array with taking into consideration that each row is specific to one specific column value. For example,</p> <p>1D array<br> 5<br> 3<br> 4 </p> <p>2D array<br> 1,2,3<br> 3,4,5<br> 6,7,8 </p> <p>In above example,let say, 5 (In 1Darray) is associated with the first row of 2d array (1,2,3). Similary, 3 in 1d array is associated with second row of 2d array(3,4,5).And similarly for the third entry of 4 (of 1d array). Now I want to sort the 1D array with taking into consideration that the associated rows with each 1D array element also change accordingly. I mean its kind of auto-arrangment of rows with change of column values. Please guide Regards Asad</p>
c#
[0]
2,180,906
2,180,907
what is server.mappath(".") in asp.net
<p>What is server.MapPath() in asp.net. Can any one please explain with example written in Vb.net</p> <p>Thank you</p>
asp.net
[9]
2,713,862
2,713,863
php path issue, solution needed
<p>The following code works when I place this script in the root </p> <pre><code>if (file_exists("pics/2012/Blackhall Primary/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } </code></pre> <p>but if I move my script to a folder /teacher/ it no longer works.</p> <p>I thought make the path ~/pics/2012/blackhall primary/ would work but it does.</p> <p>Any ideas? Thanks</p>
php
[2]
1,424,843
1,424,844
How to add a jquery listener?
<p>I have a list sorter plugin that is sorting just fine but the filter function is not working. I think it is because the filter buttons are not directly adjacent the list that needs to be filtered. How would I add a listener for the div that contains the list to be filtered?</p> <p>jsfiddle: <a href="http://jsfiddle.net/infatti/S9vU2/" rel="nofollow">http://jsfiddle.net/infatti/S9vU2/</a></p> <p>This may be a solution but not sure how to implement it with the existing jquery:</p> <pre><code>$('#random-search-field').keyup(function() { list.search($(this).val()); }); </code></pre>
jquery
[5]
5,343,477
5,343,478
Convert.ToInt32() conditional formatting according to string with comma
<pre><code>string str = e.Row.Cells[index].Text; int value = Int32.Parse(str, NumberStyles.AllowThousands, NumberFormatInfo.InvariantInfo); if (value &gt;= 100) e.Row.Cells[index].BackColor = System.Drawing.Color.Green; </code></pre> <p>Cell values are 168,88 - 125,45 - 75,3 </p> <p>After parsing str returns 16888 - 12545 - 753 , so all of the cells are set as green</p> <p>how can i compare real values.?</p>
c#
[0]
1,734,650
1,734,651
Problem escaping string
<pre><code>const string postdescWithComments = @"&lt;span class=""footerLeft""&gt;posted on &lt;a href=""{0}"" title = ""Permanent link to this post""&gt;{1}&lt;/a&gt;&lt;/span&gt;&lt;span class=""footerRight""&gt;&lt;a href=""{2}#feedback"" title=""comments, pingbacks, trackbacks"" class=""comments""&gt;&lt;img class=""feedbackimage"" src=""/skins/xxx/images/cloud.gif"" width=""13"" height=""12"" border=""0"" /&gt;Comments({3})&lt;/a&gt;&lt;a href=""{0}"" class=""moreimage"" title = ""Permanent link to this post""&gt;&lt;img src="" + &lt;%=WebUtilityMethods.GetRoot()%&gt; + ""skins/xxx/images/document.gif border=""0""&gt; More&lt;/a&gt;&lt;/span&gt;"; </code></pre> <p>I can't seem to escape this correctly and it's driving me nuts.</p> <p><code>GetRoot()</code> just returns a string</p>
asp.net
[9]
4,805,320
4,805,321
swappable Java components
<p>I want to change an application by changing a component. In Java, it would seem that the swappable object could be placed in a jar. One version of the jar could be deleted and another identically named jar would be put in its place. </p> <p>Is this the best practice for swappable Java components, and if not, then what?</p> <p>Edit: to be clear, the mooted organization is to have a jar with the constant objects, and a separate jar with the swappable object. Runtime swappability is neither expected nor sought. Remote installation and runtime swapping is probably more sophisticated than necessary for my needs. </p>
java
[1]
367,357
367,358
Elegant TryParse
<p>I feel that every time I use TryParse that results in somewhat ugly code, mainly I am using it this way :</p> <pre><code>int value; if (!int.TryParse(someStringValue, out Value) value = 0; </code></pre> <p>Is there some more elegant solution for parsing all basic DataTypes, to be specific is there a way to do fail safe parsing in one line ? By fail safe I assume setting default value if parsing fails without exception.</p> <p>btw. this is for cases where I must do some action even if parsing fails, just using the default value. </p>
c#
[0]
5,552,522
5,552,523
Using tabulator / tabspace in a TextView
<p>I wish to use some tabspace in a line where I call setText</p> <pre><code>if(id==R.id.radioButton1){ title.setText(numbertext.getText()+" Grams"); </code></pre> <p>In this case I would like to tab between numbertekst.getText() and the grams. The output is part of a simple row with values. But as I can't find the tab, the row is a little ugly.</p> <p>I know I can use multiple textfields or even a table. But as I have a lot of code already I don't want to go that way yet.</p> <p>I tried the Java way with putting \t, however that seems not to work.</p> <p>Any help would be appreciated.</p>
android
[4]
4,931,943
4,931,944
How to put a check on Empty TextField?
<p>Str is empty i mean i enter nothing in TextFied even then it's going in else case NSString *Str= textField.text; NSLog(@"%@",Str);</p> <pre><code>if([Str isEqualToString:@""]) { NSLog(@"Hi"); } </code></pre>
iphone
[8]
3,225,745
3,225,746
java using BigInteger and While
<p>I have a problem </p> <pre><code>import java.math.BigInteger; import java.io.*; import java.util.*; import java.lang.*; public class medici { public static void main(String[] arg) { { BigInteger zac = new BigInteger("3"); zac = zac.pow(399); BigInteger kon = new BigInteger("3"); kon = kon.pow(400); BigInteger nul = new BigInteger("0"); BigInteger jed = new BigInteger("1"); BigInteger detel = new BigInteger("3"); for (BigInteger a = zac; a.compareTo( kon ) &lt;= 0; a = a.add(jed)) { cis = a ; // THIS A PROBLEM String retez = ""; while ( cis &gt; 0 ); // THIS IS A PROBLEM retez = ( cis.mod(detel) ) + retez; cis = cis.divide(detel); System.out.println(retez); } } } } </code></pre> <p>Ive tried this formula <code>BigInteger cis = new BigInteger("a");</code> for this <code>cis = a ;</code></p> <p>and <code>while ( cis.compareTo( nul ) &gt; 0 );</code> for this <code>while ( cis &gt; 0 );</code></p> <p>but it doesnt work and I dont know why.</p> <p>when I use this formula, this is the same, but I used only integer when I use the same for Big Integer It doesnt work</p> <pre><code>import java.io.*; import java.util.*; import java.lang.*; public class netik { public static void main(String[] arg) { { int a ; int cis; int detel = 3; for ( a = 567880; a &lt;= 567890; a++ ){ cis = a; String retez = ""; while (cis &gt; 0) { retez = (cis % detel) + retez; cis /= detel; } System.out.println(retez); } } } } </code></pre>
java
[1]
2,691,526
2,691,527
receiving data from serialport stops when main form is minimized or moved
<p>Sir,</p> <p>I apologize if this is already covered somewhere. I did a search and find something which I have already implemented.</p> <p>I am developing an application which receives data from a device connected via serialport. I am using SerialPort datareceived event to capture data. I am to display data in text boxes of the main form. Data is received frequently. I used Timer to send command to the device, in response device send some data. Timer interval is 100 ms. In every 100 ms interval some command is sent and correspondingly data is received. I used Invoke function to update the GUI elements like TExtbox, labels etc. Everything is fine. All the elements are updating beautifully. But during receiving data if I make any change in main form like moving form, minimizing, maximizing, or clicking somewhere in the form, then data receiving stops. I couldnot find the reason why its happening ? I also changed the timer interval to 200,300,400,500 but same problem is there. </p> <p>Please tell me why its happening? And possible solution...</p> <p>Thanks In advance.... :)</p>
c#
[0]
2,502,235
2,502,236
Passing value from a form to another form (C# winforms)
<p>Please take a look at this image: <img src="http://a.imageshack.us/img21/6190/64635037.png" alt="alt text"></p> <p>I have a <code>MDI</code> form with 2 different child forms in it (<code>Form1</code>, and <code>Form2</code>). Is it possible to pass the value of <code>textBox1</code> in <code>Form1</code>, to <code>textBox1</code> in <code>Form2</code>? (Supposedly, when I press the button as a trigger).</p> <p>If yes, how? Please help.. thanks in advance...</p>
c#
[0]
3,756,358
3,756,359
Retrieve an NSMutableArray which is in a method from another method of same class
<p>I am new to iphone i have a small doubt that is I have a method in a class that is below</p> <pre><code>-(void)bookNamesWhichAreInDownloadedQueue:(NSMutableArray *)receivedBookNamesWhichAreInDownloadedQueue{ NSLog(@"receivedBookNamesWhichAreInDownloadedQueue is %@",receivedBookNamesWhichAreInDownloadedQueue); bookNamesWhichAreInDownloadedQueue = receivedBookNamesWhichAreInDownloadedQueue; NSLog(@"bookNamesWhichAreInDownloadedQueue is %@",bookNamesWhichAreInDownloadedQueue); } </code></pre> <p>here bookNamesWhichAreInDownloadedQueue is an NSMutableArray it contains some data in it.I want to retrieve this array with that data in another method in same class how it is possible.If anybody know this please help me</p>
iphone
[8]
1,127,918
1,127,919
TextView underline phone number and hyperlink
<p>I've written an app which contains a large textview for displaying notes. Is it possible to have the textview highlight any phone numbers or hyperlinks without underlining the entire view?</p>
android
[4]
593,086
593,087
How do I get anchor href value on click using jQuery?
<p>Let's say I have an anchor like this:</p> <pre><code>&lt;a onClick="return confirm('Sure?')" href="http://stackoverflow.com/"&gt;Click here&lt;/a&gt; </code></pre> <p>Is there anyway I can get the value of href "http://stackoverflow.com/" when I click "Click here"? Bearing in mind that I don't have other attributes to help, such as id or name!</p> <p>I'm overriding the confirm function and I need to redirect the user to the location provided in the anchor if they clicked ok as follows:</p> <pre><code>window.confirm = function(msg) { var targetUrl = jQuery(this).attr("href"); jQuery("#alert_box").dialog({ autoOpen: false, show: "slide", modal: true, width: 400, resizable:false, title: '&lt;img src="icons/confirm.png" /&gt; Confirm!', buttons: { "Cancel": function() { jQuery(this).dialog("close"); }, "OK": function() { //jQuery(this).dialog("close"); jQuery(location).attr('href', targetUrl); } } }); jQuery("#alert_box").html(msg); jQuery("#alert_box").dialog("open"); return false; } </code></pre> <p>Any help would be much appreciated!</p>
jquery
[5]
1,790,233
1,790,234
Is a C# field private by default?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3763612/default-visibility-for-c-classes-and-members-fields-methods-etc">Default visibility for C# classes and members (fields, methods, etc)?</a> </p> </blockquote> <p>Is a C# field by default private? In general is there a guide (possibly a msdn guide) that specifies these things? When you ommit a modifier, which one is used? Thanks indeed.</p>
c#
[0]
4,507,733
4,507,734
operator overloading internal call conversion
<p>If there is a class</p> <pre><code>class complex { private: float real,imag; public: complex operator +(complex c) { complex t; t.real=real+c.real; t.imag=imag+c.imag; return t; } </code></pre> <p>and in main if we call overloaded operator by</p> <p>c3=c1+c2;</p> <p>then compiler internall converts as c3=c1.operator+(c2)</p> <p>similarly in similar example of operator overloading,chaining of =</p> <pre><code>class circle { private: int radius; float x,y; public: circle() {} circle(int rr,float xx,float yy) { radius=rr; x=xx; y=yy; } circle&amp; operator=(const circle&amp; c) { cout&lt;&lt;endl&lt;&lt;"assignment operator invoked"; radius=c.radius; x=c.x; y=c.y; return *this; } int main() { circle c1 (10,2.5,2.5); circle c2,c3; c3=c2=c1; c1.showdata(); c2.showdata(); c3.showdata(); return 0; } </code></pre> <p>Overloaded = to operator will be called 2 times first for c2=c1 and then for c3=c2. then how will compiler treat c2=c1 with its function prototype??how will compiler internally convert this overloaded operator = call??(plz tell in reference with above addition example) Whose private fields will b accessed and to ahich object value will be returned??</p>
c++
[6]
4,727,048
4,727,049
C++ Passing a pointer to a member function as an argument
<p>I need to pass a pointer to a member function as an argument to a member function in another class. What I'm doing is something like below. I want to call int Processor::AddJob(void <em>(</em>_pFunc)(void*), void* _pArg) method with void* ProcessHandler::Task(void* a) as the first argument. I did it as </p> <pre><code>TaskFunc pFunc1 = &amp;ProcessHandler::Task; p_Processor-&gt;AddJob(pFunc1,10); </code></pre> <p>But it gives the error </p> <blockquote> <p>error: no matching function for call to Processor::AddJob(void* (ProcessHandler::<em>&amp;)(void</em>), int)’ Processor.h:47: note: candidates are: int Processor::AddJob(void* (<em>)(void</em>), void*)</p> </blockquote> <p>Can someone please help me on this.My implementation is as follows.(Not the exact code-it is much larger than this)</p> <pre><code>class Processor { public: Processor(); virtual ~Processor(); int AddJob(void *(*_pFunc)(void*), void* _pArg); }; int Processor::AddJob(void *(*_pFunc)(void*), void* _pArg) { //Job addition related code goes here } ///////////////////////////////////////////////////////////////////////////// typedef void* (ProcessHandler::*TaskFunc)(void*); class ProcessHandler { public: ProcessHandler(Processor* _pProcessor); virtual ~ProcessHandler(); void* Task(void* a); void Init(); private: Processor* p_Processor; }; void* ProcessHandler::Task(void* a) { //Task related code goes here } void ProcessHandler::Init() { TaskFunc pFunc1 = &amp;ProcessHandler::Task; p_Processor-&gt;AddJob(pFunc1,10); //This give the compile error. } ///////////////////////////////////////////////////////////////////////// int main() { Processor* pProcessor = new Processor(); ProcessHandler* pProcessHandler = new ProcessHandler(pProcessor); pProcessHandler-&gt;Init(); } </code></pre>
c++
[6]
2,517,129
2,517,130
toggle is not working
<pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("button").click(function(){ $("p").toggle(function(){ $("p").hide();}, function(){ $("p").show();} }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Click me to toggle between different background colors.&lt;/p&gt; &lt;button&gt;click me&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>i am trying to toggle between hide and show on button click...but it's not working a little help will be appreciable</p>
jquery
[5]
1,343,587
1,343,588
htmlentities utf-8 problem
<p>I got something weird happening here and I can't understand why, on my php 5.2.5 server when I use a POST Form to post the content on an input containing "é" and on the other side I echo(htmlentities($_POST["myinput"])) it echo <code>&amp;Atilde;&amp;copy;</code> </p> <p>But if I echo my $_POST["myinput"] simply it shows "é", so this mean my htmlentities don't use UTF-8 by default, where can I change the charset used by htmlentities?</p> <p>I tried changing it in my php.ini default_charset = "UTF-8", but it won't work either?</p>
php
[2]
4,905,234
4,905,235
Moving Activity to another Activity when class extends ArrayAdapter
<p>When I click the <code>edit_remainder</code> button I want to move my Activity to another Activity.</p> <p>But where the class extends ArrayAdapter I don't understand how to move to another Activity.</p> <p>Please help me with an example of the Intent class.</p> <pre><code>public class mylist extends ArrayAdapter&lt;String&gt; implements OnClickListener { private final Context context; private final String[] values; Button edit_remainder; public mylist(Context context, String[] values) { super(context, R.layout.some, values); this.context = context; this.values = values; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.buttonadd, parent, false); edit_remeinder=(Button) rowView.findViewById(R.id.btnEdit); edit_remeinder.setOnClickListener(this); return rowView; } public void onClick(View v) { Toast.makeText(getContext(), "hi", 1000).show(); // please enter moving code here } } </code></pre>
android
[4]
4,797,234
4,797,235
How can I use a ttf file for a button's text?
<p>How can I use a ttf file for a button's text?</p>
android
[4]
5,918,798
5,918,799
place condition in the read or in the code?
<p>I am checking if an item has a linked item in the database but cant decide where to put the condition. </p> <p>option one: place the condition in the database read statement.</p> <pre><code>select * from item where id = id. </code></pre> <p>Option two check afterwards in code.</p> <pre><code>temp = select * from item for(i = 0; i &lt;sizeof(temp); i++; { if(id = temp.id) {do stuff} } </code></pre> <p>Is there a significant difference between the two ? </p> <p>note code sample probably contains tons of errors, is for explanation purpose only. </p>
java
[1]
3,744,648
3,744,649
remove all children of ul element thats means remove all li's
<p>I am doing the following code to remove all the children of UL.Is it right to do.ALl the childrens are li element.</p> <p>thickBoxProductLists is the id of UL element</p> <pre><code> $('#thickBoxProductLists').children().remove(); </code></pre>
jquery
[5]
1,329,272
1,329,273
PHP's mail function doesn't send email
<p>So when I submit my form, everything is stored in the database just fine, I had a really simple email that basically consisted of, 'Hey thanks, this is your link' kind of deal and I received that just fine. But now I've upgraded to using an HTML body instead and suddenly I'm not receiving the email, any idea why?</p> <pre><code>$to = $username; $subject = 'Thanks for Registering on Dota Pub Stars!'; $message = '&lt;html&gt; &lt;head&gt; &lt;title&gt;Registration Successful!&lt;/title&gt; &lt;link rel="stylesheet" src="http://www.sithhappens.net/css/style.css" /&gt; &lt;/head&gt; &lt;body class="bodybg"&gt; &lt;div id="registrationform"&gt; &lt;p class="success"&gt;Thanks for registering on Dota Pub Stars!&lt;/p&gt; &lt;br /&gt; &lt;br /&gt; &lt;a class="button2" href="http://www.sithhappens.net/?key=' . $activation_key . '&amp;amp;username=' . $username . '&amp;amp;email=' . $email1 . '"&gt;Activate Account&lt;/a&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt;'; $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "From: $from\r\n"; mail($to, $subject, $message, $headers); </code></pre>
php
[2]
1,064,668
1,064,669
jQuery .contentWindow.document.getElementById('email_box').value help
<p>Hey all, i'm just wondering if there was any way to condense this line of code to pure jQuery without having the need to have ".contentWindow.document.getElementById('email_box').value" in there?</p> <pre><code> $('#OIPHPFrame')[0].contentWindow.document.getElementById('email_box').value = $("#txtEmail").val(); </code></pre> <p>and also the "click" event:</p> <pre><code> $('#OIPHPFrame')[0].contentWindow.document.getElementById('butImport').click(); </code></pre> <p>Any help would be awesome! :o)</p> <p><B>SOLVED! :o)</B></p> <pre><code> $('#OIPHPFrame').contents().find('#password_box').val($("#Password").val()); $('#OIPHPFrame').contents().find('#butImport').click(); </code></pre> <p>David</p>
jquery
[5]
2,977,238
2,977,239
"Request timed out." error when setting debug="false"
<p>I have a page that takes a few minutes to run. When I set <code>debug="false"</code> in the <code>&lt;compilation /&gt;</code> tag in web.config, I get a "Request timed out." error (and internal try/catch blocks in my code get a "Thread was being aborted." error. </p> <p>What is the fix to allow long pages to run in production mode? Does debug mode have an infinite timeout?</p>
asp.net
[9]
1,887,855
1,887,856
JavaScript: Error - "Expected an assignment or function call and instead saw an expression"?
<p>I am using the <strong><a href="http://JSLint.com">JSLint</a></strong> tool to ensure my JavaScript is "strict" and I'm getting the following error:</p> <pre><code>Expected an assignment or function call and instead saw an expression </code></pre> <p>On the following code:</p> <pre><code>(my_var &gt; 0 ) ? $("#abc").html(my_array.join('')) : $("#abc").html('&lt;h2&gt;Hello ' + persons_name); </code></pre> <p>Any ideas why I'm getting such an error? Also, I'm using JQuery as seen in the above code, in case that makes a difference.</p>
javascript
[3]
3,516,461
3,516,462
How to change the background colour?
<p>I want to design a identical screen like messaging screen.Iam using the below xml code for designing the screen. I want to change the background colour as gray for the edittext <code>@+id/txtMessage</code> and for the button as like the messaging screen of android.How can i done that?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:orientation="vertical" &gt; &lt;EditText android:id="@+id/txtTO" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="top" android:hint="To" /&gt; &lt;requestFocus /&gt; &lt;EditText android:id="@+id/txtMessage" android:layout_width="235dp" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:ems="10" android:hint="Type the message" /&gt; &lt;Button android:id="@+id/btnSend" android:layout_width="70dp" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:text="Send" /&gt; &lt;/RelativeLayout&gt; </code></pre>
android
[4]
5,127,618
5,127,619
When i pass one form id to the queryselectorall method im able to see all the inputs inside the form
<p>When i pass one form id to the queryselectorall method im able to see all the inputs inside the form. But when i pass two id of form to queryselector all i see it two form being returned. Can some one help me out with this ? Below is the code that im using </p> <pre><code>window.$ = function(el) { el = document.querySelectorAll(el); el.size = el.length; if (el.length === 1) { el[0].size = 1; return el[0]; } else { return el; } </code></pre> <p>};</p> <p>Complete Code:</p> <pre><code>window.onload=function(){ (function (window) { window.Q = function (el) { el = document.querySelectorAll(el); el.size = el.length; if (el.length === 1) { el[0].size = 1; return el[0]; } else { return el; } }; window.addEvents = function (el, ev, fn) { var i, el = (typeof el == 'string') ? Q(el) : el, ev = (ev.indexOf(' ')) ? ev.split(' ') : [ev]; ev.forEach(function (ea) { if (el.length) { for (var i = 0; i &lt; el.length; i++) { el[i].addEventListener(ea, fn, false); } } else { console.log(el, ea, fn) el.addEventListener(ea, fn, false); } }); }; window.callme = function (e) { console.log(e.type) } window.init = function () { /*Below code works when i bind events to one form and all the input fields gets the events attached */ //window.addEvents('#form1', 'focus keyup blur', callme); /* Uncomment the below line to reproduce the issue only the key up event gets fired and that is also getting attached to form and not to form elements*/ window.addEvents('#form1,#form2', 'focus keyup blur', callme); } })(window); window.init(); </code></pre>
javascript
[3]
4,156,926
4,156,927
How to convert from Decimal to T?
<p>I've built a wrapper over NumbericUpDown control. The wrapper is generic and can support int? and double?</p> <p>I would like to write a method that will do the following.</p> <pre><code>public partial class NullableNumericUpDown&lt;T&gt; : UserControl where T : struct { private NumbericUpDown numericUpDown; private T? Getvalue() { T? value = numericUpDown.Value as T?; // &lt;-- this is null :) thus my question return value; }} </code></pre> <p>of course there is no cast between decimal and double? or int? so I need to use a certain way of converting. I would like to avoid switch or if expressions.</p> <p>What would you do?</p> <p>To clarify my question I've provided more code...</p>
c#
[0]
191,293
191,294
Bad url in iphone sdk
<p>url <a href="http://crescerance.com/School/isummit/speakers.html" rel="nofollow">http://crescerance.com/School/isummit/speakers.html</a></p> <p>Isummit[12923:1d013] Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x91aa490 {NSUnderlyingError=0x91aa1d0 "bad URL", NSLocalizedDescription=bad URL}</p>
iphone
[8]
352,986
352,987
How do I cancel an AsyncTask
<p>I am using an Asynctask as the loop controller for a game and noticed that the thread created kept on running after the activity was finished.</p> <p>I realised that was the correct behaviour of a separate thread and then I tried hunting down answers on how to end the thread when the app enters onPause.</p> <p>I found lots of similar questions but no direct answers but eventually came up with a method so I'm going to answer my own question here to hopefully help others in future. (And to receive improvements to my answer as well)</p>
android
[4]
1,706,861
1,706,862
How do I use str_replace() with multiple parameters?
<p>Basically, I want to use both <code>$city_name</code> and <code>$ref_name</code> with str_replace(), so that if either one (or both) of them are inputted by the user, both of them are replaced with their actual variable forms.</p> <p>To give a better illustration, here's my current code;</p> <pre><code>$headlines = array('primary_headline' =&gt; $_POST['primary_headline'], 'secondary_headline' =&gt; $_POST['secondary_headline'], 'primary_subline' =&gt; $_POST['primary_subline'], 'secondary_subtext' =&gt; $_POST['secondary_subtext']); $city_name = "Dallas"; $ref_name = "Facebook"; if(isset($headlines)) { foreach($headlines as $headline) { echo(str_replace('$city_name', $city_name, $headline)); } } </code></pre> <p>I'd basically like <code>str_replace('$city_name', $city_name, $headline)</code> to become <code>str_replace('$city_name' AND/OR '$ref_name', $city_name AND/OR $ref_name, $headline)</code>.</p> <p>Any answers or comments will be greatly appreciated!</p>
php
[2]
4,056,618
4,056,619
Difference between Response.Redirect() and Response.Write()
<p>What is the difference between </p> <pre><code>Response.Redirect("Default.aspx"); </code></pre> <p>and </p> <pre><code>Response.Write("&lt;script&gt;location.href='Default.aspx';&lt;/script&gt;"); </code></pre> <p>Why someone will choose the second one?</p>
asp.net
[9]
3,505,690
3,505,691
SMS Receiver as a Service
<p>I have created SMS Receiver app... but i want to create it as an service, it should run in the background (i.e no separate UI for this app, want to work like alarm app) and even if mobile restarts it automatically starts... could any one help on this?</p> <p>My previous SMS Receiver app code was here <a href="http://stackoverflow.com/questions/10769107/unable-to-instantiate-activity-componentinfo-in-android-receive-sms-app">Unable to instantiate activity ComponentInfo in Android Receive Sms App</a></p>
android
[4]
5,562,026
5,562,027
How can I get the name/file of the script from sitecustomize.py?
<p>When I run any Python script, I would like to see the script's filename appear in the Windows command line window's titlebar. For example, if I run a script called "<code>mytest.py</code>", I want to see "<code>mytest</code>" in the titlebar. I would like this to be automatic, so I don't have to add code to every one of my scripts.</p> <p>Currently I'm attempting to do this with <code>sitecustomize.py</code>, because when Python is run, including from double-clicking a Python script, <code>sitecustomize</code> is imported before the script runs.</p> <p>I've tried getting <code>__main__</code>'s <code>__file__</code> and <code>sys.argv</code>, but <code>sitecustomize</code> doesn't see either:</p> <p>file <code>sitecustomize.py</code>:</p> <pre><code>import __main__, sys print "hasattr __main__.__file__:", hasattr(__main__, "__file__") print "hasattr sys.argv:", hasattr(sys, "argv") print "-" * 60 </code></pre> <p>file <code>mytest.py</code>:</p> <pre><code>import sys print "__file__ is:", __file__ print "sys.argv is:", sys.argv raw_input() # don't end the script immediately </code></pre> <p>output:</p> <pre><code>hasattr __main__.__file__: False hasattr sys.argv: False ------------------------------------------------------------ __file__ is: C:\Documents and Settings\Owner\Desktop\mytest.py sys.argv is: ['C:\\Documents and Settings\\Owner\\Desktop\\mytest.py'] </code></pre>
python
[7]
5,477,785
5,477,786
Black screen in inner preferenceScreen
<p>My <code>PreferenceActivity</code> contains a nested <code>PreferenceScreen</code> in another <code>PreferenceScreen</code> and I'm applying a theme to my <code>PrefenceActivity</code> that changes the background color. However when I open the nested <code>PreferenceScreen</code> I get a black background and I cannot see the options.</p> <p>This happens with android 2.1 , but it does not happen with android 1.6. Any ideas on how this can be corrected?</p>
android
[4]
4,517,151
4,517,152
Best way to handle shape drawable differences Android 2.3.5 vs 4.0
<p>I'm trying to have a shape drawable with this shape:</p> <p><img src="http://i.stack.imgur.com/Coy3J.png" alt="enter image description here"></p> <p>This works properly in 1.6 to 2.3.5 when using the following:</p> <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"&gt; &lt;solid android:color="#cc6900"/&gt; &lt;corners android:radius="0.1dp" android:bottomRightRadius="7dp" android:bottomLeftRadius="0dp" android:topLeftRadius="0dp" android:topRightRadius="7dp"/&gt; </code></pre> <p></p> <p>However, when running it on a Galaxy Nexus, or a 4.0 Emulator, I have to use this to get the same layout:</p> <pre><code>... &lt;corners android:radius="0.1dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="7dp" android:topLeftRadius="0dp" android:topRightRadius="7dp"/&gt; ... </code></pre> <p>Which gives me this on 1.6:</p> <p><img src="http://i.stack.imgur.com/jkLNe.png" alt="enter image description here"></p> <p>So basically, previous versions has all used bottomRight and bottomLeft in one way, and now 4.0 does it in another.</p> <p>Is there any easy way that I can have it be like it is for pre 4.0, and give 4.0 users the changed values? If possible, I'd prefer if I could keep it in XML and not have it in code.</p>
android
[4]
4,021,148
4,021,149
Countdown with hours and minutes - compute the difference
<p>I have two dates:</p> <pre><code>$today = '2012-12-01 10:40:00'; $check = '2012-12-03 12:00:00'; </code></pre> <p>How can I show countdown for this dates? Should show me:</p> <p>Count: <strong>49</strong> hours and <strong>20</strong> minutes. I can check only hours or only minutes with function mktime, but how can i compare this?</p>
php
[2]
4,465,386
4,465,387
spliting a string based on delimiter
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/96428/how-do-i-split-this-string-with-javascript">How do I split this string with JavaScript?</a> </p> </blockquote> <p>I have a string in following format</p> <pre><code>part1/part2 / is the delimiter </code></pre> <p>now i want to get split the string and get part 1.How can i do it?</p>
javascript
[3]
638,102
638,103
Do Messages block in Android
<p>Im writing an app which loads data from a rest interface. for this task i use a service which gets called by the activitys. Those calls are based on the "Message". I do it like that because i thought that just sending a message does not result in a blocking of the UI thread (i used much of the RemoteService example code from the android docs). But it feels like if the UI thread ater sending a message still gets blocked (ui doesnt update until the programflow, caused by the message has stoped).</p> <p>Am i getting something wrong about the whole idea of the message system ? do i need to start the service in a separate thread to get around this ?!</p>
android
[4]
4,451,642
4,451,643
Android json error.index out of range
<p>I am trying to get values from mysql and inserting them in sqlite database.But i am getting error in json index out of range.</p> <p><strong>Here is my code</strong>. <strong>I am getting json parsing Exception</strong>:</p> <pre><code> protected void onPostExecute(Void v) { try{ Database1 db=new Database1(getApplicationContext()); JSONArray jArray = new JSONArray(result); for(int i=0;i&lt;=jArray.length();i++) { JSONObject json_data = jArray.getJSONObject(i); // list1.add(json_data.getString("id")); int s=json_data.getInt("id"); j=json_data.getString("name"); db.open(); db.inserttable1(s,j); Toast.makeText(getBaseContext(),s+j,Toast.LENGTH_LONG).show(); } } catch(JSONException e) { Log.e("log_tag", "Error parsing data "+e.toString()); } </code></pre>
android
[4]
3,024,506
3,024,507
Unable to grasp this javascript snippet function abc(){a:'b'; c:'f'; f:'t'; }; Can someone explain?
<pre><code>function abc(){ a:'b'; c:'f'; f:'t'; }; </code></pre> <p>This snippet does not throw an error in console. I want to understand whats happening with the variables inside the function. Hows it being interpreted by the javascript engine.</p>
javascript
[3]
2,947,576
2,947,577
Python ljust method not working as expected on formatted strings
<p>When using string formatting resulting string is longer than expected.</p> <p>For example:</p> <pre><code>In [1]: "%s".ljust(7) % "123456" Out[1]: '123456 ' </code></pre> <p>Output string is not 7 characters long.</p> <p>I'm interested in what is exactly happening 'in the background' to result in such behavior?</p>
python
[7]
2,086,320
2,086,321
startSearch now working
<p>Hi i have the following code in onSearchRequest public boolean onSearchRequested() {</p> <pre><code> startSearch("HI", false,null,true); return true; } </code></pre> <p>This is working bt uses default google search .If i use startSearch("HI", false,null,false); then sarch dialog doesnt open... Any reason for that..</p> <p>This is the manifest file</p> <p> </p> <pre><code> &lt;activity android:name=".SearchableActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEARCH" /&gt; &lt;/intent-filter&gt; &lt;meta-data android:name="android.app.searchable" android:resource="@xml/searchable"/&gt; &lt;/activity&gt; </code></pre>
android
[4]
2,980,084
2,980,085
Android Text to speech
<p>I want to use TTS (Text to Speech) in my android application.how can i use texttospeech Engine and one more is it support Japanese language? please help me on this.</p> <p>Regards Thilag.</p>
android
[4]
5,182,965
5,182,966
custom search engine for image and url
<p>I’d like to create a search engine that pretty much functions like Google web search. However, instead of meta descriptions under each URL, I’d like photos from the website to appear.</p> <ol> <li>The search engine should pull images from the site and display them under the result in a predefined area. </li> <li>The images will most likely have to be scaled to fit.</li> <li>Also, only images of certain sizes and resolutions should be considered to show in a result so that very small images do not get pulled. </li> <li>Also, the search engine should look for images that are close the query term that the user input if possible. </li> </ol> <p>Who can do that? I need full code.</p>
php
[2]
3,468,017
3,468,018
jQuery Selector to Return All Elements Hidden By an Element Without a Particular Class
<p>Is it possible to write a single selector to query for all elements which have a hidden parent where the hidden parent doesn't have a specific class. </p> <p>For example given the HTML below, it would only select Field2 as it's parent is hidden and the parent element that hides it does not have the "tab" class.</p> <pre><code>&lt;div class="tab" style="display: none;"&gt; &lt;div&gt; &lt;input name="Field1" /&gt; &lt;/div&gt; &lt;div style="display: none;"&gt; &lt;input name="Field2" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="tab" style="display: none;"&gt; &lt;div&gt; &lt;input name="Field3" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="tab"&gt; &lt;div&gt; &lt;input name="Field4" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
4,545,901
4,545,902
Using interpreter to lookup module 'sys' in Python
<p>So I just installed the python interpreter and wanted to use the help(sys) feature to get more information about the sys module, but I got this error and had no idea what went wrong.</p> <pre><code>C:\Users\Jake&gt;python Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win 32 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import sys &gt;&gt;&gt; help(sys) 'more' is not recognized as an internal or external command, operable program or batch file. &gt;&gt;&gt; </code></pre> <p>Is this a matter of not having the source code for the sys module on my computer or something else entirely? Any help would be greatly appreciated.</p>
python
[7]
2,753,386
2,753,387
Is there an event to detect when the screen dims?
<p>I'm using a SCREEN_DIM_WAKE_LOCK and so my never turns off. It just goes from full brightness to dim.</p> <p>Is there any way for me to detect when the screen gets dim (event, receiver, etc.) ?</p>
android
[4]
3,588,375
3,588,376
Can anyone help me with this questions about eclipse and windows builder?
<p>I actually have more than one question, and I really need help because I'm starting in java's world and I don't know a lot, I used to program using C#, but now I want to learn java and there are some things that I just don't understand.(sorry for my english, it's not my first language.)</p> <p>1 question- I see you guys use something like: </p> <pre><code>new example(new example2(){ public void example3{ ......; }}); </code></pre> <p>Can anyone please tell me what that is, because I get lost when I see those kind of things.</p> <p>2- Why does it have to be "final"?, i don't get it.</p> <pre><code> JTextArea txt_number1 = new JTextArea(); txt_number1.setBounds(94, 55, 46, 23); frame.getContentPane().add(txt_number1); </code></pre> <p>btnNewButton.addActionListener(new ActionListener() {</p> <pre><code> public void actionPerformed(ActionEvent arg0) { String hola; //hola = txt_number1.getText(); THIS GIVES ME AN ERROR } }); </code></pre> <p>it's telling me that JTextArea needs to be final WHY</p> <p>my last question is, in languages like C# or Visual basic you just drag and drop, I'm using WindowsBuilder with Eclipse but even with that I still have to deal with the code! Action listener and that kind of things and now I don't know what to learn! Should I learn Jpa?, JDBc?, should I program without using a visual editor like Windows Builder?....Please I'd really appreciate if you take your time to help this noob</p>
java
[1]
4,892,530
4,892,531
Problems in posting value from Jquery UI Dialog
<p>I have submit button in side the jquery ui dialog and the dialog is inside a form. I am posting values to the same or different php page. But what I found that the values are not posted and actually submit button is not working at all. What is the fix? Please help with your opinions.</p> <p>thanks</p>
jquery
[5]
3,488,173
3,488,174
Illegalstate exception in listview
<p>in my listview i am populating datas which come from a background thread and i also called notifydatasetchanged(),still it gives exception.does anybody have solution to this.</p>
android
[4]
773,383
773,384
Differences between android:text="@string" and android:text="..."
<p>Maybe this is a silly question but is there a difference,besides the obvious,between android:text="@string/...." and android:text="..."?.I'm thinking that maybe the text that appears on the screen has the option for styling when using @string.Which one is best to use in general or it really doesn't matter?</p>
android
[4]
1,814,382
1,814,383
mimerender installation issues
<p>I am having a hard time installing mimerender. I followed all the steps and downloaded the .egg package. I was trying to use your example here:</p> <p><a href="http://stackoverflow.com/questions/713847/recommendations-of-python-rest-web-services-framework">Recommendations of Python REST (web services) framework?</a></p> <p>Can you guide me as to what my issue my be? I keep getting the following error messages:</p> <blockquote> <p>pip install mimerender Requirement already satisfied (use --upgrade to upgrade): mimerender in c:\python27\li b\site-packages\mimerender-0.3.1-py2.7.egg Downloading/unpacking mimeparse (from mimerender) Cannot fetch index base URL <a href="http://pypi.python.org/simple/" rel="nofollow">http://pypi.python.org/simple/</a> Could not find any downloads that satisfy the requirement mimeparse (from mimerender ) No distributions at all found for mimeparse (from mimerender) Storing complete log in C:\Users\bkhozair\AppData\Roaming\pip\pip.log</p> </blockquote> <p>Thank you, Bahram</p>
python
[7]
5,704,513
5,704,514
internationalization in iphone
<p>I am developing an app in English. I want to change this app into French.</p> <p>For static data I am able to do this. But For dynamic data I am unable to do this. How can I solve my problem..</p> <p>Thanks and Regards sai</p>
iphone
[8]
5,713,047
5,713,048
How can I check whether a user enters the same number twice? C++ Help?
<p>I just need quick help. Here's a breakdown of some code:</p> <pre><code>char userLetter; int userNumber; cout &lt;&lt; "Please enter a letter: "; cin &gt;&gt; userLetter; while(userLetter == 'A') { cout &lt;&lt; "Please enter a number: "; cin &gt;&gt; userNumber; //do something in the loop here cout &lt;&lt; "Please enter a letter: "; cin &gt;&gt; userLetter; } </code></pre> <p>Now I basically need to add something that will tell the user his entry is invalid if he enters the same number more than once. For example, let's say the user enters the letter A and the number 2. The while loop executes whatever it needs to do and then asks the user for a letter again. Let's say the user enters 'A' again. The loop then asks the user for another number, if the number is 2 again, the program should tell the user it's an invalid entry.</p> <p>Any help?</p>
c++
[6]
2,663,032
2,663,033
Speeding up System.Collection.Generic.Queue() possible?
<p>50\% of my simulation time is spent on the following code:</p> <pre><code> internal double simWithdrawalFast(double t) { simarrivals.Enqueue(t + Leadtime); return simarrivals.Dequeue(); } </code></pre> <p>where simarrivals is a <code>System.Collection.Generic.Queue&lt;double&gt;</code>. </p> <p>If I write my own queue, will it be faster?</p> <p>EDIT: note that there are doubles in the queue to begin with, i.e. the queue has about 200 elements when simwithdrawal is called. Each call adds and removes an element. </p>
c#
[0]
3,759,365
3,759,366
Iterating through a list of objects and displaying the property in the combobox
<p>I have 2 combo boxes, the first one lets you pick an interface and the second one should display the appropriate addresses depending on which interface you chose, I have a list of objects, each object is an interface with associated addresses. I need to display these addresses to the combo box after the user chooses what interface to connect to. </p> <p>Here is what I have so far and the problem is that it always displays the addresses for the first interface. The AddressCnt is the number of addresses for each interface. </p> <pre><code> private void cboInterface_SelectedIndexChanged(object sender, EventArgs e) { lblAddress.Text = cboInterface.SelectedItem.ToString(); cboAddress.Items.Clear(); for (int x = 0; x &lt; Interface[0].AddressCnt; x++) { cboAddress.Items.Add(Interface[0].AddressBuff[x].ToString()); } } </code></pre>
c#
[0]
4,286,932
4,286,933
how to make online radio application on android?
<p>I tried to make some test for listening mp3 file which is located in website. It was successfull. But when I tried to listen a link which is online radio, application is doing nothing. No any sounds..</p> <p>I used :</p> <pre><code>private void initializeMediaPlayer() { player = new MediaPlayer(); try { player.setDataSource("http://www.buradyo.com/"); // player.setDataSource("http://cdn.concreteloop.com/wp-content/uploads/2011/01/Jennifer-Lopez-feat.-Pitbull-On-the-Floor.mp3"); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } player.setOnBufferingUpdateListener(new OnBufferingUpdateListener() { public void onBufferingUpdate(MediaPlayer mp, int percent) { playSeekBar.setSecondaryProgress(percent); Log.i("Buffering", "" + percent); } }); } </code></pre> <p>this code is ok for mp3 file but not ok for online radio..</p> <p>Waiting your help.. Thanks</p>
android
[4]
4,362,030
4,362,031
Why use initializer_list instead of vector in parameters?
<p>What is the actual benefit and purpose of <code>initializer_list</code>, for unknown number of parameters? Why not just use <code>vector</code> and be done with it?</p> <p>In fact, it sounds like just a <code>vector</code> with another name. Why bother?</p> <p>The only "benefit" I see of <code>initializer_list</code> is that it has <code>const</code> elements, but that doesn't seem to be a reason enough to invent this whole new type. (You can just use a <code>const vector</code> after all.)</p> <p>So, what am I mising?</p>
c++
[6]
4,205,850
4,205,851
FileSystemWatcher, unsubscribe from the event
<p>I'm fooling around with the FileSystemWatcher in 4.0. I find this very useful but am getting caught in a loop. I'm trying to monitor whenever an ini is changed and change it back to the correct default (long story) however the change event copying over the new file is causing it to drop into a loop ... Any Ideas > ? I played around with the idea of deleting and recreating thefile to avoid triggering the changed event but this leads to another set of issues with the program that I'd rather avoid. Also I'd imagine I could overwrite the text but this also poses the same issue. Thanks in advance for the help</p> <pre><code> static void Main() { Watch (@"\\NoFault2010\Lexis\Data\Setup\", "tmconfig.ini", true); } static void Watch (string path, string filter, bool includeSubDirs) { using (var watcher = new FileSystemWatcher (path, filter)) { watcher.Changed += FileChanged; watcher.EnableRaisingEvents = true; Console.WriteLine("Do Not Close ... \n\nThis is a Temporary Configuration Manager for Time Matters ... \n\n\nI'm Listening ............"); Console.ReadLine(); } } static void FileChanged (object o, FileSystemEventArgs e) { string _right_stuff = @"\\NOFAULT2010\Lexis\Data\Templates\Programs\tmconfig.ini"; string _working = @"\\NOFAULT2010\Lexis\Data\Setup\tmconfig.ini"; System.Threading.Thread.Sleep(2000); File.Copy(_right_stuff, _working, true); Console.WriteLine("File {0} has been {1}", e.FullPath, e.ChangeType); MAIL_IT("[email protected]", "TM Master.INI has been altered", "Check the Master INI and Yell At Ecopy Guy " + e.ChangeType + e.FullPath); } </code></pre> <p>How would I unsubscribe from the event to avoid entering into this loop.</p>
c#
[0]
5,552,324
5,552,325
apply script to all elements
<p>i need to show all images, which are in the <code>div</code> with <code>class="deep"</code>.</p> <p>when i try the following script it doesn't work.</p> <p><code>$(".deep img").css("visibility", "visible");</code></p> <p>i can solve the problem using something like <code>.each</code>, but maybe there is something more simple?</p> <p>Thanks</p>
jquery
[5]
549,567
549,568
Check box checked Automatically in listview when scrolling the list.
<p>I have one problem, i have customize <code>listview</code> with <code>checkbox</code>. </p> <p>When i scroll the items the some <code>checkbox</code> is automatically <code>checked</code> without clicking on <code>checkbox</code>.</p> <p>Can any one help me?</p>
android
[4]
5,355,257
5,355,258
Printed representation of list
<p>I want to format a list into a string in this way: <code>[1,2,3] =&gt; '1 2 3'</code>. How to do this? Is there any customizable formatter in Python as Common Lisp format?</p>
python
[7]
5,736,390
5,736,391
Get Item From List<T> and update a property on that Item
<p>I have a List of type Person that I would like to update DisplayValue based on DisplayName. How can I accomplish this?</p> <pre><code>public class Person { public string DisplayName { get; set; } public string DisplayValue { get; set; } ... other properties } </code></pre>
c#
[0]
1,986,349
1,986,350
unable to connect postgresql in android code on windows 7
<p>i want to connect postgresql database in my android code... for that first i install postgresql 9.1 and download the jdbc driver ..... and then follow the android code from below site</p> <p><a href="http://appliedcoffeetechnology.tumblr.com/post/10657124340" rel="nofollow">http://appliedcoffeetechnology.tumblr.com/post/10657124340</a></p> <p>but i got the error message like</p> <p>org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.</p> <p>i checked all possible getconnection method but got same error... so can u provide any advice please.....</p>
android
[4]
2,706,862
2,706,863
Automating Website Testing - Website Online/Available?
<p>I would like to automate some testing of whether a long list of websites is available or not. I need to test access of certain websites in an intranet. I just need to basically create an HTTPRequest and send the URL and then read the HTTPResponse (200, 404, 500, etc.) and log the results. I have some code doing this already and I got a response of 'OK' (a 200). Is this correct? Anything else I should be doing?</p> <pre><code> try { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(URL); webRequest.Method = "GET"; HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); System.Diagnostics.Debug.WriteLine("The response code is: " + webResponse.StatusCode); System.Diagnostics.Debug.WriteLine("The response description is: " + webResponse.StatusDescription); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Catch: " + ex.Message); } </code></pre>
c#
[0]
5,980,610
5,980,611
Can I have an object return a default value if no methods are called?
<p>As an example, I want to mimic the functionality of the String object:</p> <pre><code>String mystring = new String ( "Hi there." ); System.out.println(mystring); // prints "Hi there." without calling any methods on String // (that is what I want with my object) System.out.println(mystring.toUpperCase()); // prints "HI THERE." </code></pre> <p>Starting with this:</p> <pre><code>class MyObject { private Int value ; public MyObject ( Int value ) { this.value = value ; } public Int getValue ( ) { return this.value ; } public Int multiplyBy ( Int multiplier ) { return this.value * multiplier ; } } </code></pre> <p>... How (or can I) do something like this:</p> <pre><code>MyObject myobject = new MyObject ( 6 ) ; System.out.println( myobject ) ; // want to print myobject.value (6) System.out.println( myobject.multiplyBy ( 2 ) ) ; // print 12 </code></pre> <p>I'm quite new to Java and realize that I'm probably missing some fundamental concept, but any feedback would be appreciated. Thank you.</p> <p>Edit: The responses about overriding the toString method were helpful, but it's not quite doing what I had in mind, here's a better example of what I want:</p> <pre><code>Double mydouble = new Double ( 20.1 ) ; System.out.println ( mydouble + 10.1 ) ; // prints 30.2 </code></pre> <p>How would I do this with my own object (assuming I want the default value to be a double)?</p> <p>Thanks again.</p> <p>Final Edit (hopefully): Your answers were enough to lead me to learn more about Primitive Wrappers and Autounboxing. My understanding is that there's no way to do what I want (which at this point, I would describe as autounboxing my object as a double), or at least I'll save that for another question. Cheers.</p>
java
[1]
4,686,144
4,686,145
android monitoring apps
<p>I would like to create an Android application with real-time monitoring functions. One monitoring function is to audit the audio flow. The other function is to interact with a peripheral sensor. These monitoring functions can be triggered by others. Besides, in order to save power consumption, the audio function will be running in a polling mode, i.e. sleep for a certain amount of time and wake for a certain amount of time. </p> <p>I am considering how to design the Android application. </p> <ul> <li><p>Whether to design the audio function as a Service or an Activity? The problem is if it is designed as an Activity, the audio function will be off if screen turns off after a period of time.</p></li> <li><p>How to design the polling function? Use an AlarmManager or a inner-thread with Timer?</p></li> </ul> <p>My goal is to save the power consumption as much as possible. Thanks.</p>
android
[4]
4,667,679
4,667,680
What is the way collide UILabel in UIImage?
<p>I have a task to do. I have a big image like a country and different names like name of the states in a country which are UILabels. My task is if I place the label on any state in the UIImageview, it should check whether I placed it on correct place or not.</p> <p>Can anyone let me know the logic how to do this?</p>
iphone
[8]
4,115,045
4,115,046
ASP.net AJAX: textbox readonly state
<p>I currently have a button called Edit and a text box call blah on a ajax updatepanel. is it possible to set the asp.net's textbox Readonly via trigger? </p>
asp.net
[9]
3,839,663
3,839,664
C++: boost smart pointer
<p>Could you please help me to check this code following, I got some errors?</p> <pre><code>class VideoInfo { public: VideoInfo(); virtual ~VideoInfo(); std::string filename; // name of the video file in the fileSystem unsigned int frameSequenceID; // frame index of the video file }; } } </code></pre>
c++
[6]
2,119,155
2,119,156
Show 2 by 2 elements on click
<p>I have the following container:</p> <pre><code> &lt;div id="container"&gt; &lt;div id="1"&gt;1&lt;/div&gt; &lt;div id="2"&gt;2&lt;/div&gt; &lt;div id="3" style="display:none"&gt;3&lt;/div&gt; &lt;div id="4" style="display:none"&gt;4&lt;/div&gt; &lt;div id="5" style="display:none"&gt;5&lt;/div&gt; &lt;div id="6" style="display:none"&gt;6&lt;/div&gt; &lt;/div&gt; &lt;div id="more_results"&gt;Show 2 more results&lt;/div&gt; </code></pre> <p>How to: when I click on the show more div to display the next 2 hidden div (3 and 4). And then if they click again show div (5 and 6)</p> <p><a href="http://jsfiddle.net/ymorin007/wpbBJ/" rel="nofollow">DEMO jsFiddle.</a></p>
jquery
[5]
4,788,747
4,788,748
Null-Pointer by findViewById
<p>I have in my onCreate-Method a lot of findViewById. Some of them are parameter for objects I make in the onCreate-Method. Now I tried to make the findViewById-call in the Constructor of my Objects but i get a Null-Pointer. How do I get these findViewByIds in my Object?</p>
android
[4]
1,395,875
1,395,876
check for online update when open program in C#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/555118/suggest-a-method-for-auto-updating-my-c-sharp-program">Suggest a method for auto-updating my C# program</a> </p> </blockquote> <p>I'm sorry if this question has been asked already. i have a problem whit online update because i don't know how can add code for check for update program and after check if find newer version upgrade itself.</p> <p>However, every time I make changes to the program people will have to download the new version.</p> <p>i have a host and no any problem whit host. well only i need add code for check for online update</p> <p>how can add code for check for update when open program ? what can i do ? what do i do ? can u please help me ?</p> <p>please <strong>give me sample code or sample project</strong> for understand. thanks.</p>
c#
[0]
1,182,166
1,182,167
jQuery Deferred object callback args & dynamically building?
<p>I saw this code at jQeury Site : </p> <pre><code> 1: var jqxhr = $.ajax( "example.php" ) .done(function() { alert("success"); }) .fail(function() { alert("error"); }) .always(function() { alert("complete"); }); 2: // perform other work here ... // Set another completion function for the request above 3: jqxhr.always(function() { alert("second complete"); }); </code></pre> <hr> <h2>2 Questions :</h2> <p><strong>1)</strong> I heard that the callback functions <strong>arguments</strong> of <code>success</code> , <code>error</code> , <code>complete</code> being transferred to <code>done</code> , <code>fail</code> , <code>always</code> respectively.</p> <p><img src="http://i.stack.imgur.com/j4vi1.jpg" alt="enter image description here"></p> <p>So If I want to use the <strong>jqXHR</strong> obj in always callback , How can i know from where he came (<code>error</code> or <code>success</code>) - because the <code>params order</code> in the method signature is <strong>different</strong> !!!</p> <pre><code>//here it is at place 3 </code></pre> <p><img src="http://i.stack.imgur.com/DrFGl.jpg" alt="enter image description here"></p> <pre><code>//here it is at place 1 </code></pre> <p><img src="http://i.stack.imgur.com/D3k57.jpg" alt="enter image description here"></p> <hr> <p><strong>2)</strong> I also heard that Defered Objects help us to build the callback Function dynamically. (as we can see in '<code>3:</code>')</p> <p>I dont understant why will I ever need it ? by the time I got the Section <code>3:</code> - the ajax call has <strong>already</strong> been made and alerted completed , In what scenarios the section <code>3:</code> comes into action ?</p>
jquery
[5]
4,731,366
4,731,367
Good examples of PHP code for an intermediate PHPer?
<p>I know the basics for PHP and have written a school project in PHP (although looking back on it, I'd really love to rewrite it)</p> <p>I'd really like to get a feel for how to code <em>good</em> PHP code though, for example what are the best practices when it comes to PHP? And are there recommended ways of tackling certain tasks?</p> <p>I think the best way for me to tackle this question would just be for me to spend some time browsing through some PHP code, although I realise there are questions similar to this already the answers mostly seem to reference PHP programs like wordpress . . . which is just a little over my head (not to mention incredibly large to trawl through and try and understand)</p> <p>So can anybody recommend some programs for me to look at, that promote best practises, but are simple enough for me to understand (i.e. not Wordpress, Magento, or something on that level)?</p>
php
[2]
3,445,660
3,445,661
edit the first option name
<p>I have the following code which I do not have access to. </p> <p>What I want to do is add some text into the first option which is now empty. Text such as "Select Address"</p> <pre><code>&lt;select name="My_Saved_Billing" onChange="Choose_My_Saved_Billing(this.selectedIndex)" style="background-color:#EEEEEE"&gt; &lt;option&gt;&lt;/option&gt; &lt;option value="1394"&gt;text&lt;/option&gt; &lt;/select&gt; </code></pre>
jquery
[5]
4,683,510
4,683,511
sql data type bit
<p>I have sql data type bit and i want to ask </p> <pre><code>if(dr[2] != null) </code></pre> <p>What changes should make it? Sorry for the mistakes I'm not local.</p>
c#
[0]
2,559,925
2,559,926
PHP form not working on new server
<p>I have created a form for my website by following a tutorial at tutorialzine</p> <p>I have this form working nicely on one of my websites but when I tried to install the form on a new website the form fields are full of script and it doesn't work. I have put the same form on both servers to demonstrate the problem.</p> <p>Working form: <a href="http://lagunapools.com.au/crowntest/contact.php" rel="nofollow">http://lagunapools.com.au/crowntest/contact.php</a></p> <p>Not working: <a href="http://crowndoor.com.au/crowntest/contact.php" rel="nofollow">http://crowndoor.com.au/crowntest/contact.php</a></p> <p>Any help would be appreciated.</p>
php
[2]
3,275,374
3,275,375
how to construct a long string
<p>I need to construct a long string with javascript. Thats how i tried to do it:</p> <pre><code>var html = '&lt;div style="balbalblaba"&gt;&amp;nbsp;&lt;/div&gt;'; for(i = 1; i &lt;= 400; i++){ html+=html; }; </code></pre> <p>When i execute that in firefox its taking ages or makes it crash. what is the best way to do that? What is generally the best way to construct big strings in JS.</p> <p>can someone help me?</p>
javascript
[3]
3,107,851
3,107,852
What does Python's dir() function stand for?
<p>I know that the dir() function gives you back either the names defined in the current scope or the names defined in an object. But why is it called dir()? Is it some mysterious acronyms like LISP's CAR and CDR?</p>
python
[7]
2,372,970
2,372,971
limit php script (fetch all photos in a directory) to 7
<p>can someone please help, i am using a script in php to fetch all the photos in a directory, but i want it to limit it to only fetch 7 images in total, the ones it select can be random.</p> <p>can anyone suggest a way i can do this thanks.</p> <pre><code>&lt;?php if (isset($_SESSION['user_id'])) { if ($user['id'] == $_SESSION['user_id']){ if ($user['account_type'] == "Escort"){ ?&gt; &lt;div class="profile_photos_drop"&gt;&lt;iframe src="includes/mod_photo_uploads/small_pics.php" width="184" height="194" scrolling="no" style="overflow:hidden; margin-top:-4px; margin-left:-4px; border:none;"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;? } } } ?&gt; &lt;?php $profile_bits = get_profile_bits(); while ($profile = mysql_fetch_array($profile_bits)) { $dirname = "./data/photos/".$profile_id."/"; $images = scandir($dirname); $ignore = Array("_cover.jpg", "_default.jpg", "_starlight.jpg", "_starlight_thumb.jpg", "thumb_pic1.jpg", "thumb_pic2.jpg", "thumb_pic3.jpg", "thumb_pic4.jpg", "thumb_pic5.jpg", "thumb_pic6.jpg", "thumb_pic7.jpg", "thumb_pic8.jpg", "thumb_pic9.jpg", "thumb_pic10.jpg", "thumb_pic11.jpg", "thumb_pic12.jpg", "thumb_pic13.jpg", "thumb_pic14.jpg", "thumb_pic15.jpg", "thumb_pic16.jpg"); foreach($images as $curimg){ if(!in_array($curimg, $ignore) &amp;&amp; preg_match("/\.jpg$/i", $curimg)) { echo "&lt;a href=\"".$dirname.$curimg."\" rel=\"shadowbox\" title=\"&lt;strong&gt;{$profile['display_name']}'s Photo's&lt;/strong&gt;\"&gt;&lt;img src='".$dirname.$curimg."' class=\"profile_photos\" width=\"170\" height=\"150\" &gt;&lt;/a&gt;"; }; } } ?&gt; </code></pre>
php
[2]
3,317,381
3,317,382
How to start an ACTION_PICK activity with only those contacts which have a mobile phone
<p>I want the user to select a contact to which my application would send a SMS. How do I ensure that when I start an activity with ACTION_PICK intent only those contacts with mobile phone numbers are displayed?</p> <p>Currently, I'm starting the activity like this:</p> <pre><code>Intent intent = new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI); </code></pre>
android
[4]
1,811,495
1,811,496
Rename a string-array in arrays.xml
<p>In my values/arrays.xml, I have <code>&lt;string-array name="pref_entries" translatable="false"&gt;</code> but as soon as I rename it to </p> <pre><code>&lt;string-array name="pref_entries2" translatable="false"&gt; </code></pre> <p>I get this error:</p> <p>res/values/arrays.xml:28: error: Resource at pref_entries appears in overlay but not in the base package; use to add.</p> <p>Can you please tell me how can I fix my problem?</p> <p>Thank you.</p>
android
[4]
139,039
139,040
Close a running program from java application
<p>I open up an external application from my java application. How can I close this application from the same Java application? thanks</p>
java
[1]
4,860,083
4,860,084
How to express the difference between two dates in a human-readable format
<p>If I have two dates - <code>$end_date</code> and <code>$start_date</code>, how can I express the difference between the two in a format such as "2 Years : 4 Months : 2 Days"?</p> <p>I know that I can get the difference between the two dates like so:</p> <pre><code>$dif=strtotime($end_date)-strtotime($today); </code></pre> <p>But how can I convert that result into the human-readable format, like that shown above?</p>
php
[2]
2,601,981
2,601,982
Better way to read in stream data without wrapping the whole thing in an empty try catch?
<p>Doing something like this at the moment:</p> <pre><code>try { while ((bytesRead = clientStream.Read(data, 0, data.Length)) != 0) { string message = Encoding.ASCII.GetString(data, 0, bytesRead) + Environment.NewLine; txtLog.Invoke(c =&gt; c.AppendText(message)); } } catch { } </code></pre> <p>Which works but it's pretty ugly.</p> <p>I know people are going to say not to catch all exceptions and to at least do something when an exception occurs but I'm writing a server application. If a user abruptly disconnections it doesn't matter. It doesn't need to be logged. Also, I never want the program to crash so is catching all exceptions really that bad? The program can still recover. After the while loop this code executes and everything is fine. Right?:</p> <pre><code>string clientIdentifier = tcpClient.Client.RemoteEndPoint.ToString(); bool clientRemoved = clients.TryRemove(clientIdentifier); if (clientRemoved) { listUsers.Invoke(c =&gt; c.Items.Remove(clientIdentifier)); } tcpClient.Close(); </code></pre> <p>Not really asking a specific question but more of wondering if this is fine and if not, what is a better way to handle a user abruptly disconnecting or any other form of read error?</p>
c#
[0]
3,510,555
3,510,556
combining PHP functions
<p>I've inherited some php that parses an xml file to populate a page full of unordered lists and am wondering if there is a way to consolidate the php functions to make them more efficient.</p> <p>There are 25 or so functions like the following:</p> <pre><code>function oaAccounting(){ // load SimpleXML $term = new SimpleXMLElement('training_list.xml', null, true); echo &lt;&lt;&lt;EOF &lt;ul&gt; EOF; foreach($term as $term) { if(preg_match("/accounting/i", $term-&gt;keyword)){ echo &lt;&lt;&lt;EOF &lt;li&gt;{$term-&gt;name}&lt;/li&gt; EOF; } } echo '&lt;/ul&gt;'; } </code></pre> <p>each one scans the xml file for the term/keyword it's searching for and adds the term as a list element to an unordered list specific to that function. The next function does the same thing but for a different term/keyword and adds it to a separate unordered list.</p> <p>is there a way to combine all this to prevent having to do the foreach and if 25 times in a row?</p> <p>Thanks!</p>
php
[2]
2,730,200
2,730,201
How to play more than two songs using AVAudioPlayer
<p>I want to play more than two song in my app. how do I can do it using AVAudioPlayer ?</p>
iphone
[8]
2,186,783
2,186,784
IE 7 & 8 wont load script
<p>I am using the following code to load in needed JS libraries for my widget:</p> <pre><code>function loadScrip(url, callback) { var script = document.createElement("script") script.type = "text/javascript"; if (script.readyState) { //IE script.onreadystatechange = function () { if (script.readyState == "loaded" || script.readyState == "complete") { script.onreadystatechange = null; callback(); } }; } else { //Others script.onload = function () { callback(); }; } script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } loadScrip("http://code.jquery.com/jquery-1.8.3.js", function () { loadScrip("http://code.jquery.com/ui/1.9.2/jquery-ui.js", function () { alert("Loaded"); js13 = jQuery.noConflict(true); main(); }); }); </code></pre> <p>This works absolutley fine in all browsers and in IE9.</p> <p>But in IE 7 &amp; 8 for some reason the jquery-ui.js wont load and i get error:</p> <pre><code>Line: 563 Character: 4 Code: 0 Error Message: Object doesn't support this property or method URL: http://code.jquery.com/jquery-1.8.3.js </code></pre> <p>Any ideas how to fix this? Im banging my head against the wall with this problem </p>
javascript
[3]
4,903,898
4,903,899
"Clear User Data" android
<p>What exactly does Clear User Data do? I mean I know it clears the users data from the app, but what data being stored where?</p>
android
[4]
2,863,689
2,863,690
php: keyword lookup
<p>I'm looking for a little php script that looks up keywords in a mysql table and gives the response, based on the most matching keywords. For example:</p> <ul> <li><p>imput:who are you </p></li> <li><p>mysql table: KEYWORDS:who,you RESPONSE: I'm a robot</p></li> <li><p>script returns: I'm a robot</p></li> </ul>
php
[2]
3,228,922
3,228,923
Passing parameter to a windows service in c#
<p>I am creating a windows service which has to run on specific days and time. I am passing these variables using an XML document. Here is my code for passing the values</p> <pre><code> static void Main() { ServiceBase[] ServicesToRun; Service1= new Service1(); //Load setting from xml and assign to variables "daysToExec" and "timeToExec" LoadSettings(); Service1.daysToExecute = daysToExec; Service1.timeToExecute = timeToExec; ServicesToRun = new ServiceBase[] { Service1 }; ServiceBase.Run(ServicesToRun); } </code></pre> <p>The code for OnStart() in Service1.cs </p> <pre><code> protected override void OnStart(string[] args) { timer1.Enable = true; } private void timer1_Tick(object sender, EventArgs e) { foreach (string DayToRun in daysToExecute) { if (DateTime.Now.DayOfWeek.ToString().ToUpper().Equals(DayToRun.ToUpper()) &amp;&amp; DateTime.Now.ToShortTimeString().Equals(timeToExecute)) { Process.Start("Path to executable"); } } } </code></pre> <p>But this is not starting the executable. Is there something wrong with this code.</p> <p>Thanks.</p>
c#
[0]
3,824,597
3,824,598
how to show images in grid view?
<p>I have a database which contains list of image path. My problem is I have to show all the images in a grid view. I have taken list of path from database but i am not able to show all the images in grid layout. Please help me. Thanks</p>
android
[4]