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 |
---|---|---|---|---|---|
97,458 | 97,459 | Finding javascript code which is changing style attribute | <p>I have a fairly complex Joomla build, the layout of which has become a bit messed up and I'm trying to figure out why.</p>
<p>The style attribute of an element is being changed by javascript (min-height is being added to one element and width to another).</p>
<p>This might be a long shot but is there any way to find out which piece of code is causing this to happen?</p>
| javascript | [3] |
5,015,030 | 5,015,031 | how to implement mouse gestures by tracking movement of mouse | <p>I wonder how could I track the mouse movement (like scrolling) in Java, I need to detect whether a user has made a plus or minus sign. Anyone could help me about that?</p>
<p>to clarify:</p>
<p>I have a pdf file opened in a JFrame and a JPanel, when the mouse is in the panel`s bounds it is expected that he will make a plus(+) or minus(-) sign to zoom in and zoom out the pdf file.So i need to track the movement of the mouse.Thanks in advance</p>
| java | [1] |
5,961,995 | 5,961,996 | jquery two clicks instead of one to execute code | <p>I found this javascript code, and that's exactly what I'm looking for. This is a Show/Hide code with slide effect.</p>
<pre><code>$(document).ready(function() {
if($('div.tab').length > 0) {
$('div.tab').click(function() {
if($(this).hasClass('open')) {
$(this).removeClass('open');
$(this).addClass('close');
$(this).next().slideDown(300);
return false;
} else {
$(this).removeClass('close');
$(this).addClass('open');
$(this).next().slideUp(300);
return false;
}
})
}
</code></pre>
<p>Now, I wanted to add a code to show only one DIV at a time, closing opened DIV with slide effect. So, I add some code and it works how I want it to work. But the problem is, when one DIV is opened, and I click on another, new DIV, everything is working, but when I click on already visited DIV, I need two clicks, instead of one, to execute the code. I don't have a knowledge in js coding, so I'm asking here for your help. </p>
<p>Here is a code with my changes.</p>
<pre><code>$(document).ready(function() {
if($('div.tab').length > 0) {
$('div.tab').click(function() {
if($(this).hasClass('open')) {
$(this).removeClass('open');
$(this).addClass('close')**.siblings('div.container').slideUp(300)**;
$(this).next().slideDown(300);
return false;
} else {
$(this).removeClass('close');
$(this).addClass('open');
$(this).next().slideUp(300);
return false;
}
})
}
</code></pre>
| jquery | [5] |
1,767,390 | 1,767,391 | Why doesn't #.# work for very small numbers? | <p>In my program, I ran into a problem writing a small number to a context.Response that is then being read by a jQuery ajax response.</p>
<pre><code>value = -0.00000015928321772662457;
context.Response.Write(value.ToString("#.#"));
</code></pre>
<p>returns <code>[object XMLDocument]</code></p>
<p>However,</p>
<pre><code>context.Response.Write(value.ToString("n"));
</code></pre>
<p>returns 0.00 as expected.</p>
<p>Using "n" is perfectly fine for my program, but why did "#.#" return with an XMLDocument?</p>
| c# | [0] |
4,241,037 | 4,241,038 | Javascript onclick hide div | <p>I want to hide this warning div using javascript inside it.</p>
<p>I'm i getting the javascript right? I want to hide/close the div when i click on the close icon (images/close_icon.gif)</p>
<pre><code><div>
<strong>Warning:</strong>
These are new products
<a href='#' class='close_notification' title='Click to Close'>
<img src="images/close_icon.gif" width="6" height="6" alt="Close" onClick="this.close" />
</a
</div>
</code></pre>
| javascript | [3] |
1,336,427 | 1,336,428 | Check condition before method call | <p>I have a class named Server which can be started and stopped. Certain methods should not be called unless the Server is started, in which case a NotConnectedException should be raised. Is there a way to call a method before every method in a class and determine if class variable _started is set to True?</p>
<p>I tried using a decorator, but the decorator function does not have access to the class variable. I was trying to do something like this:</p>
<pre><code>class Server(object):
_started = False
def started(self):
if(self._started == False):
raise NotConnectedException
@started
def doServerAction(self):
...
</code></pre>
| python | [7] |
2,760,347 | 2,760,348 | JavaScript current page identification | <p>I have written the following code for identifying the current page and marking it accordingly in the navigation bar. It works perfectly, except for the first time index.php is loaded (the code is located at the end of header.php file:</p>
<pre><code> path = location.pathname.split("/");
pathname= "#header_nav li a[href='" + path[(path.length-1)] + "']";
$(pathname).attr("id","current");
</code></pre>
<p>any ideas?</p>
| javascript | [3] |
235,117 | 235,118 | in php with the fopen code | <p>I'm trying to create a php page with <code>fopen()</code> this php file will house the passwords and usernames for my clients database info like host adress and stuff like that, but when I try stuff like this:</p>
<pre><code>$filename = "pass.php";
$ourfile = fopen($filename, '<?php session_start(); ?>') or die(mysql_error());
fclose($ourfile);
</code></pre>
<p>It just rejects it and says:</p>
<blockquote>
<p>Warning: fopen(pass.php) [function.fopen]: failed to open stream: No
error in C:\wamp\www\forum\installer\checkinstall.php on line 12</p>
</blockquote>
<p>I want to have something like:</p>
<pre><code><?php
session_start();
$dbhost = "localhost";
$dbname = "hey";
$dbuser = "root";
$dbpass = "";
?>
</code></pre>
<p>but ever time it just wips out that error.</p>
| php | [2] |
522,582 | 522,583 | NSKeyedUnarchiver unarchiveObjectWithFile cause crash | <p>I try to use codes</p>
<pre><code>-(bool)checIfWorksOnJailbreak;
{
NSString *s = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Info.plist"];
NSLog(@"%@",s);
if([[NSFileManager defaultManager] fileExistsAtPath:s]) {
NSDictionary *plistDictionary = (NSDictionary*)[NSKeyedUnarchiver unarchiveObjectWithFile:s];
NSString *valueString = [plistDictionary objectForKey:@"SigerIdentity"];
if([valueString isEqualToString:@"Apple OS Application Signing"])
return true;
else
return false;
}
return false;
}
</code></pre>
<p>it always cause error</p>
<pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]:
incomprehensible archive version (-1)'
</code></pre>
<p>at line </p>
<pre><code>NSDictionary *plistDictionary = (NSDictionary*)[NSKeyedUnarchiver unarchiveObjectWithFile:s];
</code></pre>
<p>Welcome any comment</p>
| iphone | [8] |
884,513 | 884,514 | iPhone etc: how to tell if the device has a camera? | <p>Version 3.1.3 if its relevant.</p>
<p>There is this suggestion which may work now, but in the future?</p>
<pre><code>NSString *device = [UIDevice currentDevice].model;
if([device isEqualToString:@"iPhone"])
</code></pre>
| iphone | [8] |
1,873,530 | 1,873,531 | What does the arguments passed to a javascript closure do? | <p>How do I explain the role of the arguments passed in the beginning vs end of a wrapped Javascript closure as the one shown below? </p>
<pre><code>(function($, window) {
return $(function() {
return alert("js!");
});
})($, window);
</code></pre>
| javascript | [3] |
1,008,937 | 1,008,938 | how to Play a sound file stocked in a data base Access | <p>Hello
Please can you give me the code that allows me to read a file.wav ("alarme.wav") stored in a database, I tried the following code:</p>
<pre><code>private void button1_Click (object sender, EventArgs e)
{
OdbcConnection cn = new OdbcConnection ("DSN = cp1");
cn.Open ();
OdbcCommand cmd1 = new OdbcCommand ("select path from WHERE Code Alarm alarm = 32 ", cn);
cmd1.Connection = cn;
fileName = cmd1.ToString ();
WaveOut wave = new ();
wave.DeviceNumber = 0;
playSound (0);
</code></pre>
<p>But he gave me the following error:
"Could not find file 'C: \ Users \ wafa \ Documents \ Visual Studio 2010 \ Projects \ ALARMED \ ALARMED \ bin \ Debug \ System.Data.Odbc.OdbcCommand'."
At the line:
"waveReader = new NAudio.Wave.WaveFileReader (fileName);" in my "playSound" function:</p>
<pre><code>public void PlaySound (int deviceNumber)
{
disposeWave ();// stop previous sounds Before Starting
waveReader = new NAudio.Wave.WaveFileReader (fileName);
var waveOut NAudio.Wave.WaveOut = new ();
waveOut.DeviceNumber = deviceNumber;
var output = waveOut;
output.Init (waveReader);
output.Play ();
}
</code></pre>
<p>Thank you in advance.
Good day :)</p>
| c# | [0] |
521,520 | 521,521 | javascript: open url and show hidden div | <p>I would like to achieve the following and would sincerely appreciate your help.</p>
<p>onclick of a button:</p>
<ol>
<li>open destination url on same window</li>
<li><code>.show()</code> specific from that url</li>
</ol>
| javascript | [3] |
5,068,010 | 5,068,011 | How to remove repetitive chars in javascript | <p>I have a file that contains words with repetitive chars, like:</p>
<ul>
<li>boooody</li>
<li>Steveeen</li>
<li>uuuuuuser</li>
<li>etccccc</li>
</ul>
<p>In Javascript(used on nodejs), how do i remove that extra chars so i get <code>body</code>, <code>user</code> etc.?</p>
| javascript | [3] |
2,145,540 | 2,145,541 | Json_encode() not working in PHP 5.1? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2370968/how-can-i-decode-json-in-php-5-1">How can I decode json in PHP 5.1?</a> </p>
</blockquote>
<p>I am using json_encode function it works fine in my localhost...when i moved to server it not working ...I googled and find out that its does not support 5.1 version ...I want to use this function .any other possibility?wheather i need to upgrade to 5.2 or wat?</p>
| php | [2] |
4,190,146 | 4,190,147 | Slick2d - on close | <p>I've recently started playing around with Slick2d in Java. I need to catch an on close event, is there any simple way of doing this with slick2d?</p>
| java | [1] |
2,359,783 | 2,359,784 | MediaPlayer error (-4, -4) | <p>i play video from URL. 1st i put video on local server and it's run in device. client put video on <a href="https://s3.amazonaws.com" rel="nofollow">https://s3.amazonaws.com</a> server. now when i play video it's not play. this is logcat:</p>
<pre><code>03-16 12:07:20.244: D/MediaPlayer(5099): Couldn't open file on client side, trying server side
03-16 12:07:20.289: W/MediaPlayer(5099): info/warning (1, 26)
03-16 12:07:20.294: E/MediaPlayer(5099): error (-4, -4)
03-16 12:07:20.309: I/MediaPlayer(5099): Info (1,26)
03-16 12:07:20.314: E/MediaPlayer(5099): Error (-4,-4)
03-16 12:07:20.314: D/VideoView(5099): Error: -4,-4
</code></pre>
<p>i dnt knw what is issue. video convert from this formats <a href="http://developer.android.com/guide/appendix/media-formats.html" rel="nofollow">http://developer.android.com/guide/appendix/media-formats.html</a>
Thanks </p>
| android | [4] |
2,666,696 | 2,666,697 | Check if TypeElement is a class or an interface | <p>So I am writing an AnnotationProcessor and in the process method you are given a <a href="http://docs.oracle.com/javase/6/docs/api/javax/lang/model/element/TypeElement.html" rel="nofollow">TypeElement</a>. I need to check if the TypeElement is an interface or a class. How would I go about doing this?</p>
| java | [1] |
1,103,598 | 1,103,599 | question related to UITextView | <p>I have n number of UITextview and that are added to UIScrollview.and uiscrollview is added to self.view.Now,I want that</p>
<p>1>If user enter text in first UITextview ,then as lenth increase os UITextview ,another UITextviews which are below it also reinitialize and maintain properly according to the size of first UITextView.inshort another UITextviews go more below then it was.</p>
<p>2>It should work in any of the case ,wether user presses return key after entering text into UITextView or may be not till end</p>
| iphone | [8] |
3,556,176 | 3,556,177 | validate combobox in javascript | <p>I have written the below code. But it does not show me the alert message when I don't select the other value and click onto the submit button.
I don't want to use <code>getElementbyId</code>. I am using the name attribute of the HTML.</p>
<pre><code><HTML>
<HEAD>
<TITLE>ComboBox Validation</TITLE>
<script Language="JavaScript">
function validate()
{
if (document.comboForm.technology.value=="0") \
{
alert("Please Select Technology");
}
}
</script>
</HEAD>
<BODY>
<form name="comboForm">
<select name="technology">
<option value="0">Select</option>
<option value="1">Java Server Pages</option>
</select>
<input type="submit" value="submit" onClick="validate();">
</form>
</BODY>
</HTML>
</code></pre>
| javascript | [3] |
4,976,619 | 4,976,620 | I dont understand how to use the open hardware monitor source code | <p>I added to the reference the OpenHardwareMonitorLib.dll</p>
<p>Now I added in my code: using <code>OpenHardwareMonitor.Hardware;</code>.</p>
<p>Then I did in the top form level: Isensor Sensor;</p>
<p>But I can't "new" it i cant create an instance of it and I'm getting null exception on it in the constructor:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using OpenHardwareMonitor.Hardware;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
ISensor Sensor;
public Form1()
{
InitializeComponent();
string t = Sensor.Name;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
</code></pre>
<p>Cannot create an instance of the abstract class or interface 'OpenHardwareMonitor.Hardware</p>
<p>I tried ot look in the source code in the code.google.com site: <a href="http://code.google.com/p/open-hardware-monitor/source/browse/#svn%2Ftags%2F0.3.2%2FWMI" rel="nofollow">http://code.google.com/p/open-hardware-monitor/source/browse/#svn%2Ftags%2F0.3.2%2FWMI</a></p>
<p>But i dont want to use all this code. I downloaded the program Open Hardware Monitor and except the exe file there is a dll file im using now in my project i was sure i can use the dll to use it easier. All i want for now is to get the temperature of the video card gpu.</p>
| c# | [0] |
1,546,864 | 1,546,865 | Download the image from the urlencoded or base64encoded string | <p>My application sends urlencoded or base64encoded string via http get request, the string contain image data, that most be download from the php file, but i dont know how php would download image from my string that is either urlencoded or base64encoded, please help me out guys... im lost</p>
| php | [2] |
3,152,305 | 3,152,306 | How to encrypt the sqlite file in IOS and which one is good method? | <p>Hi I would like to encrypt my database(sqlite) file and which encryption method is good for IOS development. Thank's in advance.</p>
| iphone | [8] |
5,606,886 | 5,606,887 | Animate the View across the layout | <p>I trying to animate the ImageView from child layout(Relativelayout) to parent layout(Relative layout). the imageview is not getting painted while entering into the parent layout.</p>
| android | [4] |
182,772 | 182,773 | Why ASP.NET TextBox.Text only returns 250 character? | <p>In my asp.net Form page I have a TextBox control like this</p>
<pre><code><asp:TextBox ID="txtQuestion" runat="server" MaxLength="1000" TextMode="MultiLine" Width="99%" Height="50px"></asp:TextBox>
</code></pre>
<p>when i type a long sentence (250+ characters) and submit the form in the code behind page I only get 250 character when I user this </p>
<pre><code>txtQuestion.Text
</code></pre>
<p>However, when I use this</p>
<pre><code>Request[txtQuestion.UniqueID]
</code></pre>
<p>I get the whole sentence.</p>
<p>I can't seem to figure out why this is happening. Can anyone help me out here?</p>
<h2>EDIT</h2>
<p>I have tried the suggestion made by <strong>Ramesh Rajendran</strong> by doing the following -</p>
<pre><code><asp:TextBox ID="txtQuestion" runat="server" Rows="50" CssClass="queCss" TextMode="MultiLine"></asp:TextBox>
</code></pre>
<p>The Css class is defined as follows -</p>
<pre><code>.queCss
{
width:99%;
height:50px;
}
</code></pre>
<p>I would also like to mention that I am using JQuery AJAX and Page Methods to populate data on some ListBox. So I have set <code>EnableEventValidation</code> to <code>false</code>. I am also using JQuery to populate some dynamic textboxes whose values I read after PostBack using Request Object.</p>
| asp.net | [9] |
168,184 | 168,185 | What are the most surprising elements of the C++ standard? | <p>I've decided to get more acquainted with my favorite programming language, but <em>only</em> reading the standard is boring.</p>
<p>What are the most surprising, counter-intuitive, or just plain weird elements of C++? What has shocked you enough that you ran to your nearest compiler to check if it's really true?</p>
<p>I'll accept the first answer that I won't believe even <em>after</em> I've tested it. :)</p>
| c++ | [6] |
5,521,882 | 5,521,883 | How to reset textbox values in dialog after destroy? | <p>I have a dialog in which there are 2 textboxes. I want to reset the textboxes values once the dialog is destroyed. How can I do that?</p>
<p>If I have entered values in the textboxes and clicked cancel, reopening the dialog will show the data entered previously.</p>
<pre><code>function setDialogWindows($element) {
$('#change').dialog({
autoOpen: true,
width: 380,
buttons: {
"Cancel": function() {
$(this).dialog('destroy');
},
"Accept": function() {
}
}):
}
</code></pre>
<hr>
<pre><code>$('#link').click(function() {
setDialogWindows('#change');
});
</code></pre>
<hr>
<pre><code><div id="change" title="Change password" >
<input type="hidden" id="User_Name" name="Name"/>
<input type="textbox" id="text1" />
<input type="textbox" id="text2" />
</div>
</code></pre>
| jquery | [5] |
300,855 | 300,856 | jquery - Live search ajax calls as user types but with small delay? | <p>Due to environment I would like to constrain this to something small and concise rather than a plugin, unless it's an extension that can be put inline aside other jquery code.</p>
<p>I have this code:</p>
<pre><code>$("#txtSearch").live('keyup', function () {
LoadList(1)
});
</code></pre>
<p>I'd like to add a delay such that if a user must wait (as in stop typing) 0.5 seconds before a call is executed.</p>
<p><strong>So basically if letters are typed with less than X time between consecutive keystrokes no ajax call occurs.</strong></p>
<p>Is there a tiny concise way to do this with Jquery?</p>
| jquery | [5] |
3,792,914 | 3,792,915 | Copying the Image Buffer from unsigned char * to CxImage | <p>How to copy Image Buffer from unsigned char * to CxImage ?</p>
<p>CxImage is the third party library - Image processing function</p>
<pre><code>//////////// Copying from cximage to unsigned char *
CxImage CxBuffer;
unsigned char * uc_Buffer = CxBuffer.GetBits();
////// HOW TO DO IN REVERSE //////////////////
</code></pre>
<p>COPYING FROM unsigned char * to CxImage ????? </p>
| c++ | [6] |
4,071,438 | 4,071,439 | Any reason there are no returned value from set.add | <p>Current, since the returned value from <code>set.add</code> is always <code>None</code>. I have to do the following.</p>
<pre><code>if 1 in s:
print 'already found'
return
s.add(1)
</code></pre>
<p>Would it be nice if I can</p>
<pre><code>if not s.add(1):
print 'already found'
return
</code></pre>
| python | [7] |
4,040,164 | 4,040,165 | Android Autocomplte Textview Filtering | <p>Hi i have an autocompltetextview but default filtering is not good for me,</p>
<p>eg The string "hum" should match to Hohum Plumbing, Humphrey Bogart, and Robert Mitchum .but currently it is not happening </p>
<p>Currently am passing arraylist and create adapter.now i can customize the filtering </p>
| android | [4] |
877,607 | 877,608 | adding another set Strings to TreeSet - java | <p>I have a public method (called getMusic) in a class called Favorites. getMusic has set. There are 3 sets and in each set has five words, Set getMusic(). In another class called myInterest, there is a treeSet called musicTable. I called getMusic method into myInterest class but I do not know how to iterate over so that the set of words can be added to musicTable TreeSet. I tried to use addAll but it's not working. Where I am going wrong and how do I fix this? .I don't want to use list, I've thought about for loop but not to sure how to use this or literate(). thank you</p>
<pre><code>public class myInterest
{
private static TreeSet<String> musicTable = new TreeSet<String>();
public Test()
{
super();
musicTable = new TreeSet<String>();
}
public static void testOut()
{
Favorites entrainment = new Favorites();
System.out.println(" " + entrainment.getMusic());
entrainment.addAll(musicTable); //error msg "cannot find symbol - method addAll(java.util.TreeSet<java.lang.String>)
musicTable.addAll(entrainment); //also tried this way but error msg "cannot find symbol - method addAll(Favorities)
}
}
</code></pre>
| java | [1] |
1,949,805 | 1,949,806 | How to identify a javascript file is loaded successfully in Script | <p>I want to add a js file from external server like </p>
<pre><code> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script>
</code></pre>
<p>How i can Identify the file is succesfully loaded <strong>programatically</strong>(Not in the console)?</p>
| javascript | [3] |
5,041,838 | 5,041,839 | How do you use replace_if with a string? | <p>I'm trying to replace all whitespace characters in each line I'm parsing with a space. The key line is:</p>
<pre><code>replace_if( theString.begin(), theString.end(), ::isspace, " ");
</code></pre>
<p>The (partial) error I can locate is:</p>
<blockquote>
<p>In function ‘void std::replace_if(_ForwardIterator, _ForwardIterator, _Predicate, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator, std::allocator > >, _Predicate = int (*)(int)throw (), _Tp = char [2]]’:
instantiated from here</p>
</blockquote>
<p>What is the correct usage of replace_if in this situation? I don't have access to Boost, so I'd prefer pure C++ suggestions please. I've tried changing " " to string(" "). I've tried making my own predicate (I am a novice, so don't rule this solution out entirely). I'd prefer to use replace_if, but will accept an answer explaining why it is too complicated for this situation. Thanks.</p>
| c++ | [6] |
331,093 | 331,094 | First Half and last half | <p>How many ways are there to get the first two bytes and last byte from an integer of byte. Also consider the big-endian and little-endian.</p>
<p>One solution might be to take an union containing an integer and two short integers. But here output may be different because of lit-endian and big-endian. Basically first half and second half has the name and access by the name, and that's why these two variables may have different values on big-endian and lit-endian.</p>
| c++ | [6] |
4,807,690 | 4,807,691 | Trying to figure out how to loop while grouping | <p>Here is the data I have:</p>
<pre><code>ID | Name | Family
1 | John | Doe
2 | Jane | Doe
3 | John | Man
4 | Jane | Blah
</code></pre>
<p>Basically what I am trying to do is group them by Family. I am getting the data inside a while statement and I just tried using array and array_push but that doesn't work at all. </p>
<p>Any ideas or suggestions on how to do this?</p>
<p>I am going to ouput this data for jquery for creating optgroups which would be grouped by Family. Currently here is what is happening: </p>
<pre><code>while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$status_id = $orders_status['orders_status_id'];
$status_name = $orders_status['orders_status_name'];
$status_group = $orders_status['orders_status_group'];
}
</code></pre>
<p>That's the basic code. I tried doing this to the above mentioned code:</p>
<pre><code>while ($orders_status = tep_db_fetch_array($orders_status_query)) {
$status_id = $orders_status['orders_status_id'];
$status_name = $orders_status['orders_status_name'];
$status_group = $orders_status['orders_status_group'];
echo 'if (currentOption.val() == "' . $status_id . '") {
var optgroup = $("<optgroup/>");
optgroup.attr("label", "' . $status_group . '");
currentOption.wrapAll(optgroup);
}
';
}
</code></pre>
<p>What that did is basically created multiple Family of Doe. Instead I would like to somehow create only one Family of Doe and push Name and ID into it</p>
| php | [2] |
5,611,579 | 5,611,580 | Application crashes while using the scroll bars in winForm Datagrid view | <p>Hi all i have a background worker thread and some unmanaged code dlls , In progress changed event of background worker . I will get the data from my database in a datatable and make this table as my DataSource. But when i use the scrollbards od DataGridView my application crashes.when I try to debug the application it gives "Unhandled exception in TestExe.exe : 0xC0000096: Privileged Instruction.</p>
| c# | [0] |
812,091 | 812,092 | reference datatype javascript | <p>From what i can infer from these 2 sources:</p>
<p><a href="http://docstore.mik.ua/orelly/webprog/jscript/ch03_12.htm" rel="nofollow">Source 1</a> and <a href="http://stackoverflow.com/questions/3907613/how-is-a-javascript-string-not-an-object">Source 2</a> </p>
<p>is that in javascript when a primitive datatype is used in the context of the object, it is internally converted to an object. But this is just a <strong>temporary conversion</strong> in that the object will be removed from memory after it is used.</p>
<p>My question is what is the <strong>advantage of using such an approach?</strong> Is it to just save memory? or is there any other advt.? </p>
| javascript | [3] |
1,204,640 | 1,204,641 | send sms programaticaly | <p>in my application i wan to send predefine smstext to one single number on certain event ,
it is possible to send sms like that! if yes please help me with sample code </p>
| iphone | [8] |
1,992,702 | 1,992,703 | Search mysql database for date range | <p>I have a database where users enter a date, among other things, with a drop down calendar, the date format is in this format 21-NOV-2012 .
Is there a way to search the database with a date range ?
I currently search date using the following ::</p>
<pre><code>sql ="SELECT * FROM ircb WHERE date LIKE '%$term1%' AND date LIKE '%$term2%' LIMIT $start_from, 15";
</code></pre>
<p>term1 is month and term 2 is year , this does not allow for date range within the month only for the month.
any help appreciated, thanks</p>
| php | [2] |
2,714,933 | 2,714,934 | Android Development: Webview progress Bar | <p>Take a look at: <a href="http://groups.google.com/group/android-beginners/msg/61802d28a8335809" rel="nofollow">http://groups.google.com/group/android-beginners/msg/61802d28a8335809</a></p>
<p>ive done that a got it to work but the progress does not change when clicking on a link in the webbrowser.</p>
<p>So the progressbar is showed when the app starts and load the home URL but when i click a link or search in google the bar is not showed. why?</p>
<p>Thank-you!</p>
| android | [4] |
5,962,563 | 5,962,564 | Replace a line in file using wildcard in Python | <p>So hopefully I havent overlooked the correct answer, but...
In keeping with the foo bar theme.
If I have a file that looks like this:</p>
<pre><code>blah boo who
bar blah blah
bar blah blah
foo some other chars
bar blah
black sheep
</code></pre>
<p>I want to be able to <strong>replace the line that starts with or includes <code>'foo'</code></strong> and replace the whole line with out knowing the following stuff.</p>
<p>My current code is nasty but works, is there a way to do it without loading the file and in a loop? or at least more efficiantly than this?</p>
<pre><code>filein = open("file", "r")
fileout = open("file.tmp", "w")
for line in filein:
if line.startswith("foo"):
fileout.write( "foo"+"my new numbers")
else:
fileout.write( line.replace('', '') )
filein.close()
fileout.close()
os.rename("file.tmp", "file")
</code></pre>
| python | [7] |
4,219,754 | 4,219,755 | Show a hidden div relative to the hovered element on click with jQuery | <p>I'm trying to get a hidden div to display relative position (directly to the right of the hovered div.)</p>
<p>On the fiddle, when the cursor hovers over the div it enlarges and repositions. What I want to achieve but can't figure out... is how to display the div details for 'this' element only, relative to the hovered div.</p>
<p>The problems I'm having are:</p>
<ol>
<li>Getting the child div (.details) to be the only one to display not all of the .details elements.
a. Getting it to display relative to the hovered element, not in an absolute position.</li>
<li>Cancelling the hover function on click, so that the div details can be navigated to without it disappearing.</li>
</ol>
<p>Fiddle: <a href="http://jsfiddle.net/pssuT/1" rel="nofollow">http://jsfiddle.net/pssuT/1</a></p>
| jquery | [5] |
3,142,102 | 3,142,103 | Jquery: Append cloned causes elements to be pushed around (IE ONLY) | <p>You can see the issue here: <a href="http://jsfiddle.net/qQ6ws/36/" rel="nofollow">http://jsfiddle.net/qQ6ws/36/</a></p>
<p>I am using shift to toggle my clone function which is called by the "start" call back on the draggable item.</p>
<p>I've had a problem with the event handler not being active unless I first left click on the content frame (lower right) and then hit a letter key. (Lclick + D key ) for example.</p>
<p>Once the event handler is active just shift click and drag on the test box to clone it. This works great in firefox.</p>
<p>Internet explorer 9 & 10 both have issues though. The test boxes keep getting offset each time they are appended to the document and the entire thing gets messed up.</p>
<p>I've tried various things but can't figure out to fix this. Any help would be much appreciated.</p>
| jquery | [5] |
1,910,678 | 1,910,679 | Can't see databases in android file explorer | <p>I'm new for android programming and now working with SQLite databases. I have a simple sample and creating code :</p>
<pre><code>public TimeTrackerOpenHelper(Context context) {
super(context, "timetracker.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
</code></pre>
<p>And in onCreate method in my activity class i create an openHelper for TimeTrackerOpenHelper:</p>
<pre><code> TimeTrackerOpenHelper openHelpler = new TimeTrackerOpenHelper(this);
</code></pre>
<p>I'm running the code and opening the file explorer following the path data/data/ but i can't see databases folder. why it isn't showed? </p>
| android | [4] |
3,903,067 | 3,903,068 | Auto pointer and allocator | <p>Instead of using try/catch blocks everytime I need to construct any objects after allocating a block of memory for them with an allocator I use internally in my container, I would like to use a class derived from std::auto_ptr (I have no c++11 here) with an overridden destructor, so that it could deallocate the pointed memory and release the pointer afterwards. Are there any disadvantages in doing this?</p>
| c++ | [6] |
1,012,951 | 1,012,952 | picture az map with zoom in c# form application | <p>I have picture that I should use it as map in my C# form application.</p>
<p>Is there any way that I can put some points or buttons on this picture that when user click on it some things happens.
A thing that is important for me is that I want user can zoom on the map. But if the user zoom on map buttons wouldn't move.
I want locate some click-able points in the map that can be zoomed and moved too.
Thanks.</p>
| c# | [0] |
3,199,595 | 3,199,596 | Initializing in constructors, best practice? | <p>I've been programming in C++ a while and I've used both methods:</p>
<pre><code>class Stuff {
public:
Stuff( int nr ) : n( nr ) { }
private:
int n;
}
</code></pre>
<p>Or</p>
<pre><code>class Stuff {
public:
Stuff( int nr ) {
n = nr;
}
private:
int n;
}
</code></pre>
<p>Note: This is not the same as <a href="http://stackoverflow.com/questions/24551/best-practice-initialize-class-fields-in-constructor-or-at-declaration">this</a>, similar but not the same.</p>
<p>What is considered best practice?</p>
| c++ | [6] |
2,122,957 | 2,122,958 | C Sharp compilation error | <p>I am getting a error while compiling some C# code, It says:</p>
<blockquote>
<p>The Type or namespace name could not
be found (are you missing a using
directive or assembly reference?)</p>
</blockquote>
<p>I cannot fix it. Any suggestions?</p>
| c# | [0] |
968,969 | 968,970 | python - how to add unicode literal to a variable? | <p>I've seen some examples like this:</p>
<pre><code>for name in os.listdir(u'somedir') :
</code></pre>
<p>my problem is that I'm getting the somedir as a variable, so how can I append the 'u' literal?</p>
<p>something like</p>
<pre><code>for name in ops.listdir(u+somedir)
</code></pre>
<p>?</p>
| python | [7] |
2,277,923 | 2,277,924 | Simple Image Sharpening algorithm for Android App | <p>I am looking for a simple image sharpening algorithm to use in my Android application. I have a grayscale image captured from video (mostly used for text) and I would like to sharpen it because my phone does not have auto focus, and the close object distance blurs the text. I don't have any background in image processing. But as a user, I am familiar with unsharp masking and other sharpening tools available in Gimp, Photoshop, etc. I didn't see any support for image processing in the Android API, and hence am looking for a method to implement myself. Thanks. </p>
| android | [4] |
2,516,586 | 2,516,587 | mysql_insert_array is a fatal error | <p>i am trying to insert the contents of the array below into my mysql table into the fields supplied. but i get fatal error: Call to undefined function mysql_insert_array();
any ideas?</p>
<pre><code> <?php
// Open database here
$connect = mysql_connect("xxxxx", "xxxx", "xxxx") or die('Couldn\'t connect to MySQL Server: ' . mysql_error());
mysql_select_db("xxxx", $connect ) or die('Couldn\'t Select the database: ' . mysql_error( $connect ));
// Let's pretend these values were passed by a form
$_POST['name'] = "Bob Marley";
$_POST['country'] = "Jamaica";
$_POST['music'] = "Reggae";
$_POST['submit'] = "Submit";
// Insert all the values of $_POST into the database table `artists`, except
// for $_POST['submit']. Remember, field names are determined by array keys!
$result = mysql_insert_array("artists", $_POST, "submit");
// Results
if( $result['mysql_error'] ) {
echo "Query Failed: " . $result['mysql_error'];
} else {
echo "Query Succeeded! <br />";
echo "<pre>";
print_r($result);
echo "</pre>";
}
// Close database
?>
</code></pre>
| php | [2] |
1,576,536 | 1,576,537 | Error when trying to select all items in listbox on button click event | <p>Error :</p>
<p>Unable to cast object of type 'System.String' to type 'System.Windows.Forms.ListBox'.</p>
<pre><code> private void button3_Click(object sender, EventArgs e)
{
foreach (ListBox item in SelectTables_Listbox.Items)
{
item.SelectedItem = true;
}
MessageBox.Show(" All tables Selected ");
}
</code></pre>
| c# | [0] |
5,142,849 | 5,142,850 | Animate text alignment using jquery | <p>At the click of a button <code>$('#btn').click()</code>, I want a group of <code>span</code> elements be set with CSS text-align right (originally text-aligned left) and make it animated so that the text slides from left to right.</p>
<p>I tried with <code>.animate({ 'text-align': "left")</code> but it doesn't seem to work.
I tried with <code>.addClass('alignRight', 1000)</code> again and the text did change but there is no sliding effect. When I tried with <code>.addClass('floatRight', 1000)</code>, it has similar effect with <code>alighRight</code>.</p>
<pre><code>.alignRight{ text-align : right;}
.floatRight(float: right;}
</code></pre>
<p>So how do I give a sliding effect from left to right? The markup is like</p>
<pre><code><div id="main" style="width: 300px;">
<div class="item" style="width: 100%;">
<span class="info">Strings</span>
</div>
<div class="item" style="width: 100%;">
<span class="info">Strings</span>
</div>
</div>
</code></pre>
| jquery | [5] |
3,745,936 | 3,745,937 | Getting all the columns in Android | <p>Can anyone please tell me how can I get all the column names used in a database table in Android..?</p>
| android | [4] |
2,627,882 | 2,627,883 | How to use Background worker in asp.net ?is there any samples in asp.net because Do work event is not firing | <p>In my application i have to bind huge amount of data to datagridview.still data bind progress bar should be used to show the progress .i have create an instance of background worker and added events Do work and Run worker completed but both are not firing is any properties should be set to fire the events in asp.netif i use RunWorkerAsync following error occured</p>
<p>Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event.</p>
| asp.net | [9] |
3,237,311 | 3,237,312 | Java: Thread safety in class with synchronized methods | <p>I read that the following class is not thread safe since threads could read inconsistent data as there is a chance for a thread to read scaled version of <code>real</code> and unscaled version of <code>imaginary</code>. But I did not understand how. </p>
<p>I was under the impression that if a thread acquires a lock and is in <code>scale()</code> method, no other thread can be in <code>getReal()</code> or <code>getImaginary()</code> methods at the same time so that other threads cannot read 'half scaled' complex numbers. Is it not correct?</p>
<pre><code> class Complex
{
double real;
double imaginary;
synchronized void scale(double scaleFactor)
{
real = real * scaleFactor;
imaginary = imaginary * scaleFactor;
}
synchronized double getReal()
{
return real;
}
synchronized double getImaginary()
{
return imaginary;
}
}
</code></pre>
| java | [1] |
4,163,021 | 4,163,022 | Is there long long defined? | <p>Where to check if type long long is defined? I wanna do something like this:</p>
<pre><code>#ifdef LONGLONG
#define long_long long long
#else
#define long_long long
#endif
</code></pre>
| c++ | [6] |
1,638,601 | 1,638,602 | How to override equals() for a Class with string array? | <p>I require clarification on String[] comparison inside Object's equal method.
Below is my code snapshot. When I execute this code, it gives true and false instead of true and true.
Also in my case Task class generate unique id for each call.
What am I doing wrong? any suggestion would be appreciated.</p>
<pre><code>public class JobTask extends Task {
String[] args;
public WFTask(String[] args) {
this.args = args;
}
@Override
public boolean equals(Object obj) {
if (! ( obj instanceof String[] ) ){
return false;
}
String[] arguments = (String[] ) obj;
boolean ret = Arrays.equals(this.args , arguments );
return ret;
}
@Override
public void execute(TaskExecutionContext context) throws RuntimeException {
--------------
--------------
}
public static void main(String[] args) {
String[] arg1 = {"a","b","c"};
String[] arg2 = {"a","b","c"};
System.out.println( Arrays.equals(arg1,arg2));
JobTask t1 = new JobTask(arg1);
JobTask t2 = new JobTask(arg2);
System.out.println( t1.equals(t2));
}
}
public abstract class Task {
private Object id = GUIDGenerator.generate();
public Task() {
}
Object getId() {
return id;
}
public abstract void execute(TaskExecutionContext context) throws RuntimeException;
}
</code></pre>
| java | [1] |
101,004 | 101,005 | IFRAME javascript close()? | <p>I can't seem to get self.close() to work on iframes. I know they aren't popups so it's quite normal that they don't but is there a work around?</p>
| jquery | [5] |
4,487,864 | 4,487,865 | How to create a dialog for multiple consecutive entries? | <p>I am currently working on an Android application that can manage a card game. I have (let's say) 4 players and after each round I click a button that opens a dialog to enter the score of the players during this round. How can I achieve this in an opened dialog? I tried several things, for example a ViewFlipper in the dialog, none of them working so far. The ViewFlipper for example doesn't have the chance to go to the next view since the dialog is already closed again when I hit the OK-button.</p>
| android | [4] |
1,088,341 | 1,088,342 | Table Adapter query Builder ASP.NET | <p>I want to connect my Table adapter with the Oracle, for that I am preparing a sql query with the query builder. The query which is running fine in Oracle but makes syntax error with query builder.It shows unable to parse the query text. I am using case statement and joins within the query.</p>
| asp.net | [9] |
3,669,992 | 3,669,993 | Color output in the CIELab space | <p>For the purpose of visualizing certain data, I'm supposed to utilize the colorings. Namely, the C++ code I have on disposal is outputting using cairo-graphics, and the function is based on RGB space. The data I work with should, on the other hand, utilize "certain slice" of the CIELab color space.</p>
<p>The question is: what would be the most appropriate way to do this with C++? Perhaps some conversion that might still rely on the RGB function provided by cairo (though I doubt this alternative, since RGB is device-dependent)?</p>
| c++ | [6] |
1,350,191 | 1,350,192 | how to restrict the input "shift+0" to "shift+9", but "shift" should accept (like "shift+A" or other) | <p>I need to restrict input of special characters (like "/", "\") as well as "$" (shift+4), "#"(shift+3), but also need to allow capital characters like "A" (shift+a), etc.</p>
<p>Below code works, but I am not restrict "$" and all (from "shift+0" to "shift+9") as I'm allowing "shift", Give me some response how to do that,</p>
<p><strong>HTML</strong> </p>
<pre><code><input type="text" id="txtboxToFilter" />
</code></pre>
<p><strong>Jquery</strong></p>
<pre><code><script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#txtboxToFilter").keydown(function (event) {
// Allow: backspace, delete, tab, escape, and enter
if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
else {
// stop the keypress for special character "/", "\"
if (event.keyCode >= 190) {
event.preventDefault();
}
}
});
});
</code></pre>
<p></p>
| jquery | [5] |
5,045,424 | 5,045,425 | Android location update problem | <p>I am working on one application in android and in my application i need to send the user's exact location to server. I m sending the location to server when i received push notification from the server that location is required.</p>
<p>Here on the onStart Method of Service Class i m calling " </p>
<pre><code>locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATES, MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,new MyLocationListener());"
"
</code></pre>
<p>to get the updates of user location and i m saving the location into the shared prefrence and when i get the location push notification i m sending the current location from shared prefrence.</p>
<p><strong>Problem:</strong></p>
<ol>
<li>My Gps provider is enabled all the time and consuming lots of battery</li>
<li>How can i save the battery?</li>
<li>I want to send the accurate location of the user?</li>
</ol>
<p>Everything is working fine but battery is consuming.</p>
<p>I want when needed then only it will call location update and after that stop the location update and gives the most accurate location of the user.</p>
| android | [4] |
4,573,401 | 4,573,402 | by reference in C++ | <p>I have this snippet of the code </p>
<pre><code>Stack& Stack:: operator=(const Stack& stack){
if(this == &stack){
return *this
}
}
</code></pre>
<p>here I define operator <code>=</code> but I can't understand, if I receive by reference stack why it should be <code>&</code> in <code>this == &stack</code> and not <code>this == stack</code> and why we return <code>*</code> in <code>return *this</code> and not <code>this</code> thanks in advance for any help</p>
| c++ | [6] |
3,989,636 | 3,989,637 | Using JQuery to remove a previous tag? | <p>I have a drop down box next to html link tag element, the link element is as below:</p>
<p><code><a href="#" class="delete" onclick="remove(this)"> Delete</a></code></p>
<p>It has an onclick attribute set to the javascript function below:</p>
<pre><code> `function remove(obj) {
$(obj).prev('select[name=estateDropDownList]').remove();
$(obj).remove();
}`
</code></pre>
<p>Now it removes the link fine, but it won't remove the PREVIOUS dropdownbox, this dropdown box has a name "estateDropDownList" and I just want it to remove only THAT dropdown box using prev() in JQuery, any ideas as to why it only removes the link and not the dropdown box?</p>
| jquery | [5] |
831,898 | 831,899 | New To Format Date Object | <p>I have a long value(1328005340400), I want to display the date format as "Tuesday, January 31, 2012 3:52:20 PM", How to format it in javascript, I just used new Date(1328005340400).toLocaleString(), but it displays "Tuesday, January 31, 2012 3:52:20 PM" in firefox and "Tue Jan 31 2012 15:52:20 GMT+0530 (India Standard Time)". How to make it as common format? can't we achieve without using third-party codes</p>
| javascript | [3] |
1,311,475 | 1,311,476 | How to populate google charts using ASP.NET Dataset/Datatable? | <p>How to populate google charts using ASP.NET Dataset/Datatable ?</p>
| asp.net | [9] |
1,251,015 | 1,251,016 | Defining multiple mime-type and file extension (pathPattern) mappings in AndroidManifest.xml? | <p>I'm trying to define two different file extension mappings and two different mime-type IntentFilters in my manifest file but I can't seem to get them all to work; one works and others don't, etc.</p>
<p>How does one define multiple pathPatterns in the manifest? Should/can all mime-types and pathPatterns be defined in a single IntentFilter? Should they be different filters? I can't find any examples that show multiple, distinct mappings.</p>
| android | [4] |
3,335,821 | 3,335,822 | Applying one of an array of styles to each selected item | <p>I have 3 (at the moment, could be more in the future) styles that I want to add to a group of divs in rotating order.</p>
<p>The classes I want to assign are:
.blue, .red, .green</p>
<p>and I have 4 divs that I want to assign them to in rotating order:</p>
<pre><code><div class="tripItem">
...
</div>
<div class="tripItem">
...
</div>
<div class="tripItem">
...
</div>
<div class="tripItem">
...
</div>
</code></pre>
<p>I would like the end result to be:</p>
<pre><code><div class="tripItem blue">
...
</div>
<div class="tripItem red">
...
</div>
<div class="tripItem green">
...
</div>
<div class="tripItem blue">
...
</div>
</code></pre>
<p>and to keep on rotating through in the same order if I was to add more divs.</p>
<p>What's the best way to go about this?</p>
| jquery | [5] |
314,958 | 314,959 | Date-Time Counter in PHP | <p>I am developing a project using PHP in which I want to do something like this:</p>
<ol>
<li>User Enter Start and End date and time both. On this page user has Play/Pause button.</li>
<li>User Enter details and save it to database. When user save this details counter will starts running. and using Play/Pause button user can pause and resume the counter. May be user pause counter today and resume it any time like after two days. </li>
</ol>
<p>So how can I maintain this counter timing. Can any one help me through code or any guidance?</p>
<p>Thank You in Advance</p>
| php | [2] |
5,474,575 | 5,474,576 | Is empty enum ( enum{}; ) portable? | <pre><code>class Test
{
enum{};
...
};
</code></pre>
<p>Is this empty enum definition portable? Compiles in gcc and and msvc.</p>
| c++ | [6] |
969,686 | 969,687 | compare functionality issue asp.net | <p>I need to compare two string and get both duplicate and original value .<br>
On calling chkDuplicateValue function i need to get both duplicate and original in the return value ?
, acts as delimeter for both the string .
Dim oldStr As String = "test1,test2,test"
Dim newStr As String = "test,test53"
Example out put : Original Value :test1,test2,test,test53 duplicate Value : test</p>
<pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oldStr As String = "test1,test2,test"
Dim newStr As String = "test,test53"
Dim refinedString As String = chkDuplicateValue(newStr, oldStr)
</code></pre>
<p>'On calling this function i need to get both duplicate and original in the return value ?</p>
<pre><code>Response.Write("Original Value" & refinedString(0))
Response.Write("duplicate Value" & refinedString(1))
'Example out put : Original Value :test1,test2,test,test53 duplicate Value : test
End Sub
Function chkDuplicateValue(ByVal newStr As String, ByVal oldStr As String) As String
Dim duplicate As String = ""
End Function
</code></pre>
| asp.net | [9] |
3,053,046 | 3,053,047 | How to read x number of characters from a text file progressively | <p>I am trying to read x characters from a text file at a time, progressively. So if I had: aaaaabbbbbcccccabckcka and im reading 5 at a time I would get, aaaaa, bbbbb,ccccc, abckc and ka. The code I am using is:</p>
<pre><code> status = is.read(bytes);
text = new String(bytes);
</code></pre>
<p>where bytes is: bytes = new byte[5], I am calling these two lines of code till status becomes -1, the problem I am facing is, the output is not what I have mentioned above, but I get this:</p>
<p>aaaaa, bbbbb, ccccc, abckc and kackc, notice the last segment 'kackc' is garbage, why is this happening ?</p>
<p>Note: that bytes is initialized once outside the reading loop.</p>
| java | [1] |
4,717,089 | 4,717,090 | Forbidden characters in input form? | <p>This is my current code it removes all non-numeric characters except $, commas and dots from an input when as user types:</p>
<pre><code><input type="text" id="price" name="price" onkeyup="updatePrice(this.value)">
function updatePrice(p) {
document.getElementById("price").value = p.replace(/[^0-9$.,]/g, '');
}
</code></pre>
<p>The problem is that it removes characters after typing them so if you type A you see it for a fraction of a second before it disappears. Keydown is no good since it runs the script before the input actually changes.</p>
<p>How can I completely prevent these forbidden characters from appearing on the input?</p>
| javascript | [3] |
4,344,884 | 4,344,885 | Android 1.6 setZOrderOnTop alternative | <p><a href="http://developer.android.com/reference/android/view/SurfaceView.html#setZOrderOnTop%28boolean%29" rel="nofollow" title="setZOrderOnTop">setZOrderOnTop</a> was introduced with Android API level 5. Is this a convenience method for functionality that existed in the earlier API levels? If so, how would I go about creating the same effect on Android 1.6?</p>
<p>Some background info:<br>
I am trying to get a GLSurfaceView with transparent pixels to render on top of the rest of my layout. So far I have not been succesful, the GLSurfaceView is displayed and renders properly, but pixels that are transparent show up completely black. My guess is that the default GLSurfaceView behaviour is the cause of my problem:</p>
<blockquote>
<p>The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed.</p>
</blockquote>
| android | [4] |
5,207,624 | 5,207,625 | Passing an argument to a python script and opening a file | <p>I've built a script that takes a filename as an argument and extracts all lines that match a certain pattern. Trouble is I can't open the filename - I keep getting :</p>
<pre><code>"TypeError: coercing to unicode: need string or buffer"
</code></pre>
<p>It's complaining about the line <code>info = open(name, 'r')</code>.</p>
<p>Here's the code:</p>
<pre><code>import re
import sys
print sys.argv[1:]
keyword = 'queued='
pattern = re.compile(keyword)
name = sys.argv[1:]
inf = open(name, 'r')
outf = open("test.txt", 'w')
for line in inf:
if pattern.search(line):
outf.write(line)
</code></pre>
<p>And I call it with </p>
<pre><code>`extract.py trunc.log`
</code></pre>
<p>Any ideas what I'm doing wrong?</p>
| python | [7] |
2,831,100 | 2,831,101 | weird calculation result | <p>why <code>d</code> is not equal <code>b</code> in this example?</p>
<pre><code> unsigned int z = 176400;
long a = -4;
long b = a*z/1000; //b=4294261
long c = a*z; // c=-705600
long d = c/1000; // d =-705
</code></pre>
<p>I use Visual Studio 2008, windows XP, core2duo.
Thanks.</p>
| c++ | [6] |
1,046,621 | 1,046,622 | android - email not working in samsung galaxy s | <p>I want to open android default email client directly. It's working in most of the devices except "Samsung Galaxy S". Actually the problem is i set the subject and body of the email in the coding this was effected in the most of the devices but it's not effected in samsung galaxy s. Here an empty compose mail opened. what can I do to make it work?</p>
<p><strong>Code</strong></p>
<pre><code>btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(emailIntent, 0);
if (!resInfo.isEmpty())
{
for (ResolveInfo info : resInfo)
{
System.out.println("info.activityInfo.packageName:"+info.activityInfo.packageName.toLowerCase());
System.out.println("info.activityInfo.name:"+info.activityInfo.name.toLowerCase());
if (info.activityInfo.packageName.toLowerCase().contains("mail") || info.activityInfo.name.toLowerCase().contains("mail"))
{
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Allergy Journal");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "My Allergy Journal Body");
emailIntent.setPackage(info.activityInfo.packageName);
startActivity(Intent.createChooser(emailIntent, "Email:"));
}
}
}
}});
</code></pre>
| android | [4] |
4,933,567 | 4,933,568 | Double template<> statements | <p>There is such function definition:</p>
<pre><code>template<>
template<>
void object::test<1>()
{
}
</code></pre>
<p>What does it mean that there are double template<>?</p>
<p>EDIT:</p>
<p>I extracted code which is valid for this example:</p>
<pre><code>#include <iostream>
template <class U>
class A {
template <int n>
void test() {
}
};
template <class T>
class B {
public:
typedef A<T> object;
};
typedef B<int>::object object;
template<>
template<>
void object::test < 1 > () {
}
int main() {
return 0;
}
</code></pre>
<p>This code compiles under g++.</p>
<p>Source: <a href="http://tut-framework.sourceforge.net/doxygen/basic_2test__vector_8cpp-example.html">TUT test framework</a></p>
| c++ | [6] |
5,155,199 | 5,155,200 | Unset an array element inside a foreach loop | <p>I'm accessing an array by reference inside a foreach loop, but the unset() function doesn't seem to be working:</p>
<pre><code>foreach ( $this->result['list'] as &$row ) {
if ($this_row_is_boring) {
unset($row);
}
}
print_r($this->result['list']); // Includes rows I thought I unset
</code></pre>
<p>Ideas? Thanks!</p>
| php | [2] |
2,216,770 | 2,216,771 | jQuery error Unrecognized expression | <p>I have some code working perfectly on a specific source solution which references jQuery 1.7.2</p>
<p>Now I copy/paste this source code to another solution which references jQuery 1.8.0</p>
<p>I don't know if jQuery version is the origin of my problem but I got an error: <strong>Unrecognized expression</strong></p>
<p>Here is the source code:</p>
<pre><code>$('#ScreenshotsTable tr.#' + screenshotID).remove();
</code></pre>
<p>Where screenshotID is (for example) equal to 7.</p>
<p>So as you can see, I would like to remove a line from a table.</p>
<p>Any idea why I got the error?</p>
<p>Thanks.</p>
| jquery | [5] |
5,238,424 | 5,238,425 | Does binding a click event to a button that already has a click event bound cause issues? | <p>Does binding a click event to a button that already has a click event bound cause issues?</p>
| jquery | [5] |
250,144 | 250,145 | Updating Progressbar in Notification bar using AsyncTask in a Service? | <p>I'm trying to download multiple binary files using a Service which contains an AsynTask for doing background work. I'm able to run the Service successfully, I've registered it in the Manifest file. I'm able to download the files, however I would like to show a progress bar in the notification bar. I am creating the Notification bar inside the onPreExecute() method and setting the progressbar and notifying the NotifactionManager inside the onProgressUpdate() method.</p>
<pre><code> private class DownloadFileAsync extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notification = new Notification(R.drawable.icon, "Downloading...", System.currentTimeMillis());
contentView = new RemoteViews(getPackageName(), R.layout.progress_layout);
contentView.setProgressBar(R.id.status_progress, 10, 0, false);
contentView.setTextViewText(R.id.status_text,currentFile);
notification.contentView = contentView;
// Toast.makeText(DownloadService.this, "Downloading...!",Toast.LENGTH_SHORT).show();
}
@Override
protected String doInBackground(String... aurl) {
int count;
try {
//Downloading code goes here
} catch (Exception e) {}
return null;
}
protected void onProgressUpdate(String... progress) {
Log.d("ANDRO_ASYNC",progress[0]);
notification.contentView.setProgressBar(R.id.status_progress, 100, Integer.parseInt(progress[0]), false);
// inform the progress bar of updates in progress
notificationManager.notify(NOTIFICATION_ID, notification);
}
@Override
protected void onPostExecute(String unused) {
Toast.makeText(DownloadService.this, "Download complete!",Toast.LENGTH_SHORT).show();
}
}
</code></pre>
<p>The DownloadFileAsync private class is inside the DownloadService class which extends Service. I'm unable to show or update the notification bar. </p>
<p>I'm currently getting an IllegalArgumentException on the line:
notificationManager.notify(NOTIFICATION_ID, notification);</p>
<p>Would really appreciate your help on this one!</p>
<p>EDIT: NOTIFICATION_ID is defined as follows: private int NOTIFICATION_ID = R.string.app_name</p>
| android | [4] |
1,830,641 | 1,830,642 | Java Arithmetic Operation '--' operator | <p>I am trying to understand the difference between <code>index = index--;</code> and <code>index=--index;</code> I checked the output of <code>index = index--;</code> assignment in the below code block (first example):</p>
<pre><code>public static void main(String[] args) {
int index = 10;
for (int i = 0; i < 10; i++) {
index = index--;
System.out.println("Index:" + index);
}//end of for loop
}// end of main method
</code></pre>
<p>Output:</p>
<pre><code>Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
Index:10
</code></pre>
<p>When I use the <code>index=--index;</code> assignment (second example)</p>
<pre><code>public static void main(String[] args) {
int index = 10;
for (int i = 0; i < 10; i++) {
index = --index;
System.out.println("Index:" + index);
}
}// end of main method
</code></pre>
<p>Output:</p>
<pre><code>Index:9
Index:8
Index:7
Index:6
Index:5
Index:4
Index:3
Index:2
Index:1
Index:0
</code></pre>
<p>I have two questions. In the second example Eclipse throws a warning: assignment <code>index = --index;</code>(The assignment to variable index has no effect) But actually it does have an effect on the variable. It decreases its value by 1. Why does Eclipse gives such a warning message? </p>
<p>In the first example, the variable is not affected by the operation (and Eclipse gives no warning). I wonder why Eclipse has no message, and I don't understand why this assignment has no effect over the variable index <code>index = index--;</code></p>
| java | [1] |
4,908,222 | 4,908,223 | confusion with float datatype | <p>I understand the integer range but i cannot know how float works</p>
<p>Range 3.4 e-38 to 3.4 e+38 (7 significant digits)</p>
<p>The range of float would be 0.000000000000000000000000000000000000034 to 340000000000000000000000000000000000000</p>
<p>how are 7 significant digits calculated?</p>
| c++ | [6] |
4,036,683 | 4,036,684 | remove cross image button in facebook sample | <p>I downloaded facebook sample code from the following link: <a href="https://github.com/facebook/facebook-android-sdk" rel="nofollow">https://github.com/facebook/facebook-android-sdk</a>. And i am trying to run that sample code and I got login screen in that login screen left corner cross image button is available. and when ever I click that button login screen is closed.and my question is how to remove cross image button</p>
| android | [4] |
1,321,364 | 1,321,365 | Can I assign a object to a integer variable? | <p>Let say I have a object. I'm assigning that to an integer. </p>
<pre><code>MyClass obj1 = 100;//Not valid
</code></pre>
<p>Let's say, I have a parameterized constructor which accepts an integer.</p>
<pre><code>MyClass(int Num)
{
// .. do whatever..
}
MyClass obj1 = 100;//Now, its valid
</code></pre>
<p>Likewise on any circumstance, does the vice-versa becomes valid?!.</p>
<pre><code>eg) int Number = obj1;//Is it VALID or can be made valid by some tweeks
</code></pre>
<p><strong>EDIT</strong>:</p>
<p>I found this to be possible using <em>Conversion Functions.</em>
Conversion functions are often called "cast operators" because they (along with constructors) are the functions called when a cast is used.</p>
<p>Conversion functions use the following syntax:</p>
<blockquote>
<p>operator conversion-type-name ()</p>
</blockquote>
<p>eg) Many have explained it neatly below</p>
| c++ | [6] |
4,549,597 | 4,549,598 | Missing expected identifier | <p>Getting message <code>expected identifier</code> in red for below these two statements </p>
<pre><code>} else if ([playpauseButton.state == UIControlStateSelected])
} else if ([playpauseButton.state == UIControlStateNormal])
</code></pre>
<p>I m not getting where i m missing identifier in below play/pause/resumeaction</p>
<pre><code>if( playpauseButton.state == UIControlStateNormal ){
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
[audioPlayer play];
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
} else if ([playpauseButton.state == UIControlStateSelected])
{
[sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateNormal];
[audioPlayer pause];
[self pauseTimer];
} else if ([playpauseButton.state == UIControlStateNormal])
{
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
[audioPlayer play];
[self resumeTimer];}}
</code></pre>
<p>I have programmed this way because i want when play is pressed it should play audio file plus start <code>NSTimer</code> to load <code>view controllers</code> one after another. When pause is pressed it should pause audio file plus <code>NSTimer</code> to avoid further loading of <code>view controllers</code> one after another and finally pause is resumed back to play audio file from the same point it should resume timer to start loading <code>view controllers</code> one after the other from that point.</p>
<p>If any one can help me to solve this.</p>
<p>Appreciate help.</p>
<p>Thanks.</p>
| iphone | [8] |
1,493,897 | 1,493,898 | How can I my activity get notified what changes user made? | <p>In my activity, i have a ListPreference which pops up a dialog and allow to select a value for a preference. </p>
<pre><code><ListPreference
android:key="limit"
android:title="@string/limit_label"
android:entries="@array/limit_label"
android:entryValues="@array/limit_values"
android:defaultValue="@string/default_limit"
/>
</code></pre>
<p>Can you please tell me if there is a call back function which I get notified what user has selected in the LIstPreference?</p>
| android | [4] |
105,858 | 105,859 | Jquery validation | <p>I am using the below code to validate a user's input:</p>
<pre><code>function validateAddress(){
//if it's NOT valid
if(f1.val().length = 0){
f1.addClass("error");
return false;
}
//if it's valid
else{
//whatever
}
</code></pre>
<p>My question is: For the user to fill his address I have 3 text_fields. id=f1 - id=f2 - id=f3. In this line</p>
<pre><code>if(my_text_field_id.val().length = 0){
</code></pre>
<p>Can I check if any of these values (f1, f2, f3) are empty? (not just one at a time)</p>
<p>Thank you</p>
| jquery | [5] |
2,761,687 | 2,761,688 | Compresing View | <p>in "iPhone tips" app when u scroll view from right to left,thay have show view being comppresed.It gives the effect like when u will open pages in book.Like when u go go next next page in a note book.How to achive this.Including the fonts in page will also get compressed.How to achive this.</p>
| iphone | [8] |
1,678,109 | 1,678,110 | java.util.NoSuchElementException even though input file has data | <p>I have written this code to find out an output and i am running this using Runtime in a servlet. It shows java.util.NoSuchElementEception even though i have checked that input file has some data:</p>
<pre><code>public class Sec1q10 {
static int fact(int n) {
int p = 1;
if (n != 1) {
p = n * fact(n - 1);
}
return p;
}
public static void main(String args[]) {
try {
System.out.println("first");
Scanner in = new Scanner(new FileReader("F:/sem5/algorithm/in.txt"));
String no = in.next();
int n = Integer.parseInt(no);
System.out.println(n);
int s = 0;
while (n != 0) {
s += fact(n);
n--;
}
System.out.println("sum=" + s);
String s1 = "" + s + "here";
PrintWriter out;
System.out.println(s1);
out = new PrintWriter("F:/sem5/algorithm/out.txt");
out.write(s1);
System.out.println(s1);
} catch (Exception ex) {
System.out.println("Exception: " + ex);
}
}
}
</code></pre>
<p>I even run this on cmd where it is showing the output without any exception but not writing anything in the file F:/sem5/algorithm/out.txt</p>
| java | [1] |
4,828,662 | 4,828,663 | Python: How do i manipulate the list to get the string starting with '+'? | <p><br>
I am comparing 2 txt files that are <code>ls -R</code> of the etc directory in a linux system. I compared the 2 files using <code>difflib.differ</code> and got this list as my result (i put the dots to keep the list short in here):</p>
<pre><code>result = [' etc:\n', ' ArchiveSEL\n', ' HOSTNAME\n', ' RMCPUser\n', ...,
' qcleaner\n', '+ extraFile\n', ' rc.d\n', '+ extraFile2\n', ...,
' resolv.conf\n', ' wu-ftpd\n']
</code></pre>
<p>I want to be able to take the strings with the <code>'+'</code> sign out to do something else. how do i manipulate the list? in the example above, i want to be able to get this string <code>"extraFile"</code> and <code>"extraFile2"</code>.</p>
<p>Thanks to all the people who posted solutions. It helps a lot and I am grateful :)</p>
<p>Here's what I did to get the string I wanted: </p>
<p>newresult = [file[2:-1] for file in result if file.startswith('+')] </p>
<p>to print out the strings: </p>
<p>for i in range (len(newresult)):<br>
print newresult[i]</p>
<p>THANKS~!!! :)</p>
| python | [7] |
3,964,113 | 3,964,114 | What is wrong with this getElementsByClassName call in Javascript? | <p>I am trying to access the width of a div to put in a cookie. This is the div:</p>
<pre><code> <div class="tab_panel" style="width:600px">
</code></pre>
<p>It is the only div with this class name. It is not an option to specify a unique id for the div. This is the code I have been using in an event to call it but it gives an error:</p>
<pre><code> document.getElementsByClassName(tab_panel).style.width
</code></pre>
<p>I know Firefox supports <code>getElementsByClassName</code>, so what am I doing wrong?</p>
| javascript | [3] |
4,073,855 | 4,073,856 | Using a std::vector<char> as a variant | <p>I want a simple variant with </p>
<ul>
<li>minimal overhead</li>
<li>that can be passed to functions written in the C language</li>
</ul>
<p>so I decided to use a std::vector like this<br></p>
<pre><code>typedef std::vector<char> SimpleVariant;
SimpleVariant data;
</code></pre>
<p>(1) store a std::string<br></p>
<pre><code>for(std::string::iterator it = str.begin(); it != str.end(); ++it)
{
data.push_back( *it );
}
data.push_back('\0');
</code></pre>
<p>(2) store a double</p>
<pre><code>data.resize(64);
std::sprintf(&data[0], "%.*g", 20, val);
</code></pre>
<p>(3) get a string<br></p>
<pre><code>std::string str = std::string( m_data.begin(), m_data.end() );
</code></pre>
<p>(4) get a double<br></p>
<pre><code>double dbl = boost::lexical_cast<double>(&data[0]);
</code></pre>
<p>Is this a reasonable approach given my requirements? Is there lightweight variant that I can use instead of trying to reinvent the wheel? <br>
I am aware of boost::variant and boost::any they are too heavyweight for my needs</p>
| c++ | [6] |
962,245 | 962,246 | Javascript Execution Question | <p>If I have an event that runs multiple javascripts does the following script wait until the previous script is complete before it runs?</p>
<p>Example:</p>
<pre><code><a href="#" onclick="javascript:SCRIPT_1();SCRIPT_2();SCRIPT_3();">Test Me</a>
</code></pre>
<p>Will <code>SCRIPT_2</code> not execute until <code>SCRIPT_1</code> is complete doing its stuff?</p>
<p>Thanks.</p>
| javascript | [3] |
3,935,524 | 3,935,525 | C# constructor shortcut needed | <p>I have two classes:</p>
<pre><code>public class PageMeta
{
public PageMeta() { }
public string DataSource { get; set; }
public string TopicID { get; set; }
public string Title { get; set; }
}
public PersonViewModel()
{
PageMeta = new PageMeta
{
Title = "Test"
};
public PageMeta PageMeta { get; set; }
}
</code></pre>
<p>Using the following code to create these:</p>
<pre><code>var r = new PersonViewModel();
r.PageMeta.DataSource="abc";
r.PageMeta.TopicID="def";
</code></pre>
<p>In real life my classes are more complicated and this is just an example. What I would like to do is to combine the creation of the PersonViewModel with the setting up of the DataSource and TopicID.</p>
<pre><code>var r = new PersonViewModel {
PageMeta.DataSource="abc";
PageMeta.TopicID="def";
}
</code></pre>
<p>Is there any way that this could be done in C# ?</p>
| c# | [0] |
2,498,139 | 2,498,140 | program on C++ to return a list which contains each word and no of occurrence in a sentence | <p>I am trying to do the code but not able to do it will be grateful if someone can help me with code. i.e if the input string is "we all love mothers, mothers are best ."</p>
<p>so the output should be :</p>
<p>we 1
all 1
love 1
mothers 2
are 1
best 1</p>
<p>also special characters should be avoided.</p>
| c++ | [6] |
Subsets and Splits