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 |
|---|---|---|---|---|---|
604,496 | 604,497 | Jquery - Adding two numbers with decimal point gives wrong total | <p>I have the following Jquery function on change event on a textbox</p>
<pre><code> $('input:text[id$=txtText1]').change(GetTotal);
</code></pre>
<p>This calls GetTotal function</p>
<pre><code> function GetTotal() {
var value1 = txtText1.val();
var value2 = txtText2.val();
var sum = add(value1, value2)
$('input:text[id$=txtSubTotals]').val(sum);
}
</code></pre>
<p>This is the add function</p>
<pre><code> function add() {
var sum = 0;
for (var i = 0, j = arguments.length; i < j; i++) {
if (IsNumeric(arguments[i])) {
sum += parseFloat(arguments[i]);
}
}
return sum;
}
</code></pre>
<p>In textbox 1 the value is 1.45 and in Textbox 2 it is 1.44 instead of getting 2.89. I am getting the following value 2.8899999999999997 </p>
| jquery | [5] |
237,377 | 237,378 | validate checkboxes using php | <p>I have a form with series of checkboxes with the same name of 'name=category[]'. And now I need to count how many checkboxes are selected by a user. Further I need to check at least 1 checkbox is being selected or upto 10 checkboxes. </p>
<p>This is the way that I am trying so far...</p>
<pre><code>if ( isset ( $_POST['category']) {
if (( sizeof( $_POST['category']) == 10 || sizeof( $_POST['category']) <= 10 )) {
// form processing....
} else {
echo 'Atleast 1, not more than 10 categories.';
}
} else {
echo 'Please select atleast one category.';
}
</code></pre>
<p>can anybody tell me is there an another way to accomplish this task? That mean, to get this two errors... </p>
| php | [2] |
1,795,523 | 1,795,524 | Error handling using `Deferred` | <p><code>Deferred</code> objects have two main pools of callbacks, namely <code>doneCallbacks</code> and <code>failCallbacks</code>. Both pools are "linear": the callbacks are stored one after the other in the order they were given in.</p>
<p>This linear structure seems to go against the "tree-like" structure one has to consider when handling errors. At every step, there are two cases: fail and pass.</p>
<pre><code>if(err) {
// stuff
if(err) {
// stuff
} else {
// stuff
}
else {
// stuff
if(err) {
// stuff
} else {
// stuff
}
}
</code></pre>
<p>It seems that because of the imposed linearity of <code>Deferred</code>s, they are not very suited for error handling. Am I overlooking something?</p>
| jquery | [5] |
2,452,328 | 2,452,329 | how to iterate DOM ol and save its li values to array using jquery | <p>I would like to iterate ol and save all li into array</p>
<pre><code><ol id="sortableAvailable">
<li id="1"><a href="" >Foo 1</a></li>
<li id="2"><a href="" >Foo 2</a></li>
<li id="3"><a href="" >Foo 3</a></li>
<li id="4"><a href="" >Foo 4</a></li>
</ol>
</code></pre>
<p>js should be somthing like this:</p>
<pre><code>var testInfoList = {};
testInfoList.ConfiguredTests = [];
/* some iteration that do the following */
testInfoList.ConfiguredTests.push({
ID: /*here i want the ID*/,
Value: /*here i want the value*/
});
</code></pre>
| jquery | [5] |
789,510 | 789,511 | Pagination Problems(PHP superglobal variable issue, undefined index) | <p>i am trying to implement pagination somewhere and i have this issue:</p>
<p>I have this part to change links:</p>
<pre><code>echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
</code></pre>
<p>which gives this error for this part:</p>
<pre><code>$Page = $_GET["Page"];
if(!$_GET["Page"])
{
</code></pre>
<p>It says undefined index..
Why do I get this Error?
Thanks</p>
| php | [2] |
984,680 | 984,681 | Syntax error on if-else Javascript statement | <p>I'm fairly new to JavaScript so I don't quite understand why I am getting a syntax error on 'else'. Any advise?</p>
<pre><code><script language="javascript">
$(document).ready(function() {
$('#toggleButton').click(function() {
if ($('#toggleSection').css("opacity") == 0); {
$('#toggleSection').fadeIn("slow");
}
else {
$('#toggleSection').fadeOut("slow");
}
return false;
});
});
</script>
</code></pre>
| javascript | [3] |
5,508,395 | 5,508,396 | Kendo UI Window Cant Using | <p>I want use Kendo ui window but i cant what is problem </p>
<pre><code><div id="window">
</div>
<div id="rightColumn">
<p>
<asp:Button Text="Edit Advert" Visible="false" ID="btnEditAdv" CssClass="msgbutton" runat="server" />
</p>
</div>
<script type="text/javascript">
$(document).ready(function () {
var window = $("#window").kendoWindow({
title: "Centered Window",
width: "200px",
height: "200px",
visible: false
}).data("kendoWindow");
});
$("#btnOpen").click(function () {
var window = $("#window").data("kendoWindow");
window.center();
window.open();
});
</script>
</code></pre>
| asp.net | [9] |
2,330,018 | 2,330,019 | Do programmers keep error reporting on or off? | <p>I was wondering if php programmers keep error_reporting in php.ini on or off after delivering the website?</p>
| php | [2] |
2,875,101 | 2,875,102 | Object to string conversion in JavaScript | <p>I was playing around with object to string conversion in JavaScript. All objects inherit two conversion functions - <code>toString()</code> and <code>valueOf()</code>. When JavaScript tries to convert object into string, it searches for the <code>toString()</code> implementation and then for <code>valueOf()</code> implementation. So I overrode the <code>toString()</code> and <code>valueOf()</code> in this way:</p>
<pre><code>var obj = {
x: 10,
y: 20,
toString: function() {
return "x = " + this.x + ", y = " + this.y;
},
valueOf: function() {
return this.x + ", " + this.y;
}};
</code></pre>
<p>Concatenating the object literal with a string:</p>
<pre><code>console.log("hello " + obj);
</code></pre>
<p><strong>OUTPUT</strong> : <code>hello 10, 20</code></p>
<p>Shouldn't the output be : <code>hello x = 10, y = 20</code>?</p>
<p>Appreciate any help. </p>
| javascript | [3] |
1,028,417 | 1,028,418 | Splitting data from URL? | <p>Say my url is <code>site.php?id=X-34837439843</code></p>
<p>How do i split it so I return</p>
<pre><code>$table = "X";
$id = "X-34837439843";
</code></pre>
<p>Basically I'm using the same page to select from different tables, and the letter at the beginning of the ID represents which table, so I need to split the left side of the <code>"-"</code>.</p>
| php | [2] |
5,337,732 | 5,337,733 | Can i hold 1024 bit data in any of Iphone data type? | <p>Can i store 1024 bit data in
uint64_t or NSUinteger or NSDecimal Number or any of the Iphone(objective-c) data type
and also need to do arithmatic operations including & , % </p>
<p>thanks </p>
| iphone | [8] |
1,234,476 | 1,234,477 | Does asp.net lifecycle continue if I close the browser in the middle of processing? | <p>I have an ASP.NET web page that connects to a number of databases and uses a number of files. I am not clear what happens if the end user closes the web page before it was finished loading i.e. does the ASP.NET life cycle end or will the server still try to generate the page and return it to the client? I have reasonable knowledge of the life cycle but I cannot find any documentation on this.</p>
<p>I am trying to locate a potential memory leak. I am trying to establish whether all of the code will run i.e. whether the connection will be disposed etc.</p>
| asp.net | [9] |
3,104,778 | 3,104,779 | Why Android cannot read the file to a File object? | <p>This is my code to create a File Object. I am sure that the file is existing. However the file <code>length()</code> returns 0 and the <code>exists()</code> returns false too.</p>
<pre><code>File uploadFile = new File(Environment.getExternalStorageDirectory() + "/DCIM/DSC00050.jpg");
int totalSize = (int) uploadFile.length(); // Get size of file, bytes
</code></pre>
| android | [4] |
1,171,420 | 1,171,421 | java replaceAll function of string have a problem | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5179449/wrong-output-using-replaceall">Wrong output using replaceall</a> </p>
</blockquote>
<p>Hi,</p>
<p>If I have string:</p>
<pre><code>String test = "replace()thisquotes";
test = test.replaceAll("()", "");
</code></pre>
<p>the test result is still: <code>test = "replace()thisquotes"</code></p>
<p>so () is not replaced.</p>
<p>Any ideas?</p>
<p>Thanks in advance.</p>
| java | [1] |
570,641 | 570,642 | java string matching problem | <p>I am facing a very basic problem. Some time small things can take your whole day :(
but thank to stackoverflow memebers who always try to help :)</p>
<p>I am trying to match 2 strings if they match it should return TRUE</p>
<p>now I am using this </p>
<pre><code>if (var1.indexOf(var2) >= 0) {
return true;
}
</code></pre>
<p>But if var1 has value "maintain" and var2 has value "inta" or "ain" etc. it still return true :(.
Is there any way in java that can do full text matching not partial?
For example </p>
<pre><code>if("mango"=="mango"){
return true;
}
</code></pre>
<p>thanks ! ! !</p>
| java | [1] |
1,408,478 | 1,408,479 | Does assigning another variable to a string make a copy or increase the reference count | <p>On p.35 of "Python Essential Reference" by David Beazley, he first states:</p>
<blockquote>
<p>For immutable data such as strings, the interpreter aggressively
shares objects between different parts of the program.</p>
</blockquote>
<p>However, later on the same page, he states </p>
<blockquote>
<p>For immutable objects such as numbers and strings, this assignment
effectively creates a copy.</p>
</blockquote>
<p>But isn't this a contradiction? On one hand he is saying that they are shared, but then he says they are copied.</p>
| python | [7] |
209,399 | 209,400 | image url Concatenate string | <p>i want to achievet the following Url</p>
<pre><code>ImageUrl='~/products_pictures/(imageId)_middle.jpg
</code></pre>
<p>im using gridview and datalist</p>
<p>im trying the follwoing combination but it not working</p>
<pre><code> <asp:Image ID="Image1" ImageUrl='~/products_pictures/<%#Eval("Id")%>_middle.jpg' runat="server" /></td>
<asp:Image ID="Image1" ImageUrl=<%"~/products_pictures/"%><%#Eval("Id")%><%"_middle.jpg"%> runat="server" />
</code></pre>
| asp.net | [9] |
321,023 | 321,024 | I want to develop Text-To-Speech(TTS) software for message reader. | <p>I want develop a Text-To-Speech software for some activity.
For Example: opportunities to provide verbal readout of recent updates to an account through a users cell phones.
Please help me regarding this.
Please provide me some good links, java projects or Free TTS software's for message reader or any other important information on this.</p>
<p>Thanks & Regards,</p>
<p>Shrikant A.</p>
| java | [1] |
3,742,602 | 3,742,603 | How do I delay the running of an android test so that an AsyncTask is finished first? | <p>I'm writing a test for my android app. The app loads in some external data into a view using an AsyncTask. I want to test that the AsyncTask worked and that the data is properly placed into the view. The problem is that my test is running (and failing) before the AsyncTask is complete.</p>
<p>What's the best way of handling this scenario?</p>
| android | [4] |
2,165,657 | 2,165,658 | How to grant permission dynamically in android, i.e while running an application, Is this achievable? | <p>I have few doubts.</p>
<ol>
<li><p>Is it possible for Android application after installation, to ask user for permission for accessing certain functions? Like say the app A wants to read contacts for a specific purpose. If the user grants permission, then the activity will take place. Else it wont. Is it possible? </p></li>
<li><p>Is there a way of allowing user to select/de-select permissions during installation time?</p></li>
<li><p>I have read that using CyanogenMod grants user these kind of priveleges. Is there any solution for non-rooted user, apart from take-it-or-leave-it approach? </p></li>
</ol>
| android | [4] |
5,542,788 | 5,542,789 | Can you play a mp3 file from the assets folder? | <p>I store all my sounds in the res folder. I'm wondering if there is a way to store them in the assets folder and play them from there?</p>
<p>This is the code I'm using now:</p>
<pre><code>void StartSound(int id) {
if (id==0)
return;
AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
float actualVolume = (float) audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
float maxVolume = (float) audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
// float volume = actualVolume / maxVolume;
float volume=(float) ( .01*(double)cGlobals.iVol);
// Is the sound loaded already?
if (nLastSound!=0)
soundPool.stop(nLastSound);
int t=soundPool.play(id, volume, volume, 1, 0, 1f);
nLastSound=t;
}
</code></pre>
<p>I want to change this to avoid a memory error when the APK tries to load. If I remove some of the files from the res folder it works fine. I'm hopping I want have the same issue if they are saved as a file.</p>
| android | [4] |
3,886,037 | 3,886,038 | What do the colored bubbles mean in hierarchy viewer? | <p><img src="http://i.stack.imgur.com/lLtvm.png" alt="enter image description here"></p>
<p>I am guessing they are a quick overview of the time it took to draw the view, but I am not positive. </p>
| android | [4] |
933,187 | 933,188 | C#:SerialPort: read and write buffer size | <p>I am writing a program to send and receive data via a serial port with C#.</p>
<p>Although I have read this reference: <a href="http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.readbuffersize.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.readbuffersize.aspx</a>, I am not quite clear if I change the values of the buffer for reading and writing:</p>
<pre><code>serialPort.ReadBufferSize = 1; // or 1024 ?
serialPort.WriteBufferSize = 1;// or 1024 ?
</code></pre>
<p>The values (1 or 1024) should be better to be smaller or bigger?</p>
<p>Thanks in advance.</p>
| c# | [0] |
2,786,093 | 2,786,094 | Change Value of Hidden Field using Javascript | <p>I have following form where i want to assign value of "R.EmailAddress" field to a Hidden field
"email_From". </p>
<p>I tried to use the function doCalculate in Javascript but its not assigning R.EmailAddress to email_From, is it because of input type="image" ??</p>
<pre><code><form name="eMail" method="post" action="/emailform.asp" >
<input type="text" name="R.EmailAddress" class="textfield_contact" value="">
<input type="hidden" name="email_From" value="contact@shopbyus.com">
<input type="image" src="submit.gif" border="0" name="submit" value="Submit" `onClick="doCalculate(this.form)">`
</code></pre>
<p>My Javascript function looks like below</p>
<pre><code><script language="javascript" type="text/javascript">
function doCalculate(theForm){
var aVal = theForm.R.EmailAddress.value;
theForm.email_From.value=aVal;
alert(aVal);
}
</script>
</code></pre>
| javascript | [3] |
4,923,518 | 4,923,519 | how to append dropdown list box | <pre><code>$("#Grid").click(
$("#showgrid").load('SomeURL'));
$.each($('#Grid td:nth-child(4n)'), function() {
var forthColumn = $(this);
forthColumn.append("<select><option value='1'>Division 1</option><option value='2'>Division 2</option><option value='3'>Division 3</option></select>");
});
};
</code></pre>
<p>I am trying to append the dropdown list box? this way but I am not seeing the dropdownbox at 4th colum?</p>
<p>is this right?
thanks for all..</p>
| jquery | [5] |
3,441,335 | 3,441,336 | Apply function to array nodes until not array nodes are arrays | <p>Let's say I have this structure, in an array:</p>
<pre><code>Array
(
[0] => Array
(
[0] => Heading1
[1] => Array
(
[0] => Array
(
[0] => 2
[1] => Heading2.1
)
[1] => Array
(
[0] => 2
[1] => Heading2.2
)
)
)
[1] => Array
(
[0] => Heading1.2
)
)
</code></pre>
<p>How do I go about applying a function only to the array elements holding heading2.1 and heading 2.2?</p>
<p>The function I want to apply may nest arrays even further. How can I make it so that my function will also run on these newly created arrays? And the arrays that are then created, until there are not arrays on the second deepest level?</p>
| php | [2] |
4,783,141 | 4,783,142 | Can I open My Dll File | <p>I have a .cs file there is my codes.I compiled it and I got a .dll file.
Can I open my .dll file and see my c# codes because I want to compile it again? </p>
| c# | [0] |
2,890,046 | 2,890,047 | Android and HTML5 CACHE.MANIFEST | <p>I have searched with google, and can't find out how much of CACHE.MANIFEST android supports, and what versions of android that supports it.</p>
<p>Anyone out there that have more knowledge on the subject???</p>
| android | [4] |
315,158 | 315,159 | How to retrieve return value from $.post function | <p>as my subject / title. here is my code</p>
<pre><code>$(document).on("keyup","[name=BNAM]",function(){
var nam = $(this).attr("name");
var val = $(this).val();
var typ = $(this).prev().val();
$.post(
"pro/bulletins_handle.php",
{BTN:"QCHKNAM",BTYP:typ,BNAM:val},
function(data){
alert(nam+":"+val+":"+data); //display to check the return value of data
var reTURN = data; //assign data into reTURN
alert($(this).html());//Error: it say undefined
});
alert(reTURN); //Error: reTURN is not defined
});
</code></pre>
<p>** my return from post is 0 or 1 **</p>
<p><hr/>
Questions:<br/>
1). How to retrieve return value from $.post function?<br/>
2). Why it say undefined? $(this) is not = [name=BNAM] ??</p>
| jquery | [5] |
4,829,548 | 4,829,549 | How to create a photo sharing activity? | <p>How can I create a custom activity that can be chosen by the user via the share option when viewing the photo gallery? I have options like "Share with Facebook, Twitter, FlickR" etc. But I want to add my own option in there.</p>
<p>i.e. Go to "Photos", then click the "Share" button. You will be presented with a bunch of share providers. What do I need to do to get my activity in there?</p>
| android | [4] |
4,093,192 | 4,093,193 | How to get the last used time stamp of recently used apps | <p>I want to know how much time (in hours or in days) has passed since the recent apps was last used.
like I will get the recent 5 tasks from below code but how to get their last used time stamp.</p>
<pre><code>ActivityManager m = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
RecentTaskInfo task = m.getRecentTasks(5,0).get(0);
</code></pre>
| android | [4] |
3,757,088 | 3,757,089 | jquery binding events to link fails | <p>I have got this jquery code:</p>
<pre><code>$(document).ready(function(){
$('a').bind('click', false);
var url;
$('a').on('click',function(e){
url=$(this).attr('href'); //;
$('#AjaxPage').load(url+" .AjaxContent");
});
</code></pre>
<p>});</p>
<p>The problem is the click event works the first time .. but on the content loaded from the loaded function , the links there dont have the click event i binded .. why is that?
I thought you use 'on' as you would use 'live'</p>
<p><strong>Update:</strong></p>
<p>Now my load function doesnt get executed:</p>
<pre><code> $(document).ready(function(){
$('a').bind('click', false);
var url;
$(document).on('click', 'a',function(){
url=$(this).attr('href'); //;
$('#AjaxPage').load(url+" .AjaxContent");
});
});
</code></pre>
| jquery | [5] |
3,589,188 | 3,589,189 | String to date with no format specified | <p>I want to convert a string into a date, this is simple. But what I'd like to do it without knowing the date format.</p>
<p>Here is a situation: say I have 100 dates and all are in the same format but I'd like to write a Java program to find out this format for me. The result of this program should give me a list of all the possible formats.</p>
<p>For example:</p>
<pre><code> 06-06-2006
06-06-2009
...
06-13-2001 <- 99th record
</code></pre>
<p>the result of this will give me date format can be <code>mm-dd-yyyy</code></p>
<p>If the 99<sup>th</sup> record also was <code>06-06-2006</code> the result should be <code>mm-dd-yyyy</code> and <code>dd-mm-yyyy</code>.</p>
<p>Can someone please help me with an example?</p>
| java | [1] |
5,914,142 | 5,914,143 | Superglobals can't be accessed via variable variables in a function? | <p>I can't access superglobals via variable variables inside a function. Am I the source of the problem or is it one of PHP's subtleties? And how to bypass it?</p>
<pre><code>print_r(${'_GET'});
</code></pre>
<p>works fine</p>
<pre><code>$g_var = '_GET';
print_r(${$g_var});
</code></pre>
<p>Gives me a Notice: Undefined variable: _GET</p>
| php | [2] |
2,556,738 | 2,556,739 | array index for iphone | <pre><code> NSString *list = @"Norman, Stanley, Fletcher";
NSMutableArray *a2 = [[NSMutableArray alloc] init];
//a2= [list componentsSeparatedByString:@", "];
[a2 addObject:list];
//NSArray *listItems = [list componentsSeparatedByString:@", "];
NSLog(@"array is %@",a2);
NSLog(@"array o %@",a2[0]);
</code></pre>
<p>how to get a2[0]=Norman , a2[1]=stanley???</p>
| iphone | [8] |
5,186,708 | 5,186,709 | editing values stored in each subarray of an array | <p>I am using the following code which lets me navigate to a particular array line, and subarray line and change its value.</p>
<p>What i need to do however, is change the first column of all rows to BLANK or NULL, or clear them out.</p>
<p>How can i change the code below to accomplish this?</p>
<pre><code><?php
$row = $_GET['row'];
$nfv = $_GET['value'];
$col = $_GET['col'];
$data = file_get_contents("temp.php");
$csvpre = explode("###", $data);
$i = 0;
$j = 0;
if (isset($csvpre[$row]))
{
$target_row = $csvpre[$row];
$info = explode("%%", $target_row);
if (isset($info[$col]))
{
$info[$col] = $nfv;
}
$csvpre[$row] = implode("%%", $info);
}
$save = implode("###", $csvpre);
$fh = fopen("temp.php", 'w') or die("can't open file");
fwrite($fh, $save);
fclose($fh);
?>
</code></pre>
| php | [2] |
4,516,320 | 4,516,321 | Setting a DateTime to the first of the next month? | <p>If I have <code>var olddate = DateTime.Parse('05/13/2012');</code></p>
<p>and I want to get <code>var newdate = (the first of the month after olddate, 06/01/2012 in this case);</code></p>
<p>What would I code? I tried to set the month+1 but month has no setter.</p>
| c# | [0] |
5,509,776 | 5,509,777 | Android fix the image size | <p>In my screen I am having 3 buttons and in next row below those buttons I am having 3 names (name corresponding to those buttons) but my problem is that when ever name changes then size of buttons also changes but I do want to fix the size of buttons here is my code please help me</p>
<pre><code><TableLayout android:background="@drawable/toptab"
android:layout_width="fill_parent" android:id="@+id/tableLayout"
android:layout_height="wrap_content"
android:stretchColumns="1" android:gravity="center_vertical"
android:layout_alignParentBottom="true">
<TableRow>
<ImageButton android:id="@+id/btnPrev" android:background="@drawable/imgPrev"
android:layout_marginLeft="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<ImageButton android:id="@+id/btnRefresh"
android:layout_gravity="center" android:background="@drawable/refreshbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ImageButton android:id="@+id/btnNext"
android:background="@drawable/imgNext"
android:layout_width="5dp"
android:layout_height="20dp"
android:layout_marginRight="5dp" />
</TableRow>
<TableRow >
<TextView android:id="@+id/prev" android:text="Hk" android:layout_marginLeft="5dp" />
<TextView android:id="@+id/refresh" android:text="Refresh" android:layout_gravity="center" />
<TextView android:id="@+id/next" android:text="RS" android:layout_marginRight="5dp" />
</TableRow>
</TableLayout>
</code></pre>
| android | [4] |
5,646,382 | 5,646,383 | To count no. times a function is called? | <p>is there any method to count how many times a function is called in python?
I'm using checkbutton in GUI. I have written a function for that checkbutton command, i need to perform some actions based on the checkbutton status, i mean based on whether it is ticked or not. My checkbutton and button syntax are like this</p>
<pre><code>All = Checkbutton (text='All', command=Get_File_Name2,padx =48, justify = LEFT)
submit = Button (text='submit', command=execute_File,padx =48, justify = LEFT)
</code></pre>
<p>so i thougt of countin no. of times the command function is called, and based on its value i can decide whether it is ticked or not. please help</p>
| python | [7] |
4,171,449 | 4,171,450 | Parsing Character Stream | <p>I am getting a continuous stream of characters which I have moved into a flat file in a single line. Now these characters are coming in below form.</p>
<pre><code>keepalivekeep_aliveenroll,10.213.17.4,0,12,594,4,5,METRO-A,1enroll,10.213.17.4,0,13,594,4,5,METRO-B,1clear,10.213.17.4,0,14,100010934,1323168443
</code></pre>
<p>What i want is to move messages coming between particular tags (<code>keep_alive</code>, <code>clear</code>, <code>enroll</code>, etc.) in different lines. For example output from above should be:</p>
<pre><code>keep_alive
keep_alive enroll,10.213.17.4,0,12,594,4,5,METRO-A,1
enroll,10.213.17.4,0,13,594,4,5,METRO-B,1
clear,10.213.17.4,0,14,100010934,1323168443
</code></pre>
<p>What is the best way to do this in Java? What is noteworthy here is that file is getting continuous data and I need to do this continuously in some kind of loop.</p>
| java | [1] |
5,533,759 | 5,533,760 | How do you set the max number of characters for an EditText in Android? | <p>How do you set the max number of characters for an Android EditText input. I see setMaxLines, setMaxEMS, but nothing for number of characters.</p>
| android | [4] |
340,407 | 340,408 | Programmatically lock and unlock iPhone screen | <p>How do I programmatically lock and unlock the main screen (i.e. the device itself) of an iPhone?</p>
| iphone | [8] |
2,379,522 | 2,379,523 | Extract a string within a string | <p>How can I access <code>WWW.GOOGLE.COM</code> within this <code>String</code>.</p>
<p>I can use the <code>substring</code> method to chop off <code>javascript:linkToExternalSite('</code> but how can I remove the subsequest string.</p>
<p>So that</p>
<pre><code>javascript:linkToExternalSite('WWW.GOOGLE.COM','D','SDFSDX2131D','R','','X','D','DFA','SAFD')
</code></pre>
<p>becomes </p>
<pre><code>WWW.GOOGLE.COM
</code></pre>
<p>This works </p>
<pre><code>string = string.substring(31, string.length());
string = string.substring(0, string.indexOf("'"));
</code></pre>
| java | [1] |
4,183,658 | 4,183,659 | How can System.out.printIn() accept integers? | <p>So I started learning java several days ago and got a question. For the next expression:</p>
<pre><code>String foo=123;
</code></pre>
<p>is not allowed. However, in <code>System.out.printIn()</code>, we can use something like:</p>
<pre><code>int x=5;
System.out.println(x);
</code></pre>
<p>Since implicitly assigning a integer to a string is not allowed, why the expression above works? Anyone can give a detailed explanation? I'm also wondering when can we use this kind of implicit thing and when we cannot.</p>
| java | [1] |
5,870,415 | 5,870,416 | Do we still need "script.type='text/javascript" when creating a script dynamically? | <p>The code is like this: </p>
<pre><code>var script = document.createElement('script');
//script.type = 'text/javascript'; // do I need this ?
script.src = src;
document.body.appendChild(script);
</code></pre>
<p>The second line has been commented out because it makes no difference to have it.
Or am I missing something ?</p>
<p>Thanks,</p>
| javascript | [3] |
3,417,957 | 3,417,958 | Calling javascript without any action | <p>i have the following lines of html code -</p>
<pre><code> <div class="twitters" id="cbd">
<p><a href="javascript:;" onClick="tweeet('<?php echo $c; ?>')">My Tweets!</a></p>
</div>
</code></pre>
<p>Now what i need to do is call the tweet() javascript function without any link being clicked or any button being clicked . i.e this function is called on its own whenever the page is loaded. </p>
| javascript | [3] |
1,840,703 | 1,840,704 | javascript function redefinition | <p>Is it possible to redefine a javascript function from within it's own body. For example could I do the following:</p>
<pre><code>function never_called_again(args) {
//do some stuff
never_called_again = function (new_args) {
//do some new stuff
}
}
</code></pre>
<p>Is the above valid and does it have the correct semantics? I don't want to create a new global variable with the old function name because I'm trying to do this kind of thing not in the global scope but from various object scopes and I don't want name clashes when I redefine the function within those local scopes.</p>
| javascript | [3] |
3,911,230 | 3,911,231 | how to integrated paypal in my shopping cart | <p>hi i have a basket having items added to it .now i have a button named Pay .i want to integrated paypal on clicking on this button.please provide me all detail how to do integrate paypal.please help</p>
| php | [2] |
1,070,022 | 1,070,023 | JavaScript function returns before JSON result arrives | <pre><code>function GetId() {
var id;
$.post("/Edit/CreateId", function (data) {
id = data;
});
return id;
}
</code></pre>
<p>But it returns before the id comes back from the server; so id is undefined.</p>
<p>Is there any workaround this?</p>
| jquery | [5] |
3,442,153 | 3,442,154 | returning bool value into C- environment | <p>Say I have a function pointer in C- library</p>
<pre><code>int (*fptr)(void);
</code></pre>
<p>And I have a class in c++</p>
<pre><code>class A { static int func(); }
</code></pre>
<p>I can do following and it will be safe on any platform</p>
<pre><code>ftpr = A::func;
</code></pre>
<p>I would like for <code>A::func()</code> to return <code>bool</code>.</p>
<pre><code>class A { static bool func(); }
</code></pre>
<p>and I do not mind casting</p>
<pre><code>fptr = reinterpret_cast<int(*)()>(A::func);
</code></pre>
<p>But will it be safe on any platform? At the first glance it seems like it will (as long as <code>sizeof(bool) <= sizeof(int)</code>) but I am not so sure.</p>
| c++ | [6] |
634,405 | 634,406 | ArrowObj in Y2Axis | <p>in the plotted curves I try to indicate the maximum value with an arrow, to the axis "Y" no problem but how do you Y2Axis?
Can someone explain to me to begin,
thank you in advance!.</p>
| c# | [0] |
3,589,828 | 3,589,829 | How to display numeric in 3 digit grouping | <p>How to display a numeric numbers in 3 digit groupings.</p>
<p>For Ex: 1234 to be 1,234 or 1 234</p>
| c# | [0] |
4,271,942 | 4,271,943 | Android: is it possible to force GridView to wrap to content width? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5650760/android-gridview-width-not-wrapping-to-content">Android: GridView width not wrapping to content?</a> </p>
</blockquote>
<p>I am trying to display a GridView in a Dialog. Despite all my efforts, the GridView width grows to the entire screen, instead of wrapping to the columns. The layout and an image depicting the issue are below (I set a background color for the GridView to illustrate the issue).</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/colorgridview"
android:background="#FF00CCBB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="4"
android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
android:columnWidth="70dp"
android:stretchMode="none"
/>
</code></pre>
<p><img src="http://i.stack.imgur.com/ZITGD.png" alt="enter image description here"></p>
| android | [4] |
4,928,553 | 4,928,554 | concat a for loop - php | <p>I want to concatenate a for loop</p>
<pre><code>$stringd = "xxx". for($i=1;$i<=$_POST['cc'];$i++) { echo $_POST[$i]." ";} . "hello";
</code></pre>
<p>The above throws an error; how do I write one?</p>
| php | [2] |
2,659,512 | 2,659,513 | PEFormatError: 'Invalid NT Headers signature' issue on Windows 7 64-bit | <p>I'm experiencing a PEFormatError: 'Invalid NT Headers signature' everytime I am opening a PE file (installer type). My machine is a Windows 7 Professional 64-bit. My python is 32-bit, 2.7 version. I installed the 32-bit version because I have some python modules that are only running on the 32-bit version of python. I also installed the latest version of pefile (1.2.114). Below is the complete stack trace:</p>
<pre><code>Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
pe = pefile.PE('e:/processing/procdir/PROCEXP.EXE')
File "build\bdist.win32\egg\pefile.py", line 1718, in __init__
self.__parse__(name, data, fast_load)
File "build\bdist.win32\egg\pefile.py", line 1806, in __parse__
raise PEFormatError('Invalid NT Headers signature.')
PEFormatError: 'Invalid NT Headers signature.'
</code></pre>
<p>The weird thing here is that when I tried it on another Windows 7 Pro machine, with the same python version, pefile and file tested, it works and is not raising PEFormatError.</p>
<p>Any ideas? Thanks in advance!</p>
| python | [7] |
2,841,811 | 2,841,812 | Loading holding page before main content is displayed? | <p>I am creating a site that pulls various feeds from the web, while these feeds are being loaded I would like to display a holding page that says loading and then disappears presenting the loaded feeds, can anyone point me towards any tutorials for this or any advice on how to achieve this using jQuery?</p>
| jquery | [5] |
842,718 | 842,719 | My program is succeeding but it is showing a black screen | <pre><code>#import <UIKit/UIKit.h>
@interface UntitledAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
@property (nonatomic, retain) UIWindow *window;
@end
#import "UntitledAppDelegate.h"
@implementation UntitledAppDelegate
@synthesize window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIButton *playButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
playButton.frame = CGRectMake(110.0, 360.0, 100.0, 30.0);
[playButton setTitle:@"Play" forState:UIControlStateNormal] ;
playButton.backgroundColor = [UIColor clearColor];
[playButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ];
UIImage *buttonImageNormal = [UIImage imageNamed:@"star.gif"];
UIImage *strechableButtonImageNormal = [buttonImageNormal stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[playButton setBackgroundImage:strechableButtonImageNormal forState:UIControlStateNormal];
UIImage *buttonImagePressed = [UIImage imageNamed:@"Crown.png"];
UIImage *strechableButtonImagePressed = [buttonImagePressed stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[playButton setBackgroundImage:strechableButtonImagePressed forState:UIControlStateHighlighted];
[playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside];
[self .window addSubview:playButton];
return YES;
</code></pre>
| iphone | [8] |
4,273,156 | 4,273,157 | BK-Tree implementation in C++ | <p>Any one has <a href="http://en.wikipedia.org/wiki/BK-tree" rel="nofollow">BK-Tree</a> implementation in C++.,</p>
| c++ | [6] |
4,838,457 | 4,838,458 | javascript call url from different domain | <p>I want to post some data via javascript to another domain. Something like:</p>
<pre><code>http://www.othersite.com/submitfunnyname?name=blah
</code></pre>
<p>The other site (othersite.com) has a REST interface that you can call (well actually this is a get example) to submit a funny name to them.</p>
<p>Can I do this already with javascript? I'm a little confused on this - I know if that service wants to return some data, I'd need to use something like JSON-P - even though here I'm submitting some data, I guess the service will return some message structure letting me know the result, so it would have to be JSON-P, right?</p>
<p>Thanks</p>
| javascript | [3] |
613,089 | 613,090 | IE7 hangs on my site build in asp.net 3.5 | <p>Whenever I open a new window with javascript like this:</p>
<pre><code>function openwindow(){
window.open(blah blah)
}
</code></pre>
<p>on my masterpage my IE7 browser hangs.The new window is a chatroom page built in ajax controltoolkit and a music playlist for a user to listen to his/her created playlist.The problem only occurs in IE7 but ok on other browsers such as firefox,safari,google chrome,or opera....anybody knows? Thanks in advance...</p>
| javascript | [3] |
6,000,680 | 6,000,681 | How to delete an object from within itself? | <p>I have an array of objects (A) which has an array of objects (B) inside it.<br>
I'm trying to move B to a different object in array A.<br>
I'm trying to use this:</p>
<pre><code>public function killToken($a) {
array_push($a->tokens,$this); // Put this token in new array (works)
unset($this); // Remove token from this array (does not work)
}
</code></pre>
<p>I call this function via: <code>$b->killToken($a);</code></p>
<p>I've tried several variations on this, but I just can't figure out how to get rid of the object from inside itself.</p>
<p>Any help would be appreciated.</p>
| php | [2] |
1,639,976 | 1,639,977 | showing text on textview thn pausing the main thread | <p>I'd like to know if there is any way I could see the result on the <code>textview</code> first before the <code>thread.sleep</code> function kicks in.
I am making a quiz application for mcq's in android using sqlite and incase a wrong answer is checked in the radio group I'd like the the textview to display the correct answer and thn go to the next query after a delay,the code is as follows:</p>
<pre><code>if (rb1.isChecked() && corrAns.equals("Option1")) {
counter++;
//q_no++;
tvScore.setText("Your score out of 20 is "+counter);
}
</code></pre>
<p>by using this code the thread delays but displays the correct option after the query is incremented,is there any way to implement with which I can see the correct answer first b4 the thread sleeps??</p>
<pre><code> if (rb2.isChecked() && corrAns.equals("Option2")) {
counter++;
// q_no++;
tvScore.setText("Your score out of 20 is "+counter);
}
if (rb3.isChecked() && corrAns.equals("Option3")) {
counter++;
//q_no++;
tvScore.setText("Your score out of 20 is "+counter);
}
else {
Pscore.setText("The correct answer was " +corrAns);
//Thread t=new Thread(){
try{
Thread.sleep(3000);
//q_no++;
}catch (InterruptedException e){
e.printStackTrace();
}
//finally{
//q_no++;
//}
}
</code></pre>
| android | [4] |
5,264,843 | 5,264,844 | unicode format error | <p>So, I just started mining twitter data using its python twitter api.
And was about to plot the tweet stucture
But I am getting this error</p>
<pre><code> f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 108:
ordinal not in range(128)
</code></pre>
<p>This is the code..</p>
<pre><code>def draw_tweet_graph(g):
OUT = "graph.dot"
try:
nx.drawing.write_dot(g, OUT)
except ImportError, e:
dot = ['"%s" -> "%s" [tweet_id=%s]' % (n1, n2, g[n1][n2]['tweet_id']) \
for n1, n2 in g.edges()]
f = open(OUT, 'w')
f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
f.close()
</code></pre>
| python | [7] |
5,341,025 | 5,341,026 | Javascript Arrays - removing array Elements | <p>I have the following array setup, i,e:</p>
<pre><code>var myArray = new Array();
</code></pre>
<p>Using this array, I am creating a breadcrumb menu dynamically as the user adds more menu items. I am also allowing them to removing specific breadcrumb menu items by clicking on the cross alongside eatch breadcrumb menu item.</p>
<p>Array may hold the following data:</p>
<pre><code>myArray[0] = 'MenuA';
myArray[1] = 'MenuB';
myArray[2] = 'MenuC';
myArray[3] = 'MenuD';
myArray[4] = 'MenuE';
</code></pre>
<p>My questions are:</p>
<p>a) In javascript, how can I remove element [1] from myArray and then recalculate indexes or is this not possible?</p>
<p>b) If I don't want menu option MenuB, do I need to splice it to remove it?</p>
<p>My problem is, if the user removes menu items as well as create news one at the end, how will the indexes to these elements be spreadout?</p>
<p>I just want to be able to remove items but don't know how the array indexes are handled.</p>
<p>Thanks.
Tony.</p>
| javascript | [3] |
3,531,907 | 3,531,908 | How to order an array of arrays by index in javascript | <p>I'm trying to order an array of arrays by it's 2nd index, so if I have something like:</p>
<pre><code>a[0][0] = #
a[0][1] = $
a[1][0] = x
a[1][1] = y
a[1][2] = z
a[2][0] = qaz
a[2][1] = qwerty
</code></pre>
<p>I get:</p>
<pre><code>a[0][0] = #
a[1][0] = x
a[2][0] = qaz
a[0][1] = $
a[1][1] = y
a[2][1] = qwerty
a[1][2] = z
</code></pre>
<p>Thanks in advance!!</p>
| javascript | [3] |
474,109 | 474,110 | Question about rotate bitmap with Canvas.rotate | <p>As we know, we can rotate a bitmap through 2 ways. </p>
<p><strong>The 1st way is:</strong></p>
<pre><code>Matrix mt = new Matrix();
mt.postRotate(degree);
Bitmap bitmap = CreateBitmap(src, 0, 0, w, h, mt, true);
canvs.drawBitmap(bitmap, 0, 0, paint);
</code></pre>
<p>In this way, we always need create new bitmap for every rotation, it is not good way for high performance game or app. </p>
<p><strong>The 2nd way is:</strong></p>
<pre><code>canvas.save();
canvas.rotate(degree);
canvas.drawBitmap(bitmap, 0, 0, paint);
canvas.restore();
</code></pre>
<p>In this way, we avoid creating new bitmap frequently, but the rotation bitmap is distortion, the bitmap quality is worse than first way. </p>
<p>So, Is there 3rd way to rotate bitmap with high performance and good quality? </p>
<p>Your any comments are really appreciated!</p>
| android | [4] |
5,613,706 | 5,613,707 | Phone not recognized in android debugger | <p>I am trying to run the android debugger on my phone, but the console as well as eclipse plugin reports a ??? in place of the device name.
The attached phone is a sony ericsson xperia mini, running android 2.3 and the computer is running on ubuntu 10.10 .
I have enabled the usb debugging option on the phone.</p>
| android | [4] |
995,716 | 995,717 | How to start ringing with default ringtone? | <p>I need to start ringing with default system ringtone. Which must be a datasource for MediaPlayer ?</p>
| android | [4] |
1,808,758 | 1,808,759 | Android Handling dynamically added views while orientation change | <p>I have a ViewGroup that gets inflated dynamically. I have set Id's to all the inflated views. I am still not able to retain the inflated ViewGroup whenever the orientation is changed.</p>
<p>Any particular check that i am missing here ?</p>
| android | [4] |
5,584,783 | 5,584,784 | How to input php echo outside of the php tag | <p>I have this php code that input selected="" at a specific url. I need selected="" to in inserted into my html.</p>
<pre><code> <?php
$uri = $_SERVER['REQUEST_URI'];
if ( strpos($uri,'retailers/amazon/?sort=2') !== false ) {
echo 'selected=""';
} else {
echo 'test';
}
?>
</code></pre>
<p>This is the html, I need to insert selected=""... Something like this </p>
<pre><code><option selected="" value="retailers/amazon/?sort=2">Newest to Oldest</option>
</code></pre>
<p>...</p>
<pre><code><select onchange="window.location=this.value;">
<option value="">Select</option>
<option selected="" value="retailers/amazon/?sort=2">Newest to Oldest</option>
<option value="retailers/amazon/?r_sortby=highest_rated&r_orderby=desc">Success Rate: High to Low</option>
<option value="retailers/amazon/?r_sortby=highest_rated&r_orderby=asc">Success Rate: Low to High</option>
<option value="retailers/amazon/?sort=0">Most Comments</option>
</select>
</code></pre>
| php | [2] |
5,742,458 | 5,742,459 | how to wrap file object read and write operation (which are readonly)? | <p>i am trying to wrap the read and write operation of an instance of a file object (specifically the <code>readline()</code> and <code>write()</code> methods).</p>
<p>normally, i would simply replace those functions by a wrapper, a bit like this:</p>
<pre><code>def log(stream):
def logwrite(write):
def inner(data):
print 'LOG: > '+data.replace('\r','<cr>').replace('\n','<lf>')
return write(data)
return inner
stream.write = logwrite(stream.write)
</code></pre>
<p>but the attributes of a file object are read-only ! how could i wrap them properly ?</p>
<p>(note: i am too lazy to wrap the whole fileobject... really, i don't want to miss a feature that i did not wrap properly, or a feature which may be added in a future version of python)</p>
<p><strong>more context :</strong></p>
<p>i am trying to automate the communication with a modem, whose AT command set is made available on the network through a telnet session. once logged in, i shall "grab" the module with which i want to communicate with. after some time without activity, a timeout occurs which releases the module (so that it is available to other users on the network... which i don't care, i am the sole user of this equipment). the automatic release writes a specific line on the session.</p>
<p>i want to wrap the <code>readline()</code> on a file built from a socket (cf. <code>socket.makefile()</code>) so that when the timeout occurs, a specific exception is thrown, so that i can detect the timeout anywhere in the script and react appropriately without complicating the AT command parser... </p>
<p><em>(of course, i want to do that because the timeout is quite spurious, otherwise i would simply feed the modem with commands without any side effect only to keep the module alive)</em></p>
<p><em>(feel free to propose any other method or strategy to achieve this effect)</em></p>
| python | [7] |
3,464,003 | 3,464,004 | Python OLS calculation | <p>Is there any good library to calculate linear least squares OLS (Ordinary Least Squares) in python?</p>
<p>Thanks.</p>
<p>Edit:</p>
<p>Thanks for the SciKits and Scipy.
@ars: Can X be a matrix? An example:</p>
<pre><code>y(1) = a(1)*x(11) + a(2)*x(12) + a(3)*x(13)
y(2) = a(1)*x(21) + a(2)*x(22) + a(3)*x(23)
...........................................
y(n) = a(1)*x(n1) = a(2)*x(n2) + a(3)*x(n3)
</code></pre>
<p>Then how do I pass the parameters for Y and X matrices in your example? </p>
<p>Also, I don't have much background in algebra, I would appreciate if you guys can let me know a good tutorial for that kind of problems. </p>
<p>Thanks much.</p>
| python | [7] |
2,330,770 | 2,330,771 | How can I install additional packages in Java? | <p>I am very new to Java.
I would like to use some features from package called <code>daj</code></p>
<p>The tutorial code has the following lines.</p>
<pre><code>import daj.*;
import java.util.*;
import java.lang.Math;
import Msg;
</code></pre>
<p>But first and fourth lines produce red underscore such that program cannot compiles.</p>
<p>How can I resolve this problem?</p>
| java | [1] |
4,404,765 | 4,404,766 | C# code for best-fit circle | <p>I would like C# code for determining the centre and radius of the circle that best fits the points in an array using the least squares method or equivalent.</p>
<p>Having searched on web I've found none.</p>
| c# | [0] |
5,544,211 | 5,544,212 | Adding View to a Custom ViewGroup | <p>I am trying to add Views to a custom ViewGroup. The ViewGroup gets drawn, but no Views that were added to it are visible. LineView's (which extends a View) onDraw() method does not get called. What am I doing wrong?</p>
<pre><code> public class TestActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ShapeView shapeView = new ShapeView(this);
shapeView.setBackgroundColor(Color.RED);
drawContainer = (RelativeLayout)findViewById(R.id.draw_container);
drawContainer.addView(shapeView);
}
}
public class ShapeView extends ViewGroup {
private LineView mLineView;
public ShapeView (Context context) {
super(context);
RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(200, 200);
this.setLayoutParams(p);
mLineView = new LineView(context);
this.addView(mLineView);
}
}
</code></pre>
| android | [4] |
4,086,361 | 4,086,362 | how can i code for for epub file that should come in the readable form? | <p>I have an epub file that is stored on sd card, and I have no converter software. I want to write code for convert this file into readable form but my code is not running? Please help me. Thanks.</p>
<p>My code is as follows:</p>
<pre><code>import java.io.FileOutputStream;
import java .io.FileInputStream;
import android.epublib.Book;
import android.epublib.InputStreamResource;
import android.epublib.epub.EpubWriter;
public class Epub{
public static void main(String[] args) {
try {
// Create new Book
Book book = new Book();
// Create EpubWriter
EpubWriter epubWriter = new EpubWriter();
// Write the Book as Epub
epubWriter.write(book, new FileOutputStream("/sdcard/test1_book1/.epub"));
}
catch(Exception e)
{
e.printStackTrace();
}
}
//read epub file
EpubReader epubReader = new EpubReader();
Book book = epubReader.readEpub(new FileInputStream("/sdcard/awakening/.epub”));"
}
</code></pre>
| android | [4] |
2,634,800 | 2,634,801 | how to fix Warning: preg_match() | <p>I have the below scripts and they give me this warning.</p>
<pre><code>( ! ) Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier ']'
</code></pre>
<p>This is my code:</p>
<pre><code>if ((preg_match("<[^>]*script*\"?[^>]*>", $check_url)) || (preg_match("<[^>]*object*\"?[^>]*>", $check_url)) ||
(preg_match("<[^>]*iframe*\"?[^>]*>", $check_url)) || (preg_match("<[^>]*applet*\"?[^>]*>", $check_url)) ||
(preg_match("<[^>]*meta*\"?[^>]*>", $check_url)) || (preg_match("<[^>]*style*\"?[^>]*>", $check_url)) ||
(preg_match("<[^>]*form*\"?[^>]*>", $check_url)) || (preg_match("\([^>]*\"?[^)]*\)", $check_url)) ||
(preg_match("\"", $check_url))) {
die ();
</code></pre>
<p>How can I fix this?</p>
| php | [2] |
567,705 | 567,706 | Resume TLS connection in Java | <p>I'm working on Java TLS client and server witch will communicate frequently. I know that negotiating TLS connection is very resource and time consuming. I found one very interesting solution in <a href="http://www.gnu.org/software/gnutls/manual/html_node/Client-with-Resume-capability-example.html" rel="nofollow">GnuTLS</a>. I'm interested is it possible to create Java TLS Client with resume capability - establish a new connection using the previously negotiated data.</p>
<p>Best wishes</p>
| java | [1] |
3,248,065 | 3,248,066 | How to stop user from login screen second time if app is already started once? | <p>I am making a app having login screen.The validation & other stuff of login is handled by webservice.</p>
<p>My question is that if the user installed the application,then if for the first time user runs the application, a login screen appears to do login through the details given by user at downloading time from market.If user successfully logs in then at second time when he/she runs app,login screen should not appear.</p>
<p>Can anyone help me out.
Thanks in advance. </p>
| android | [4] |
1,935,040 | 1,935,041 | Scope of "this" in JavaScript | <p>I have a JavaScript class that looks like this:</p>
<pre><code>function SomeFunction()
{
this.doSomething(function()
{
this.doSomethingElse();
});
this.doSomethingElse = function()
{
}
}
</code></pre>
<p>This code throws an error because the scope of "this" inside the function that is passed into doSomething() is different that than the scope of "this" outside of that function. </p>
<p>I understand why this is, but what's the best way to deal with this? This is what I end up doing:</p>
<pre><code>function SomeFunction()
{
var thisObject = this;
this.doSomething(function()
{
thisObject.doSomethingElse();
});
this.doSomethingElse = function()
{
}
}
</code></pre>
<p>That works fine, but it just feels like a hack. Just wondering if someone has a better way.</p>
| javascript | [3] |
1,994,546 | 1,994,547 | Core plot issues in Iphone? | <p>I am using core plot framework to draw a graph in i phone.i am using the rating of the user as input draw the graph.i have 5 values in 5 arrays which is given by user corresponding to 5 items. i want to draw each input in graph with different colors.can anyone help me? </p>
| iphone | [8] |
4,164,066 | 4,164,067 | Open ID for My URL | <p>I have My own Domain <code>shakarganj.com.pk</code> and I want to Use google Open ID for this Domain and want to use domain email as openid for my web pages.And also want to get log of who is accessing my web page from which email address.</p>
<p>I am using Open Id Control with following code but it only works with all gmail accoutns i need with my domain email like <code>mailk.adeel@shakarganj.com</code></p>
<pre><code><rp:OpenIdLogin runat=server Identifier="https://www.google.com/accounts/o8/id" Visible=false ExampleUrl="" LabelText=" " RegisterText=" " ExamplePrefix=" " ID="OpenIdLogin1" ></rp:OpenIdLogin>
</code></pre>
<p>this is the exampel what i want </p>
<p><a href="http://samples.dotnetopenauth.net/v3.4/OpenIdRelyingPartyWebForms/loginGoogleApps.aspx" rel="nofollow">http://samples.dotnetopenauth.net/v3.4/OpenIdRelyingPartyWebForms/loginGoogleApps.aspx</a> </p>
<p>If i give my domain email like malik.adeel@shakarganj.com.pk it goes to mail.shakarganj.com.pk and authenticate only domain user to acces the form please now tell me how can i do this like this </p>
| asp.net | [9] |
1,586,973 | 1,586,974 | How to build a relationship with live change function and external photo changing in jQuery? | <p>I'm currently using the following function to set a timeout inside of a change event for a HTML select option...</p>
<pre><code>jQuery(function($) {
var mselect = $("#myselect");
mselect.live('change',function () {
window.setTimeout(function () {
console.log("the new value is now: "+nextQuery(".nextSKU").text());
},3000);
});
});
</code></pre>
<p>I'm pretty much writting out a sku number for an item every time my select option changes, and a setTimeOut for a delay effect. But how can I replace my setTimeOut for something more efficient...meaning, I want to execute console.log(....), when the src of my product image updates. How can I do this if my image element looks like this...</p>
<pre><code><img id="imgLargeImageImage" class="nextProdImage" itemprop="image" src="http://.../.../.../SHT-GD-M-SM1.jpg" alt="Gold Shirt">
</code></pre>
<p>When the image changes based on the select you choose, the < img > tag will change the src like this...</p>
<pre><code><img id="imgLargeImageImage" class="nextProdImage" itemprop="image" src="http://.../.../.../SHT-GD-N-394.jpg" alt="BLUE Shirt">
</code></pre>
<p>Thanks for any advice!</p>
| jquery | [5] |
382,752 | 382,753 | running a for loop in a foreach loop | <p>I have to write the contents in this format</p>
<pre><code>somename1 value1 value2 value1 value2 ....
somename2 value1 value2 value1 value2 ....
somename3 value1 value2 value1 value2 ....
somename4 value1 value2 value1 value2 ....
somename5 value1 value2 value1 value2 ....
</code></pre>
<p>value1 and value2 are the part of the x and y co-ordinates of a point, so for this I have created a class:</p>
<pre><code>class Points
{
string name;
double[] X;
double[] Y;
}
class PointsCollection
{
List<Points> aPoints
}
//now when accessing the PointCollection
foreach(Points aPoints in PointsCollection)
{
stream.Write(aPoints.Name)
//now i have to write the value1 and valud2
}
possible code
//now when accessing the PointCollection
foreach(Points aPoints in PointsCollection)
{
stream.Write(aPoints.Name)
int length1 = aPoints.Real;
int length2 = aPoints.Imag;
for(int i = 0 ; i < length1; i++)
{
stream.Write(aPoints.Real[i]);
stream.Write(",");
stream.Write(aPoints.Imag[i]);
}
stream.WriteLine();
}
</code></pre>
<p>Question : Is it the correct to use for loop inside the foreachloop?</p>
| c# | [0] |
1,926,836 | 1,926,837 | Passing variable with JavaScript function | <p>I am trying to pass variable though the <code>GetDetail</code> function below. I can pass string/number and it works properly.</p>
<p>But I'm unable to pass variable</p>
<pre><code>detLink.onclick = new Function ("GetDetails()");
detLink.setAttribute('onclick',"javascript:GetDetails()")
</code></pre>
| javascript | [3] |
3,598,931 | 3,598,932 | how to bind time range in gridview | <p>I have only start time and end time and duration gap.I want to bind Grid View like this</p>
<pre><code>Start Time=09:00:00
End Time=15:00:00
Duration gap=20 minutes
09:00:00-09:20:00
09:20:00-09:40:00
09:40:00-10:00:00
14:40:00-15:00:00
</code></pre>
| c# | [0] |
3,008,823 | 3,008,824 | Searching for pattern inside a string | <p>Is it possible to search for certain patterns inside std::string in C++?</p>
<p>I am aware of <code>find()</code>, <code>find_first_of()</code> and so on, but I am looking for something more advanced.</p>
<p>For example, take this XML line: <code><book category="fantasy">Hitchhiker's guide to the galaxy </book></code></p>
<p>If I want to parse it using <code>find()</code> I could do it as follows:</p>
<pre><code>string line = "<book category=\"fantasy\">Hitchhiker's guide to the galaxy </book>"
size_t position = line.find('>');
std::string tmp = line.substr(0,position);
position = tmp.find(' ');
std::string node_name = tmp.substr(0, position);
std::string parameters = tmp.substr(position+1);
...
</code></pre>
<p>This feels very "grindy" and inefficient. It would also fail, if I had multiple tags nested inside each other, like this:</p>
<p><code><bookstore><book category=\"fantasy\">Hitchhiker's guide to the galaxy </book></bookstore></code></p>
<p>Is there a way to search for pattern, as in search for <code><*></code> where <code>*</code> represents any amount of characters of any value, getting the value of <code>*</code>, splitting it to parameters and node name, then searching for <code></nodename></code> and getting the value inbetween <code><nodename></code> and <code></nodename></code> ?</p>
| c++ | [6] |
4,568,840 | 4,568,841 | Error when compiling Java source file | <p>I'm a beginner in Java and I created this class:</p>
<pre><code>class test
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
</code></pre>
<p>as test.java, and when I compiled it with this cmd: </p>
<pre><code>javac C:\Users\Aimad\Desktop\test.java
</code></pre>
<p>and then:</p>
<pre><code>java C:\Users\Aimad\Desktop\test.class
</code></pre>
<p>I received this error :</p>
<blockquote>
<p>Could not find or load main class C:\Users\Aimad\Desktop\test.class</p>
</blockquote>
| java | [1] |
2,194,917 | 2,194,918 | How to add the image and text to button in code ? and not via xml | <p>How to add the image and text to button in code ? and not via xml </p>
| android | [4] |
2,532,707 | 2,532,708 | Android saving videos to sd card | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5472226/how-to-save-file-from-website-to-sdcard">How to save file from website to sdcard</a> </p>
</blockquote>
<p>I am trying to figure out how to save videos from the web to my sd card.
could please help me out thats be great thanks</p>
| android | [4] |
9,650 | 9,651 | Java: Identifier expected | <p>What's the issue here?</p>
<pre><code>class UserInput {
public void name() {
System.out.println("This is a test.");
}
}
public class MyClass {
UserInput input = new UserInput();
input.name();
}
</code></pre>
<p>This complains:</p>
<pre><code><identifier> expected
input.name();
</code></pre>
| java | [1] |
256,242 | 256,243 | Create String array (in xml) from java array? (Android) | <pre><code>ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(RoutesActivity.this, directionArray, R.id.route_direction_spinner);
</code></pre>
<p>So, I'm trying to make a spinner, and I have a java String array (directionArray). My problem is Eclipse returns this error when hovering over "createFromResource":
"The method createFromResource(Context, int, int) in the type ArrayAdapter is not applicable for the arguments (RoutesActivity, String[], int)"
And gives me this Quick Fix:
"Change type of 'directionArray' to 'int'."
Basically, I have an array in Java that I need to use in an ArrayAdapter, but apparently it won't let me. Is there a way to create an xml resource from within java, and/or a way to bypass the above error?</p>
| android | [4] |
1,116,528 | 1,116,529 | PHP Different Environments for Different Users | <p>I've got a PHP application which already has multiple environments setup on different servers (Development, Staging and Production). I'd like to be able to direct different users to different environments based on a database column. We charge users a monthly fee for this application, and we'd like to be able to offer certain users (ones we invite like our mentors) to use our Staging environment so they can help us spot potential problems before they go into production. </p>
<p>What is the best way to handle this? Have a 'environment' column in our users table and redirect the user to the proper environment after they login?</p>
<p>I can't seem to figure out how others have handled this from a good bit of Googling, so any advice would be greatly appreciated.</p>
<p>Thanks.</p>
| php | [2] |
5,547,730 | 5,547,731 | Javascript bitshift alternative to math.round | <pre><code>var1=anyInteger
var2=anyInteger
(Math.round(var1/var2)*var2)
</code></pre>
<p>What would be the syntax for JavaScripts bitshift alternative for the above?</p>
<p>Using integer not floating</p>
<p>Thank you</p>
| javascript | [3] |
217,455 | 217,456 | Using HTML in TextView | <p>I have the following:</p>
<pre><code>textView.setText(Html.fromHtml("<font color=\"red\" size=\"24\">Hello</font>"));
</code></pre>
<p>The string 'Hello' does turn red but the size does not change.</p>
<p>It is as if the size attribute is just ignored, does anyone know why this is? Am I doing something wrong?</p>
| android | [4] |
4,940,601 | 4,940,602 | how to Isolated $row element | <p>how to echo all item in row (mysql) and Isolated ","</p>
<pre><code>// samle : $row_Recordset1['tags'] is
"tag1,tag2,tag3"
</code></pre>
<p>i want write For example :</p>
<pre><code><a>tag1</a>
<a>tag2</a>
<a>tag3</a>
</code></pre>
| php | [2] |
5,839,245 | 5,839,246 | How to make data member accessible to class and subclass only | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5300163/why-is-there-no-sub-class-visibility-modifier-in-java">Why is there no sub-class visibility modifier in Java?</a> </p>
</blockquote>
<p>The access level table for Java, shows 4 different options for controlling access to members of a class:</p>
<pre><code>Modifier Class Package Subclass World
public Y Y Y Y
protected Y Y Y N
no modifier Y Y N N
private Y N N N
</code></pre>
<p>There is no modifier, however, for "accessible to class and subclass only". That is:</p>
<pre><code>Modifier Class Package Subclass World
c++prot Y N Y N
</code></pre>
<p>Is it possible at all to define such access level in Java?</p>
<p>If so, how?</p>
<p>If this isn't possible, this must be due to a well thought design principle. If so, what is that principle. In other words, why having such access level in Java isn't a good idea?</p>
| java | [1] |
3,261,031 | 3,261,032 | Find first class name after click | <p>I am looking to toggle the visibility of the first instance of a certain class, but only after the clicked item.</p>
<p>Here is what I have now...</p>
<pre><code>$(document).ready(function() {
$('.showContentLink').click(function(){
$(this).next('.showInfo').toggle();
});
$('.showInfo').hide();
});
</code></pre>
<p>If I click <code>showContentLink</code> it should find the first <code>"showInfo"</code> class after after the clicked item.</p>
<pre><code><a href="" class="showContentLink">show content</a>
<div class="stuff">some stuff</div>
<div class="stuff">some stuff</div>
<div class="showInfo">Show me</div>
<a href="" class="showContentLink">show content</a>
<div class="stuff">some stuff</div>
<div class="stuff">some stuff</div>
<div class="showInfo">Show me</div>
</code></pre>
| jquery | [5] |
5,179,054 | 5,179,055 | long running php script issue on firefox/IE | <p>I am executing one php script, which is taking around 8 minutes to execute. this code is working fine on chrome, but on IE/Firefox it is not working. In the chrome, i am getting the output after 8 minutes, but in IE/Firefox i am not getting any response.</p>
<p>What could be issue? Please help on that. any issue with browser/header.</p>
| php | [2] |
5,948,901 | 5,948,902 | How can I check if a string is null or empty and trim if not null or empty? | <p>I tried the following:</p>
<pre><code>dummy.Title = ds1Question.Title.null ? "Dummy title" : ds1Question.Title.Trim();
</code></pre>
<p>I was expecting to see something like nullorempty with intellisense but it seems there is nothing that can do that. Is there another way I can do this?</p>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.