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,460,425 | 1,460,426 | Facebook Error after xcode upgrade | <p>I have been using xcode 4.1 till yesterday and my facebook integration using FBConnect was also working fine . But when i update my xcode to xcode 4.2 , i am getting error on facebook after successful login like "This endpoint has been deprecated. To temporarily reenable it, you may disable the "august_2012" platform migration.</p>
<p>need to fix this issue. </p>
<p>Plz help</p>
<p>Thanks</p>
| iphone | [8] |
2,601,040 | 2,601,041 | different php versions causing problems | <p>Can anyone spot anything that would be causing me massive problems between the following two server/php configs:</p>
<p><a href="http://www.turkishrealestateforsale.com/phpinfo.php" rel="nofollow">http://www.turkishrealestateforsale.com/phpinfo.php</a>
and
<a href="http://rent-turkey-property.com/phpinfo.php" rel="nofollow">http://rent-turkey-property.com/phpinfo.php</a></p>
<p>I am having particular problems with form processing, including one where it seems to stop processing half way through the script for no apparent reason, echo works here, but not here.</p>
<p>I am guessing it is the Server API being Apache 2.0 Handler and CGI, if this is right, can anyone point me to a cheat sheet or any documentation on the Idiosyncrasies between the two.</p>
| php | [2] |
503,036 | 503,037 | '' equals false in Javascript? What would be the safest way to distinguish between '' and boolean false? | <p>We use an external API whcih returns '' or boolean false while Javascript seems to find the both equal.
for example:</p>
<pre><code>var x = '';
if (!x) {
alert(x); // the alert box is shown - empty
}
if (x=='') {
alert(x); // the alert box is shown here too - empty
}
var z = false;
if (!z) {
alert(z); // the alert box is shown - displays 'false'
}
if (z=='') {
alert(z); // the alert box is shown here too - displays 'false'
}
</code></pre>
<p>How can we distinguish between the two? </p>
| javascript | [3] |
2,366,498 | 2,366,499 | System.out.println() not working | <p>this is my first post. I am excited to a part of this community and I have been struggling with this problem for a while, so here goes:</p>
<p>In the following code:</p>
<pre><code>if (j == 0)
{
if (!Arrays.equals(cipherData, c))
{
System.out.print("C: ");
for (int i = 0; i < encryptedData.length; i++)
System.out.print((char)cipherData[i]);
System.out.println();
}
}
</code></pre>
<p>The <code>System.out.println()</code>
method returns nothing at all. No line, or anything and I have no idea why. The goal is to print a blank line after printing the byte array is printed above when those if conditions are true. </p>
<p>Any help would be much appreciated and welcome. </p>
| java | [1] |
866,606 | 866,607 | Increasing a number on the first line of a file by 1 with php | <p>I have a script for counting the number of downloads of a file that I downloaded from the internet. Basically it has a log file that it adds a line of text every time the file is downloaded.</p>
<p>I want to modify it slightly so that the first line is a number, and every time a file is downloaded it increases that number by one (So it's easy to see exactly how many people have downloaded it.)</p>
<p>Here's the code I have right now (this isn't working):</p>
<pre><code>$conten = @file_get_contents(LOG_FILE);
//First line: $conten[0];
$content = fgets($conten);
$fo = @fopen(LOG_FILE, 'r+');
if ($fo) {
$content++;
@fputs($fo, ".$content.");
@fclose($fo);
}
$f = @fopen(LOG_FILE, 'a+');
if ($f) {
@fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$fname."\n");
@fclose($f);
}
</code></pre>
<p>The $f part works fine...it's the parts above that which aren't working like I want.</p>
<p>Thanks!</p>
| php | [2] |
348,560 | 348,561 | android - is any differences exits between emulator and device | <p>My application is working properly in the emulator. In Case of Device it is not working properly. it means application is running but in middle of the application it is forcibly stoped. after that i am getting the NPE(Null Pointer Exception). Why it's came? is any differences exits between emulator and device when the running of application. please can anybody help me.</p>
<p>thanks</p>
| android | [4] |
4,254,878 | 4,254,879 | how to apply different touch animations | <p>How to apply different touch animations in one application like(drag,single touch,multiple touch and others). i appreciate your reply.</p>
| iphone | [8] |
4,393,779 | 4,393,780 | How do i find the third longest word in string | <p>Hello im a bit stuck i dont know how to find the third longest word in a string, i have got my code to find the longest but i cant manage to get it to find the third longest. any help?</p>
<pre><code>public void longestWord()
{
string sentance, word;
word = " ";
char[] a = new char[] { ' ' };
sentance = textBox1.Text; //<--string here
foreach (string s1 in sentance.Split(a))
{
if (word.Length < s1.Length)
{
word = s1;
}
}
label9.Text = ("The longest word is " + word + " and its length is " + word.Length + " characters long");
}
</code></pre>
<p>P.S an example of the string im testing is: </p>
<ol>
1.
</ol>
<p>DarkN3ss is my most experienced provider of Windows based business solutions. I focus on delivering my business value in best possible understanding of this technologies and directions.
DarkN3ss recognising me as an “elite business partner” for implementing solutions based on my capabilities and experience with Windows and Linux products.</p>
| c# | [0] |
3,291,982 | 3,291,983 | What does the Python error "name 'self' is not defined" mean? | <p>I can't figure out what's wrong with this <a href="http://ideone.com/wuXCV" rel="nofollow">very simple snippet</a>:</p>
<pre><code>class A(object):
def printme(self):
print "A"
self.printme()
a = A()
</code></pre>
<blockquote>
<p>Traceback (most recent call last): File "prog.py", line 1, in
class A(object): File "prog.py", line 5, in A
self.printme() NameError: name 'self' is not defined</p>
</blockquote>
| python | [7] |
4,564,155 | 4,564,156 | How to raise an action picker with options of Send to via sms, email, etc | <p>I've seen in applications a popup that prompts me what I do want to do with a text. I am prompted to choose from Send by SMS, Send by Email, Send by Bluetooth, Send by Fring etc.</p>
<p>How do I make such a popup, it seamed to be automatically built?<br>
Also how do I tell what message to use?<br>
And if needed how do I tell who the contact is? Maybe chooses the options based on the contact, (if has email, show email)</p>
| android | [4] |
1,513,635 | 1,513,636 | C# White Framework | <p>This question is for any expert on White Framework.</p>
<p>What's White Framework?</p>
<p>As you can see here in <a href="http://white.codeplex.com/" rel="nofollow">http://white.codeplex.com/</a> , it's a powerful framework for automatic functional tests.</p>
<p><strong>Fact</strong>:
Actually, framework is intended to work with calling strongly typed control which are present in a form.</p>
<p><strong>Question</strong>:
It's possible to get a PRECISE control by using the mouse coordinates?</p>
<p><strong>Possible Way:</strong>
I have actually found a possible solution, but it lacks of perfomance, of course.
The way is:</p>
<p>1: Get Window</p>
<p>2: Get all controls of window ( filtered by Text/Edit/Button Control Types )</p>
<p>3: with linq get the control which actual Bounds (x,y,width,height) contains the mouse
location</p>
<p><strong>Better Way</strong>:</p>
<p>?</p>
<p>Thanks,</p>
<p>Luca</p>
| c# | [0] |
865,925 | 865,926 | How to specify onActivityResult() for 2 views? | <p>I have 3 views in my application.
My first view (FIRST_VIEW) has 2 buttons (BTN_2 and BTN_3).
Each button will start seperate views, means BTN_2 causes to start SECOND_VIEW and BTN_3 will start THIRD_VIEW. In my FIRST_VIEW i have one onActivityResult() function. How can I set two onActivityResult() functions for each button result (that is from SECOND_VIEW and from THIRD_VIEW)? How can I specify that onActivityResult() function for each view?
Please Help me.....
Thank you..</p>
| android | [4] |
4,586,972 | 4,586,973 | Is it possible to check whether a background image has been loaded using jQuery? | <p>I am trying to find out whether it is possible to check if a background image has been loaded before fading in the content? The background image is set in the css so if the user doesnt have js turned on they are still able to view the site.</p>
<p>I have tried <code>$(".quick-load").load(function () {
$("#content").fadeIn();
});</code></p>
<p>I have also used .ready() but none have had any effect.</p>
<p>The exact problem i am having is that the image will flicker on some occasions. </p>
<p>Any ideas would be helpful, thanks.</p>
| jquery | [5] |
2,053,802 | 2,053,803 | Shortest way to change an array | <p>I have an array</p>
<pre><code>$a = array('a', 'b', 'c');
</code></pre>
<p>What is the shortest and optimum way to change it to</p>
<pre><code>$a = array('1a1', '1b1', '1c1');
</code></pre>
| php | [2] |
5,533,451 | 5,533,452 | Show an element with handle | <p>I want to show/hide an element with an handle. My dev page is <a href="http://dev.lephonographe.fr/" rel="nofollow">here</a> and the handle is the Contact button. Since I can only show/hide an entire element, I've got a fixed Contact button which can be clicked when the contact page is hidden, and one in the contact page itself when it's shown. The problem is that when the contact page is hiding, it overlaps the fixed Contact button.</p>
<p>I've been given the solution shown <a href="http://jsfiddle.net/rlemon/F6Efp/8/" rel="nofollow">here</a>, but since my element does not start from the top of the screen, with a negative <code>top</code> it's visible outside of the container element.</p>
<p>Is there any way to hide the part of the element which is outside its parent? Or is there any other way to achieve what I want?</p>
<p>Thanks</p>
| jquery | [5] |
1,501,212 | 1,501,213 | Writing in a text file, without overwriting, it in C # | <p>I would like to know if it is possible to write in a text file without overwriting its current contents and without creating or merging Lists of string etc. So lets say i run the program once and i write Hello , and when i run it again i write Everyone so the txt has now Hello Everyone. Moreover, does anyone know how to read only a specific block of line from a file, for example from , to , or from Dear to Best Regards etc. Thanks a lot in advance!!! I hope that my question is clear enough</p>
| c# | [0] |
921,099 | 921,100 | return value of new in java | <p>What would be the return value of new in java in case of insufficient memory? I have the following code </p>
<pre><code>TreeNode newNode = new TreeNode(n);
if(newNode == null)
return false;
</code></pre>
<p>eclipse says that it is a dead code. How should we check for memory error in java?</p>
| java | [1] |
1,020,419 | 1,020,420 | How to swap without third variable in java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/756750/swap-the-values-of-two-variables-without-using-third-variable">Swap the values of two variables without using third variable</a> </p>
</blockquote>
<p>I was asked in an interview to swap two numbers, without using third variable and without using arithmetic operators, i could not figure out.How can we do that ? Is it possible ?. Regrets if this is a immature question</p>
<pre><code>int a =20;
int b =30;
</code></pre>
| java | [1] |
4,125,638 | 4,125,639 | how to create a deck of cards constructor | <p>so far this is what I have</p>
<pre><code>import java.util.Random;
public class DeckOfCards
{
public static final int DECK_SIZE = 52;
//Instance Variables
private boolean[] deck; //An implicit set of 52 Playing-Cards
private int cardsInDeck;//Number of cards currently in the deck
private Random dealer; //Used to rendomly select a card to be dealt
//Constructor
public DeckOfCards()
{
deck = new boolean[52];
for (int j = 0; j<deck.length ; j ++)
deck [j] = false;
</code></pre>
<p>Am I heading the right direction?... What do I do after this? I am not very familiar with boolean arrays</p>
| java | [1] |
4,214,961 | 4,214,962 | getting value using explode | <p>I am trying to parse following string...</p>
<pre><code>IN.Tags.Share({"count":180,"url":"http://domain.org"}
</code></pre>
<p>is my following approach correct to get the value of count?</p>
<pre><code>$str = 'IN.Tags.Share({"count":180,"url":"http://domain.org"}';
$data = explode(':', $str);
$val = explode(',', $data[1]);
return $val[0];
</code></pre>
<p>Or is there any better way to handling this type of strings? I think it could be done using regex as well.</p>
<p>thanks.</p>
| php | [2] |
3,860,314 | 3,860,315 | Processing multiple drag and dropped files fails when using regular expressions | <p>In my application the user can drag and drop multiple text files onto a GUI control to convert them to another format. Here is the relevant code: </p>
<pre><code> private void panelConverter_DragDrop(object sender, DragEventArgs e)
{
string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string filename in filenames)
{
convertFile(filename);
}
}
private void convertFile(string filename)
{
// build name of output file
string convertedFile = Path.ChangeExtension(filename, ".out");
// open input file for reading
FileInfo source = new FileInfo(filename);
StreamReader srcStream = source.OpenText();
// open output file for writing
StreamWriter dstStream = new StreamWriter(convertedFile);
// loop over input file
string line;
do
{
// get next line from input file
line = srcStream.ReadLine();
if (!Regex.IsMatch(line, @"fred=\d+"))
{
dstStream.WriteLine(line);
dstStream.Flush();
}
} while (line != null);
}
</code></pre>
<p>The problem is that when I drop multiple files on the GUI, only one of them actually gets processed. I have found that if I comment out the Regex line, all of the dropped files are processed. Am I missing something in my handling of regular expressions in this context?</p>
| c# | [0] |
2,792,275 | 2,792,276 | How to combine the UItabbar and navigationcontroller without using UItabbarcontroller? | <p>Iam developing on applocation.In that i want to use the UITabbar and navigation controller.Because every tab in the tabbar contain the back and save buttons for saving that tab information and coming back.So i want use the both UItabbar and navigationcontroller.Please tell me how to use both.</p>
| iphone | [8] |
4,755,022 | 4,755,023 | Python dictionary optimize this script | <p>I have a string like <code>rdb_master_mongodb</code> where <code>rdb_</code> is fixed and <code>master</code> is a database name which can be anything and <code>mongodb</code> can be one among <code>mysql</code>, <code>mongodb</code>, <code>postgres</code>, <code>mssql</code> or <code>bdb</code>. I need to fetch the value for this string from the dictionary which has the value in <code>myDict[master][mongodb]</code>. In order to get this I need to split the string <code>rdb_master_mongodb</code> and get the values of <code>master</code> and <code>mongodb</code>. I can't use split because sometimes the string becomes <code>rdb_master_test_mongodb</code>. Hence I have to use <code>endswith</code> to get the exact key. Howeveer, <code>endswith</code> does not work on a list.</p>
<p>I have to get the matching tuple value from a tuple. Right now I do this like:</p>
<pre><code>import re
name = 'rdb_master_mongodb'
s = re.sub('rdb_', "", name)
VALID_DB = ('mysql', 'postgres', 'mongodb', 'mssql', 'bdb')
(a, b, c, d, e) = VALID_DB
if s.endswith(a):
db = a
if s.endswith(b):
db = b
if s.endswith(c):
db = c
if s.endswith(d):
db = d
if s.endswith(e):
db = e
db_name = re.sub('_'+db, "", s)
print db_name+" is "+db
</code></pre>
<p>Is there a better way to do this?</p>
| python | [7] |
2,001,522 | 2,001,523 | How to read pdf file in my appliation | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/10299839/how-to-read-pdf-in-my-android-application">How to read pdf in my android application?</a> </p>
</blockquote>
<p>My application will have a link for a pdf file. When user click on a link, pdf file should download to local storage if it is not already present and my application should open that pdf file in a pop-up window and that popup will have close button at top right corner of window. I don't want default/third party pdf reader to display my pdf file.</p>
<p>Please help me how I can implement this requirement in my application.</p>
| android | [4] |
6,003,048 | 6,003,049 | How to resolve memory issue while scaling / roating a bitmap in android? | <p>I want to zoom and roate a image in an Android activity.
I am doing it as follows </p>
<pre><code> Matrix matrix = new Matrix();
matrix.postRotate(rotation);
matrix.postScale(zoomScale,zoomScale);
Bitmap scaledBitmap = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
imageView.setImageBitmap(scaledBitmap);
</code></pre>
<p>but it gives me a memory error after a few rotations and zooming.
How can i resolve this ? Most application do it pretty efficiently on a daily basis.</p>
| android | [4] |
5,764,381 | 5,764,382 | Storing a random byte string in Python | <p>For my project, I need to be able to store random byte strings in a file and read the byte string again later. For example, I want to store randomByteString from the following code:</p>
<pre><code>>>> from os import urandom
>>> randomByteString=urandom(8)
>>> randomByteString
b'zOZ\x84\xfb\xceM~'
</code></pre>
<p>What would be the proper way to do this?</p>
<p>Edit: Forgot to mention that I also want to store 'normal' string alongside the byte strings.</p>
| python | [7] |
3,688,796 | 3,688,797 | How do I programmatically mute the iPhone or bring the volume to zero? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1465733/setting-iphone-to-vibrate-and-setting-iphone-back-to-sound-via-app">Setting iphone to vibrate and setting iphone back to sound via app.</a> </p>
</blockquote>
<p>I know there are other questions on this same topic, but the iPhone SDK has changed significantly since then.</p>
| iphone | [8] |
1,808,889 | 1,808,890 | Best way to autload class from multiple directory | <p>Hello I'm trying to load classes that are stored in separate directories.
I try with SPL but i must set load directory where to search. </p>
<p>My structure is like in Zend fw:</p>
<blockquote>
<p>|--root</p>
<p>|-- Library</p>
<p>|---- database[dir]</p>
<p>|---------adapter.php</p>
<p>|---------results.php</p>
<p>|-----registry[dir]</p>
<p>|---------format.php</p>
<p>|---------bla-bla.php</p>
<p>|--index.php</p>
</blockquote>
<pre><code>function __autoload($class_name)
{
include LIB."database/".$class_name.".php";
include LIB."registry/".$class_name.".php";
}
</code></pre>
<p>How to autoload all from library (all folders) without definig include LIB."database/","registry" </p>
| php | [2] |
5,948,500 | 5,948,501 | python check if letter part of word in string | <p>I want to write a function which checks whether a letter is part of a word e.g</p>
<pre><code>"u" part of word in "i c u" = false
"u" part of word in "umbrella" = true
</code></pre>
| python | [7] |
288,999 | 289,000 | chart drawing in Java | <p>I draw a chart using Java, but I don't use anything like JChart2D etc.
I opened wolframalpha and draw a plot eg: plot[100*(x^2)] and then when you put a cursor on a plot you will see two crossing lines, which help you specify points. Can i make something like this using Java in jPanel?</p>
| java | [1] |
522,204 | 522,205 | Missing and Additional values in 2 list | <p>I have two lists:</p>
<pre><code>list1 = ['1','2','3','4','5','6']
list2 = ['4','5','6','7','8']
</code></pre>
<p>Now I want to find missing and additional value in list2.</p>
<p>The output should be:</p>
<pre><code>Missing value = 1,2,3
Additional Value = 7,8
</code></pre>
| python | [7] |
4,774,221 | 4,774,222 | How do I make an Android library for static linking that includes resources? | <p>I am successfully linking some of my code stored in a .jar-based library to my Android app. The .jar code references Android library content just fine.</p>
<p>The problem is I need to include 'res' resources in the library but can't work out how to do this.</p>
<p>Any suggestions?</p>
| android | [4] |
2,476,905 | 2,476,906 | Display a list of results with numbers in ASP.NET | <p>I have a common problem in an ASP.NET web form. I'm just surprised that I haven't found a common solution :)</p>
<p>I have a list of results being returned from a SQL Server database. I want to show those results in my web page with number to the left of them. For instance, my result set may look like the following:</p>
<pre><code>New York | NY
Chicago | IL
Los Angeles | CA
</code></pre>
<p>In my web page, I would like to show them as:</p>
<pre><code>1. New York, NY
2. Chicago, IL
3. Los Angeles, CA
</code></pre>
<p>I was surprised that I can't find a way to make the numbers automatically appear. Am i doing something wrong? If not, what is the recommended approach?</p>
<p>Thanks</p>
| asp.net | [9] |
4,330,536 | 4,330,537 | Internet Explorer 8 choking on function call (JavaScript) | <p>I have this line in a function handling click events. It works in Firefox, but not IE8 and I don't see how to create a workaround. (Jquery answers welcome!). </p>
<p>n.b I cannot use the this keyword as in context it will be useless.</p>
<pre><code>elementsList[i].previousSibling.lastChild.addEventListener("click", (function(el){
return function(){
toggle(el)
};
})(elementsList[i]),false);
</code></pre>
<p>edit</p>
<p>To answer comments</p>
<p>elementsList is an array containing various nodes such as divs and p tags.</p>
| javascript | [3] |
817,277 | 817,278 | How I detect what language the current system | <p>How I detect what language the current system?</p>
<p><img src="http://i.stack.imgur.com/cA1M9.jpg" alt="Taskbar"></p>
| c# | [0] |
2,104,008 | 2,104,009 | how to display current location when camera is open in iphone | <p>I am implementing one iphone application in which i want to implement below functionality.</p>
<p>When i open camera infront of any object(i.e Hotel,bank,ATM) then it will display related its information.</p>
<p>I want to implement same functionality same as wikitude which is in apple store.</p>
<p>Please help me for this query or please provide me related info or document or any material.</p>
<p>Thanks in advance.</p>
| iphone | [8] |
5,565,416 | 5,565,417 | how to play wav file in c# | <p>how to play a wav file in c# from windows form resources folder???</p>
| c# | [0] |
3,223,102 | 3,223,103 | Should if statments be in inner or outer method? | <p>Which of these designs is better? What are the pros and cons of each? Which one would you use? Any other suggestions of how to deal with methods like is are appreciated. </p>
<p>It is reasonable to assume that Draw() is the only place that the other draw methods are called from. This needs to expand to many more Draw* methods and Show* properties, not just the three shown here.</p>
<pre><code>public void Draw()
{
if (ShowAxis)
{
DrawAxis();
}
if (ShowLegend)
{
DrawLegend();
}
if (ShowPoints && Points.Count > 0)
{
DrawPoints();
}
}
private void DrawAxis()
{
// Draw things.
}
private void DrawLegend()
{
// Draw things.
}
private void DrawPoints()
{
// Draw things.
}
</code></pre>
<p>Or</p>
<pre><code>public void Draw()
{
DrawAxis();
DrawLegend();
DrawPoints();
}
private void DrawAxis()
{
if (!ShowAxis)
{
return;
}
// Draw things.
}
private void DrawLegend()
{
if (!ShowLegend)
{
return;
}
// Draw things.
}
private void DrawPoints()
{
if (!ShowPoints || Points.Count <= 0))
{
return;
}
// Draw things.
}
</code></pre>
| c# | [0] |
3,807,513 | 3,807,514 | Jquery dialog window example not working | <p>Trying to learn Jquery and am on the verge of giving up!! Have spent 2 days trying to get a dialog box to display! </p>
<p>Can anyone help as to why this code doesnt work? I just get hello at the top of the page!</p>
<p>jQuery:</p>
<pre><code><script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/jquery.ui.core.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var $dialog = $('#dialog')
//.html('This dialog will show every time!')
.dialog({
autoOpen: false,
title: 'Basic Dialog'
});
$('#opener').click(function() {
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
</script>
</code></pre>
<p>HTML</p>
<pre><code><div id="dialog">hello</div>
<button id="opener" style="margin-left:66px;margin-top:3px;font-size:11px;width:60px">Click</button>
</code></pre>
| jquery | [5] |
4,095,103 | 4,095,104 | how can I get the position of a cell in a table using javascript? | <p>By position I mean, how many columns are to the left of the cell and how many rows are on top of it. What I need exactly is two functions:</p>
<pre><code>function FindColPos(element)
{
/* find column position */
return colPos;
}
function FindRowPos(element)
{
/* find row position */
return rowPos;
}
</code></pre>
<p>the functions MUST be written that way, I can't add other stuff to my document like ID's since I only have access to the head of the document where I would insert the javascript functions. (All this is part of another project in C#). The element passed to the function would be a cell in a row (a <code><TD></code> element) but it would be better if I can pass any element inside the <code><TD></code> and the function can recognize the parent <code><TD></code>. I'm not advanced enough on javascript to figure it out myself. I actually don't even know if it's possible. Hope you can help.</p>
| javascript | [3] |
1,255,427 | 1,255,428 | How to create multiple objects based on frequency and date | <p>for some reason, I am unable to figure how to code it in a clean way.
I have a task object and this object has a start date and end date. I want to pass this object to method that will take this task, clone it X number of times according to the frequency and set its start date to the occurance date.</p>
<p>Offcourse, things can be much better illustrated by examples:
So lets say I have task that has start date of June 1 ,2012 and end date of September 15, 2012. The frequency is set to monthly. I want to pass this task to a method that would create an array of 4 tasks for me (June, July, Aug, September) of whose the start date is set to the first of the respective month</p>
<pre><code>ArrayList<task> spawnTasks(Task task, Frequency Monthly){
ArrayList<Task> arr = new ArrayList<Task>();
Task TaskJune = task.clone();
TaskJune.setStartDate("June, 1, 2012");
Task TaskJuly = task.clone();
TaskJuly.setStartDate("July, 1, 2012");
Task TaskAug = task.clone();
Taskaug.setStartDate("Aug, 1, 2012");
Task TaskSept = task.clone();
TaskSept.setStartDate("Sept, 1, 2012");
}
</code></pre>
<p>So as you can see I created the task once a month because frequency is monthly ( I can have biweekly or monthly only) and it happened on the 1st because thats the start date and it never exceeded september because the enddate is sept 15.</p>
<p>I know I have to use Calendar and loop to do it but I just can't figure it out</p>
| java | [1] |
234,593 | 234,594 | have my dns server | <p>I have my own registered domain. I want to set up my own DNS server and host a website completely independent of any third party hosting service. I have Windows Server 2003 and have installed the DNS role and configured it with a single forward zone (I am new to this terminology and am not sure if I am using it correctly). Lets say my domain is xyz.com I have the DNS role set up for xyz.com as the domain with a forward lookup zone. Also, I have reserved an internal IP to my server using the router's DHCP reservation list. So I basically have a static IP for my server on the internal network. How do I go about setting up this infrastructure so that I can have my own DNS set up and host my website ?</p>
| asp.net | [9] |
4,792,056 | 4,792,057 | Calling [super scrollViewDidScroll]; on subclass of UIWebView crashes | <p>I'm not sure how this works. I was following this post: <a href="http://stackoverflow.com/questions/8857655/check-if-uiwebview-scrolls-to-the-bottom">check if UIWebView scrolls to the bottom</a></p>
<p>I want to know when the scrollViewScrolls to do some custom things. I subclasses UIWebView. All I did was this so far:</p>
<pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[super scrollViewDidScroll:scrollView];
NSLog(@"%s", __FUNCTION__);
}
</code></pre>
<p>It crashes on the <code>[super scrollViewDidScroll:scrollView]</code> method. When I delete that line, it works fine. I don't want to take away the superclass' implementation of this method. I just wanted to add some custom functionality to it (place a toolbar above the webview like the Facebook app). Is there a reason why this is crashing? Thanks.</p>
| iphone | [8] |
388,771 | 388,772 | landscape view not shows image and portrait show | <p>I want to load image runtime in my activity but it is load in portait view only.
If I want to load it in landscape it doesn't.
I also do it by both seprate xml for landscape and portrait.
and also try by only one xml.
I draw image like this</p>
<pre><code> result_img.setImageDrawable(getResources().getDrawable(R.drawable.invalid_title));
</code></pre>
<p>But it draw in only portait layout.</p>
| android | [4] |
3,018,816 | 3,018,817 | jquery hide element not working | <p>I searched SO for a fix for this, found it, but my implementation seems flawed. Any clues?</p>
<pre><code> $(document).ready(function(){
$('#updt').ajaxForm(function(data) {
if (data==1){
$('#success').fadeIn("slow");
$('#updt').resetForm();
setTimeout(function() {
$("#success").hide('blind', {}, 500)
}, 5000);
}
else if (data==2){
$('#badserver').fadeIn("slow");
}
else if (data==3)
{
$('#bademail').fadeIn("slow");
}
});
});
</code></pre>
| jquery | [5] |
3,724,604 | 3,724,605 | Editing the LMC button which copy to clipboard | <p>I have some problems with <a href="http://www.lettersmarket.com/view_blog/a-3-copy_to_clipboard_lmcbutton.html" rel="nofollow">LMC Button</a> because of the way it is coded.</p>
<pre><code>ShowLMCButton('Copied Text Here');
</code></pre>
<p>An image "Copy" is loaded when the page loads, with the words "Copied Text Here" being copied to clipboard when the image is clicked on.</p>
<p>If I do this:</p>
<pre><code>var text = "New Text";
ShowLMCButton(text);
</code></pre>
<p>The words "New Text" is copied to the clip no problem, but the variable text have to be there on page load. There is no way I can change the words.</p>
<p>This is the ShowLMCButton function</p>
<pre><code>function ShowLMCButton(cliptext, capt, js, furl)
{
var params = 'txt=' + encodeURIComponent(cliptext);
if (!isNotEmpty(furl)) { furl = "clippy/lmcbutton.swf"; }
if (isNotEmpty(capt)) { params += '&capt=' + capt; }
if (isNotEmpty(js)) { params += '&js=' + js; }
document.write('<object width="40" height="20">');
document.write(' <param name="movie" value="' + furl + '">');
document.write(' <PARAM NAME=FlashVars VALUE="' + params + '">');
document.write(' <embed src="' + furl + '" flashvars="' + params + '" width="40" height="20"></embed>');
document.write('</object>');
//alert('file: ' + furl + ' Params: ' + params); // debug
}
</code></pre>
<p>How can I copy text that I type in a textarea/input textfield?</p>
<p><a href="http://www.lettersmarket.com/uploads/lettersmarket/lmcbutton/demo_lmcbutton.html" rel="nofollow">Here is the demo of the button</a></p>
| javascript | [3] |
3,918,072 | 3,918,073 | Jquery & Variable ID Names | <p>I am trying to avoid having the same code for different ids. Something like submitter1, submitter2, etc. In the same process, having the variable also used to get the input box id of differentlocation1, differentlocation2, etc. Can someone help me out with the code below?</p>
<pre><code>$(document).ready(function() {
$('#submitter<--Variable Here-->').click(function(event) {
event.preventDefault();
var newlocation = $("input[name=differentlocation"<--Same Variable Here-->"']");
alert(newlocation); //testing purposes
//$('#location').val(newlocation).change(); //Changes location input box
//$("#submit").click(); //submits new location
});
});
</code></pre>
<p>This code works using static ids, but like I said I would like to adjust it to use variable ids as well. </p>
<p>Thanks.</p>
| jquery | [5] |
3,374,465 | 3,374,466 | How to overcome special characters in Rss feed in android? | <p>i have <code>rss feed</code> when sax parsing the rss feed . it can't parse
the entire feed due to some special characters problem like <code>&</code> and <code>€”</code>.
how to overcome this problem and display entire feed <code>(item)data</code> in <code>strings</code>.</p>
| android | [4] |
5,393,361 | 5,393,362 | Any ideas about the best work around for __new__ losing its arguments? | <p>So, I only realised today that <code>__new__</code> is deprecated for receiving arguments, as of python 2.6 (it isn't mentioned in the documentation, which is also not true in terms of the behavior of <code>__new__</code> calling <code>__init__</code> as far as I can see). This means my functional code has started raising warnings, and I want to rid myself of them. But I can't see an elegant way to work around.</p>
<p>I have a bunch of classes that perform optimizations when they are constructed. So I have</p>
<pre><code>class Conjunction(Base):
def __new__(cls, a, b):
if a == True:
return b
elif b == True
return a
else:
return super(Conjunction,cls).__new__(cls, a, b)
</code></pre>
<p>And so on (real versions cover lots more cases). So unlike what Guido says in <a href="http://mail.python.org/pipermail/python-dev/2008-February/076854.html" rel="nofollow">this response</a> (the only reference to it I can find), my <code>__new__</code> method <em>does</em> use its arguments, and <em>cannot</em> be replaced by an overridden <code>__init__</code> function.</p>
<p>The best I can do is to split this in two:</p>
<pre><code>def Conjunction(a, b):
if a == True:
return b
elif b == True
return a
else:
return ConjunctionImpl(a, b)
class ConjunctionImpl(Base):
# ...
</code></pre>
<p>But that is plain ugly and stinks to high heaven. Am I missing an elegant way to have a class constructor return some arbitrary object based on the constructor parameters it is given?</p>
| python | [7] |
2,957,245 | 2,957,246 | Image button in PHP doesn't work properly | <p>I have an image button on my PHP page. I need to execute a piece of code when this button is clicked. I'm trying the following.</p>
<pre><code><?php
if(isset($_POST['btnSubmit']))
{
echo "Do some stuff.";
}
?>
<input type="image" name="btnSubmit" id="btnSubmit" src="images/btnsubmit.gif">
</code></pre>
<p>When I click the button <code>btnSubmit</code>, the <code>if</code> condition should be evaluated to true and the message within the <code>if</code> body should be echoed to the web page but the condition is never satisfied when I click this button. </p>
<p>When I change the button type to <code>type='submit'</code>, it works. I need to use the <code>type='image'</code> anyhow. How can I do that?</p>
| php | [2] |
2,015,172 | 2,015,173 | How can I dispose/release a string file in this case? | <p>Im trying to use using but getting error on the using it self.</p>
<pre><code>public void Save(string path , bool Locked , PictureBox pb)
{
string fn;
string t = Path.GetFileNameWithoutExtension(wo_name);
if (File.Exists(path + "\\" + "DATABASE" + "\\" + t + "\\" + wo_name))
{
using (string f = Path.Combine(path + "\\" + "DATABASE" + "\\" + t + "\\" + wo_name))
{
File.Delete(f);
}
fn = path + "\\" + "DATABASE" + "\\" + t + "\\" + wo_name;
}
else
{
fn = path + "\\" + "DATABASE" + "\\" + wo_name + "\\" + wo_name + ".txt";
}
OptionsFile setting_file = new OptionsFile(fn);
setting_file.SetKey("File Name", fn);
setting_file.SetKey("Version", version);
setting_file.SetKey("Button Lock", Locked.ToString());
setting_file.SetKey("picturebox.Width", pb.Width.ToString());
setting_file.SetKey("picturebox.Height", pb.Height.ToString());
setting_file.SetListFloatKey("Coordinates_X", woc.Point_X);
setting_file.SetListFloatKey("Coordinates_Y", woc.Point_Y);
setting_file.SetListIntKey("ConnectionStart", connectionStart);
setting_file.SetListIntKey("ConnectionEnd", connectionEnd);
}
</code></pre>
<p>In this save function above i did:</p>
<pre><code>using (string f = Path.Combine(path + "\\" + "DATABASE" + "\\" + t + "\\" + wo_name))
{
File.Delete(f);
}
</code></pre>
<p>Before it there was just string f = ....Path.... and the Fiel.Delete
I just added the using but on the using im getting error: 'string': type used in a using statement must be implicitly convertible to 'System.IDisposable'</p>
| c# | [0] |
373,495 | 373,496 | Android's Processes | <p>I need to know some information about all android's basic processes, such as</p>
<ul>
<li>com.android.phone<br/></li>
<li>android.process.acore<br/></li>
<li>com.android.mms<br/></li>
<li>com.android.alarmclock<br/></li>
<li>com.android.calendar<br/></li>
<li>android.process.media<br/></li>
<li>com.android.voicedialer<br/></li>
<li>android.process.im<br/></li>
</ul>
<p>unfortunately, i could not find any good information on the internet<br/>
Thanks for your cooperation.</p>
| android | [4] |
4,585,820 | 4,585,821 | To check if an element exists in the Stacked List | <p>I was supposed to code pop, push and contains for linkd List Stack. I did manage to get pop and push to work but had no luck with contains. For some strange reason it always returns false even if the thing is in the list, could any one help.</p>
<hr>
<p>public class LinkedListStack implements Stack {</p>
<pre><code>IntNode<E> front;
IntNode<E> current = front, previous;
private int size =0;
public void push(Object o) {
IntNode<E> temp = new IntNode<E>((E) o);
if(current==null && size==0){
current = temp;
front = temp;
}else{
current.link = temp;
previous = current;
current = temp;
}
size++;
}
public E pop() {
IntNode<E> pop = current;
current = previous;
previous = null;
size--;
return (E)pop;
}
public boolean contains(Object find) {
IntNode<E> temp = front;
while(temp!=null){
if(temp.equals((find))){
return true;
}else{
temp = temp.link;
}
}
return false;
}
</code></pre>
<p>}</p>
| java | [1] |
2,400,284 | 2,400,285 | How should Deep Copy Work? | <p>OK when doing a deep copy obviously references should not be copied. However, if the object being copied contains objects that themselves are references to to the same object should that be maintained or should the data just be copied.</p>
<p>Example</p>
<pre><code>public class Program() {
public void Main(String[] args) {
Person person = new Person();
person.setName("Simon");
List<Person> people = new ArrayList<Person>();
people.add(person);
people.add(person);
people.add(person);
List<Person> otherPeople = magicDeepCopyFunction(people);
otherPeople.get(0).setName("Adam");
// should this output 'Adam' or 'Simon'?
System.out.println(otherPeople.get(1));
}
}
</code></pre>
<p>I can see arguments for both but I am wondering what the consensus was.</p>
| java | [1] |
5,757,447 | 5,757,448 | Why do I need to use a lambda expression here instead of using the model object property directly? | <p>I am following an ASP.net MVC 3 tutorial , which sets up an online music store .</p>
<p>This code is the <code>Delete.cshtml</code> view for <code>StoreManagerController.cs</code></p>
<pre><code>@model MyStore.Models.Album
@{ ViewBag.Title = "Delete";}
<h2>Delete</h2>
<h3>Are you sure you want to delete this?</h3>
@Html.DisplayFor(model => model.Genre.Name)
</code></pre>
<p>What I'd like to know is , in the last line, why cant we do this</p>
<pre><code>@Html.DisplayFor(model.Genre.Name)
</code></pre>
<p>Why is a lambda expression used here?
Thanks</p>
| asp.net | [9] |
797,766 | 797,767 | Trying to wrap my head around objects, constructors and prototypes | <p>Consider the following code:</p>
<pre><code>function Robot(weapon) {
this.weapon = weapon;
this.fire = function() {
alert('Firing ' + this.weapon + 'projectile.');
};
}
var gunRobot = new Robot('gun');
</code></pre>
<p>vs.</p>
<pre><code>function makeRobot(weapon) {
return {
weapon: weapon,
fire: function() {
alert('Firing ' + this.weapon + 'projectile.');
}
};
}
var laserRobot = makeRobot('laser');
</code></pre>
<p>So, if I understood right, the main difference between these two is that in the first example, gunRobot has a constructor property which points to Robot, whereas in the second example, laserRobot has a construtor property which points to Object. Both don't add anything to their prototype, right?</p>
<p>Now, if I change the first example to:</p>
<pre><code>function Robot(weapon) {
this.weapon = weapon;
}
Robot.prototype.fire = function() {
alert('Firing ' + this.weapon + 'projectile.');
};
var gunRobot = new Robot('gun');
</code></pre>
<p>gunRobot's constructor property points to the Robot constructor, whose prototype property has a property fire. Now, if I call</p>
<pre><code>gunRobot.fire();
</code></pre>
<p>as, gunRobot doesn not have a fire property, the next prototype up in the prototype chain is visited and checked for a fire property, right?</p>
<p>I'm mainly a Java programmer, so it's quite hard to wrap my head around JS notion of object-orientation :-).</p>
| javascript | [3] |
4,770,570 | 4,770,571 | logging and wrapping exceptions. is this good practice? | <p>Do you think it's worth it to wrap all service methods in a try catch block to log exceptions like this:</p>
<pre><code>public void attachClean(Car instance) {
log.info("attaching clean Car instance");
try {
getSessionFactory().getCurrentSession().lock(instance, LockMode.NONE);
log.info("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
</code></pre>
<p>it seems like a lot of typing</p>
| java | [1] |
1,909,903 | 1,909,904 | How do I check if a function is being passed as a parameter? | <h2>Question:</h2>
<p><strong>How do I check if a function is being passed as a parameter?</strong></p>
<p>Especially if the function being passed is returning a string etc?</p>
<p>IE in the example below I don't want to htmlentities the function html being passed as a parameter, but I do want to htmlentities anything else. Also assuming there could be more than a single parameter that needs to take a function later.</p>
<h3>Example:</h3>
<pre><code>function html($tag,$content)
{
if(!is_callable($content)){$var=htmlentities($var, ENT_NOQUOTES, "UTF-8");}
return "<".$tag.">".$content."</".$tag.">";
}
echo html(html('Example','Example'),'Example');
</code></pre>
<p>This example does not seem to work for me. I still get htmlentitied content when its a function.</p>
| php | [2] |
3,991,677 | 3,991,678 | Getting data with out scraping | <p>I've got a directory where people submit data. It's stored and pending while it's moderated to make sure it's o.k.</p>
<p>Once approved I'd like another couple of sites that I control and a few I won't (on different servers) to be able to grab that data. This would be on a cron or something so there wouldn't be any human interaction. Moderation is fully dependent on that first moderation.</p>
<p>How do I go about doing this securely.</p>
<p>I've thought about grabbing it as rss, parsing and storing. I've thought about doing soap requests, grabbing xml files, etc....</p>
<p>What would YOU do?</p>
| php | [2] |
504,404 | 504,405 | Calling a function in jquery? | <pre><code>// Explicit global
$.fn.getRedemptionID = function(){
window.varMy = data.DATA[0].item1;
}
</code></pre>
<p>How do you call the above function to get the variable varMy ?</p>
| jquery | [5] |
3,920,733 | 3,920,734 | can we configure google+ in our iPhone application? | <p>Actually i need to provide google + connectivity in an universal application so is there any one who can help me or can provide me any reference to start on it.</p>
<p>As we configure facebook in our iPhone application.</p>
<p>Thank u in advance (you guys are great)</p>
| iphone | [8] |
831,996 | 831,997 | PHP syntax error issue | <p>I am getting this weird issue for my php script. </p>
<p>I have </p>
<pre><code>Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
in simpleTest.php on line 82
</code></pre>
<p>I am not sure why my codes not working. </p>
<pre><code><?php
foreach ( $response->getPods() as $pod ) {
?>
<tr>
<td>
<h3><?php echo $pod->attributes['title']; ?></h3> //line 82..this gives me error...
<?php
foreach ( $pod->getSubpods() as $subpod ) {
?>
<img src="<?php echo $subpod->image->attributes['src']; ?>"> //this would gives me error too...
<hr>
<?php
}
?>
</code></pre>
<p>Thanks for the help!</p>
| php | [2] |
105,714 | 105,715 | How to redirect URLs to login page? | <p>I have an application which has a login page which comes up with the URL: </p>
<p><a href="http://localhost:8080/Analyze" rel="nofollow">http://localhost:8080/Analyze</a> </p>
<p>when the user fills the login page and clicks submit.it goes to a page with the URL: </p>
<p><a href="http://localhost:8080/Analyze/analyze" rel="nofollow">http://localhost:8080/Analyze/analyze</a> </p>
<p>Now if i copy the url:http://localhost:8080/Analyze/analyze and paste in a new browser window I get </p>
<p>HTTP Status 405 - HTTP method GET is not supported by this URL </p>
<p>What can I do to redirect back to the login page: </p>
<p><a href="http://localhost:8080/Analyze" rel="nofollow">http://localhost:8080/Analyze</a> if I copy paste <a href="http://localhost:8080/Analyze/analyze" rel="nofollow">http://localhost:8080/Analyze/analyze</a> in a new browser window. </p>
| java | [1] |
961,456 | 961,457 | how to break out from outer each loop | <p>I have the following scenario:</p>
<pre><code>$.each(array, fucntion() {
...
$.each(array1, function() {
if condition () { }
});
});
</code></pre>
<p>How can I break out of outer <code>each</code> loop when my condition evaluates to true inside the inner <code>each</code> loop?</p>
| jquery | [5] |
5,659,638 | 5,659,639 | Split a list to individual entries | <p>I am extracting some emails from a CSV file and then saving it to another CSV file.</p>
<p>email variable should be in this format: </p>
<pre><code>email = ['[email protected]'], ['[email protected]'], ['[email protected]']
</code></pre>
<p>but in certain cases it will be returned as: </p>
<pre><code>email = ['[email protected]', '[email protected]'], ['[email protected]']
</code></pre>
<p>In certain rows it finds 2 emails, so that is when it is presented like this.</p>
<p>What would be an efficient way to change it??</p>
| python | [7] |
4,884,172 | 4,884,173 | is there any easy way to expose methods of private parent class c++ | <p>Is there any way to directly expose some methods of private parent class.
In the following example if I have an object of type Child I want to be able to directly call method a() of its parent, but not b();
Current solution spawns a lot of boilerplate code especially if there are a lot of arguments.</p>
<pre><code>class Parent {
public:
void a(int p1, double p2, int p3, std::vector <int> &p4);
void b();
};
class Child : private Parent {
public:
void a(int p1, double p2, int p3, std::vector <int> &p4) {
Parent::a(p1, p2, p3, p4);
}
};
</code></pre>
| c++ | [6] |
5,252,087 | 5,252,088 | Working of Treeset | <pre><code>import java.util.*;
public class Explorer1
{
public static void main(String[] args)
{
TreeSet<Integer> s = new TreeSet<Integer>();
TreeSet<Integer> subs = new TreeSet<Integer>();
for(int i = 606; i < 613; i++) if(i%2 == 0) s.add(i);
subs = (TreeSet)s.subSet(608, true, 611, true);
s.add(609);
System.out.println(s + " " + subs);
}
}
</code></pre>
<p>O/P: [606, 608, 609, 610, 612] [608, 609, 610]<br>
Can any explain why 609 is getting added to <code>subs</code> as it is added after assigning to object.</p>
| java | [1] |
2,848,138 | 2,848,139 | mail parsing subject encoding | <p>i am using this class <a href="https://code.google.com/p/php-mime-mail-parser" rel="nofollow">https://code.google.com/p/php-mime-mail-parser</a></p>
<p>to parse emails</p>
<p>class is fully of problems</p>
<p>today i found big one</p>
<p>i have just recieved message from gmail now</p>
<p>message subject is encoded, and i can't decode it!</p>
<pre><code>Subject: =?windows-1256?B?4+XjIMzPx/AgyO3kx8ogys7VIMfhz+bj7eQ=?=
From: Some One <[email protected]>
</code></pre>
<p>i can't decode the subject..</p>
<p>any one know a better mail parsing class?</p>
<p>IF NO: How can i decode this subject?</p>
| php | [2] |
1,816,421 | 1,816,422 | Removing a python module from $pythonpath | <p>Is there any way to 'uninstall' a module from the python path other than removing the files manually?</p>
<p>Pip, easy_install, setuptools etc all have install options, but no remove options!</p>
<p>I'm using Ubuntu 9.10</p>
| python | [7] |
2,629,781 | 2,629,782 | Check the type of derived class | <p>In my program I have a class named Entity. Another class Invader inherits Entity. Since I want to have 4 different kinds of invaders, I declare classes Invader1, Invader2, Invader3 and Invader4 which inherit from Invader. Now I declare a Entity pointer type vector to store all Invaders like:</p>
<pre><code>entities.push_back(new Invader4());
entities.push_back(new Invader3());
entities.push_back(new Invader2());
entities.push_back(new Invader1());
entities.push_back(new Invader0());
</code></pre>
<p>When I check the type of the element in entities at runtime, say</p>
<pre><code>typeid(*entities->at(index))
</code></pre>
<p>It may return one of the 4 kinds of invaders. In entities there are also other objects which inherit Entity. So i just want to check if the type of the object is Invader or not, I don't want to know if it is Invader1, Invader2, etc.</p>
<p>How I can achieve this?</p>
| c++ | [6] |
2,336,513 | 2,336,514 | How to stop running iphone app in background in iphone sdk 4.0 and above | <p>Please tell me some solution for how to stop app at background when we close the app in iphone sdk 4.0 and above.</p>
<p>can any one provide me some sample code for it.</p>
<p>Thanks,
Priyanka</p>
| iphone | [8] |
2,416,983 | 2,416,984 | making single client and server | <p>I have written a client server program:</p>
<pre><code> {
import java.net.*;
class verify {
public static int serverPort=998;
public static int clientPort=999;
public static int buffer_size=1024;
public static DatagramSocket ds;
public static byte buffer[]=new byte[buffer_size];
public static void TheServer() throws Exception {
int pos=0;
while (true) {
int c=System.in.read();
switch(c) {
case -1:
System.out.println("server quits");
return;
case '\r':
break;
case '\n':
ds.send(new DatagramPacket(buffer,pos,InetAddress.getLocalHost(),clientPort)) ;
pos=0;
break;
default:
buffer[pos++] = (byte) c;
}
}
}
public static void TheClient()throws Exception {
while(true) {
DatagramPacket p=new DatagramPacket(buffer,buffer.length);
ds.receive(p);
System.out.println(new String(p.getData(),0,p.getLength()));
}
}
public static void main(String args[]) throws Exception{
if(args.length==1) {
ds=new DatagramSocket(serverPort);
TheServer();
} else {
ds=new DatagramSocket(clientPort);
TheClient();
}
}
}
}
</code></pre>
<p>Can I make my pc both server and client.If yes please suggest a way out.</p>
| java | [1] |
2,436,497 | 2,436,498 | get identifier of link given the class jquery | <p>i have this piece of html</p>
<pre><code><li><a href="#" id="9000" class="yes vpslink"><img src="x.gif" /></a></li>
<li><a href="#" id="9001" class="no vpslink"><img src="x.gif" /></a></li>
$('.vpslink').click(function(e) {
var id='i dont know dude';
alert('you clicked on id'+id);
});
</code></pre>
<p>How do I find the id of this class, link ?</p>
| jquery | [5] |
2,810,325 | 2,810,326 | Put select element in a javascript prompt? | <p>I would like to have a javascript prompt pop up that has a selection element in it rather than a text input. When searching for a solution it seems that using jquery could definitely work but I am new to HTML and javascript and the tutorials for a jquery popup are daunting (I cannot figure out how to implement them)! Is it possible to create such a pop up with just javascript? I was hoping something like this would be possible:</p>
<pre><code>prompt(<select>[options...]</select>);
</code></pre>
<p>Thanks in advance! </p>
| javascript | [3] |
2,014,122 | 2,014,123 | JQuery multiple hover effects not working | <pre><code>$(document).ready(function () {
$("#aboutme-block").hide();
$("#stories-block").hide();
$("div.aboutme").hover(function () {
$("#aboutme-block").fadeIn(1000);
$("#stories-block").hide();
});
$("div.stories").hover(function () {
$("#stories-block").fadeIn(1000);
$("#aboutme-block").hide();
});
});
</code></pre>
<p>Could someone tell me what is wrong here?</p>
| jquery | [5] |
4,090,071 | 4,090,072 | PHP classes, inheriting, implements | <p>I am looking at <a href="http://stackoverflow.com/questions/3548253/should-i-use-multiple-classes-for-game">Should I use multiple classes for game?</a> - Robert Pitt's answer.</p>
<pre><code>interface Weapons {
public function Fire();
}
class Colt implements Weapons {
function Fire() {
echo 'Fire!';
}
}
abstract class Human implements Colt
{
}
class Sniper extends Human
{
public function __construct()
{
}
}
</code></pre>
<p>On the "Human" am I perhaps to implement the "Weapons" rather then Colt, and then on the "Sniper" initialize the Right weapon class?</p>
<pre><code>class Sniper extends Human
{
public $weapon;
public function __construct($weapon)
{
$this->weapon = new $weapon;
}
$this->weapon->fire();
}
</code></pre>
<p>Or something like that? I am confused of how it works..</p>
<pre><code>EXAMPLE 1
class A {
public $class;
__construct() {
$this->class = new $class;
}
hello() {
$this->class->hello();
}
}
class B {
public function hello() {
echo 'hi';
}
}
</code></pre>
| php | [2] |
3,163,245 | 3,163,246 | Access COM DLL using VS 2008 on Windows 7 64 bit | <p>I am using Windows 7 64 bit OS and VS 2008 SP1 as development environment.</p>
<p>One of the console application uses a COM component. When I try to create an instance of a class from the COM component, I got following error:</p>
<p>Creating an instance of the COM component with CLSID {CE92C3B9-9A93-40E1-85AB-6A49170AEF7F} from the IClassFactory failed due to the following error: 80010105.</p>
| c# | [0] |
528,904 | 528,905 | Why is this giving error on using in built qsort | <p>I have written some piece of code which is giving me the error . The code is as follows :- </p>
<pre><code> long long int compare (const void * a, const void * b)
{
return ( *(long long int*)a - *(long long int*)b );
}
long long int number;
long long int *ar =(long long int *)(malloc(sizeof(long long int)*number));
//Took the values of number and ar from and then performed the following
qsort(ar,number,sizeof(long long int),compare);
</code></pre>
<p>This code results into following error :-</p>
<p><code>invalid conversion from long long int (*)(const void*, const void*)' to int (*)(const void*, const void*) initializing argument 4 of void qsort(void*, size_t, size_t, int (*)(const void*, const void*))'</code> </p>
<p>what am i doing wrong here ? </p>
| c++ | [6] |
4,360,802 | 4,360,803 | bit pattern(variable value) for boolean in java? | <p>as we know in java variables are bit holders with a designated type. And for primitives the bits represents a numeric value. </p>
<p>For example. a byte with value 6 has a bit pattern 00000110.</p>
<p>so i wanted to know as boolean is also a primitive what is the bit pattern for it for value true and false.</p>
| java | [1] |
6,012,599 | 6,012,600 | Android Intent Button To Market | <p>I am trying to get a button on my app go to the market place when clicked. Not to another app, but to my publisher area with all my apps. Can anyone help, it just seems to force close at the moment?</p>
<p><code>final String APP_MARKET_URL = "market://developer?pub=PUB+ID+HERE";</code></p>
| android | [4] |
4,782,723 | 4,782,724 | send sms for a missed calls | <p>i would like to develop an app that send a message when ever that receives a missed
call.but i have a problem when ever i start that activity that send the sms to previous
ones how to solve this problem,i have a small idea a set that particular missed call as
read or delete it other wise my app has to access the missed the missed calls i a
specific peroid of time
try{</p>
<pre><code> cursor = getContentResolver().query(
Uri.parse("content://call_log/calls"),
projection,
selection,
selectionArgs,
sortOrder);
// cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.MISSED_TYPE));
while (cursor.moveToNext()) {
String callLogID = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls._ID));
String callNumber = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NUMBER));
String callDate = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.DATE));
String callType = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.TYPE));
String isCallNew = cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.NEW));
//String missedcall= cursor.getString(cursor.getColumnIndex(android.provider.CallLog.Calls.MISSED_TYPE));
/*if(Integer.parseInt(callType) == android.provider.CallLog.Calls.MISSED_TYPE && Integer.parseInt(isCallNew) > 0){
tv.append("hai");
//if (_debug) Log.v("Missed Call Found: " + callNumber);
}*/
if(cursor.getString(cursor.getColumnIndexOrThrow(android.provider.CallLog.Calls.TYPE)).equalsIgnoreCase("3") && Integer.parseInt(isCallNew)>0)
{
tv.append("ok"+callNumber+"\n");
sm.sendTextMessage(callNumber, null, " iam in work i will call you later", null, null);
}
}
}catch(Exception ex){
//if (_debug) Log.e("ERROR: " + ex.toString());
</code></pre>
| android | [4] |
4,853,467 | 4,853,468 | PHP Send Mail Alternative | <p>I know PHPMailer and I'm using this but I have some user groups and send multiple emails to multiple groups, so at this time it runs too slow. Is there any other way or any third party tools? Is there any library?
thanks in advance</p>
| php | [2] |
1,805,027 | 1,805,028 | background image in html page in iphone | <p>I m the beginner in iphone development.</p>
<p>How i call the background image from my project directory in Xcode in html page. I have taken previously UISegment control and after that i calling two html page on webview in uisegmentcontroller.
Now i want to set background images on those html pages.
It is possible?
if it is yes then how?</p>
<p>thanks in advance..</p>
| iphone | [8] |
1,928,661 | 1,928,662 | constants in Python: at the root of the module or in a namespace inside the module? | <p>I'm building a Python module with about a hundred of constants.</p>
<p>I would like to avoid naming issues when people import my module so I was wondering what is the best way to do it.</p>
<pre><code>MY_CONSTANT = 1
MY_SECOND_CONSTANT = 2
...
MY2_CONSTANT = "a"
MY2_SECOND_CONSTANT = "b"
...
</code></pre>
<p>Or</p>
<pre><code>class My:
CONSTANT = 1
SECOND_CONSTANT = 2
...
class My2
CONSTANT = "a"
SECOND_CONSTANT = "b"
...
</code></pre>
<p>Or maybe another of your suggestion?</p>
<p>Coming from Java, I surely prefer the second way, but some might find it overkill...</p>
| python | [7] |
1,667,627 | 1,667,628 | How to print to the screen - "console.log is not a function" | <p>I have tried numerous ways...what am I doing wrong??? I am determined to learn and really understand this.</p>
<pre><code>//On line 2, declare a variable myName and give it your name.
var myName = "Jeanne";
//On line 4, use console.log to print out the myName variable.
console.log ("Jeanne");
//On line 7, change the value of myName to be just the first 2 letters of your name.
myName.substring(0, 2);
//On line 9, use console.log to print out the myName variable;
console.log("Jeanne");
</code></pre>
| javascript | [3] |
5,943,612 | 5,943,613 | how to change keyboard language programmatically | <p>I have made android app. my client ask me that change default language at soft keyboard case by case. one case, keyboard should be English keyboard, another, Korean keyboard.</p>
<p>how can i do?</p>
| android | [4] |
5,147,180 | 5,147,181 | Hosting Windows Forms control inside ASP.NET page - IE only? | <p>I've just found out that there is a possibility to host a Windows Forms control inside ASP.NET page. But I'm wodnering - will it run only in IE or in other browsers, such as Firefox, too?</p>
| asp.net | [9] |
1,785,658 | 1,785,659 | handling EOFException in java | <p>I have created a method in my java assignment to write into a file from a <code>LinkedList</code> (I used serialization) , then I have created another method to read the file into the <code>inkedList</code>. The following is my method's body:</p>
<pre><code>try {
FileInputStream fin = new FileInputStream("c:\\Info.ser");
ObjectInputStream ois = new ObjectInputStream(fin);
Employee e = (Employee) ois.readObject();
linkP.add(e);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
</code></pre>
<p>but it doesnt work right. I think this part:</p>
<pre><code>Employee e = (Employee) ois.readObject();
linkP.add(e);
</code></pre>
<p>reads only the first object of the file into the linkedlist and ignores other objects. I surrounded it for loop and while loop several times but it causes <code>EOFException</code>. How can I change my method to read all of the file's objects into the LinkedList?</p>
| java | [1] |
916,082 | 916,083 | Correct usage of GetComputerName - Do I need to reserve extra space for null character | <p>I was wondering, what is the correct usage of <a href="http://msdn.microsoft.com/en-us/library/ms724295%28v=vs.85%29.aspx" rel="nofollow">GetComputerName</a>. Should it be</p>
<pre><code>TCHAR computerName[1024 + 1];
DWORD size = 1024;
GetComputerName(computerName, &size);
</code></pre>
<p>or</p>
<pre><code>TCHAR computerName[1024];
DWORD size = 1024;
GetComputerName(computerName, &size);
</code></pre>
| c++ | [6] |
2,080,160 | 2,080,161 | asp.net datagrid sorting | <p>I have a datagrid that is displaying data that is being returned from a stored procedure. That works fine. The problem is that I want to do sorting. I know that there is sorting functionality in the grid, however, I don't want to go back to the server and get a new set of data. What I want to do is just re-sort the data that is already being displayed.</p>
<p>Anyone have any ideas on how that is done?</p>
<p>Thanks!</p>
<p><strong>UPDATE</strong></p>
<p>Basically, I couldn't not find an easy solution to this issue. I tried updating my dataGrid to a gridView control and even that (for my particular issue) was difficult. I wound up un-doing all the changes and just adding another grid that had just the data I wanted for the requirement. </p>
<p>If anyone else has an issue like this I would recommend taking it out of a datagrid and writing it in jQuery. I could of written a table that had the data I wanted (and fully sortable using a plug-in mentioned below) in 15 minutes compared to the hours I spent trying to jam a square peg into a round hole.</p>
| asp.net | [9] |
965,827 | 965,828 | Monthly calendar | <p>I am new to C# is know some visual basic but I don't know C#. Now my question is I have a monthly calendar on my page and when someone selects the date and hits the submit button the date should appear in the label to the right. Here is a part of my code:</p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
label6.Text = monthCalendar1.Text;
}
private void label6_Click(object sender, EventArgs e)
{
label6.Text = monthCalendar1.SelectionStart.ToShortDateString();
}
</code></pre>
<p>I am not understanding why it is not working.</p>
<p>Edit: What is not working is the label for the calendar when the user picks a date and click the submit button the date should go over to the label.</p>
<p>I have been here answering question and all i am asking is for someone to help me understand what I am doing wrong. And you guys want to down vote me..</p>
| c# | [0] |
4,283,043 | 4,283,044 | getting a specific adjacent element in jquery | <p>if I have the following table:</p>
<pre><code><tr class="alternate">
<td>{$order.titel}</td>
<td>{$order.auteur}</td>
<td>&euro;{$order.prijs}</td>
<td>{$order.aantal}</td>
<td>&euro; {$order.aantal*$order.prijs}</td>
<tr>
</code></pre>
<p>and inside jquery I currently have the 4th td selected, how can i get the data from within the first td, keeping in mind that I start looking from the 4th td (eg. the 4th td is 'this')?</p>
| jquery | [5] |
938,973 | 938,974 | Why `args[0].Trim() == null` is always false? | <p>I have a method like this:</p>
<pre><code>public string StartCapture(string[] args)
{
if(args[0].Trim() == null || args[0].Trim() == string.Empty )
{
//do stuff
}
}
</code></pre>
<p>Why I get a note that <code>args[0].Trim() == null</code> will always be false?</p>
| c# | [0] |
570,835 | 570,836 | All thing is Object | <p>in .Net All Thing is Object but I have question. I write a method </p>
<pre><code>public static MvcHtmlString ObjectTable(this HtmlHelper helper,
ICollection<Object> objects, ICollection<string> header)
</code></pre>
<p>but I don't add system.object and get error for add the namespace.
my question is:if all thing in .NET driven form object but why i should add the namespace?</p>
| c# | [0] |
4,206,955 | 4,206,956 | how to post and retrieve data on different sites using c# | <p>i am trying to post on different websites using c#. I am doing it through a web Browser( the one already in .Net). The code i have done so far is below, in this i am successfully opening facebook and when i click on <code>button_2</code> it automatically fills the login form and i am successfully logged in then. This means i can do it for other sites as well by doing a little changes. </p>
<p>Now the problem here is i want to post some data to different sites, like a link or something, and when i am logged in successfully like in did in the code below what lets say a page opens and in that page i have to fill some data or that link the fields they ask. How to do that to proceed further to fill other form fields? And when i have done that i want to save that final result from that site to a text file?</p>
<p>Kindly tell me how to do that? Or any useful links.
Regards.</p>
<pre><code> private void button1_Click(object sender, EventArgs e)
{
webBrowserCtl.Navigate("https://login.facebook.com/login.php?login_attempt=1");
webBrowserCtl.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
string s = webBrowser1.DocumentText;
// btnLogin.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
HtmlElement ele = webBrowserCtl.Document.GetElementById("email");
if (ele != null)
ele.InnerText = "email here";
ele = webBrowserCtl.Document.GetElementById("pass");
if (ele != null)
ele.InnerText = "password here";
ele = webBrowserCtl.Document.GetElementById("Login");
if (ele != null)
ele.InvokeMember("click");
}
</code></pre>
| c# | [0] |
2,456,886 | 2,456,887 | How can we identify the primitive data type of a given variable? | <p>How can we identify the primitive data type of a given variable?</p>
| java | [1] |
1,677,668 | 1,677,669 | How do I get the UDID of the iPod/iPhone? | <p>I have seen programs that do this, like the very useful 'BetaHelper' application.</p>
<p>How do I get the Unique Device Identifier of the iPod of iPhone that my application is running on?</p>
| iphone | [8] |
1,732,059 | 1,732,060 | Example to see return value in multithread scenario | <p>I have a method. I want to return a value not from the main thread but from separate thread. Can you give example of it?</p>
| c# | [0] |
2,637,584 | 2,637,585 | How to insert text to rich edit control in Win32 while preserving any previous formatting | <p>I'm developing chat application in win32. Currently i'm dynamically allocating memory for rich edit controls text, append new line and set the new text with SetWindowText.</p>
<p>When a message arrives with specific keywords the app colors the line and appends it to the chat window. Everything's fine. Problem arises when next message is received - any previous formatting is lost!</p>
<p>How to solve this issue?</p>
| c++ | [6] |
3,538,234 | 3,538,235 | How shift graph in Android's Canvas | <p>I draw a graph with canvas in android, but I want to shift it to left or right side. I don't want to scroll it, I just want to shift it in one page by which you can see the graph is shifting lively.
I would be appreciated if any body help me.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.