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,138,393 | 1,138,394 | Short circuit all() statement in Python | <p>Is there a way to short circuit an all() statement in Python?</p>
<p>So something like this:</p>
<pre><code>return all([x != 0, 10 / x == 2, True, False, 7])
</code></pre>
<p>won't return an error if x is 0?</p>
| python | [7] |
2,915,726 | 2,915,727 | JVM Eager loading options | <p>I was just wondering if there is is any option in SUN (Oracle) JVM to enable eager loading of classes. Like IBM JVM has option -Dibm.cl.eagerresolution </p>
<p>I want to use reflection in my code and was thinking that eager loading of the classes might reduce the lookup time while instantiating object using reflection.</p>
<p>Please suggest if eager loading will be benefit when using reflection.</p>
| java | [1] |
5,680,641 | 5,680,642 | Android custom Library | <p>I have created a custom library that contains a UI that is to display data being read in from an external device. I have successfully created and applied the library to the project I need it in. </p>
<p>My main issue is I cant seem to use it at all. Ive tried to create an instance of the class file and this is failure. I have functions inside that class file I would like to use, but am unable since a simple declaration of a new class throws an exception for me. </p>
<p>Basically I dont want you to fix my problem, I want to see how this is done correctly. Ive searched the Internet for days and can not even find examples on how to do this.</p>
<p>I thought it would work just like creating an instance of any other class, but it does not. Thank you. </p>
| android | [4] |
3,780,718 | 3,780,719 | Efficient EnumSet + List | <p>Someone knows a nice solution for <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/EnumSet.html" rel="nofollow">EnumSet</a> + List</p>
<p>I mean I need to store enum values and I also need to preserve the order , and to be able to access its index of the enum value in the collection in O(1) time.</p>
| java | [1] |
5,463,832 | 5,463,833 | Force an application to choose application | <p>I have developed 2 different applications and both have QR Code scanner. Now whenever I open any application and try to scan the code. It asks me to choose application to scan code. And displays both the applications. How can I force my application to not to ask and choose its own scanner?</p>
<p>Thanks in advance.</p>
| android | [4] |
1,712,820 | 1,712,821 | How to keep focus on the Window opend using "window.Open" after the Page Load of the Parent Page? | <p>I am working on an application. I have opened a Window using</p>
<pre><code> window.open()
</code></pre>
<p>Now after opening this window, the parent Page is getting Refreshed(Means Page Load is Happening). </p>
<p>Now , How can I set the Focus on the Child Window after the Page load of the Parent Page.
Please Help.</p>
| asp.net | [9] |
5,681,581 | 5,681,582 | Save to file not working for following PHP code | <p>i have the following code which stopped working recently. The problem is that no data is written to the text file "testFile.txt"</p>
<p>Hi, i have the following code which stopped working recently. The problem is that no data is written to the text file "testFile.txt"</p>
<pre><code><?php
$myFile = "testFile.txt";
$fh = fopen($myFile, 'a');
$IP = $_SERVER["REMOTE_ADDR"].',';
$logdetails= $IP.date("F j, Y, g:i a O T");
$stringTimeout = $_POST['_delay'];
$stringData1 = $_POST['userChoices'];
$s = ',';
$postData = $s.$stringTimeout.$s.$stringData1."\n";
fwrite($fh,$logdetails.$postData, 'a');
fclose($fh);
header("Location: http://www.google.com");
exit;
?>
</code></pre>
<p>Any ideas why this might be??</p>
<p>Thanks!</p>
| php | [2] |
5,528,997 | 5,528,998 | Setting owner of a file in java ( ver-7) in Windows XP SP2 | <p>Here's the code:</p>
<pre><code>import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.attribute.UserPrincipal;
import java.nio.file.FileSystems;
import java.lang.UnsupportedOperationException;
import java.io.IOException;
public class SetOwnerOfFile{
public static void main(String args[]){
Path path=Paths.get("c:\\demotext.txt");
try{
UserPrincipal owner=Files.getOwner(path);
System.out.format("The owner of file is: %s%n",owner.getName());
UserPrincipalLookupService lookupservice=FileSystems.getDefault().getUserPrincipalLookupService();
Files.setOwner(path,lookupservice.lookupPrincipalByName("joe"));
UserPrincipal newowner=Files.getOwner(path);
System.out.format("Now the owner of file is: %s%n",newowner.getName());
}
catch(UnsupportedOperationException x){
System.err.println(x);
}
catch(IOException x){
System.err.println(x);
}
}
}
</code></pre>
<p><strong>Output:</strong>
<br>The owner of file is: \Everyone
<br>java.nio.file.attribute.UserPrincipalNotFoundException
<br><br>The program is throwing IOException. Does it mean my OS restricts modification of the owner of a file? If not, please suggest me some solution.</p>
| java | [1] |
1,047,763 | 1,047,764 | class library and security in dotnet technology | <p>suppose i have developed class library and i want the i can use this library in my project only but if someone try to copy the dll file and want to use it in his project then he will not be able to do so. so i just want to know how could embed this type of security in the dll file...please tell me all ways. thanks</p>
| c# | [0] |
4,272,692 | 4,272,693 | Variable assignments inside for and then if loops | <p>For the following working code, I resorted to creating a class instance to store the name variable of my file output [a_string] and the file object itself [f_object]. I found that variables assigned inside the first if statement did not appear in the scope inside the following elif statement.</p>
<pre><code>#Text file splitter, data bewteen the '*' lines are copied into new files.
class Output_file():
def __init__(self,a_string='none',f_object='none'):
self.name=a_string
self.foutput=f_object
outputfile=Output_file()
n=0
filehandle=open('original file.txt')
for line in filehandle:
if line[0]=='*': #find the '*' that splits the rows of data
n+=1
outputfile.name = 'original file_'+str(n)+'.txt'
outputfile.foutput= open(outputfile.name,'w')
outputfile.foutput.write(line)
elif len(line.split()) ==5 and n > 0: #make sure the bulk data occurs in blocks of 5
outputfile.foutput= open(outputfile.name,'a+')
outputfile.foutput.write(line)
outputfile.foutput.close()
</code></pre>
<p>Do I have to use a class instance to store the file name and object or is there a better way? </p>
| python | [7] |
3,455,605 | 3,455,606 | Javascript 'new' Keyword | <p><code>'Javascript: The Good Parts'</code> provides this example regarding the "Constructor Invocation Pattern" (page 29-30).</p>
<pre><code>var Quo = function (string) {
this.status = string;
};
Quo.prototype.get_status = function() {
return this.status;
};
var myQuo = new Quo("confused");
document.writeln(myQuo.get_status()); // returns confused
</code></pre>
<p>The section ends with, <code>"Use of this style of constructor functions is not recommended. We will see better alternatives in the next chapter."</code></p>
<p>What's the point of the example and strong recommendation against using this pattern?</p>
<p>Thanks.</p>
| javascript | [3] |
3,287,117 | 3,287,118 | Android - Buttons supported in notification expanded view? | <p>I am trying to get buttons to work in notification expanded view. The goal is to use the buttons to launch activities from the notification view. Is this even supported? Here is a very simple outline with irrelevant details omitted:</p>
<ol>
<li>Create a RemoteView object using a layout with some ImageButtons.</li>
<li>Create pending intent for each button and set them using RemoteView.setOnClickPendingIntent(...)</li>
<li>Create a Notification object and set it's contentView as the RemoteView created in step 1.</li>
<li>Set Notification object's contentIntent.</li>
<li>Send the Notification.</li>
</ol>
<p>This works beautifully on my Droid X. I can click on each button and launch it's associated activity successfully.</p>
<p>This works on my pal's Evo 4G as well, except that it launches the button's intent plus the notification's content intent. So two intents launched. But I can deal with that. </p>
<p>This also works on HTC Incredible.</p>
<p>Unfortunately, it doesn't work on most other phones: Vibrant, Hero, Vision, WildFire, MIleStone, Droid 1. These are the ones I know so far based on user feedback. On these phones, only the notification contentIntent is being launched. It appears the button's click events aren't being captured/detected.</p>
<p>I am at my wit's end trying to work around this. I am beginning to think it's impossible, but it works on some phones! Any suggestion/help is appreciated.</p>
<p>Thanks!</p>
| android | [4] |
5,993,529 | 5,993,530 | Open-sided Android stroke? | <p>Is it possible to create an Android shape object with stroke on only certain sides?</p>
<p>Eg I have:</p>
<pre><code><stroke
android:width="3dip"
android:color="#000000"
android:dashWidth="10dip"
android:dashGap="6dip" />
</code></pre>
<p>Which is similar to this CSS:</p>
<pre><code>border: 3px dashed black;
</code></pre>
<p>How can I set the stroke on just one side? This is how I would do it in CSS:</p>
<pre><code>border-left: 3px dashed black;
</code></pre>
<p>How do you do this in Android XML?</p>
| android | [4] |
4,891,536 | 4,891,537 | display html content in div | <p>How to display html content </p>
<pre><code> <script type="text/javascript">
function replaceContent(show) {
var display = new Array();
display[1] = 1.html;
display[2] = 2.html;
document.getElementById("ShowItems").innerHTML = display[show];
}
</script>
<a href="#" onclick="replaceContent(1)">1</a>
<a href="#" onclick="replaceContent(2)">2</a>
<a href="#" onclick="replaceContent(3)">3</a>
<div id="ShowItems">...</div>
</code></pre>
<p>thankyou.</p>
| javascript | [3] |
598,494 | 598,495 | Android TabHost.setCurrentTab() not working | <p>I have a <code>TabActivity</code> that I am having problems after the device changes orientation. Followed some places on how to keep the current tab open after the change, but even tho I do get the correct tab number, it always sets it back to 0. </p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
int currentTab = 1;
if (savedInstanceState != null)
currentTab = savedInstanceState.getInt("tabNumber");
tabHost = getTabHost(); // (TabHost) findViewById(android.R.id.tabhost);
createTabs(tabHost);
tabHost.setCurrentTab(currentTab);
}
protected void onSaveInstanceState(Bundle outState) {
outState.putInt("tabNumber", getTabHost().getCurrentTab());
super.onSaveInstanceState(outState);
}
</code></pre>
<p>Am I doing something wrong here?</p>
| android | [4] |
4,412,228 | 4,412,229 | Publish slow and how does two updates work? | <p>If one publish two apk versions one after each other, incrementing the android:versionCode </p>
<ol>
<li><p>What happens if a user two days later makes an update, does he/she get both or only the latest
update?</p></li>
<li><p>If one get both updates, is there a way to say update only the last one?</p></li>
<li><p>Lately when publishing and app it takes so long before it's active as an update on Play,
it used to be very fast, now it varies a lot and sometime it takes a day or more.
Especially if you do a couple after another, any thoughts, your experience?</p></li>
</ol>
<p>Thanks!</p>
| android | [4] |
1,848,955 | 1,848,956 | Error in jquery lib jquery-1.3.2.min.js | <p>I am using jquery-1.3.2.min.js in my application. when opening my page i am getting error in IE . Error is in jquery-1.3.2.min.js file at line number 1067</p>
<p>return (text || "").replace( /^\s+|\s+$/g, "" );</p>
<p>at this line . Why this error is coming in IE.</p>
| jquery | [5] |
4,774,727 | 4,774,728 | How to effectively draw Polyline using Google API? | <p>i'm drawing polyline on MapView using "google direction API" and getting success in it.But the thing is that it draws straight line between two locations(with their longitude and latitude).I don't know how to draw line effectively like shown by google maps,when we click "get directions" between two locations. </p>
| iphone | [8] |
3,501,737 | 3,501,738 | Explicit constructor call in C++ | <p>1) what is the return value of following statement:</p>
<pre><code>obj.classX::classX();
</code></pre>
<p>2) Another question regarding constructors in C++:</p>
<pre><code> classX();
</code></pre>
<p>creates an object. What is the expanded code generated by the compiler?</p>
| c++ | [6] |
5,486,311 | 5,486,312 | Toggle replace text upon action(s) | <p>I have an element that when clicked it slides down to show the rest of the content, it says "<em>Show More Information</em>".</p>
<p>What I need is to change that text when clicked to expand to say "<em>Show Less Information</em>", but then change it back to "<em>Show More Information</em>" when collapsed.</p>
<p>Here's a fiddle that can be used as a starting point: <a href="http://jsfiddle.net/QWB4J/1/" rel="nofollow">http://jsfiddle.net/QWB4J/1/</a></p>
<p>I tried using <code>.replaceWith</code> but it only works when expanding and not collapsing.</p>
<p>Any help it's greatly appreciated.</p>
<p><strong>EDIT-</strong></p>
<p>Here's a fiddle with the solution: <a href="http://jsfiddle.net/QWB4J/24/" rel="nofollow">http://jsfiddle.net/QWB4J/24/</a></p>
<p>Solution provided by <strong>willw</strong>.</p>
| jquery | [5] |
2,778,428 | 2,778,429 | Install Android | <p>I download</p>
<blockquote>
<p>android-sdk_r06-windows_2</p>
<p>eclipse-java-helios-win32</p>
<p>ADT-0.9.7</p>
<p>jdk-6u21-windows-i586</p>
<p>apache-ant-1.8.1-bin</p>
</blockquote>
<p>and i follow google guide but i can't install android because
when i want to run android sdk below error occur</p>
<blockquote>
<p>Failed to fetch URL <a href="https://dl-ssl.google.com/android/repository/repository.xml" rel="nofollow">https://dl-ssl.google.com/android/repository/repository.xml</a>, reason: dl-ssl.google.com</p>
</blockquote>
<p>when i want to run eclipse below error occur</p>
<blockquote>
<p>JDK need </p>
</blockquote>
<p>but i installed jdk before</p>
<p>How can i install it ?
Do i need other files accept these files?</p>
| android | [4] |
678,661 | 678,662 | issue with fragment: disable pageviewer and load a specified fragment | <p>hi mate i have an activity with pageviewer. every page is a fragment and the user can swype to changepage.
In the action bar there are an action item called "C".
if user click on C, i want to disable pageviewer and load a fragment called "F-C". After clicked on C the user must see only the fragment "F-C" on the screen.
how can do this ?</p>
| android | [4] |
1,557,699 | 1,557,700 | write cell data to a html table using innerHTML | <p>having trouble putting together the final function displayLetter(a,b,c,d,e,f,g) and writing to table with innerHTML with array element and variables in variableTest() I know I need to use .length and to determine how many cells I need. W3C only gets me so far. Thanks for the help!</p>
<pre><code> <html>
<head>
<title>
</title>
<script>
</script>
</head>
<body>
<h1>TEST THIS SCRIPT</h1>
<table border="1">
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
<th>G</th>
</tr>
<a href="add data" id="reload">Add Employee</a>
</body>
<html>
</code></pre>
<p>MY JS:</p>
<pre><code> function addData()
{
var testarray = new Array();
testarray[0] = window.prompt("Enter a letter","z");
variableTest(x,y);
displaySalary(a,b,c,d,e,f,g);
}
function variableTest(x,y)
{
a=1;
b=2;
c=3;
d=4;
e=5;
}
displayLetter(a,b,c,d,e,f,g)
{
}
</code></pre>
| javascript | [3] |
4,015,867 | 4,015,868 | How to get android:layout_gravity="bottom" to work in LinearLayout | <p>I am trying to have 1 image on the top of my LinearLayout and 1 at the bottom on the LinearLayout.</p>
<p>But after all the things I tried, I can only get 1 image layout below another. I want 1 align to the top, 1 align to the bottom.</p>
<pre><code><LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/bg1"
android:layout_gravity="top" />
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:background="@drawable/bg2"
android:layout_gravity="bottom" />
</LinearLayout>
</code></pre>
<p>I have tried using RelativeLayout (in the main container) with layout_alignParentBottom (in my second image), but that does not solve my problem either. </p>
<p>Thank you for any idea.</p>
| android | [4] |
3,637,598 | 3,637,599 | php restructing an array | <p>Given my Array</p>
<pre><code>array [0]
fielda: cca
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [1]
fielda: cca
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [2]
fielda: cca
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [3]
fielda: ccb
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [4]
fielda: ccb
fieldb: my value b
fieldc: my value c
fieldd: my value d
</code></pre>
<p>Is there a simple way to restructure it so that fielda is grouped like so</p>
<pre><code>array [0]
fielda: cca
array [0]
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [1]
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [2]
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [3]
array [1]
fielda: ccb
array [0]
fieldb: my value b
fieldc: my value c
fieldd: my value d
array [1]
fieldb: my value b
fieldc: my value c
fieldd: my value d
</code></pre>
| php | [2] |
484,640 | 484,641 | WriteLine with a class | <p>I'm making a SchoolApp program to learn about C# and I have this main function that I'm trying to make work:</p>
<pre><code>namespace SchoolApp
{
class Program
{
public static void Main(string[] args)
{
School sch = new School("Local School");
sch.AddStudent(new Student { Name = "James", Age = 22 }); // this function
sch.AddStudent(new Student { Name = "Jane", Age = 23 });
Console.WriteLine(sch); // this implementation
}
}
}
</code></pre>
<p>School class:</p>
<pre><code>namespace SchoolApp
{
class School
{
public string name;
public School()
{
}
public School(string the_name)
{
name = the_name;
}
public void AddStudent(Student student)
{
}
}
}
</code></pre>
<p>Student class:
namespace SchoolApp</p>
<pre><code>{
class Student
{
public int Age;
public string Name;
public Student()
{
Age = 0;
Name = "NONAME";
}
public string _name
{
get
{
return this.Name;
}
set
{
Name = value;
}
}
public int _age
{
get
{
return this.Age;
}
set
{
Age = value;
}
}
}
}
</code></pre>
<p>I'm new to C# and I am pretty lost as to how I should make the AddStudent and how to work with the WriteLine to write the class. The output should be along these lines:</p>
<p>School: Local School
James, 22
Jane, 23</p>
<p>Someone suggested using List<> I hit the same problem of not knowing enough about it.</p>
<p>EDIT: Thank you all for your extremely fast answers. I got it working and will now commense reading the answers in depth so I don't have to ask related questions again!</p>
| c# | [0] |
4,977,807 | 4,977,808 | Strtotime not correct on when calculating relative time between user login time and now | <p>User login time is saved in Database(Mysql).I need the relative time betwwen login and now.</p>
<p>I used strtotime , but not getting correct .</p>
<p>First time when login gives strtotime as '1322787648' , then
calculate strtotime now '1322831782' , then again I login in
this time it get '1322788641' .</p>
<p>Here Second login strtotime value is lesser than strtotime('NOW') which IS calculated before second login.</p>
<p>I think calculating strtotime in afternoon get error but forenoon it works great.</p>
<pre><code> foreach ($chapterArray as $dat) {
//$dat['date_time'] coming date from Database
$time = strtotime($dat['date_time']);
$now = strtotime('now');
if (floor(($now - $time) / 86400) != 0) {
$time = floor(($now - $time) / 86400) . ' days ago';
}
elseif (floor(($now - $time) / 3600) != 0) {
$time = floor(($now - $time) / 3600) . ' hours ago';
}
elseif (floor(($now - $time) / 60) != 0) {
$time = floor(($now - $time) / 60) . ' minutes ago';
}
else {
$time = 'a few seconds ago';
}
}
</code></pre>
| php | [2] |
3,886,611 | 3,886,612 | How do I convert byte[] to Bitmap? | <p>Let's say I have a byte buffer and how do I get Bitmap ?
Thanks in advance.</p>
| java | [1] |
4,046,015 | 4,046,016 | Listview fill method gets an error | <p>What's wrong with my code? This code is from my VB .NET program which I converted to C# but gets an error.. It is used to to SELECT data from database with the use of LIKE for searching.. Here is my code:</p>
<pre><code>public void byItemCode(ListView LV, String SearchBox)
{
try
{
con.Open();
ds.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter("SELECT ItemCode, Title, Genre, Film, YearReleased, Classification, NumberOfDiscs FROM tblDVDInventory WHERE ItemCode LIKE '%" + SearchBox + "%' ORDER BY Title", con);
da.Fill(dt);
int num = 1;
for (int ctr = 0; ctr <= dt.Rows.Count - 1; ctr++)
{
ListViewItem Item = new ListViewItem();
Item.Text = num;
Item.SubItems.Add(dt.Rows[ctr]["ItemCode"]);
Item.SubItems.Add(dt.Rows[ctr]["Title"]);
Item.SubItems.Add(dt.Rows[ctr]["Genre"]);
Item.SubItems.Add(dt.Rows[ctr]["Film"]);
Item.SubItems.Add(dt.Rows[ctr]["YearReleased"]);
Item.SubItems.Add(dt.Rows[ctr]["Classification"]);
Item.SubItems.Add(dt.Rows[ctr]["NumberOfDiscs"]);
LV.Items.Add(Item);
num = num + 1;
}
con.Close();
}
catch (Exception error)
{
MessageBox.Show(error.ToString());
}
}
</code></pre>
<p>and then on the Search Form, here is the code:</p>
<pre><code>var Search = new SearchMethods();
if (cmbSearchBy.Text == "Item Code")
{
lvwInventory.Items.Clear();
Search.byItemCode(lvwInventory, txtSearch.Text);
}
</code></pre>
<p>I wonder how to do this the right way in C#? Thanks.</p>
| c# | [0] |
2,648,213 | 2,648,214 | convert all C# files to utf-8 encoding | <p>I need utf-8 encoding for my web page so i am thinking about converting all *.cs and *.aspx files to utf-8. Is that smart idea or is better to convert just *.aspx files.</p>
<p>Now i have problems with čžćšđ</p>
| c# | [0] |
1,140,598 | 1,140,599 | Find out what exception is being thrown in PHP | <p>I'm trying to learn PHP on the fly here, and something is broken, but I am unsure how to figure out what the problem is. An exception is being thrown, and I was able to isolate the line that is throwing the exception by printing debugging messages, but how do I figure out the nature of the error that is being thrown? All that happens is my php code stops executing.</p>
| php | [2] |
133,163 | 133,164 | how to use @ in python.. and the @property and the @classmethod | <p>this is my code:</p>
<pre><code>def a():
print 'sss'
@a()
def b():
print 'aaa'
b()
</code></pre>
<p>and the Traceback is:</p>
<pre><code>sss
Traceback (most recent call last):
File "D:\zjm_code\a.py", line 8, in <module>
@a()
TypeError: 'NoneType' object is not callable
</code></pre>
<p>so how to use the '@'</p>
<p>thanks</p>
<p><strong>updated</strong></p>
<pre><code>class a:
@property
def b(x):
print 'sss'
aa=a()
print aa.b
</code></pre>
<p>it print :</p>
<pre><code>sss
None
</code></pre>
<p>how to use @property</p>
<p>thanks</p>
<p><strong>updated2</strong></p>
<p>and the classmethod:</p>
<pre><code>class a:
@classmethod
def b(x):
print 'sss'
aa=a()
print aa.b
</code></pre>
<p>the it print :</p>
<pre><code><bound method classobj.b of <class __main__.a at 0x00B2DC00>>
</code></pre>
| python | [7] |
4,925,293 | 4,925,294 | Image changing every day of the year (365 days) | <p>I need a little help with my code there are 366 images to change called 001.jpg, 002.jpg ... 366.jpg. It gets the date and put the picture for it. The code works but I can't get it to output in my img tag.</p>
<pre><code><html>
<head>
<script type="text/javascript">
var firstJan = Math.floor((new Date().setFullYear(new Date().getFullYear(),0,1))/86400000);
var today = Math.ceil((new Date().getTime())/86400000);
var dayOfYear = today-firstJan;
var bgdImage;
if((dayOfYear+'').length == 1)
bgdImage = '00'+dayOfYear+'.jpg';
else if((dayOfYear+'').length == 2)
bgdImage = '0'+dayOfYear+'.jpg';
else
bgdImage = dayOfYear+'.jpg';
document.getElementById('bla').src = "bgdImage";
</script>
</head>
<body onload=img()>
<img id="bla" width="100%" height="100%" />
</body>
</html>
</code></pre>
| javascript | [3] |
5,035,936 | 5,035,937 | check if a number is - , + or x | <p>How can I check if a number has a <code>-</code>, <code>+</code>, <code>x</code> or nothing in front of it?</p>
<p>Options to check would be:</p>
<pre><code>20
+20
-20
x20
</code></pre>
<p>20 being any number.</p>
| javascript | [3] |
3,887,700 | 3,887,701 | Javascript object creation on the fly | <p>I'm sure I've seen some examples of this in jquery. But for me, the following code does not work. The firebug debugger tells me that: 'Location is undefined'. Could you tell me if this is possible?</p>
<pre><code>function ResolveGeoCode() {
var Location;
Location.Ad1 = "Hello ";
Location.Ad2 = "World";
return Location;
}
var loc = ResolveGeoCode();
var String1 = loc.Ad1; //This contains "Hello "?
var String2 = loc.Ad2; //This contains "World"?
</code></pre>
<p>Could a name be given to this type of feature I'm looking for?</p>
<p>Thanks.</p>
| javascript | [3] |
932,218 | 932,219 | jquery .load, simple question | <pre><code>function loadImage(currentImage)
{
$('#loader').show();
$('#photopreview').attr('src','img/' + currentImage).load(function() {
$('#loader').hide();
$('#photopreview').show();
});
}
</code></pre>
<hr>
<pre><code>google.maps.event.addListener(marker, "mouseover", function() {
loadImage(this.html);
});
google.maps.event.addListener(marker, "mouseout", function() {
$('#photopreview, #loader').hide();
});
</code></pre>
<p>When I hover my markers more than once, all i see is the loader, instead of loader -> image. Works well in Firefox, but not in IE and Chrome. Did i miss something? Thanks</p>
| jquery | [5] |
5,534,160 | 5,534,161 | Is there any specific use when a c/c++ sentence consists of only a variable name? | <p>I once saw a snip of code as below,</p>
<pre><code>/** Starts a synchronized block
*
* This macro starts a block synchronized on its argument x
* Note that the synchronized block defines a scope (i.e. { })
* All variables declared in it will live inside this block only
*/
#define SYNCHRONIZE_ON(x) { \
const abcd::LockBase & __lock = \
abcd::MakeLock(x); __lock;
/** Ends a synchronized block */
#define END_SYNCHRONIZE }
</code></pre>
<p>The <code>SYNCHRONIZE_ON</code> and <code>END_SYNCHRONIZE</code> are used together to synchronize on an object.
The macro <code>SYNCHRONIZE_ON</code> defines a variable <code>____lock</code> in it's block.</p>
<p>The question here is: <strong>what is the sentence <code>__lock;</code> (after the <code>abcd::MakeLock(x);</code>) for?</strong> Notice that this sentence consist of only the variable name.</p>
| c++ | [6] |
4,846,131 | 4,846,132 | php expire page after pre-determined hours elapsed | <p>I want to create a simple PHP application, through which students can submit their projects. I wish to set a timer (say in hours or even days), which when elapsed, the system automatically submits all the projects and disables the submit form.</p>
<p>Any idea of how I can set the timer and take action on page expire?</p>
| php | [2] |
1,567,364 | 1,567,365 | How do I tell Python to convert integers into words | <p>I'm trying to tell Python to convert integers into words.</p>
<p><strong>Example:</strong> (using the song 99 bottles of beer on the wall)</p>
<p>I used this code to write the program:</p>
<pre><code>for i in range(99,0,-1):
print i, "Bottles of beer on the wall,"
print i, "bottles of beer."
print "Take one down and pass it around,"
print i-1, "bottles of beer on the wall."
print
</code></pre>
<p>But I cannot figure out how to write the program so that the words (i.e. Ninety nine, Ninety eight, etc.) will be displayed instead of the numbers.</p>
<p>I have been wracking my head in the python book I have, I understand that maybe I just do not understand <code>for</code>/<code>if</code>/<code>elif</code>/<code>else</code> loops yet but I'm just spinning my wheels.</p>
<p>Could anyone provide any insight? I'm not looking for a direct answer, although that might help me see my problem, just anything to point me in the right direction would be great.</p>
| python | [7] |
3,428,873 | 3,428,874 | dynamic form javascript, php, mysql | <p>I already have javascript code to add multiple text fields:
What I want to know is how many fields were added and store them in mysql db </p>
<p>EX: 10 fields were added $_GET['1'], $_GET['2'] ............. $_GET['10']
how can I know that specific no of fields submitted to next page in php?</p>
<pre><code><html>
<head>
<script type="text/javascript">
var intTextBox=0;
//FUNCTION TO ADD TEXT BOX ELEMENT
function addElement()
{
intTextBox = intTextBox + 1;
var contentID = document.getElementById('content');
var newTBDiv = document.createElement('div');
newTBDiv.setAttribute('id','strText'+intTextBox);
newTBDiv.innerHTML = "Text "+intTextBox+": <input type='text' id='" + intTextBox + "' name='" + intTextBox + "'/>";
contentID.appendChild(newTBDiv);
}
//FUNCTION TO REMOVE TEXT BOX ELEMENT
function removeElement()
{
if(intTextBox != 0)
{
var contentID = document.getElementById('content');
contentID.removeChild(document.getElementById('strText'+intTextBox));
intTextBox = intTextBox-1;
}
}
</script>
</head>
<body>
<form action="testjs.php">
<div id="content"></div>
<p><input type="button" onclick="addElement()" value="ADD" > <input type="button" onclick="removeElement()" value="REMOVE" ></p>
<input type="submit" value="SUBMIT">
</form>
</body>
</html>
</code></pre>
| php | [2] |
2,332,268 | 2,332,269 | Web App vs Portal Platform - convincing the customer | <p>We're evaluating a set of requirements for a customer who wants Liferay which mainly has AAA and Web CMS requirements, and allowing user to upload their own content. Also all inetgration is via web services.</p>
<p>However there is no need for other features such as actual "portlets", i18n, mashups, skins, themes, tagging, social presence, no collaboration etc</p>
<p>So we feel we can do this as a standard JEE web app and not use Liferay (or any other portal product) since these are overheads we dont need.</p>
<p>The customer feels the <strong>Web CMS requirements + user upload justify the "portal" product.</strong></p>
<p>Can anyone help me with some points to convince the customer? Assuming our point of view is right.</p>
| java | [1] |
3,752,525 | 3,752,526 | jQuery: Scroll down page a set increment (in pixels) on click? | <p>I'm trying to make a page scroll down 150px from the current position when an element is clicked. So lets say you're roughly halfway scrolled down a page. You click this link, and it will slide you down an additional 150 pixels.</p>
<p>Is this possible with jQuery?</p>
<p>I've been looking at scrollTop and the scrollTo plugin, but I can't seem to connect the dots.</p>
| jquery | [5] |
5,390,891 | 5,390,892 | Stopping PHP script putting URL's in address bar? | <p>I have a script that pulls in meta data from a list of URL's but when I try to out too many it it says URL is too long and wont run.</p>
<p>My question is how can I stop this from happening?</p>
<pre><code><?php
ini_set( 'default_charset', 'UTF-8' );
error_reporting(E_ALL);
//ini_set( "display_errors", 0);
function parseUrl($url){
//Trim whitespace of the url to ensure proper checking.
$url = trim($url);
//Check if a protocol is specified at the beginning of the url. If it's not, prepend 'http://'.
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
$url = "http://" . $url;
}
//Check if '/' is present at the end of the url. If not, append '/'.
if (substr($url, -1)!=="/"){
$url .= "/";
}
//Return the processed url.
return $url;
}
//If the form was submitted
if(isset($_GET['siteurl'])){
//Put every new line as a new entry in the array
$urls = explode("\n",trim($_GET["siteurl"]));
//Iterate through urls
foreach ($urls as $url) {
//Parse the url to add 'http://' at the beginning or '/' at the end if not already there, to avoid errors with the get_meta_tags function
$url = parseUrl($url);
//Get the meta data for each url
$tags = get_meta_tags($url);
//Check to see if the description tag was present and adjust output accordingly
$tags = NULL;
$tags = get_meta_tags($url);
if($tags)
echo "<tr><td>Description($url)</td><td>" .$tags['description']. "</td></tr>";
else
echo "<tr><td>Description($url)</td><td>No Meta Description</td></tr>";
}
}
?>
</code></pre>
| php | [2] |
3,971,859 | 3,971,860 | Rewriting a Javascript equation | <p>I have the following piece of code</p>
<pre><code>var total = 5;
var arr = new Array("750", "400", "432", "355", "263");
id = 0;
num = 100;
var ht = 310;
var max = 750;
var cm = 20;
var bHg = 0;
var wdt = 100;
var bm = 20;
for (var i = 0; i < total; i++) {
ar = parseInt(arr[i]);
// how to rewrite these equations
**bHg = (ar * ht / max) / num * id;
printfu(cm + 50 + (i * (wdt + bm)) + bm,
cm + (ht - bHg), wdt, bHg);**
}
function printfu(a,b,c,d) {
document.write(a + b + c + d + "\n");
}
</code></pre>
<p>From a learning purpose, how can I write the 2 lines with a different equation to produce the same output</p>
<pre><code>bHg = (ar * ht / max) / num * id;
printfu(cm + 50 + (i * (wdt + bm)) + bm, cm + (ht - bHg), wdt, bHg);
</code></pre>
<p>OUTPUT of the above</p>
<p>520 640 760 880 1000 </p>
| javascript | [3] |
3,771,253 | 3,771,254 | A stategy for parsing favicon locations? | <p><strong>Linked IN</strong></p>
<pre><code>No link...Use default location.
http://www.linkedin.com/favicon.ico
</code></pre>
<p><strong>Twitter</strong></p>
<pre><code> <link href="/phoenix/favicon.ico" rel="shortcut icon" type="image/x-icon" />
</code></pre>
<p><strong>Pinterest</strong></p>
<pre><code><link rel="icon" href="http://passets-cdn.pinterest.com/images/favicon.png" type="image/x-icon" />
</code></pre>
<p><strong>Facebook</strong></p>
<pre><code><link rel="shortcut icon" href="https://s-static.ak.facebook.com/rsrc.php/yi/r/q9U99v3_saj.ico" />
</code></pre>
<p>I've determined that the only 100% way to find a favicon is to check the source and see where the link is. </p>
<ul>
<li>Default location is not always used. Note first 2 examples. </li>
<li>Google API works only about 85% of the time. <a href="http://www.google.com/s2/favicons?domain=%27path.com%27" rel="nofollow">Try It Out</a></li>
</ul>
<p>Is there a function that can parse this info out? Or is there a good strategy for using a regex to pull it out manually.</p>
<p>I will be parsing the html server side to get this info.</p>
<p><strong>Ideas:</strong></p>
<p>Regex Example: <a href="http://regexpal.com/" rel="nofollow">Try Here</a>. Seems to easy...but here is a starting point.</p>
<pre><code><link\srel="[Ss]hortcut [Ii]con"\shref="(.+)"(.+)>
</code></pre>
| php | [2] |
3,453,873 | 3,453,874 | Get current HTML element in PHP | <p>I may have misunderstood the purpose of PHP here. But I want to do the following:</p>
<p>I have a PHP function, and I call it from HTML, e.g. </p>
<pre><code> <BODY>
<DIV id='A'>
<?php emit("hello1"); ?>
</DIV>
<DIV id='B'>
<?php emit("hello2"); ?>
</DIV>
</BODY>
</code></pre>
<p>And I want to know, within the function, which <code>DIV</code> it was called from.
e.g.</p>
<pre><code> <?php function emit($txt){
echo "$txt";
echo "from DIV id $DIVID"
}
?>
</code></pre>
<p>And I want it, obviously, to print</p>
<pre><code>hello1 from DIV id A
hello2 from DIV id B
</code></pre>
<p>Is there any way of finding the "current" DIV's ID?</p>
| php | [2] |
4,760,559 | 4,760,560 | Can i retrieve array value not using loop? | <p>is there a way to retrieve array value not using any loop function?
I have this sort of array</p>
<pre><code>$at=array(
array(
array('Title:','titl','s','c',$titles),
array('First Name:','name','i','A',2,10 ),
),
</code></pre>
| php | [2] |
708,635 | 708,636 | PHP: Trying to figure out how to extract words from a string | <p>I would like to create an array of all the words in a string. I tried to Google but only found <code>str_split</code>, which does not separate the words.</p>
| php | [2] |
5,832,541 | 5,832,542 | Javascript Dynamic Script Loading IE problems | <p>I'm trying to load dynamically script with this code:</p>
<pre><code>var headID = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.type='text/javascript';
script.src="js/ordini/ImmOrd.js";
script.setAttribute("onload", "crtGridRicProd();");
headID.appendChild(script);
</code></pre>
<p>I need to launch crtGridRicPrdo() function when the page starts, and in FireFox all works fine but in Internet Explorer I have a problems!</p>
| javascript | [3] |
5,594,207 | 5,594,208 | How to read a div property in js? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3211326/how-to-get-the-attributes-of-a-html-element-using-jquery">How to get the attributes of a HTML element using JQuery?</a> </p>
</blockquote>
<p>I have a piece of JS and I need to read property 'value' from a div.</p>
<p>I do this:</p>
<pre><code>$('#calendar_event_path')
</code></pre>
<p>I get this as and answer:</p>
<pre><code>[<div id="calendar_event_path" value="company_events_index"></div>]
</code></pre>
<p>How can I get "company_events_index" value from the div?</p>
| javascript | [3] |
3,705,536 | 3,705,537 | BSSID vs MAC address? | <p>I dont understand the difference between the MAC address and BSSID</p>
<p>I understand that MAC is an identifier to local networks, but when I searched BSSID on wiki I got:</p>
<blockquote>
<p>In an infrastructure BSS, the BSSID is the MAC address of the wireless
access point (WAP).</p>
</blockquote>
<p>source: <a href="http://en.wikipedia.org/wiki/Service_set_%28802.11_network%29" rel="nofollow">http://en.wikipedia.org/wiki/Service_set_%28802.11_network%29</a></p>
<p>if bssid is the mac address of wap, then how come MAC dresses and BSSID are different? I tried this on a simple android app, when I getConnectionInfo I have a different bssid from a MAC address. Can someone please explain this to me?</p>
<p>Thanks</p>
| android | [4] |
323,632 | 323,633 | Viewing file using asp.net | <p>In our application, we allow user to upload documents which can be PDF, Doc, XLS, TXT. Uploaded documents will be saved on web server. We need to display link for each document user uploaded and when user click on that link, it should open relevant document. it is expected to have required software to open relevant documents.</p>
<p>To upload document, we use saveAs method of FileUpload control and it works absolutely fine.
Now, how to view it?</p>
<p>I believe, i need to copy/download file to local user machine and need to open it using Process.Start.</p>
<p>For that i need to find user local temp directory. if i put path.GetTempPath(), it gives me web server directory and copy file there. </p>
<pre><code>File.Copy(
sPath + dataReader["url"].ToString(),
Path.GetTempPath() + dataReader["url"].ToString(),
true);
</code></pre>
<p>Please advise.</p>
| asp.net | [9] |
4,444,042 | 4,444,043 | what is a pythonic way to get the number of times list1[i] < list2[i] and vise versa | <p>I have two lists with values, the expected result is a tuple <code>(a,b)</code> where <code>a</code> is the number of i values which <code>list1[i] < list2[i]</code>, and <code>b</code> is the number of i values where <code>list1[i] > list2[i]</code> (equalities are not counted at all).</p>
<p>I have this solution, and it works perfectly:</p>
<pre><code>x = (0,0)
for i in range(len(J48)):
if J48[i] < useAllAttributes7NN[i]:
x = (x[0]+1,x[1])
elif J48[i] > useAllAttributes7NN[i]:
x = (x[0], x[1]+1)
</code></pre>
<p>However, I am trying to improve my python skills, and it seems very non-pythonic way to achieve it. </p>
<p><strong>What is a pythonic way to achieve the same result?</strong></p>
<p><strong>FYI</strong>, this is done to achieve the required input for <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.binom_test.html" rel="nofollow"><code>binom_test()</code></a> that tries to prove two algorithms are not statistically identical.
<br>I don't believe this information has any additional value to the specific question though.</p>
| python | [7] |
4,397,582 | 4,397,583 | problem in detecting logoff using c# | <p>I tried to detect logoff event and write it in a text.</p>
<p>How can this be fixed? i wanted to write the logoff time in a text file but the text file is not created when i logoff the PC.</p>
<pre><code>static void Main(string[] args)
{
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
Console.ReadLine();
SystemEvents.SessionSwitch -= SystemEvents_SessionSwitch;
}
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
if (e.Reason == SessionSwitchReason.SessionLogoff)
{
TextWriter tw = new StreamWriter("D:\\date.txt");
tw.WriteLine("logoff" + DateTime.Now);
tw.Close();
}
if (e.Reason == SessionSwitchReason.SessionLogon)
{
TextWriter tw1 = new StreamWriter("D:\\date.txt");
tw1.WriteLine("logoff" + DateTime.Now);
tw1.Close();
}
}
</code></pre>
| c# | [0] |
4,862,864 | 4,862,865 | Setting Toolbar Items | <p>I try to set toolbar items in the navigationcontrollers top view. Seems to work in the subviews... but why not in the top view...any ideas? I get the add button... but not my custom button.</p>
<pre><code>- (void)configureToolbarItems {
UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(addNewTaskButtonPressed)];
//Green button
greenButton=[app makeGreenButton:self];
UIBarButtonItem *greenBarButton = [[UIBarButtonItem alloc] initWithCustomView:greenButton];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
// Set our toolbar items
[self setToolbarItems:[NSArray arrayWithObjects:
addButtonItem,flexibleSpace, greenBarButton, nil] animated:YES]; }
</code></pre>
<p>This is the makeButton procedure... works fine in other views:</p>
<pre><code>-(UIButton*)makeGreenButton:(UIViewController*)caller {
UIButton *greenButton;
//load the image for yellow button
UIImage *greenButtonImage = [UIImage imageNamed:@"greenButton.png"];
//create the button and assign the image
greenButton = [UIButton buttonWithType:UIButtonTypeCustom];
[greenButton setImage:greenButtonImage forState:UIControlStateNormal];
greenButton.showsTouchWhenHighlighted=TRUE;
//set the frame of the button to the size of the image (see note below)
greenButton.frame = CGRectMake(0, 0, greenButtonImage.size.width*2, greenButtonImage.size.height*2);
//Add target
[greenButton addTarget:caller action:@selector(greenButtonReleased:) forControlEvents:UIControlEventTouchUpInside];
return greenButton; }
</code></pre>
| iphone | [8] |
87,460 | 87,461 | converting a string of numbers to letters python | <p>I need to convert a string of numbers into a string of letters to form words Example: if the input to your program is 1920012532082114071825463219200125320615151209190846 it should return stay hungry. stay foolish.</p>
<p>I have a program that converts a word to a string of numbers:</p>
<pre><code>string = raw_input('Please enter your string of lowercase characters: ')
Dictionary = {'a':'00', 'b':'01', 'c':'02', 'd':'03', 'e':'04', 'f':'05',
'g':'06', 'h':'07', 'i':'08', 'j':'09', 'k':'10', 'l':'11',
'm':'12', 'n':'13', 'o':'14', 'p':'15', 'q':'16', 'r':'17',
's':'18', 't':'19', 'u':'20', 'v':'21', 'w':'22', 'x':'23',
'y':'24', 'z':'25', ' ':'32', '.':'46'}
n = ''
p= 0
for character in string:
n += Dictionary[string[p]]
p += 1
print n
</code></pre>
<p>So i need to make a program that takes the string of numbers (n) and convert it back to the original words. </p>
<p>Really not sure what to do here so any help would be appreciated!</p>
| python | [7] |
1,154,219 | 1,154,220 | how to implement idf in java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1960333/any-tutorial-or-code-for-tf-idf-in-java">Any tutorial or code for Tf Idf in java</a> </p>
</blockquote>
<p>IDF is inverse document frequency.</p>
<p>IDF = log(document containing the term / number of documents)</p>
<p>How to do it in java ? </p>
<p>Any advices? </p>
| java | [1] |
183,302 | 183,303 | Python: functions returned by itemgetter() not working as expected in classes | <p>The <a href="http://docs.python.org/library/operator.html#operator.itemgetter" rel="nofollow">operator.itemgetter()</a> function works like this:</p>
<pre><code>>>> import operator
>>> getseconditem = operator.itemgetter(1)
>>> ls = ['a', 'b', 'c', 'd']
>>> getseconditem(ls)
'b'
</code></pre>
<p><strong>EDIT I've added this portion to highlight the inconsitency</strong></p>
<pre><code>>>> def myitemgetter(item):
... def g(obj):
... return obj[item]
... return g
>>> mygetseconditem = myitemgetter(1)
</code></pre>
<p>Now, I have this class</p>
<pre><code>>>> class Items(object):
... second = getseconditem
... mysecond = mygetseconditem
...
... def __init__(self, *items):
... self.items = items
...
... def __getitem__(self, i):
... return self.items[i]
</code></pre>
<p>Accessing the second item with its index works</p>
<pre><code>>>> obj = Items('a', 'b', 'c', 'd')
>>> obj[1]
>>> 'b'
</code></pre>
<p>And so does accessing it via the <code>mysecond</code> method</p>
<pre><code>>>> obj.mysecond()
'b'
</code></pre>
<p>But for some reason, using the <code>second()</code> method raises an exception </p>
<pre><code>>>> obj.second()
TypeError: itemgetter expected 1 arguments, got 0
</code></pre>
<p>What gives?</p>
| python | [7] |
4,197,788 | 4,197,789 | Copy data from one object to another | <p>Hey
I want to copy data from one entity to another.<br>
I have something like this :</p>
<pre><code> MyEntity newEntity = new Entity()
newEntity.Property1 = oldEntity.Property1 ....
</code></pre>
<p>Is there easier way to do this? I have many properties and I would like to write something like <code>newEntity = oldEntity</code>, but this is impossible because of primary key duplication</p>
| c# | [0] |
587,325 | 587,326 | Android audio Manager trouble | <p>I am using Android audio Manager and in my app when you click a button it silents the phone and at certain time it brings the phone back to normal mode. but the problem is that when i click the button it changes it to silent but then automaticly it changes it back to normal mode again for some reason. i am using </p>
<p>in one file im using</p>
<pre><code>soAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
soAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
</code></pre>
<p>and in another file i am using</p>
<pre><code>goAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
goAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
</code></pre>
| android | [4] |
4,500,801 | 4,500,802 | Number of sentence occurrences in another sentence (in PHP) | <p>I am looking for a way to find the number of sentence occurrences in another sentence</p>
<p>For example (I have):</p>
<blockquote>
<p>Hello brother, I have been waiting to tell you something very
important. Good bye brother, I will see you next week</p>
</blockquote>
<p>and I am searching for:</p>
<blockquote>
<p>brother, I</p>
</blockquote>
<p>This should present me the result of:</p>
<blockquote>
<p>result = 2</p>
</blockquote>
| php | [2] |
4,856,222 | 4,856,223 | c# drawing a rectangle on a picturebox? | <p>I have many images and coordinates of them with width and height. A picture is put in a picturebox and I send the coordinates to draw the rectangle on it. There are many pictureboxes on a panel. </p>
<p>I send their paths to a <code>PicturePanel</code> class also with some coordinates and width/height properties to draw a rectangle. However, my problem is that, it draws it, and immediately deletes it. If I don't put a messagebox after each image, i don't see the rectangles. Here is the code;</p>
<pre><code>if (IsRun())
{
MessageBox.Show("rontool true");
Rectangle ee = drawARectangle(xCoor, yCoor, MainScreen.tempR.wid / ratioOfx, MainScreen.tempR.heig / ratioOfy); // I wrote this, it only creates and returns the rectangle.
//MessageBox.Show("x : " + xCoor + " y: " + yCoor + " width : " + (MainScreen.tempR.wid / ratioOfx) + " height: " + (MainScreen.tempR.heig / ratioOfy));
using (Pen pen = new Pen(Color.Red, 2))
{
pictureBox.CreateGraphics().DrawRectangle(pen, ee);
// e.Graphics.DrawRectangle(pen, ee);
}
}
</code></pre>
<p>This is in</p>
<pre><code>private void PictureBox_Paint(object sender, PaintEventArgs e).
</code></pre>
<p>A for loop is in another class, creates a picturebox, and initializes its x, y etc. however, it draws and immediately deletes it. or sometimes it doesn't even draw.</p>
<p>If I don't put a messagebox after each image, I don't even see the rectangles. Can you help me?</p>
| c# | [0] |
5,462,714 | 5,462,715 | Android ActionBar Tab Navigation | <p>I am following <a href="http://www.youtube.com/watch?v=gMu8XhxUBl8" rel="nofollow">http://www.youtube.com/watch?v=gMu8XhxUBl8</a> example. Setting up the tabs is working fine. On each tab, I am using a cursor to get the data from SQLite and display it. where should I write that code ? In TabActivity ? In AFragmentTab ? </p>
| android | [4] |
2,465,757 | 2,465,758 | use php dom parser inside another class - ERROR: Call to a member function on a non-object | <p>I'm using PHP simple dom parser <a href="http://simplehtmldom.sourceforge.net/manual.htm" rel="nofollow">http://simplehtmldom.sourceforge.net/manual.htm</a>.
I'm able to successfully use it and remove an html tag with specific id by doing </p>
<pre><code>$html = str_get_html('<div><div class="two">two</div></div>');
function test($str, $class){
$e = $str->find($class,0);
$e->outertext = '';
echo $str->outertext;
}
test($html, '#two');
</code></pre>
<p>My problem is when i try to use the function inside another php class. It doesn't work. Here's what i did</p>
<pre><code>$html = new simple_html_dom(); //initialized the object
class Someclass {
public function test($wrap, $class){
global $html;
$html->load($wrap);
$e = $html->find($class,0);
$e->outertext = '';
echo $html->outertext;
}
}
</code></pre>
<p>I'm getting an error <strong>Fatal error: Call to a member function load() on a non-object</strong>
What am i doing wrong. I'm i calling this correctly.</p>
| php | [2] |
714,833 | 714,834 | Iphone: Check List | <p>Is there standard way to implement standard Iphone Check List like when you choose ringtone in Settings ? When you click on a row and checkmark appears ...</p>
<p>Or I should draw a checkmark by myself and set it by row index ?</p>
| iphone | [8] |
5,365,699 | 5,365,700 | Compilation error creating an adapter in a fragment | <p>I have a fragment which contains several views including a ListView. In order to set the adpater for the listview, I thought I'd recycle some old (working) code I'd previously written in an <em>activity</em>. The code in the activity looked something like this:</p>
<pre><code>adapter = new myadapter(
this,
list_of_things,
R.layout.custom_row_view,
new String[] {"label","day","time"},
new int[] {R.id.text1,R.id.text3, R.id.text2}
);
</code></pre>
<p>Where myadapter was a method within my activity's class, defined like so...</p>
<pre><code>public class myadapter extends SimpleAdapter {
</code></pre>
<p>Now I tried to put the same myadapter method inside my fragment class and called </p>
<pre><code>adapter = new myadapter(
this,
list_of_things,
R.layout.custom_row_view,
new String[] {"label","day","time"},
new int[] {R.id.text1,R.id.text3, R.id.text2}
);
</code></pre>
<p>but now I get a compile time error: </p>
<pre><code>The constructor MyTestFragment.myadapter(MyTestFragment, ArrayList<HashMap<String,String>>, int, String[], int[]) is undefined
</code></pre>
<p>I don't know whether my bug could be some minor typo - or whether its something more fundamental, like not being allowed adapters within fragments.</p>
| android | [4] |
3,745,717 | 3,745,718 | How to remove table row "If that table cell not contains values in an array"? | <p>This is my example code:</p>
<p>My array is:</p>
<pre><code>var myarray = ["air india", "king fisher", "Go Air"];
</code></pre>
<p>and my table is:</p>
<pre><code> <table>
<tr>
<td>air india</td>
<td>code:121</td>
</tr>
<tr>
<td>Indiago</td>
<td>code:325</td>
</tr>
</table>
</code></pre>
<p>Now, i want to remove the rows which not contains values in the array 'myarray'. In this case i need to remove second row(Indiago is not in myarray). </p>
| jquery | [5] |
3,079,528 | 3,079,529 | How to start a program Automatically from the main method | <p>Here is my code</p>
<pre><code>def main():
# This code reads in data.txt and loads it into an array
# Array will be used to add friends, remove and list
# when we quit, we'll overwrite original friends.txt with
# contents
print"Welcome to the program"
print "Enter the correct number"
print "Hockey fan 1, basketball fan 2, cricket fan 3"
choice = input("Select an option")
while choice!=3:
if choice==1:
addString = raw_input("Who is your favorite player??")
print "I love Kessel"
elif choice==2:
remInt = raw_input("Do you think that the Cavaliers will continue ther loosing ways?")
print "I think they can beat the Clippers"
else:
"You must choose a Number (1,2 or 3)"
print "Cricket is a great sport"
choice = input("Select an option")
inFile = open('data.txt','r')
listNumbers = []
for numbers in inFile:
listNumbers.append(numbers)
print numbers
inFile.close()
if __name__ == "__main__":
main() # will call the 'main' function only when you execute this from the command line.
</code></pre>
| python | [7] |
1,951,870 | 1,951,871 | I want to open a popup on clicking a button showing an aspx page | <p>I have seen this in the West-Wind Toolkits where they have created their control called Hover Panel but i'm not able to implement it.So,is there another method to do so.</p>
| asp.net | [9] |
3,778,084 | 3,778,085 | Handle iglob error when path to search doesn't exist | <p>I'm trying to use iglob instead of glob to get a list of say .txt files. If no .txt files exist, glob doesn't return any errors, but iglob does.</p>
<p>Code:</p>
<pre><code>def iGlobLatest():
dir_list = glob.iglob('*.txt')
print dir_list.next()
</code></pre>
<p>if no .txt files exist, I get this:</p>
<p>Traceback (most recent call last):</p>
<p>File "T:\prod\offlineValidation\scripts\goofin.py", line 98, in iGlobLatest()</p>
<p>File "T:\prod\offlineValidation\scripts\goofin.py", line 88, in iGlobLatest print dir_list.next()</p>
<p>StopIteration</p>
<p>If I use try/except, I can avoid the error, but is that the only way? Other suggestions for checking the existence of .txt files involve using glob, but since I'm trying to use iglob instead of glob.... </p>
| python | [7] |
5,151,076 | 5,151,077 | php send email with attachment | <p>How to send the email with resume attachment ,</p>
<p>i take snippet from this place <a href="http://www.weberdev.com/get_example-4595.html" rel="nofollow">Click here</a> </p>
<p>In this site, snippet works fine,</p>
<p>Even i got the mail, but attachment is not working, am getting attment as noname with 0kb </p>
<p>size file, What is Issue in that snippet ,</p>
| php | [2] |
2,829,235 | 2,829,236 | Question regarding embedding variables in double-quoted strings in PHP | <p>Are the following instructions equivalent?</p>
<pre><code># 1
$str = "$var1$var2</td>";
# 2
$str = "$var1" . "$var2" . "</td>";
</code></pre>
<hr>
<p><strong>EDIT:</strong> Thank you all.</p>
<p><code>header('Location:</code><a href="http://stackoverflow.com/questions/4686724/question-regarding-anonymous-methods-as-class-members">Question regarding anonymous methods as class members</a><code>);</code></p>
| php | [2] |
3,509,126 | 3,509,127 | override and overload perspective | <ul>
<li>Overloading - same method with different signatures in the same
class.<br/></li>
<li>Overriding - same method signature different implementations in
subclass <br/></li>
</ul>
<p>If i have an overloaded method in the parent class does the child class overload or override this particular method? </p>
| java | [1] |
1,552,429 | 1,552,430 | Android RotateAnimation compass rotation | <p>I have a custom built compass that is used as part of a navigation app that I have written. I have also written an algorithm that that smooths out the compass (a type of low-pass filter). Everything works great and the compass is fluid. I pass in a current degrees and previous degrees arguments to the RotateAnimation. Problem is when you spin around quickly with the compass, after a certain point, the gap is so large between the current and previous degrees that the rotate switches direction to the path of least distance. It has to do with the sort of lag that happens from the low-pass filter - that it has to catch up wit the real-time direction. I was wondering if anyone has dealt with this (I have seen some compass apps from the store that handle this) or has some kind of algorithm/solution, to keep the orientation of the rotation. Here is some code:</p>
<pre><code>RotateAnimation rotate = new RotateAnimation(startingPointer, pointerDeg, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotate.setInterpolator(new LinearInterpolator());
rotate.setDuration(ROTATION_INTERVAL);
rotate.setFillAfter(true);
pointer.setAnimation(rotate);
startingPointer = pointerDeg;
</code></pre>
| android | [4] |
4,790,660 | 4,790,661 | Exception Handling in java | <p>i was trying to run the following code but i am getting error please clarify my doubt</p>
<pre><code>import java.util.*;
class Except
{ public class AlfaException extends Exception{}
public static void main(String[] args)
{
int b;
Scanner s=new Scanner(System.in);
try
{
b=s.nextInt();
}
catch(InputMismatchException ex)
{
try
{
if(('b'> 67)&&('b'<83)){}
}
catch(AlfaException e){
throw new AlfaException("hello");
}
System.out.println("error found");
}
}
}
Except.java:20: non-static variable this cannot be referenced from a static cont
ext
throw new AlfaException("hello");
^
</code></pre>
<p>1 error</p>
| java | [1] |
3,793,173 | 3,793,174 | Python: Why am I getting ValueError: too many values to unpack | <p>I am not sure why I am getting this error. I have read and tried different things, but it is not working.</p>
<pre><code>def product():
y, x= raw_input('Please enter two numbers: ')
times = float(x) * int(y)
print 'product is', times
product()
</code></pre>
<p>What am I doing wrong? Thank you so much</p>
| python | [7] |
3,805,052 | 3,805,053 | cloning elements, avoiding more than one clone at a time when adding | <p><a href="http://jsfiddle.net/p57hm/" rel="nofollow">http://jsfiddle.net/p57hm/</a></p>
<p>I simply want one more clone on each click. Did i miss something obvious_ Thanks</p>
<p>Script:</p>
<pre><code>$(function(){
$('input').click(function(){
$('.cloneitem').clone().appendTo('#container');
});
});
</code></pre>
<p>HTML:</p>
<pre><code><input type="button" value="clone it"/>
<div id="container"></div>
<div class="cloneitem">clone</div>
</code></pre>
| jquery | [5] |
3,472,486 | 3,472,487 | Is it possible for a object to "autodestroy" itself? | <p>Is it possible to have something along the lines of...</p>
<pre><code>class PrivateStuff {
[private] void autodestroy() {
// something something
}
}
</code></pre>
<p>... and have the object be kinda destroyed? Like all references to it be set to null.</p>
<p>P.S. I know you can't really "destroy" an object in Java like you would in other languages (like C), and that it's only killable by the GC, but I'm kinda curious if there's a way to force the GC to kill the caller. Just as an experiment, no intent of use it in a real application.</p>
| java | [1] |
2,874,144 | 2,874,145 | Giving preference to one operator[] over another | <p>Consider the following class:</p>
<pre><code>class Test
{
public:
Test( char );
Test( int );
operator const char*();
int operator[]( unsigned int );
};
</code></pre>
<p>When I use it:</p>
<pre><code>Test t;
Test& t2 = t[0];
</code></pre>
<p>I get a compiler error where it can't figure out which operator[] to use. MSVC and Gcc both. Different errors. But same problem.</p>
<p>I know what is happening. It can construct a Test from either an int or a char, and it can either use <code>Test::operator[]</code> or it can cast to const char* and use the built <code>char*[]</code>.</p>
<p>I'd like it to prefer <code>Test::operator[]</code>.</p>
<p>Is there a way to specify a preference like this?</p>
<p>UPDATE: First, I'll agree with response below that there is no language feature that lets you specify a priority for conversions. But like juanchopanza found below - you can create such a preference indirectly by making one conversion require no casts, and make the other require a cast. E.g. <code>unsigned int</code> as the argument for <code>operator[]</code> won't work but, using <code>int</code> will. </p>
<p>The default index argument is unsigned - for gcc and msvc anyway - so making the index argument unsigned will cause the compiler to prefer the right operator. </p>
<p>@Konrad: about implicit conversions to built-in types. Agree generally. But I need it in this case.</p>
| c++ | [6] |
4,950,275 | 4,950,276 | how to check a dropdown has a value in jquery? | <p>what is the best way to check is a drop down contains a value which isnt null.</p>
<pre><code> <select class="dropinput" name="Finish1" id="dropFinish1" tabindex="10" disabled="disabled">
<option value=""></option>
</select>
</code></pre>
<p>How to check the above drop down contains no values? </p>
| jquery | [5] |
597,699 | 597,700 | Get an attribute of a class with another attribute | <p>I've got a fundamental problem.</p>
<p>There are several classes, extending another one ("Skill").<br>
"Skill" contains some abstract methods like:</p>
<pre><code>public abstract int getID();
public abstract String getName();
public abstract String getDescription();
</code></pre>
<p>and the subclasses:</p>
<pre><code>@Override
public int getID()
{
return 69;
}
@Override
public String getName()
{
return "name";
}
@Override
public String getDescription()
{
return "description";
}
</code></pre>
<p>Now, let's say i need to get the description of the subclass with the id "89".<br><br>
Is there an easier way of doing this, than having a HashMap storing id->classname and then getting an object of the class by doing the following?:</p>
<pre><code>Class cl = Class.forName(classname);
Object o = cl.getConstructor().newInstance();
Method m = cl.getMethod("getDescription");
return (String) m.invoke(o);
</code></pre>
| java | [1] |
4,250,722 | 4,250,723 | Python Function runs to first if statement no matter input | <p>I'm learning Python from an online tutorial. My problem is that when I run the script, no matter what I input the response I get is the if go == "kitchen"...</p>
<pre><code>def go_to():
go = raw_input("Go to? ")
if go == Kitchen or breakfast:
print "You rumble down stairs and into the kitchen. Your mom has left some microwaved waffles on the table for you. Your big boy step sits by the counter."
elif go == "back to bed" or "back to sleep" or bed or sleep:
print "You hit snooze and roll over."
elif go == "bathroom" or "toilet" or "potty" or "pee" or "poop" or "take a sh*t" or "take a dump" or "drop a load":
print "You make a stop at the head first."
go_to()
else:
print "That is not a command I understand."
go_to()
go_to()
</code></pre>
| python | [7] |
4,007,177 | 4,007,178 | modify checkbox using javascript | <p>I had declared 5 checkboxes with name and id attribute in a html:</p>
<pre><code><input type="checkbox" name="category" value="One" id=11>One<br/>
<input type="checkbox" name="category" value="Two" id=12>Two<br/>
<input type="checkbox" name="category" value="Three" id=13>Three<br/>
<input type="checkbox" name="category" value="Four" id=14>Four<br/>
</code></pre>
<p>After declaration, I want to run a javascript that would enable the checkbox1 using that checkbox id.</p>
<p>Let me know to clarify something.</p>
| javascript | [3] |
985,630 | 985,631 | Add Two Custom Navigations To BXSlider | <p>I'm trying to use this -> <a href="http://bxslider.com/" rel="nofollow">http://bxslider.com/</a> on my page, but the problem is that I need to use it 4 times with 2 different navigation methods. It has a function to use a custom navigation called pagerCustom and you input the class there and it works great, but when you try adding both classes...<b>error</b></p>
| jquery | [5] |
5,294,035 | 5,294,036 | Jquery multiple choice quiz using clickable buttons | <p>I'm a beginner in Jquery.
I want to create a multiple choice quiz with over 30 questions. Each questions has four options assigned to 4 clickable CSS buttons - NOT radio buttons). The user clicks on just one button to make the choice. Each button would fire a script (in a click-function), and depending on the button clicked, (eg button A) a point or no points is assigned to a variable in memory, then a new set of questions is automatically paged in to replace the former set. This goes on to the end of the bank of 30 questions, when total scores are then (and only then) displayed on screen.
I want the same buttons (A,B, C,D) to remain displayed on the screen throughout, without having CSS rewrite them, but each button be re-assigned a different correct or incorrect script (eg, this time question C is correct and, if clicked, awards 1 point) based on the next bank of questions and the correct button choice for the answer in that new bank.</p>
<p>It's easy to copy 30 banks of questions with their different questions into the html file, but there must be a more elegant way to switch the code from one button to the other, depending on the correct button to click, without having to use so many lines.</p>
| jquery | [5] |
3,255,557 | 3,255,558 | C++ Notation : "<?" | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3437410/c-extension-and-operators">C extension: <? and >? operators</a> </p>
</blockquote>
<p>I've been having trouble deciphering some C++ code and haven't been able to find anything through search. Can anyone help me out with the code below using the '< ?' notation?</p>
<pre><code>int maximumLength(int countA, int countB, int maxA, int maxB) {
long long ca=countA,cb=countB,ma=maxA,mb=maxB;
if(ma==0) ca=0;
if(mb==0) cb=0;
long long res=ca+cb;
// any help on the below two lines is appreciated!
res<?=(cb+1)*ma+cb;
res<?=(ca+1)*mb+ca;
return (int)(res);
}
</code></pre>
| c++ | [6] |
2,918,659 | 2,918,660 | Android application internet connection | <p>I'm new to Android and this is my first application. I'm to connect internet and download JSON from my companies server but unable to get input stream please check this code and provide me assistance.</p>
<pre><code>URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.connect();
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
</code></pre>
<p>URL is not the issue I have tested many URL's. In this code last line gives error. I uses open connectivity (No proxy only firewall) on my development machine and emulators browser is able to access internet.</p>
<p>I have already added </p>
<pre><code><uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</code></pre>
<p>parallel to uses-sdk tag in Manifest file.</p>
| android | [4] |
2,313,348 | 2,313,349 | how to get the value of checksum in php header | <p>I have a header in php which contains a link like</p>
<pre><code><?php
header("Location: "."https://abc.com/ppp/purchase.do?version=3.0&".
"merchant_id=<23255>&merchant_site_id<21312>&total_amount=<69.99>&".
"currency=<USD>&item_name_1=<incidentsupporttier1>&item_amount_1=<1>&".
"time_stamp=<2010-06-14.14:34:33>&**checksum=<calculated_checksum>**");
?>
</code></pre>
<p>when i run this page the value of checksum is calculated and the link is opened</p>
<p>now how checksum is calculated?
calculated_checksum=md5(abc);</p>
<p>md5 is an algorithm which calculates the value of checksum based on certain values inside the bracket.</p>
<p>now i want to know how can i pass the value of checksum in the header url </p>
| php | [2] |
5,807,835 | 5,807,836 | C#.NET Excel and OLEDB Connection String | <p>I am trying to read data from Excel file into my windows application. </p>
<p>Connection String :</p>
<pre><code>provider = Microsoft.Jet.OLEDB.4.0; Data Source = "Excel File";
Extended Properties = \"Excel 8.0; HDR = Yes; ImportMixedTypes = Text;
Imex = 1;\"
</code></pre>
<p>With this connection string I am able to read data from Excel file <strong>even though Microsoft office - Excel is not installed onto the computer</strong>. But some how, my program is not compatible with this connection string. </p>
<p>Connection String which I am using right now is </p>
<pre><code>provider = Microsoft.ACE.OLEDB.12.0; Data Source = "Excel file";
Extended Properties = "Excel 12.0; HDR = Yes; Imex = 1;
</code></pre>
<p>This connection string is compatible with my program but <strong>it only works on the computer which do have Microsoft office - Excel install.</strong> </p>
<p>Can anyone suggest me where I am making mistake.</p>
<p>Thanks.</p>
| c# | [0] |
3,209,316 | 3,209,317 | JQuery.select() for <div> | <p><a href="http://api.jquery.com/select/" rel="nofollow">http://api.jquery.com/select/</a> mentions that $().select() </p>
<blockquote>
<p>"The select event is sent to an element when the user makes a <strong>text selection</strong> inside it. This event is <strong>limited</strong> to <code><input type="text"></code> fields and <code><textarea></code> boxes."</p>
</blockquote>
<p>I am trying to detect text selection in <code><div></code>.</p>
<p>What's the best way to provide the equilvalent $().select()?</p>
<p>Thanks in advance for your help.</p>
| jquery | [5] |
5,802,624 | 5,802,625 | Ajax image gallery ("imago"). Scroll position | <p>I am using Ajax Image Gallery from this site: <a href="http://imago.codeboje.de/" rel="nofollow">http://imago.codeboje.de/</a>.
The problem is that with every image click or lefgt/right arrow click image changes and the scroll moves to the beginning of the page. But I need the scroll to be at the place of the image. How can I do that?</p>
| javascript | [3] |
1,039,044 | 1,039,045 | How to get a difference between two dates? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/41948/how-do-i-get-the-difference-between-two-dates-in-javascript">How do I get the difference between two Dates in JavaScript?</a> </p>
</blockquote>
<p>How to get the difference between two dates using javascript.I need the exact day difference between those two dates.Here is my code</p>
<pre><code>function calculateDifference() {
var startDate = document.getElementById("MainContent_txtOStartDate").value;
var endDate = document.getElementById("MainContent_txtOEndDate").value;
return DateDiff(startDate, endDate);
}
function DateDiff(startDate, endDate) {
var a = Date.parse(startDate) - Date.parse(endDate);
alert(a);
}
</code></pre>
<p>Any suggestion?</p>
| javascript | [3] |
2,467,130 | 2,467,131 | How to put a Scanner input into an array... for example a couple of numbers | <pre><code>Scanner scan = new Scanner(System.in);
double numbers = scan.nextDouble();
double[] avg =..????
</code></pre>
| java | [1] |
1,461,042 | 1,461,043 | EasySlider 1.7 - blank side when vertical=true and continuous=true | <p>www.natebarnes.com is my site. I have my slider set to scroll vertically, to come out from behind the horizon graphic at the bottom of the screen.</p>
<p>When setting easyslider to scroll vertical and cycle contniuosly, it seems to be inserting a blank slide or something. It seems to be a common complaint on the 1.7 comment thread, however I've not found an answer for it. Any help would be a great relief. Thanks in advance!</p>
| jquery | [5] |
3,148,148 | 3,148,149 | Possible Javascript submit one value from multiple equal name input? | <p>This code has two links with same name but different values. If i click first link, i want to get value 10. Is it possible using javascript with link submit()?? </p>
<pre><code> <form name="listpages" action="page.php" method="post">
<input type="hidden" name="pgnum" value="10">
<a href="javascript: document.listpages.submit()"></a>
<input type="hidden" name="pgnum" value="20">
<a href="javascript: document.listpages.submit()"></a>
</form>
</code></pre>
<p>thanks in advance</p>
| javascript | [3] |
4,865,340 | 4,865,341 | How to stop fopen from triggering warning when attempting to open an invalid/unreachable URI | <p>I'm using fopen to generate a price feed.</p>
<pre><code>if (($handle = fopen("http://feedurl", "r")) !== FALSE) {
}
</code></pre>
<p>Is there a way to stop this warning if the feed fails:</p>
<blockquote>
<p><b>Warning</b>: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in…</p>
</blockquote>
| php | [2] |
1,224,269 | 1,224,270 | Error: undefined reference to operator+(Stack<int> const&, Stack<int> const&)' | <p>I know that if I dont define copy Constructor or Constructor, c++ define it auto<br>
and i know Shallow & deep copy<br>
but in below code i have a bug that it seem about copy constructor </p>
<pre><code>#include<iostream>
#include <vector>
using namespace std;
template<class T>
class Stack
{
private:
vector<T> stack;
public:
vector<T> returnStack()
{
return stack;
}
vector<T> returnStack() const
{
return stack;
}
void Push(T item)
{
stack.insert(stack.begin()+stack.size(),item);
}
friend Stack operator+(const Stack &one,const Stack &other);
};
template<class T>
Stack<T> operator+(const Stack<T> &one,const Stack<T> &other)
{
Stack<T> newStack;
for (typename vector<T>::size_type i = 0; i < one.returnStack().size(); i++)
{
newStack.Push(one.returnStack()[i]);
}
for (typename vector<T>::size_type i = 0; i < other.returnStack().size(); i++)
{
newStack.Push(other.returnStack()[i]);
}
return newStack;
}
int main()
{
Stack <int > a;
Stack <int > b;
a.Push(1);
a.Push(2);
b.Push(3);
b.Push(4);
Stack <int> c=a+b ;//have a bug
return 0;
}
</code></pre>
<p>above code realese below error<br>
<code>undefined reference to operator+(Stack<int> const&, Stack<int> const&)'</code></p>
<p>I spend very time to debug its but i tired .can you help me ? </p>
| c++ | [6] |
2,438,474 | 2,438,475 | how to search properly the vector for a value | <p>The problem I have, I have to add to a vector, the missing chars.
For example I have initially</p>
<p>s,a,p,i,e,n,t,i,a</p>
<p>and I have to add missing chars to it<br>
s,a,p,i,e,n,t,i,a,<strong>b,c,d ...</strong></p>
<p>I am trying to use this code to search for an existing value.</p>
<pre><code>for(char c='a';c!='z';++c)
{
if (vec.end()!=find(vec.begin(),vec.end(),c))
vec.push_back(c);
}
</code></pre>
<p>The find returns <code>last</code> when it fails to locate a value. But how do I know if last value was in it?</p>
<p><strong>EDIT</strong></p>
<p>When the for loop starts, for 'a' returns vec.end() so it should not go in, but goes in, and adds 'a' again in the end.</p>
<p>See this in debugger
<img src="http://img203.imageshack.us/img203/2048/bb1f.jpg" alt="alt text"></p>
<p>(The bug I have, the value in last position gets inserted twice, I have to omit this)</p>
| c++ | [6] |
802,907 | 802,908 | Unable to get properties from properties file? | <p>I have written a class FetchProp that extends class PropMap which fetches the values from properties file.When i run FetchProp as junit test case it is giving me correct output i.e it fetches properties the way i want.Then i have created class CreateReport that calls a method of FetchProp which helps in generation of report.But when i run a test case on CreateReport the FetchProp is not fetching the properties as it used to do when run standalone?</p>
<p>Can any one suggest what may be the issue</p>
<p>PS: I have checked the path where properties file is placed and i am displaying the properties file path every time i run the program and file has the properties i want to get.</p>
| java | [1] |
3,259,580 | 3,259,581 | set new id for element in jquery | <p>i have code blow to change new id for a element with jquery.</p>
<pre><code>$('.trclick').click(function(){
var id = $(this).attr('id');
var idright = split_right(id,'__');
var val = $('#ims_master_test_day1__'+idright).val();
$('#ims_master_test_day').attr( 'id', 'ims_master_test_day__' + idright );
});
</code></pre>
<p>It work but it active only one. Please help me. Thanks!</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.