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 |
---|---|---|---|---|---|
1,419,957 | 1,419,958 | Python - open a command which open another shell | <p>I am writing a Python code which calls a command line (e.g. python itself) and the command will open its own shell. How can Python take control of this shell?</p>
<pre><code>import subprocess
subprocess.call(['./testprg'])
# testprg will open its own shell
# so the code below will not work
subprocess.call(['i 2'])
</code></pre>
<p>testprg is another program which open a shell prompt. Enter "i 2" will trigger a "insert" command with the value 2.</p>
| python | [7] |
5,753,217 | 5,753,218 | Specifying rowfilter criteria to be evaluated in DataTable event handlers | <p>We have a mini business application framework of our own to meet our custom needs. We are using datatables in our business classes for storing collections (e.g. detail data). Our framework identifies any datatable type properties declared in a business object and attaches a few event handlers to provide services like authorization control, change tracking etc. Things are running fine but today a small requirement got me a little baffled.</p>
<p>Apart from all authorization requirements e.g. role based access to edit the datatable, edit some columns of the datatable etc., our devs now require to specify a criteria for a datatable and all the matching rows (fulfilling that criteria) will then be prevented from editing.</p>
<p>For example if there is a datatable having values as below - </p>
<hr>
<p>SettingName | Value | IsPolicyControlled</p>
<hr>
<p>Setting1 | 10 | False</p>
<p>Setting2 | 20 | True</p>
<hr>
<p>The devs want to specify a criteria through our business framework as below -</p>
<p>someBusinessObject.MakeReadOnly("Settings", "IsPolicyControlled == true");</p>
<p>the first parameter being the datatable name and second the criteria for readonly rows. Now as the framework developer my duty will be to prevent any editing in any rows that match the specified condition.</p>
<p>For that I can attach some event handler to that datatable to monitor any changes that are being made, e.g. I can handle RowChanging to monitor the change being made. Now I need to verify that whether the row that is being changed matches the specified condition. Something like </p>
<p>if (RowMatchesCondition(e.Row))
// block changes</p>
<p>Now I could find no optimized mechanism of getting this done. One thing that came to my find is to use a DataTable.Select() method with that condition and to check if the current row (in RowChanging) exists within the returned DataRow array. But I am looking for a little better solution.</p>
<p>Thanks for any help buddies.</p>
| c# | [0] |
5,565,786 | 5,565,787 | Matt Ryall’s jQuery live filter - only return results that start with the string? | <p>Can Matt Ryall’s jQuery live filter be modified to only show results that begin with the search text? </p>
<p><a href="http://mattryall.net/blog/2008/07/jquery-filter-demo" rel="nofollow">http://mattryall.net/blog/2008/07/jquery-filter-demo</a>
Thanks</p>
| jquery | [5] |
704,718 | 704,719 | alias conflict namespace c# | <p>Looking for an explanation. </p>
<p>I have the same name space in two different assemblies. Say </p>
<pre><code>NsA.xxx.NsB
</code></pre>
<p>Now I created an alias to resolve the issue and called it xxx.<br>
I left "global" as the alias namespace for the other assembly. </p>
<p>The trouble is that "xxx" as an alias conflicted with "xxx" namespace part. I resolved the Issue by haveing my alias named "XXX". Now there was no conflict and everyone returned to thinking happy thoughts.</p>
<p>This is unexpected (to me). Is this a bug?</p>
| c# | [0] |
757,705 | 757,706 | How to insert an item at the beginning of an ObservableCollection? | <p>How can I do that? I need a list (of type <code>ObservableCollection</code>) where the latest item is first.</p>
| c# | [0] |
4,482,701 | 4,482,702 | C# - Prevention of automatic timezone conversion of datetime values while getting data from database through WCF | <p>I am working on a C# client server application with the server in a different geographical region than the client ie. across time zones. The application makes use of WCF as the middle tier between the UI and Server.
Our requirement is to fetch data from the database and display it in the UI.
The problem is that the datetime columns values (part of the DataTables loaded with data from the database) are automatically getting converted to the local date,time at the client region.</p>
<p>Is there any setting in WCF which prevents automatic timezone conversion of datetime values
that are a part of a dataset?</p>
<p>Thanks in advance for any help.</p>
<p>Regards,
Sujay</p>
| c# | [0] |
2,426,619 | 2,426,620 | How can I refer to class variable in a function without referring to its class in Python? | <p>I have a following class:</p>
<pre><code>class Foo:
CONSTANT = 1
def some_fn(self):
a = Foo.CONSTANT
# do something
</code></pre>
<p>How can I refer to <code>Foo.CONSTANT</code> without referring to <code>Foo</code>, or refer to <code>Foo</code> in a generic way? (I don't want to change all references to it when renaming a class)</p>
| python | [7] |
519,952 | 519,953 | how instance of class is creating recursively and thus causing stackoverflow error | <p>Consider following 2 programs giving same error<br>
First calss:</p>
<pre><code>public class Testing {
Testing t=new Testing();
public static void main(String args[]){
testing t1=new testing();
}
}
</code></pre>
<p>Second class:</p>
<pre><code>class foo{
void baz(){
new testing();
}
}
public class testing {
testing t=new testing();
public static void main(String args[]){
foo f=new foo();
f.baz();
}
}
</code></pre>
<p>how does above code giving following error?<br>
I know instance of class is creating recursively but I want to know how?</p>
<pre><code>Exception in thread "main" java.lang.StackOverflowError
at com.Testing.<init>(Testing.java:4)
at com.Testing.<init>(Testing.java:4)
</code></pre>
<p>also Why doesn't this happen if we do</p>
<pre><code> public class testing {
testing t2=new testing();
testing t1=new testing();
public static void main(String args[])
{//anything}
}
</code></pre>
<p>as t1 will require t2 object to be initalized and vice-versa?</p>
| java | [1] |
5,622,813 | 5,622,814 | Is there a Newline constant defined in Java like Environment.Newline in C#? | <p>In C# there is the static property <a href="http://msdn.microsoft.com/en-us/library/system.environment.newline.aspx" rel="nofollow">Environment.Newline</a> that changed depending on the running platform.</p>
<p>Is there anything similar in Java?</p>
| java | [1] |
638,121 | 638,122 | passing element reference through dynamically created html | <p>Lets say that I have a element reference obtained ala...</p>
<pre><code>var x=document.getElementById("ID123");
</code></pre>
<p>Now I want to include some function of x on a dynamically created html element ala...</p>
<pre><code>myWin.document.write("<input type='button' data-doit=????? value='Do It' onclick='window.doit(?????);'/>");
</code></pre>
<p>so that function doit() can recreate the original reference x</p>
<pre><code>function doit()
{
var x = ?????;
}
</code></pre>
<p>Right now I'm doing this by obtaining a numeric index of x as found via getElementsByTagName and passing that as a parameter to doit().</p>
<p>Is there some way to do this?</p>
| javascript | [3] |
3,877,288 | 3,877,289 | How to change the frame of AlertView in iPhone App...? | <p>I want to Add TextBox on AlertView. But When i'm adding, it overlaps little with buttons on it...So i want to increase the height and width of alertview...Could Anybody tell any idea??</p>
| iphone | [8] |
3,675,566 | 3,675,567 | Attach a pan gesture recognizer an image | <p>Could someone guide in what I need to do? I need to attach a pan gesture recognizer to an image which rotate clockwise and anticlockwise as we move.</p>
<p>Thanks</p>
| iphone | [8] |
1,078,516 | 1,078,517 | How to show bg color in fadeIn effect and remove style properties using jQuery | <p>i want to change background color on hover function but i want to show in slow motion. Also i am adding some CSS Property on hover and want to remove and hover out. But my function does not work according to my requirment.</p>
<pre><code>$(function (){
$('.box').hover(function (){
$('body').css({'background-color':'black'})
$(this).css('-moz-transition', 'opacity .3s')
$(this).css('-webkit-transition', 'opacity .3s')
$(this).css('-o-transition', 'opacity .3s')
$(this).css('-ms-transition', 'opacity .3s')
}, function () {
$('body').css({'background-color':'black'})
$(this).remove('-moz-transition','none')
})
})
</code></pre>
| jquery | [5] |
2,269,601 | 2,269,602 | Persisting data between crashes | <p>We're going to be building an application that manages multiple types of queues. I'm looking into the best ways to not lose data if the application crashes for any reason. I've done some googling using the term "persisting" which leads me to JPA over and over. I have some experience with JPA. I'm no expert on the "shutdown sequence" of Java in the event of a crash and am wondering what's involved with persisting a queue. Are there libraries that provide some of this functionality?</p>
| java | [1] |
1,077,744 | 1,077,745 | JavaScript use constructor parameters in methods, which way is valid? | <p>I have js object like this:</p>
<pre><code>var Dog = function(dogName) {
this.bark = function() {
console.log(dogName + " is barking");
}
}
</code></pre>
<p>and </p>
<pre><code>var Dog = function(dogName) {
this.dogName = dogName;
this.bark = function() {
console.log(this.dogName + " is barking");
}
}
</code></pre>
<p>I can use both the same way:</p>
<pre><code>var puppy = new Dog("Ringo");
puppy.bark();
</code></pre>
<p>My question is is there any practical difference between those two approaches? Is it better to assign constructor parameters to <code>this.<field></code>, or I can just utilize those parameters straight away as they are accessible to inner functions? Are there any special cases for both?</p>
| javascript | [3] |
3,411,855 | 3,411,856 | message error: Cannot access mscorlib.dll | <p>I am using snippetcompiler. I once added references to .NET 3.5 and the remove them but since I got this error each time I run a cs file:</p>
<p>cannot copy v2...\mscorlib.dll to c:\windows\system32</p>
<p>How to correct this if someone knows ?</p>
| c# | [0] |
3,439,467 | 3,439,468 | Best ASP.NET Websites for Sample Code / Code Projects | <p>I am new to .NET development. </p>
<p>Would you please let me know few best ASP.NET Websites for Sample Code / Code Projects?</p>
<p>Thank you & Regards.</p>
<p>Shravya.</p>
| asp.net | [9] |
5,258,076 | 5,258,077 | How often should I use try and catch in C#? | <p>When writing a C# application whose #1 priority is to <b>never crash</b>, how often should I used a try-catch block?</p>
<p>Can I encapsulate all the statements in a method in try-catch blocks?</p>
<pre><code>public void SomeMethod()
{
try
{
// entire contents of the function
// library calls
// function calls
// variable initialization .. etc
}
catch (Exception e)
{
// recover
}
}
</code></pre>
<p>What are the downsides to wrapping everything in try-catch blocks?</p>
| c# | [0] |
3,755,680 | 3,755,681 | How To Handle An InvalidOperationException In A foreach Loop Containing yield return? | <p>I have the following code in which I am trying to take each element returned by an ICollectionView and translate it into a different object.</p>
<pre><code> public IEnumerator GetEnumerator()
{
foreach (TOriginal original in _collectionView)
{
if (!Equals(original, null))
{
yield return GetTranslated(original);
}
else
{
yield return default(TTranslated);
}
}
}
</code></pre>
<p>If _collectionView is changed during the foreach (this is happening in my test app) then it throws an InvalidOperationException, but I can't wrap the foreach loop in a try/catch because VisualStudio complains "'yield return' statement couldn't appear in a try/catch block".</p>
<p>How can I handle the exception?</p>
| c# | [0] |
4,950,172 | 4,950,173 | Implementation of **kwargs construct in python | <p>I implemented a class in python which currently inherits from dict, but really, I don't want it to. The main reason for inheriting is so that I can use the **kwargs construct for copying the contents into an argument list.</p>
<p>I presume python does some sort of iteration over the dictionary, but I can't find any documentation.</p>
<p>Is this possible, and, if so, how?</p>
<p>Code sample just to make things clearer:</p>
<pre><code> class MyThing():
def __init__(self):
self.dictionary = {}
thing = MyThing()
# code that causes thing.dictionary to be populated
somefunc(**thing)
</code></pre>
<p>results in this:</p>
<pre><code>TypeError: somefunc() argument after ** must be a mapping, not instance
</code></pre>
| python | [7] |
178,648 | 178,649 | php difference between function exit and return false | <p>I have seen at the end of the function sometimes written "return false" also "exit". What is the main difference between these two and in which kind of situations are these two required?</p>
| php | [2] |
2,641,192 | 2,641,193 | Need help designing application with UIPageControl and UIScrollView | <p>I have looked at the PageControl example from Apple and have an architectural requirement difference. In the example the scroll view and page control objects are at the app delegate level. This means the scroll view and page control appears on every view of the application.</p>
<p>However, I have a "settings" view toggled from an info button (for now) that should not have these controls displayed. Therefore, I need to move my scroll view, page control, and view controllers objects down a layer and I'm struggling with how to best do this.</p>
<p>For example, the primary application view consists of metals (periodic elements). From this view I need a scroll view, page control, and info button on every view descending from here. Each metal will have it's own subclass where different images, calculations, etc will be displayed but I believe I need each of these subclassed elements to share the same scroll view, page control, and viewControllers array, right? Do I need a singleton?</p>
| iphone | [8] |
2,305,165 | 2,305,166 | Drupal and CodeIgniter | <p>im still in learning process on learning Drupal and CodeIgniter but i was thinking if it is possible to create a web application using Drupal as a CMS and CI as a framework?</p>
| php | [2] |
3,899,317 | 3,899,318 | Not able to uploade website on server | <p>I am try to uploading website.I don't know how configure database(web.config file) on uploading time.I am using Somee.com , anyone familiar with somee.com Or know how to configure database the please help me.</p>
<p><strong>webconfig file code</strong></p>
<pre><code><configuration>
<connectionStrings>
<add name="abc" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Jai-Ganesh\Documents\Visual Studio 2010\WebSites\testinmg\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="RemoteOnly" ></customErrors>
</system.web>
</configuration>
</code></pre>
<p>Note: I don't know what is path of the dataSource in server. </p>
<p>Link of the page:
[<strong><a href="http://www.imureditor.somee.com/add_value.aspx" rel="nofollow">http://www.imureditor.somee.com/add_value.aspx</a></strong>][1]</p>
| asp.net | [9] |
3,896,162 | 3,896,163 | Appending Jquery HTML? | <p>I am trying to append the text of a link inside a <code><li></code> to a <code><ul></code> The problem is getting it to scan through and find duplicates and not add a new <li>. </p>
<p>Here is the code:</p>
<pre><code>$('.popular-list li a').live("click",function() //this will apply to all anchor tags
{
var stuff = $(this).text();
var match = $('#favoritesdrinks li:contains(' + stuff + ')');
if(match) {
alert("Already Added")
} else {
$('#favoritesdrinks').append('<li>'+stuff+'</li>');
}
}
);
</code></pre>
<p>UPDATE- THIS IS WORKING CODE:</p>
<pre><code> $('.popular-list li a').live("click",function() //this will apply to all anchor tags
{
var $stuff = $(this).text();
var hasDuplicate = false;
$('#favoritesdrinks li').each( function(){
if ($(this).text() === $stuff ){
hasDuplicate = true;
return false;
}
});
if (hasDuplicate ) {
alert("Already Added") }
else {
$('#favoritesdrinks').append('<li>'+$stuff+'</li>');
}
});
</code></pre>
| jquery | [5] |
2,562,170 | 2,562,171 | Android 2D Game Architecture | <p>I am creating a 2d puzzle game on android and want to get the community's input on a design decision. The basic design is this. There is a SurfaceView one which the 2d graphics are drawn in a background thread. Then I also have a RelativeLayout that overlays the surface view. The layout .xml looks like this:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center" >
<SurfaceView
android:id="@+id/game_surface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<RelativeLayout
android:id="@+id/game_overlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
</code></pre>
<p>All touch events will be received by the game_overlay and will be routed to the game thread as needed. I will use LayoutInflater to inflate a layouts and place them inside game_overlay, then clear the game_overlay when needed. My rational for doing things way is that you get the best of both worlds. You don't have draw your own custom buttons to the canvas (Like a reset level button), rather leverage all that powerful android layout functionality. However you are able to perform the game rendering in the background, and have that thread stay alive all the time.</p>
<p>So now onto my questions. If you have tried something like this before I would like to hear your experience. Can I expect to pay a performance penalty for layering views like this? And more importantly would that performance hit be detrimental to the app's frame rate? Is there any other problem with this approach that you can spot. </p>
| android | [4] |
1,921,328 | 1,921,329 | Probem with access an element with '::' in id | <p>In following fiddle : <a href="http://jsfiddle.net/Q9sHz/5/" rel="nofollow">http://jsfiddle.net/Q9sHz/5/</a></p>
<p>I have an <li> with id "test1::newtest"</p>
<p>When I press button - enable 'Li Point1' the <li> element Li Point1 remains un draggable but if I remove the :: from the id as in fiddle : <a href="http://jsfiddle.net/Q9sHz/6/" rel="nofollow">http://jsfiddle.net/Q9sHz/6/</a>
It becomes draggable when I click the button.</p>
<p>Is having ':' within an ID not allowed ?</p>
| jquery | [5] |
3,602,263 | 3,602,264 | Show only a part of string in a TextView | <p>I am trying to accomplish a currency converter app for android and I'm using Google Currency Converter to do it by sending an URL with this form :</p>
<pre><code>http://www.google.com/ig/calculator?q="amount""from currency code"=?"to currency code"
</code></pre>
<p>Example :-</p>
<pre><code>http://www.google.com/ig/calculator?q=10USD=?EGP
</code></pre>
<p>and the out put for the Example will be :</p>
<pre><code>{lhs: "10 U.S. dollars",rhs: "59.701849 Egyptian pounds",error: "",icc: true}
</code></pre>
<p>and what I want to do is to show in the TextView (which will show the final result for the user) only this :-</p>
<pre><code>59.701849 Egyptian pounds
</code></pre>
<p>so any ideas will be helpful and thanks for your help in advance... </p>
| android | [4] |
2,244,387 | 2,244,388 | How to make background (Black portion) of showed Image transparent and draw on canvas in android? | <p>I am working on photo puzzle . So u all can understand what I have to do. I have problem on specific area discussed below ::
I have a canvas. Mask an image with this bitmap shown below. The White portion is changed/replaced by image say mBitmap and black portion remain black. I need to make the black portion transparent as I will use this Image to reorganize side by side in future step . But now this black portion give me much pain when I reorganize/ merge them all together to construct the original image then black portion make other image black . If it will transparent then black portion can show the overlapped image portion of other image .
Please help me out as soon as possible ....</p>
| android | [4] |
1,568,491 | 1,568,492 | Manually throw an exception | <p>How would I manually throw an <code>IndexOutOfBoundsException</code> in Java and optionally print a message?</p>
| java | [1] |
3,834,021 | 3,834,022 | Clear an input field after submission using JavaScript | <p>I am a JavaScript newbie. I have an input text field that I wish to clear after pressing the form submit button. How would I do that?</p>
| javascript | [3] |
4,534,500 | 4,534,501 | Android Button Reference? | <p>So I'm having some issues with a method I'm going to be using to change a button's color based on a number received from the game engine (so if it returned 0 it would be red, 1 would change it to blue, 2 would change it to yellow) but I keep getting errors when trying to reference the button.</p>
<p>I'm referencing the buttons in this way:</p>
<pre><code>Button x0y0 = (Button) findViewById(R.id.x0y0);
</code></pre>
<p>But I am getting an error, eclipse does not recognize </p>
<p>Any help on how I can get buttons into this program and have them change color based on what the engine returns to it?</p>
| android | [4] |
5,122,386 | 5,122,387 | FaceDetection onLine API in Android | <p>Can any one tell me which is the best way for onLine FaceDetection in Android. Is there any API for the same? If yes, then how we can implement that? Please suggest me for the right solution.</p>
<p>Thanks in advance.</p>
| android | [4] |
4,547,245 | 4,547,246 | What does this mean? $length = null === $length ? strlen($data) : (int)$length ; | <p>I'm aware of ternary operator, more or less.
But I'm unable to read this line.</p>
<pre><code>$length = null === $length ? strlen($data) : (int)$length ;
</code></pre>
<p>What does $length = null === $length means?</p>
<p>Thanks a lot,
MEM</p>
| php | [2] |
3,561,684 | 3,561,685 | Sliding div not moving smoothly | <p>I have a slider which im trying to slide by using mouse move but it doesn't move naturally it jumps in stages but i do not know why.</p>
<p>I have a jsfiddle here:
<a href="http://jsfiddle.net/97Mnf/3/" rel="nofollow">http://jsfiddle.net/97Mnf/3/</a> you will see the slider doesn't move with the mouse properly.</p>
<p>My code is :</p>
<pre><code>window.onload = function(){
document.getElementById('cursor').addEventListener("mousedown", mousePos, false);
}
function mousePos(e){
var x = e.pageX;
document.getElementById('cursor').addEventListener("mousemove", function(e){mousemoveCalc(e,x);}, false);
document.getElementById('cursor').removeEventListener("mouseup", mousemoveCalc, false); //not working
document.getElementById('cursor').removeEventListener("mouseout", mousemoveCalc, false); //not working
}
function mousemoveCalc(e,x){
var difx = 0 + parseInt(x + e.pageX);
if(difx > 270){
difx=270;
}else if(difx<0){
difx=0;
}
document.getElementById('cursor').style.left = difx+'px';
}
</code></pre>
| javascript | [3] |
4,700,166 | 4,700,167 | List Table Creation in Java | <p>I'm trying to create a list as below in Java. Maybe I'm naive to OOP and Java, therefore I'm not able to resolve it.</p>
<p>I need to create a below table</p>
<pre><code>Character Count Price
A 1 2
B 1 12
C 1 1.25
D 1 0.15
A 4 7
C 6 6
</code></pre>
<p>I have create a class as below:</p>
<pre><code>class ProductList {
private char ProductName;
private double Price;
private int Count;
public char getProductName() {
return ProductName;
}
public void setProductName(char productName) {
ProductName = productName;
}
public double getPrice() {
return Price;
}
public void setPrice(double price) {
Price = price;
}
public int getCount() {
return Count;
}
public void setCount(int count) {
Count = count;
}
}
</code></pre>
<p>Then comes my main class which create the list of the product table as above.</p>
<pre><code>public class ProductEntryList {
public static void main(String[] args) {
ProductList[] entry = new ProductList[6];
//Product Entry for A
entry[0].setProductName('A');
entry[0].setCount(1);
entry[0].setPrice(2);
//Similarly for other entries of product
for(int loop = 0;loop<entry.length;loop++) {
System.out.print(entry[loop].getProductName()+" ");
System.out.print(entry[loop].getCount()+" ");
System.out.print(entry[loop].getPrice()+"\n");
}
}
}
</code></pre>
<p>I'm quite bugged why I m getting</p>
<pre><code> Exception in thread "main" java.lang.NullPointerException
at ProductEntryList.main(ProductEntryList.java:13)
</code></pre>
<p>Any input this would be helpful.</p>
| java | [1] |
5,164,209 | 5,164,210 | Refresh JavaScript section only? | <p>I have a section of JavaScript that displays the current temperature, but it does not update as the temperature changes. Is there a way to have that section of JavaScript update on a timer?</p>
<p>EDIT: Sorry, here's the code (not created by me).</p>
<pre><code><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
// javascript will go here
$(function(){
// Specify the ZIP/location code and units (f or c)
var loc = '10001'; // or e.g. SPXX0050
var u = 'f';
var query = "SELECT item.condition FROM weather.forecast WHERE location='" + loc + "' AND u='" + u + "'";
var cacheBuster = Math.floor((new Date().getTime()) / 1200 / 1000);
var url = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent(query) + '&format=json&_nocache=' + cacheBuster;
window['wxCallback'] = function(data) {
var info = data.query.results.channel.item.condition;
$('#wxIcon').css({
backgroundPosition: '-' + (61 * info.code) + 'px 0'
}).attr({
title: info.text
});
$('#wxIcon2').append('<img src="http://l.yimg.com/a/i/us/we/52/' + info.code + '.gif" width="40" height="40" title="' + info.text + '" />');
$('#wxTemp').html(info.temp + '&deg;' + (u.toUpperCase()));
};
$.ajax({
url: url,
dataType: 'jsonp',
cache: true,
jsonpCallback: 'wxCallback'
});
});
</script>
</code></pre>
| javascript | [3] |
642,212 | 642,213 | The TargetControlID is not valid / adding a control to a form in the asp.net code | <p>I am trying to add a control that I define in C# to my asp code, by doing this in my code:</p>
<pre><code><% this.Controls.Add(blah.GetControl()); %>
</code></pre>
<p>but I get the error: The TargetControlID of 'a8f08c40d0fab104ca20b1460ee1cbdd1e121' is not valid. The value cannot be null or empty.</p>
<p>Thats the controls GUID that I randomly generate in the get method.</p>
<p>Any explanation as to why I am getting it? Is what I am doing even allowed - putting that code above into my aspx file?</p>
<p>Edit: Additional code for the new ID problem:</p>
<pre><code>.
.
<div id="divDetailsContent" style="width:100%">
.
.
<% this.Controls.Add(blah.GetControl("divDetailsContent")); %>
.
.
public static blah GetControl(n)
{
.
.
blah.TargetID = n;
.
.
}
</code></pre>
| asp.net | [9] |
2,894,620 | 2,894,621 | Is arr.length=0 better than arr=[] in javascript while reseting | <p>I'm improving the performance of a HTML5 Game,while I reset some arrays,in order to reduce the garbage collection,I tend to use array.length=0(Yet I'm not sure if it's working in real world)<br>
I did some tests to find out the speed of these 2 types of reset array here<br>
<a href="http://tinkerbin.com/hqQvp5fQ" rel="nofollow">http://tinkerbin.com/hqQvp5fQ</a> </p>
| javascript | [3] |
1,946,812 | 1,946,813 | Java - Key-Value Decision Making | <p>What would be the best way to store the following Business Rules in a File so that they can be applied on the input values which would be keys?</p>
<pre><code>Key-INDIA; Value-Delhi.
Key-Australia; Value-Canberra.
Key-Germany, Value-Berlin.
</code></pre>
<p>One Solution :- Xml</p>
<pre><code><Countries>
<India>Delhi</India>
<Australia>Canberra</Australia>
<Germany>Berlin</Germany>
</Countries>
</code></pre>
<p>As the number of rules are going to be > 1000; implementing it using Map is not possible.</p>
<p>Regards,
Shreyas.</p>
| java | [1] |
4,113,787 | 4,113,788 | modify function and If statement | <p>I have a inputbox that displays a default text "Input Network ID Here...". I need to take <code>$inputUri</code> and check it against function <code>checkUrl($string)</code> to see if its still there. If the text hasn't been cleared then display the <code>addError</code> message </p>
<pre><code>public function checkUrl($string)
{
$inputUri = 'Input Network ID Here...';
if(empty($string) || preg_match("#^([A-Z0-9][A-Z0-9_ -]*(?:.[A-Z0-9][A-Z0-9_ -]*)+):?(d+)?/?#i", $string))
{
return true;
}
else
{
if( isset($this) )
{
$this->addError("Input Network ID");
}
return false;
}
}
</code></pre>
| php | [2] |
3,162,351 | 3,162,352 | Blocking access to my app's database | <p>I need to block user access to my app's data stored in the SD card... like the images etc as they are crucial to my app's proper functioning and if deleted by mistake, will cause the application to function way different from what is expected of it. Is there any way to do so programmatically, like when I create this directory structure during my first run, lock the access to it to be only unlocked when the app runs?</p>
| android | [4] |
4,107,018 | 4,107,019 | beginner java - how to check if integer is in a given range? | <p>Hoping for something more elegant than</p>
<pre><code>if (i>0 && i<100)
</code></pre>
| java | [1] |
2,570,583 | 2,570,584 | Deactivate/activate link with jQuery? | <p>I'm looking for a simple solution to deactivate/activte button links. I could use addClass/removeClass to change the color to gray when deactivated, but there is still possible to click on the link. Is there a way to handle this?</p>
| jquery | [5] |
2,278,504 | 2,278,505 | removing last 3 characters on a file (file extension) | <p>my file name are being stored in a variable <strong>$file_name</strong>... how can i remove the extension and just have the name only? is there something other than strcmp that i can use... that doesn't seem to do it</p>
| php | [2] |
2,291,144 | 2,291,145 | Total a natural number with real number by php? | <p>How can increase a number according to percent with PHP?</p>
<p>For example: <code>100 + 20% = 120</code> or <code>1367 + 33% = 1818.11</code></p>
<p>If output was this: <strong>1818.11</strong> i want only this: <strong>1818</strong> or this <strong>12.32 = 12</strong> or <strong>546.98 = 546</strong></p>
<p>How is it?</p>
| php | [2] |
1,731,198 | 1,731,199 | Compile an exe file inside c++ | <p>I want to create a c++ program in which</p>
<ol>
<li><p>I can read an external file (that can be exe,dll,apk...etc...etc). That is read the file convert them into bytes and store them in an array</p></li>
<li><p>Next,I want to compile the bytes inside the array
Now this is the tricky part i want to compile the bytes into an array just to check that if the bytes are working well</p></li>
<li>You may say i am converting a file into bytes and then converting those bytes back to the same file....(Yes indeed i am doing so)</li>
</ol>
<p>Is this possible?</p>
| c++ | [6] |
780,880 | 780,881 | javascript validate uk date | <p>I am trying to validate a date in the format dd/mm/yyyy using a function I have found online, but I get this error : 'input is null'</p>
<p>Can anybody tell me where my syntax is wrong?</p>
<pre><code>if (validateDate($("#<%=StartDate.ClientID%>")) == false) {
alert("not date");
}
else {
alert("date");
}
function validateDate(dtControl) {
var input = document.getElementById(dtControl)
var validformat = /^\d{1,2}\/\d{1,2}\/\d{4}$/ //Basic check for format validity
var returnval = false
if (!validformat.test(input.value))
alert('Invalid Date Format. Please correct.')
else { //Detailed check for valid date ranges
var dayfield = input.value.split("/")[0]
var monthfield = input.value.split("/")[1]
var yearfield = input.value.split("/")[2]
var dayobj = new Date(yearfield, monthfield - 1, dayfield)
if ((dayobj.getMonth() + 1 != monthfield) || (dayobj.getDate() != dayfield) || (dayobj.getFullYear() != yearfield))
alert('Invalid Day, Month, or Year range detected. Please correct.')
else {
returnval = true
}
}
if (returnval == false) input.focus()
return returnval
}
</code></pre>
| javascript | [3] |
1,931,630 | 1,931,631 | is java an open source programming language? | <p>i know about python, ruby, perl etc.. but is java a really open source programming language?
because i searched on google too but didnt get proper answer. so asking here</p>
| java | [1] |
3,340,009 | 3,340,010 | transpose number to USD | <p>I have</p>
<pre><code>onclick="document.getElementById('field1').value =
(Math.round((parseFloat(document.getElementById('field2').value,2)*100))/100 +
Math.round((parseFloat(document.getElementById('field3').value,2)*100))/100).toFixed(2);"
</code></pre>
<p>Field 2 and 3 are text input (numeric values). How can I transpose the value of field 1 to a currency value. Example</p>
<pre><code>onclick="document.getElementById('field1').value = parseInt(document.getElementById('200.75').value) * parseInt(document.getElementById('11').value);"
</code></pre>
<p>and have field1 return $2,208.25 </p>
| javascript | [3] |
4,708,159 | 4,708,160 | python line separated values in a text when converted to list, adds "\n" to the elements in the list | <p>I was astonished that a thing this simple has been troubling me. Below is the code</p>
<pre><code>list = []
f = open("log.txt", "rb") # log.txt file has line separated values,
for i in f.readlines():
for value in i.split(" "):
list.append(value)
print list
</code></pre>
<p>The output is </p>
<pre><code>['xx00', '\n', 'xx01in', '\n', 'xx01na', '\n', 'xx01oz', '\n', 'xx01uk', '\n']
</code></pre>
<p>How can I get rid of the new line i.e. '\n'?</p>
| python | [7] |
1,913,971 | 1,913,972 | How best to convert a byte[] array to a string buffer | <p>I have a number of byte[] array variables I need to convert to string buffers.</p>
<p>is there a method for this type of conversion ? </p>
<p>Thanks </p>
<p>Thank you all for your responses..However I didn't make myself clear....
I'm using some byte[] arrays pre-defined as public static "under" the class declaration
for my java program. these "fields" are reused during the "life" of the process.
As the program issues status messages, (written to a file) I've defined a string buffer
(mesg_data) that used to format a status message.
So as the program executes
I tried msg2 = String(byte_array2)
I get a compiler error:
cannot find symbol
symbol : method String(byte[])
location: class APPC_LU62.java.LU62XnsCvr
convrsID = String(conversation_ID) ;</p>
<p>example: </p>
<pre><code>public class LU62XnsCvr extends Object
.
.
static String convrsID ;
static byte[] conversation_ID = new byte[8] ;
</code></pre>
<p>So I can't use a "dynamic" define of a string variable because the same variable is used
in multiple occurances. </p>
<p>I hope I made myself clear
Thanks ever so much </p>
<p>Guy </p>
| java | [1] |
5,467,289 | 5,467,290 | Error using double quotes in a string in javascript | <p>I need to put this string in a variable:</p>
<pre><code>chart cid="20"
</code></pre>
<p>but when I escape: <code>\"</code> this way:</p>
<pre><code>AddSettings = AddSettings + "chart cid=\"0\"";
</code></pre>
<p>I still get a javascript error and the sentence shows up in the browser insted of get into the <code>AddSetting</code> variable.</p>
<p>I also tried this way:</p>
<pre><code>AddSettings = AddSettings + 'chart cid="0"';
</code></pre>
<p>And the same thing happens.</p>
| javascript | [3] |
1,169,299 | 1,169,300 | How to find status bar of a browser is appearing or not through jquery | <p>I am trying to create a small site. For that i designed some layout. Every thing is fine except the height. I am giving the main div height as the height of the document with <code>$(document).height()</code>. Because of the status bar, i have to reduce the 2pixels from the resultant height. In IE9 looking good. But when I open same in the Firefox there is some gap at the bottom. Browsers are looking like this.</p>
<p><img src="http://i.stack.imgur.com/ZTQ0W.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/8Xaho.png" alt="enter image description here"></p>
<p>Now I want to adjust the height based on the visibility of the status bar which is presented at the bottom of the IE browser. How to find it is visible or not through jquery</p>
| jquery | [5] |
1,483,119 | 1,483,120 | How to Pre validate Image size in fileupload | <p>I have a fileupload control. I want, when a user browse a image through this control of size more than 50 kb , an error message should display. How to do this?
I have one customvalidator as below...</p>
<pre><code><asp:FileUpload ID="Fileupload1" runat="server"/>
<asp:CustomValidator ID="CustomValidator1"
runat="server"
ErrorMessage="not valid size"
Display="Dynamic"
ValidationGroup="I"
ControlToValidate="Fileupload1"
OnServerValidate="CustomValidator1_ServerValidate"
CssClass="validationCss">
</asp:CustomValidator>
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (Fileupload1.HasFile)
{
if (Fileupload1.PostedFile.ContentLength &amp;gt;= 20960)
{
args.IsValid = false;
// this.ModalPopupExtender1.Show();
}
else
{
args.IsValid = true;
}
}
}
</code></pre>
<p>My validation is working, but when i click on the done button.
I want error message before I click the button.</p>
<pre><code> <script type="text/javascript">
function OnBrowse()
{
if(Page_ClientValidate("I"))
{
///Your login here......
alert("something....");
return false;
}
return true;
}
</script>
</code></pre>
| asp.net | [9] |
1,728,195 | 1,728,196 | providing animation to an image in android | <p>I am working on an android application which involves saving images in database.Now i am struck in a problem.I have to animate the image on android emulator.Can anyone help me ..</p>
<p>Thanks in advance
Tushar Sahni</p>
| android | [4] |
5,720,324 | 5,720,325 | Clipboard Task error | <p>Here is the error I am getting:</p>
<blockquote>
<p>An exception of type 'System.Threading.ThreadStateException' occurred
in System.Windows.Forms.dll but was not handled in user code</p>
<p>Additional information: Current thread must be set to single thread
apartment (STA) mode before OLE calls can be made. Ensure that your
Main function has STAThreadAttribute marked on it.</p>
</blockquote>
<p>I am trying to assign a value to the clipboard within a <code>Task</code>. When I execute the code I get the error above.</p>
<p>Here is the clipboard code:</p>
<pre><code>static public class ClipBoard
{
static private string _data = string.Empty;
static public Semaphore ClipBoardSemaphore = new Semaphore(1, 1);
static public void SetData(string data)
{
Clipboard.Clear(); //error here
Clipboard.SetDataObject(data, true);
_data = data;
}
static public string GetData()
{
return _data;
}
}
</code></pre>
<p>As you can see the error happens when the clipboard is cleared.
Here is the code that invokes the Task:</p>
<pre><code>for (int i = 0; i < zom.Count; i++)
{
Task t = Task.Factory.StartNew(zom[i].Process);
t.Wait();
}
</code></pre>
| c# | [0] |
2,737,108 | 2,737,109 | Multiple constructors with one parameter | <p>So, at school we got an assignment to make a car in OOP, until now its been pretty easy and straight forward. But now I need to create four constructors, one with no parameters, two with one parameter and one with two parameters.</p>
<p>As far as I know the way overloading works is that it checks the amount of parameters you supply it with and then checks which constuctor it has to use. As two of the constructors are the same, both accepts ints, only one needs to change the amount or gears, and the other needs to change the maximum speed.</p>
<p>Is there a way to do this without passing an extra parameter?</p>
| c# | [0] |
3,498,618 | 3,498,619 | Don't convert newline when reading a file | <p>I'm reading a text file:</p>
<pre><code>f = open('data.txt')
data = f.read()
</code></pre>
<p>However newline in <code>data</code> variable is normalized to LF ('\n') while the file contains CRLF ('\r\n').</p>
<p>How can I instruct Python to read the file as is?</p>
| python | [7] |
2,717,583 | 2,717,584 | Seeking open source or LGPL repalcement for var_dump() | <p>Before I code my own ... I have tried all the code in the PHP manual and not of it is very good. I have Gogoled for hours, but tend to find only GPL code, which can't be included in a commercial product (I'm just a guy trying to make a few bucks on the side, not working for a mega-corporation which could develop or buy code).</p>
<p>Things like <a href="http://krumo.kaloyan.info/" rel="nofollow">Krumo</a> look very good, but are actually too sophisticated for me. For instance, I don't want to click to expand, since I want to use the code in my error page and have the user copy/paste it into an email or print it out & fax it.</p>
<p>What I want is table dump, recursed, preferably with variable type as well as value and a count of array members (maybe string lengths too). Something static, simple and straightforward, which will mostly be used to dump $_SESSION on the error page (oh, and a nicely formatted stack trace would be nice too ;-)</p>
<hr>
<p>Update: Please, standalone code only; nothing that is part of a framework. Thanks.</p>
| php | [2] |
5,616,687 | 5,616,688 | how to bring up an alarm sound chooser | <p>I have found out how to bring up a ringtone chooser with...</p>
<pre><code>Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
startActivityForResult( intent, 999);
</code></pre>
<p>...but can not find the equivalent for choosing the <strong>alarm</strong> sound. Is it a similar method?</p>
| android | [4] |
3,039,787 | 3,039,788 | Set select list to current date and next day with leading zeros | <p>I've got a problem passing off date information to another site because they still require two digit dates even for the first nine days of the month. I've gotten 90% of the way using the code from the SO page for <a href="http://stackoverflow.com/questions/8164508/set-select-list-to-current-date-using-jquery">set select list to current date using Jquery</a>. That moves the months and days from 1-31 and 1-12. I need the output to be from 01-31 and 01-12.</p>
<p>The current situation:</p>
<pre><code>function ragequit() {
var today = new Date();
var daym = today.getDate();
var monthm = today.getMonth();
$('#StartMonth option[value=' + (monthm) + ']').prop('selected',true);
$('#StartDay option[value=' + (daym) + ']').prop('selected',true);
$('#EndMonth option[value=' + (monthm+1) + ']').prop('selected',true);
$('#EndDay option[value=' + (daym+1) + ']').prop('selected',true);
}
</code></pre>
<p>It is calling the month perfectly because this is December. Also had to add <code>m</code> to each of the values so that it doesn't compete with another tool that increments the date when the start date is changed.</p>
<p>Simply put, I have <code>12 7 2011</code> - I need <code>12 07 2011</code>.</p>
| jquery | [5] |
6,011,930 | 6,011,931 | Javascript alert message contains URL | <p>I am using the following javascript function:</p>
<pre><code><!-- Notifying message at the beginning of openning the website -->
<script language="javascript" type="text/javascript">
alert('Sorry!');
</script>
<!--End -->
</code></pre>
<p>I want to add the URL after "(Sorry!)" in the alert message but I don't know how to append the URL to the message itself inside the javascript.</p>
| javascript | [3] |
1,053,386 | 1,053,387 | iPhone: How do I create a simple Done button? | <p>Newbie alert! I have a simple calculator with 4 text input fields. When I tap into a field the number pad appears and I enter numbers. No problems so far. Now, when testing this using the simulator I press return on the keyboard and using TextFieldShouldReturn my fields perform their calculations perfectly and the number keypad disappears nicely. The problem is, the number keypad does not have a 'Done' key so if I place a button let's say on the toolbar how do I code it to perform the action of the Return key?</p>
| iphone | [8] |
2,928,380 | 2,928,381 | PHP Rename problem! | <p>I have a problem using php rename function. If I use the following syntax it works fine.</p>
<pre><code><?php
rename("pages/file.php", "pages/xfile.php");
?>
</code></pre>
<p>but instead if I use this:</p>
<pre><code><?php
$val = '"pages/file.php"';
$rval = '"pages/xfile.php"';
rename($val, $rval);
?>
</code></pre>
<p>It does not work and gives an error:</p>
<pre><code>Warning: rename("pages/file.php","pages/xfile.php") [function.rename]: The system cannot find the path specified. (code: 123) in C:\wamp\www\page_rename.php on line 2
</code></pre>
| php | [2] |
3,316,579 | 3,316,580 | Accessors: setter does not work | <p>I am playing with Javascript accessor properties (I am restarting from zero to study javascript), trying to create getter and setter for a simple object, here the code:</p>
<pre><code>var dummy = {
name: 'empty',
description: 'static description',
get nameAccessor(){return 'name value is: ' + this.name;},
set nameAccessor(value){ this.name = value;},
get descAccessor(){return 'desccription value is: ' + this.description;},
};
console.log(dummy.nameAccessor);
console.log(dummy.nameAccessor('Mazinga'));
console.log(dummy.nameAccessor);
</code></pre>
<p>But it throws an error: </p>
<blockquote>
<p>Uncaught TypeError: Property 'nameAccessor' of object # is not
a function</p>
</blockquote>
<p>when it executes the setter code:</p>
<pre><code> console.log(dummy.nameAccessor('Mazinga'));
</code></pre>
<p>What's going wrong here?</p>
<p><strong>EDIT</strong>:</p>
<p>Ok, it seems to be not a well-known feature of javascript, butI followed this example from
<a href="http://rads.stackoverflow.com/amzn/click/0596805527" rel="nofollow">Javascript: Definitive Guide</a></p>
<pre><code>var o = {
data_prop: value,
get accessor_prop() { /* function body here */ },
set accessor_prop(value) { /* function body here */ }
};
</code></pre>
| javascript | [3] |
4,372,213 | 4,372,214 | How to dismiss progressdialog if mp3 is already playing in android | <p>My question is how do you dismiss the ProgressDialog if mp3 is already playing?</p>
<p>Please check what I have tried so far:</p>
<pre><code>mediaPlayer.setDataSource(timelessFuture);
mediaPlayer.prepare();
// gets the song length in milliseconds from URL
mediaFileLengthInMilliseconds = mediaPlayer.getDuration();
progressDialog = ProgressDialog.show(this, "Downloading", "Please wait while podcast is being downloaded...");
if(!mediaPlayer.isPlaying()){
mediaPlayer.start();
play.setCompoundDrawablesWithIntrinsicBounds(R.drawable.button_pause, 0, 0, 0);
} else {
mediaPlayer.pause();
play.setCompoundDrawablesWithIntrinsicBounds(R.drawable.button_play, 0, 0, 0);
}
primarySeekBarProgressUpdater();
</code></pre>
<p>What am I missing in here?</p>
| android | [4] |
4,226,764 | 4,226,765 | How can I clean stuff up on program exit? | <p>I have a command line program that wants to pickle things when I send it a ctrl-C via the terminal. I have a some questions and concerns: </p>
<ol>
<li><p>How do I perform this handling? Do I check for a KeyboardInterrupt? Is there a way to implement an exit function? </p></li>
<li><p>What if the program is halted in the middle of a write to a structure that I'm writing to? I presume these writes aren't treated atomically, so then how can I keep from writing trash into the pickle file? </p></li>
</ol>
| python | [7] |
1,207,925 | 1,207,926 | Unable to filter a listview with 2 lines | <p>I am trying to provide a searchable listview. Each listitem has a name & address text box but I only want to filter on the name. My current code does nothing, i.e no filtering occurs at all. Is there a way of setting the column to filter by?</p>
<pre><code> //class variables
private SimpleCursorAdapter mAdapter;
private EditText filterText = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.add_customer_listview);
//listViewCustomers = (ListView) findViewById(R.id.list);
buildingListViewAdaptor();
setListAdapter(mAdapter);
// set up the filter
filterText = (EditText) findViewById(R.id.search_box);
filterText.addTextChangedListener(filterTextWatcher);
}
private TextWatcher filterTextWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
mAdapter.getFilter().filter(s);
Log.d(GlobalTools.ErrorCodes.INFO, "Searchtext=" + s.toString());
}
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
};
private void buildingListViewAdaptor(){
//1. Get the data
CustomerLocationDataHandler clDataHandler = new CustomerLocationDataHandler(getContentResolver());
Cursor cursor = clDataHandler.allCustomerLocations();
clDataHandler=null;
//2. Build the adaptor
mAdapter = new SimpleCursorAdapter(this,
R.layout.list_item_custom_font, // was list_item_custom_font
cursor,
new String[]{MyobiliseData.Columns_CustomerLocations.CUSTOMER_NAME,MyobiliseData.Columns_CustomerLocations.CITY},
new int[] {R.id.text1,R.id.text2}
);
}
</code></pre>
| android | [4] |
102,346 | 102,347 | C# method lines program | <p>I need method of lines, so that when you have method call <code>Rows (4)</code>, a method prints four blank lines.</p>
<p>This is my code but it wont work, tell me what is wrong?</p>
<pre><code>namespace something
{
class Program
{
static void Main(string[] args)
{
Console.Write("give number: ");
int lines = int.Parse(Console.ReadLine());
line(lines);
Console.WriteLine("lines end");
Console.ReadKey();
}
private static void line(int lines)
{
for (int i = 1; i <= lines; i++);
Console.WriteLine(" ");
}
}
}
</code></pre>
| c# | [0] |
2,509,244 | 2,509,245 | Java read utf-8 encoded file, character by character | <p>I have a file saved as utf-8 (saved by my application in fact). How do you read it character by character?</p>
<pre><code>File file = new File(folder+name);
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
</code></pre>
<p>The two options seem to be:</p>
<pre><code>char c = dis.readByte()
char c = dis.readChar()
</code></pre>
<ul>
<li>The first option works as long as you only have ascii characters stored, ie english.</li>
<li>The second option reads the first and second byte of the file as one character.</li>
</ul>
<p>The original file is being written as follows:</p>
<pre><code>File file = File.createTempFile("file", "txt");
FileWriter fstream = new FileWriter(file);
BufferedWriter out = new BufferedWriter(fstream);
</code></pre>
| java | [1] |
2,479,961 | 2,479,962 | Implementing non member functions | <p>I am working on an assignment and have hit a wall on a particular area. I can't figure out how I am supposed to implement the non member functions from the header into the .cpp file. Here is the header:</p>
<pre><code>class complx
{
double real, imag;
public:
complx( double real = 0., double imag = 0.); // constructor
complx operator+(complx); // operator+()
complx operator+(double); // operator+()with double
complx operator- (complx); // operator-()
complx operator* (complx); // operator*()
bool operator== (complx); // operator==()
//Sets private data members.
void Set(double new_real, double new_imaginary) {
real = new_real;
imag = new_imaginary;
}
//Returns the real part of the complex number.
double Real() {
return real;
}
//Returns the imaginary part of the complex number.
double Imaginary() {
return imag;
}
};
ostream &operator << ( ostream &out_file, complx number );
extern istream &operator >> ( istream &in_file, complx &number );
extern ifstream &operator >> ( ifstream &in_file, complx &number );
complx &operator + (double, complx);
complx &operator - (double, complx);
complx &operator * (double, complx);
}
</code></pre>
<p>I have most of the member functions figured out, but it's the three at the bottom of the header that are giving me fits. Any help would be greatly appreciated. Thanks!</p>
<p>p.s. sorry for the formatting, it's not copying over very well.</p>
| c++ | [6] |
3,060,959 | 3,060,960 | place text over capture image in Android? | <p>I am working on an fun application in android. In which I need to capture an image and just after that before saving I need to add some text over the captured image.
Is it possible to edit captured image at run time in android please suggest me.
Thaanxx in advance..!</p>
| android | [4] |
1,965,953 | 1,965,954 | line of error appears when passing a message in php | <p>i been working in the login code .. it works fine except this message that appears when openenig the login page !!</p>
<pre><code>Notice: Undefined index: msg in C:\xampp\htdocs\thesite\login.php on line 103
</code></pre>
<p>it has appeard when i typed this in loginExcution.php</p>
<pre><code> else {
//Login failed
header("location:login.php? msg=*invalid name or password");
exit();
}
</code></pre>
<p>and this to show the message in the login form page </p>
<pre><code><?php
$msg = $_GET['msg'];
print $msg;
?>
</code></pre>
| php | [2] |
3,549,210 | 3,549,211 | Background distorted | <p>I'm using android:background="@drawable/home_background"
but on switching the screen to landscape , the image gets distorted and stretched too much . The picture is a .jpg</p>
| android | [4] |
898,784 | 898,785 | auto implement in c# | <p>i need info about what auto implement in c# is?and how can i use it?thanks</p>
| c# | [0] |
1,812,965 | 1,812,966 | Trigger hover effect over another element when hovering an element | <p>I am having issues with this: I want to force a hover function over the image when infact hovering over the h3 element</p>
<p>html:</p>
<pre><code><p><a><img class="size-full wp-image-1236 alignleft" alt="phone-icon-red" src="..." width="50" height="50" /></a></p>
<h3>Contact Us</h3>
</code></pre>
<p>CSS:</p>
<pre><code>img:hover{
margin-left: 10px;
}
</code></pre>
<p>js:</p>
<pre><code>$('h3').hover(function(e){
e.preventDefault();
$(this).prev('p').find('img').trigger('mouseover');
});
</code></pre>
<p>See my <strong><a href="http://jsfiddle.net/7L4WZ/166/" rel="nofollow">fiddle</a></strong></p>
| jquery | [5] |
517,340 | 517,341 | Joining elements of a list | <p>I have a list of tuples like:</p>
<pre><code>data = [('a1', 'a2'), ('b1', 'b2')]
</code></pre>
<p>And I want to generate a string like this: <code>"('a1', 'a2'), ('b1'. 'b2')"</code></p>
<p>If i do something like: <code>','.join(data)</code>, I get an error: </p>
<pre><code>TypeError: sequence item 0: expected string, tuple found
</code></pre>
<p>If I want to do something in a single line without doing something like:</p>
<pre><code>for elem in data:
str += ',%s' % str(elem)
</code></pre>
<p>then is there a way?</p>
| python | [7] |
272,361 | 272,362 | C++ compiler structures such as Virtual method Table etc | <p>I am aware of the C++ Virtual Table which allows dynamic dispatch for doing things at runtime (although if I am honest I am not completely sure of the full list of things it achieves).</p>
<p>I am wondering what other "low level" aspects of C++ are there, which one doesnt usually come across when learning the C++ language?</p>
<p>Things like:</p>
<p>-How is multithreading and locking on objects performed?</p>
<p>-Overloading/overwriting functions</p>
<p>-Generics</p>
<p>Are there other "structures", similar to the vtable, which assist with these types of things on a lower level?</p>
<p>(and if anyone can help with what the VTable actually does it would be most appreciated!)</p>
| c++ | [6] |
3,249,695 | 3,249,696 | C++ - Namespace vs. Static Functions | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1434937/namespace-functions-versus-static-methods-on-a-class">Namespace + functions versus static methods on a class</a> </p>
</blockquote>
<p>I want to group similar functions togther. I can do it one of two ways. To me they are just syntactical differences...in the end it does not matter. Is this view accurate?</p>
<p>Namespace:</p>
<pre><code>namespace util
{
void print_array(int array[])
{
int count = sizeof( array ) / sizeof( array[0] );
for (int i = 0; i <= count; i++) cout << array[i];
}
}
</code></pre>
<p>Class: </p>
<pre><code>class Util
{
public:
static void print_array(int array[])
{
int count = sizeof(array);
for (int i = 0; i <= count; i++) cout << array[i];
}
};
</code></pre>
<p>Call with </p>
<pre><code>Util::print_array() // Class
</code></pre>
<p>or </p>
<pre><code>util::print_array() // Namespace
</code></pre>
| c++ | [6] |
2,492,786 | 2,492,787 | How does variable assignment work in JavaScript? | <p>So I was playing around the other day just to see exactly how mass assignment works in JavaScript.</p>
<p>First I tried this example in the console:</p>
<pre><code>a = b = {};
a.foo = 'bar';
alert(b.foo);
</code></pre>
<p>The result was "bar" being displayed in an alert. That is fair enough, <code>a</code> and <code>b</code> are really just aliases to the same object. Then I thought, how could I make this example simpler.</p>
<pre><code>a = b = 'foo';
a = 'bar';
alert(b);
</code></pre>
<p>That is pretty much the same thing, isn't it? Well this time, it returns <code>foo</code> not <code>bar</code> as I would expect from the behaviour of the first example.</p>
<p>Why does this happen?</p>
<p><strong>N.B.</strong> This example could be simplified even more with the following code:</p>
<pre><code>a = {};
b = a;
a.foo = 'bar';
alert(b.foo);
a = 'foo';
b = a;
a = 'bar';
alert(b);
</code></pre>
<p>(I suspect that JavaScript treats primitives such as strings and integers differently to hashes. Hashes return a pointer while "core" primitives return a copy of themselves)</p>
| javascript | [3] |
5,420,441 | 5,420,442 | how to dynamically generate page numbers and only load the corresponding page in the grid? | <p>I need to load data in the gridview dynamically. That is when the user clicks the page number 2 then those records only has to be displayed.. I made a stored proc to return only those records whose page number is sent.. It will also return me the number of records too.. Now i want to create a placeholder which will create the page number buttons dynamically based on the number of records. Could anyone help me with the placeholder code.. ??</p>
| asp.net | [9] |
2,275,550 | 2,275,551 | Multibyte Character - Patter matching | <p>I am reading Shift-JIS encoded XML file and store it in ByteBuffer, then convert it into a string and try to find start of a string and end of of a string by Pattern & Matcher. From these 2 positions I try to write buffer to a file. It works when there is no multibyte chars. If there is a multibyte char, I miss some text at the end, since value of end is little off </p>
<pre><code>static final Pattern startPattern = Pattern.compile("<\\?xml ");
static final Pattern endPattern = Pattern.compile("</doc>\n");
public static void main(String[] args) throws Exception {
File f = new File("20121114000606JA.xml");
FileInputStream fis = new FileInputStream(f);
FileChannel fci = fis.getChannel();
ByteBuffer data_buffer = ByteBuffer.allocate(65536);
while (true) {
int read = fci.read(data_buffer);
if (read == -1)
break;
}
ByteBuffer cbytes = data_buffer.duplicate();
cbytes.flip();
Charset data_charset = Charset.forName("UTF-8");
String request = data_charset.decode(cbytes).toString();
Matcher start = startPattern.matcher(request);
if (start.find()) {
Matcher end = endPattern.matcher(request);
if (end.find()) {
int i0 = start.start();
int i1 = end.end();
String str = request.substring(i0, i1);
String filename = "test.xml";
FileChannel fc = new FileOutputStream(new File(filename), false).getChannel();
data_buffer.position(i0);
data_buffer.limit(i1 - i0);
long offset = fc.position();
long sz = fc.write(data_buffer);
fc.close();
}
}
System.out.println("OK");
}
</code></pre>
| java | [1] |
3,004,301 | 3,004,302 | Burger game - function not running | <p>I am trying to create a game in Python called the 'Burger Game' and I really need some help with this. </p>
<p>So basically, the problem is when I run my program, my <code>def displayIntro():</code> should print but it doesn't run, and when I click enter it printS 'Incorrect Command Try Again' and then it prints <code>def DisplayIntro()</code>.</p>
<p>Here's what my code looks like:</p>
<pre><code>def displayIntro():
print('Hello There What Would You Like Type Menu For The Food Menu')
print()
user_choice = input()
menu = ['Chips']
if user_choice == 'menu':
menu.append('burger')
else:
print("Incorrect Command Try Again")
displayIntro()
</code></pre>
| python | [7] |
1,188,287 | 1,188,288 | C# is there a problem with division? | <p>This is a piece of my code, it is called every second, after about 10 seconds the values start to become weird (see below):</p>
<pre><code>double a;
double b;
for (int i = 0; i < currAC.Length; i++ )
{
a = currAC[i];
b = aveACValues[i];
divisor = (a/b);
Console.WriteLine("a = " + a.ToString("N2") + "\t" + "b = " + b.ToString("N2"));
Console.WriteLine("divisor = " + divisor);
Console.WriteLine("a+b = " + (a+b));
}
</code></pre>
<p>and the output:</p>
<p>a = <strong>-0.05</strong> <strong>b = 0.00</strong></p>
<p>divisor = <strong>41</strong></p>
<p>a+b = <strong>-0.0524010372273268</strong></p>
<p>currAC and aveACValues are double[]</p>
<p>what on earth is going on???? The addition result is correct every time, but the division value is wrong, yet it is reading a and b correctly??</p>
<p><strong>EDIT: '41' is the value of the first calculation, ie when a = currAC[0], but this should not remain???</strong></p>
| c# | [0] |
235,276 | 235,277 | Redirecting in a PHP page to another PHP page | <p>I have a register.php, login.php, and main.php. How do i redirect user after after registration submit to login page and then login page submit to main page.</p>
| php | [2] |
967,305 | 967,306 | XML tags closing before value being inserted | <p>The following code:</p>
<pre><code>// Read Attendees Data (For Organisation)
$attendServ = new AttendeeService();
$attendData = $attendServ->getAllActiveAttendeeByOrg($organisation_id);
$attendee = new DOMDocument('1.0');
$attendee->formatOutput = true;
$root = $attendee->createElement('attendee');
$root = $attendee->appendChild($root);
for ($i=0;$i<count($attendData);$i++) {
$row = $attendee->createElement('row');
$row = $root->appendChild($row);
foreach ($attendData[$i] as $tag=>$value)
{
$nodename = $attendee->createElement($tag);
$nodename = $row->appendChild($nodename);
$nodevalue = $attendee->createTextNode($value);
$nodevalue = $row->appendChild($nodevalue);
}
}
// Test Organisation Output
header ("Content-Type:text/xml");
echo $attendee->saveXML();
</code></pre>
<p>Produces:</p>
<pre><code><?xml version="1.0"?>
<attendee>
<row>
<attendee_id/>1
<attendee_name/>A
<attendee_initials/>A.1.
</row>
</attendee>
</code></pre>
<p>Instead of:</p>
<pre><code><?xml version="1.0"?>
<attendee>
<row>
<attendee_id>1</attendee_id>
<attendee_name>A</attendee_name>
<attendee_initials>A.1.</attendee_initials>
</row>
</attendee>
</code></pre>
<p>Any clue where I am going wrong?</p>
| php | [2] |
4,042,871 | 4,042,872 | Web.config replacement, missing section | <p>I've spent a day on this 'simple' problem... </p>
<p>I'm using Web Deployment Projects to deploy my MVC3 webapp. I tell it to replace the appSettings section with one in a config file by entering</p>
<pre><code>appSettings=Config\AppSettings.Production.config;
</code></pre>
<p>That works perfectly. The resulting (deployed) Web.config file has been correctly transformed and now contains the production settings I told it to use.</p>
<p>But, trying to do the same thing with a custom section 'spring' using exactly the same method</p>
<pre><code>spring=Config\Spring.Production.config;
</code></pre>
<p>...I get...</p>
<p><em>web.config(1): error WDP00002: missing section spring</em></p>
<p>The spring section is at exactly the same level as the appSettings element, so I don't know why it doesn't work. </p>
<p>There are loads of other people with the same problem, but no satisfactory answers that I can find. </p>
| asp.net | [9] |
2,524,564 | 2,524,565 | Returning values through a Dialog | <p>I currently have a method which should return the result of a dialog. The code I am using is</p>
<pre><code> private int ShowDialog(String FileName)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
// set title
alertDialogBuilder.setTitle("Play File");
// set dialog message
alertDialogBuilder
.setMessage("Would you like .... file")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id)
{
dialog.cancel();
return 1;
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
return 0;
}
});
AlertDialog alert11 = alertDialogBuilder.create();
alert11.show();
}
</code></pre>
<p>But it seems like the onClick method should be a void. Is there anyway by which I can make this method return a value and in return cause the ShowDialog method to return that value.?</p>
| android | [4] |
2,858,809 | 2,858,810 | Prevent empty string on query if viewing root | <p>I use the following for getting the current URL in PHP:</p>
<pre><code>$pageURL = $_SERVER["REQUEST_URI"];
return $pageURL;
</code></pre>
<p>This is used in my links to create e.g <code>/login?continue=/page/i/want</code></p>
<p>However when I'm viewing the home page I will get <code>/login?continue=</code> how do I force it to become <code>/login?continue=/</code> when viewing the home page??</p>
<p>I tried this:</p>
<pre><code>if($pageURL == '')
$pageURL = '/';
</code></pre>
<p>but that didn't force the query string :/</p>
<p>Any ideas? Thanks</p>
| php | [2] |
4,809,175 | 4,809,176 | Using reCaptcha in a Wordpress Page | <p>All,
I've got a Page in Wordpress that I'm creating to allow some people to submit some feedback on to me. On my page I've got the following code to include the reCaptcha:</p>
<pre><code><?php
require_once('http://localhost/website/recaptchalib.php');
$publickey = "12345"; // you got this from the signup page
?>
</code></pre>
<p>Then where I want the reCaptcha displayed I've got the following bit of code:</p>
<pre><code> <?php echo recaptcha_get_html($publickey); ?><div id="captchaStatus"></div>
</code></pre>
<p>However, when I try and display this page I get the following error message from Wordpress:</p>
<pre>Fatal error: Call to undefined function recaptcha_get_html()</pre>
<p>Is there a better way to include the reCaptcha on a Wordpress page? I know there is a reCaptcha plugin but I believe that is only for pages with Comments on it which isn't my need here.</p>
<p>Do I need to not include it as a link and instead a path to the recaptcha page? If so, how can I do that from a page in Wordpress to my base folder?</p>
<p>Any advice is greatly appreciated.</p>
<p>Thanks</p>
| php | [2] |
5,694,322 | 5,694,323 | Change .htaccess form a Path with PHP | <p>i have a htaccess file:</p>
<pre><code>AuthName "LogIn Interner Berei"
AuthType Basic
AuthUserFile /home/www/web502/html/login/.htpasswd
require valid-user
</code></pre>
<p>and a Session Login System:</p>
<pre><code>if ( $Account->logged )
{
} else {
}
</code></pre>
<p>and how can i make that if logged in disable the htaccess file?</p>
| php | [2] |
3,280,061 | 3,280,062 | anyway to make menu items small...? | <p>i was wondering if there is anyway <code>to decrease the size of menu items displayed</code> from either xml or through coding...?</p>
<p>another question is that can i draw the tabwidget on the bottom of the screen. i mean i want them on the bottom can i do that...?</p>
<p>another question is that is there any <code>two column list view</code> in android. now i know that there is a <code>list view with two item</code> but they are following each other.one is below the other but is there any <code>listview</code> that has columns just like in a table...?</p>
| android | [4] |
5,279,356 | 5,279,357 | How to assign access privilege of file(Stored in file table ) to user(Stored in my user table) | <p>I am writing a repository program in java, I have a User table that contains the users of repository and a File Table that contains all the imported files in repository, in MYSQL database.How can I set access privileges of my files to users?In fact how can I determine which user have witch access privilege(read,write,read and write) to which file in repository?</p>
<p>Thanks </p>
| java | [1] |
650,443 | 650,444 | javascript don't display the image placeholder if the image is not found | <p>Is there a way to not display the image placeholder if the image was not found? I've got images loaded by automatic feed, and for some items images are there, but for some there are not. So, if the image is not there, I would like to display placeholder.</p>
<p>Thank you,</p>
<p>H</p>
| javascript | [3] |
3,735,923 | 3,735,924 | How to get apache version | <p>everyone i want to get apache version. Actualy i want to use setenv() function in php file . but i m not able to use that its throughing an error undefined call to a function setenv() . it might b because of my apache version.Please suggest</p>
<p>Thanks & Regards</p>
<p>Shri.</p>
| php | [2] |
4,187,966 | 4,187,967 | Media Player <object> - catch mouse events | <p>I'm trying to catch mouse events on my media player within javascript but no success. I also enabled 'SendMouseClickEvents' but still nothing. </p>
<pre><code><object click="das();" id="Player' + j +'" width="160" height="120" ';
s +=' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ';
s +=' type="application/x-oleobject"> ';
s +=' <param name="openState" value="wmposMediaOpen">';
s +=' <param name="URL" value="inserts/' + sFileName + '"/> ';
s +=' <param name="captioningID" value="videoCaptions"/> ';
s +=' <param name="AutoStart" value="1"/> ';
s +=' <param name="PlayCount" value="1"/> ';
s +=' <param name="Rate" value="1"/> ';
s +=' <param name="uiMode" value="none"/> ';
s +=' <param name="enableContextMenu" value="1"/> ';
s +=' <param name="stretchToFit" value="0"/> ';
s +=' <param name="mute" value="true"/> ';
s +=' <param name="SendMouseClickEvents" value="1"/> ';
s +=' <param name="SendMouseMoveEvents" value="1"/> ';
s +='</object>
</code></pre>
| javascript | [3] |
4,882,304 | 4,882,305 | Jquery code cleanup | <p>Is there a way to not have to write this 'twice'
See below where the function for #start_date and #end_date is exactly the same. </p>
<pre><code><script type="text/javascript">
jQuery(function($){
$("#start_date").datepicker({
showButtonPanel: true,
minDate: 1,
dateFormat: 'dd/mm/yy'
});
$("#end_date").datepicker({
showButtonPanel: true,
minDate: 1,
dateFormat: 'dd/mm/yy'
});
});
</script>
</code></pre>
| jquery | [5] |
4,598,745 | 4,598,746 | How To: View placeholder for embedded activities | <p>The Activity screen that I'm working on uses a relative layout to include several local controls along with an embedded activity in the middle. Ideally, I'd like to configure the relative layout and contained controls within a layout file rather than having to code it manually. The idea is then to get the placeholder view (via Id) and "fill" it with the content of the activity. </p>
<p>Is there a control or technique for this already? Any suggestions are welcome.</p>
<p>Thanks,</p>
<p>J</p>
| android | [4] |
1,329,082 | 1,329,083 | Dispatch events to child | <p>I have a ListView containing items with one button each and I want to handle user events in this order:</p>
<ol>
<li>TouchEvent on <em>ListView</em>.</li>
<li>TouchEvent on <em>ListItem</em>.</li>
<li>Click on Button inside <em>ListItem</em>.</li>
</ol>
<p>How can I do this?</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.