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
5,347,462
5,347,463
Php, out-pay of coins
<p>If one were to make a "vending machine" and you would write in how much you would pay and if you paid £100 for a £2 item, then make it echo the amount you get back, and then echo the amount in coins (1p,5p etc. If you get my drift.) how would you do the echo'ing of coins?</p> <pre><code>$valg = $_POST['select']; $pris = $_POST['pris']; $r_pris = explode(" ", $valg); $resultat = $r_pris['1']-$pris; if ($resultat&lt;0){ $slut_pris = "du skal have " . $resultat . " kroner tilbage"; } elseif($resultat==0){ $slut_pris = "lige og plet på."; } else { $slut_pris = "du mangler " . $resultat . " kroner"; } </code></pre>
php
[2]
1,967,562
1,967,563
Change css class of loop values in PHP
<p>I have the following </p> <pre><code>echo "&lt;span&gt;".apply_filters(" $value\n", $value)."&lt;/span&gt;"; </code></pre> <p>that outputs </p> <pre><code>&lt;span&gt;Value&lt;/span&gt; &lt;span&gt;value 2&lt;/span&gt; &lt;span&gt;value 3&lt;/span&gt; </code></pre> <p>I want to append a 1 to each span outputted, so </p> <pre><code>&lt;span class="span-1"&gt;Value&lt;/span&gt; &lt;span"span-2"&gt;value 2&lt;/span&gt; &lt;span"span-3"&gt;value 3&lt;/span&gt; </code></pre> <p>How would I go about doing this or when can I find information/correct terminology on the issue? </p> <p>Thanks</p> <hr> <pre><code>foreach ( (array) $keys as $key ) { $keyt = trim($key); if ( '_' == $keyt{0} || 'pricing' == $keyt || 'vehicleType' == $keyt || 'coverageRegion' == $keyt || 'locationType' == $keyt ) continue; $values = array_map('trim', get_post_custom_values($key)); $value = implode($values,', '); echo "&lt;span class='srch-val'&gt;".apply_filters(" $value\n", $value)."&lt;/span&gt;"; } </code></pre>
php
[2]
3,151,097
3,151,098
JQUery validation plugin for checking data availability
<p>I am learning how to use JQuery validation plugin, I got a simple input text field like this:</p> <pre><code>&lt;input type="text" name="username"&gt; </code></pre> <p>But I don't know how to use this plugin to do some data availability tasks.</p> <p>Could you help me please?</p>
jquery
[5]
5,417,811
5,417,812
how to work with device keyboard
<p>Actually i have an editText box where i have to type a password..Now when i click the editText box an device input keyboard is open. So what i want is that when i click "done" in device input keyboard and if the password is right i have to move to the next activity..</p> <p>But i dont know how to use event of device input keyboard..so please anyone suggest me..if possible with an example..I have send the snapshot to know you what exactly i want..</p> <p><img src="http://i.stack.imgur.com/m4UrM.png" alt="enter image description here"></p> <p>so as i enter password in the editText and click done in inputKeyboard it will move to next activity...here in inputKeyboard "done" is not visible but in my app it is there in my inputKeyboard</p> <p>regards Anshuman</p>
android
[4]
1,215,603
1,215,604
Android_Alert Message_Which will not Close
<p>I am trying to develop popup message box which shows warning to user and won't allow to go anywhere (even not allowed to go at home screen/menu).</p> <p>I'm trying to put button on it until I press on that button and write username and password, so that user can't go any where.</p> <p>Should I interrupt or simply call to another activity? As I want to do this above thing after completing task on 1st activity, And I want do above pop thing on next ativity.</p>
android
[4]
5,202,267
5,202,268
How to add to $.get in JQuery error handling function?
<p>How to add to $.get in JQuery error handling function ? My request looks like</p> <pre><code>$.get('www.test.com', temp_parameters, function(data) { alert('data='+data['result']); },"json"); </code></pre> <p>but there is no function if error happens. Where to add that function ?</p>
jquery
[5]
1,430,579
1,430,580
how to open row in edit mode in gridview
<p>how to make gridview ro visible false when i click on delete button because i am using static data and i want to open the row in gridview in edit mode when i click on edit button. How to do this in c#</p>
asp.net
[9]
1,788,619
1,788,620
attaching DOM event handlers from a plugin that loads asynchronously?
<p>I have a jQuery plugin that loads asynchronously and attaches events to a DOM element on page load.</p> <p>Intermittently the DOM elements are not attached with events from the plugin - This happens due to the loading of these DOM elements via another javascript file.</p> <p>Is there any way to ensure that event handlers are always attached to DOM elements?</p>
jquery
[5]
3,112,704
3,112,705
How do I Update DataSet with update sql, then Udate the database in C sharp
<p>How do I Update DataSet with update sql, then Udate the database in C sharp. I have so code it does something but does not actually update the database. I feel I am really close to figuring this out, but I am missing something or I am not doing something right. my code is below if someone can see what it is I am not doing please let me know, I have been looking at this for the past 7 hours and can't figure it out.</p> <pre><code> { DataSet oDS = new DataSet(); OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=StaffAs.accdb;"); conn.Open(); // Create the DataTable "SAssign" in the Dataset and the OrdersDataAdapter // UPDATE StaffAssignment SET StaffID = 4 WHERE (StaffID = 2) OleDbDataAdapter oOrdersDataAdapter = new OleDbDataAdapter(new OleDbCommand("SELECT * FROM StaffAssignment", conn)); OleDbCommandBuilder oOrdersCmdBuilder = new OleDbCommandBuilder(oOrdersDataAdapter); oOrdersDataAdapter.FillSchema(oDS, SchemaType.Source); oOrdersDataAdapter.UpdateCommand = new OleDbCommand(String.Format("UPDATE StaffAssignment SET StaffID = 4 WHERE (StaffID = 2)")); DataTable pTable = oDS.Tables["Table"]; pTable.TableName = "UpdateStaffA"; oOrdersDataAdapter.Fill(pTable); try { oOrdersDataAdapter.Update(pTable); } catch (OleDbException e) { //Allows for update without violating interigty constainst return; } conn.Close(); </code></pre> <p>}</p>
c#
[0]
2,559,131
2,559,132
How to create movable and resizable graphic objects for a graphic 2D drawing application?
<p>Good day, I'm learning how to develop applications for Android (API 14). I'd like to create an application in which I could create 2D graphic objects (shapes or text), select them, move, resize, rotate or select and move their nodes. A picture taken by the camera should be used as a background image. The application should be fast so that it is comfortable to work with. Could you please advise some resources where I could learn what libraries or classes should I use to achieve this? Many thank in advance. Vojtech</p> <p>Something like one can see in "Smart Diagram Lite" application where an graphical object can be dragged to another place.</p>
android
[4]
1,504,803
1,504,804
Login page shows blank
<p>The login page on a project i'm currently fixing up shows blank. i tried echoing some words to find out where the fault lied. I found out that commenting out the below piece of code made it to display.</p> <pre><code>elseif( isset($_POST['do_login'] ) ){ //Login user $email = (isset($_POST['login']) &amp;&amp; is_string($_POST['login']) &amp;&amp; strlen($_POST['login'])&lt;100)?$_POST['login'] : null; $password = (isset($_POST['password']) &amp;&amp; is_string($_POST['password']) &amp;&amp; strlen($_POST['password'])&lt;100)?$_POST['password'] : null; $remember = isset($_POST['chkremember']) ? true : false; $result = $auth-&gt;login($email, $password, $remember); switch($result){ case 1: $msg = 'You have successfully logged in.' break; case 2: $msg = 'Your account has not yet been confirmed. &lt;br/&gt; Please check the e-mail message sent by us and click the confirmation code to validate this account. &lt;a href="user_login.php?view=resend&amp;resend_email='.$email.'"&gt;resend activation e-mail&lt;/a&gt;'; break; case 3: $msg = 'Your account is not enabled!'; break; case 4: $msg = 'Account with given login credentials does not exist!'; break; } } </code></pre> <p>Can anyone help me figiure out what's wrong with this piece of code?</p>
php
[2]
696,382
696,383
problem passing listener class to a function
<p>I'm using a library that manipulates a binary search tree. In this library is a function that traverses the tree and passes each node it finds to a callback class:</p> <p><code>bool TCODBsp::traverseInvertedLevelOrder(ITCODBspCallback *callback, void *userData)</code></p> <p><code>ITCODBspCallback</code> is a base class in the library from which the user is supposed to derive his own callback class to pass to the function. Here is the base class:</p> <pre><code>class ITCODBspCallback { public : virtual bool visitNode(TCODBsp *node, void *userData) = 0; }; </code></pre> <p>Here's my derived class:</p> <pre><code>class MyCallback: public ITCODBspCallback { public: virtual bool visitNode(TCODBsp*, void*); // defined in my implementation file }; </code></pre> <p>I then pass <code>MyCallback</code> to the function like this:</p> <p><code>bsp-&gt;traverseInvertedLevelOrder(new MyCallback(), NULL);</code></p> <p>and g++ gives me the following errors:</p> <p><code>expected type-specifier before 'MyCallback'<br> expected ')' before 'MyCallback'<br> no matching function for call to 'TCODBsp::traverseInvertedLevelOrder(int*, NULL)'<br> note: candidates are: bool TCODBsp::traverseInvertedLevelOrder(ITCODBspCallback*, void*)</code></p> <p>Anyone know what's wrong? I'm curious why it thinks <code>MyCallback</code> is an <code>int*</code>, in particular.</p>
c++
[6]
1,423,205
1,423,206
Get stored id's using iteration
<p>I please need some help: I have this database, which has this fields with their respect values:</p> <pre><code>agency_id | hostess_id 3 | 12-4-6 5 | 19-4-7 1 | 1 </code></pre> <p>In hostess_id are stored all hostesses ids that are associated with that agency_id but separated with a "-" </p> <p>Well, i login as a hostess, and i have the id=4 I need to retrieve all the agency_id which contain the id=4 , i can't do this with like operator.. i tried to do it by saving the hostess_id row to an array, then implode it, but i can't resolve it like this.</p> <p>Please, please any idea?</p>
php
[2]
4,811,446
4,811,447
Unregister a live click event when the objects keep on changing dynamically
<p>I have a div in which i dynamically add different tables.</p> <p>I need to maintain a column that was sorted out.</p> <p>I am using Global Variables for storing the column names.</p> <p>Since the table gets changed (a different structured table can be added dynamically too)</p> <p>I register a TH (table head click event). In which i need to pass the JSON url.</p> <p>I use LIVE event since the table is appended later on.</p> <p>I want to get deregister all the TH click events when a new table is added.</p> <p>I use UNBIND but it does not work. My click event fire twice with different params.</p> <p>Code:</p> <pre><code> $("#" + control.attr("id") + " tr th").unbind("click"); $("#" + control.attr("id") + " tr th").live( "click" , function() { var table_head = $(this); var new_sort_column = (table_head.text()); opts.columnName = new_sort_column; ColumnName = new_sort_column; opts.IsAscending = GlobalIsAscending ; GlobalIsAscending = !GlobalIsAscending ; getPageSet(control, opts, 0); } ); </code></pre> <p>// Might be required (This code is a part of my jquery plugin where Opts is jquery options)</p> <p>Any help is appreciated.</p>
jquery
[5]
477,619
477,620
Downloading empty file
<p>For the life of me I can't see why, but it has the correct file name and all, but the files themselves are empty after download. As far as I can see its going to the correct spot, the database has the correct info too. </p> <pre><code>function download() { global $session,$project,$config,$args; $fid = $args[0]; $query = query('SELECT * FROM files WHERE id = ?',$fid); if(num($query) == 1) { $file = fetch($query); //$happyfix = "http://imengine.gofreeserve.com/admin"; $filename = URL . "/_files/{$file-&gt;in_project}/{$file-&gt;in_folder}/" . md5($fid) . ".{$file-&gt;extension}"; //$filename = $happyfix . "/_files/{$file-&gt;in_project}/{$file-&gt;in_folder}/" . md5($fid) . ".{$file-&gt;extension}"; if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header("Content-Type: $file-&gt;mimetype"); // change, added quotes to allow spaces in filenames, by Rajkumar Singh header("Content-Disposition: attachment; filename=\"".$file-&gt;name . '.' . $file-&gt;extension."\";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); readfile("$filename"); exit(); } else { redirect('That file does not exist','','error'); } } </code></pre>
php
[2]
5,468,705
5,468,706
Hide microphone button Android virtual keyboard
<p>I wanted to know if is it possible to hide the microphone button (speech-to-text) in Android Virtual Keyboard programatically.</p> <p>I know I can disable this option through device settings, but I don't want the user to use this feature in my application independently of his/her settings. I mean i want to force this behaviour inside my app.</p> <p>Thanks in advance, Demian</p>
android
[4]
3,047,128
3,047,129
Help submitting a form
<p>This was working but has suddenly stopped for some reason. I can't see what's wrong. Can someone tell me what I am doing wrong here? I'm using an onclick event in a span tag then calling this function.</p> <p>Firefox reports: <code>Error: document.forms[0].submit is not a function</code></p> <pre><code> function submitlogin() { document.forms[0].submit() } &lt;form method="post" id="submit" action="something.asp"&gt; &lt;span id="button" onclick="submitlogin()"&gt;&lt;/span&gt; &lt;/form&gt; </code></pre> <hr> <p>This is what the form looks like</p> <pre><code> &lt;form method="post" id="myform" action=""&gt; &lt;div&gt; &lt;input type="text" id="name" name="name" /&gt; &lt;/div&gt; &lt;div id="btn-container"&gt; &lt;span id="button" onclick="submitlogin();"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
javascript
[3]
2,153,405
2,153,406
How to mock object?
<p>How to mock object for testing if the class you're testing is abstract? you can't instantiate from it ?</p>
java
[1]
4,145,992
4,145,993
I don't understand this function(options)
<p>I don't understand this, if I have image slider and image preloader </p> <pre><code>jQuery.fn.awShowcase = function(options); //slider $.fn.preloader = function(options); // preloader </code></pre> <p>They don't work on the same page because the function is the same?</p>
jquery
[5]
1,935,278
1,935,279
Help! Error: The local variable transactionType may not have been initialized
<p>I get this Error: The local variable transactionType may not have been initialized</p> <p>but the thing is it is initialized in my if statement! </p> <pre><code>if (transactionChar == 'w') transactionType = "Withdrawal"; else if (transactionChar == 'd') transactionType = "Deposit" ; </code></pre> <p>then when i go to print out transactionType, it wont let me because it gives me that error! my declaration statement looks something like this. </p> <pre><code>String transactionType; char transactionChar; </code></pre> <p>Please Help. I have been trying to figure it out for the past 4 hours!</p>
java
[1]
4,910,607
4,910,608
Why is this python operation returning a tuple?
<pre><code>from datetime import date from datetime import timedelta a = date.today() - timedelta(1) # a above is a tuple and not datetime # Since I am a C programmer, I would expect python to cast back to datetime # but it is casting it to a tuple </code></pre> <p>Can you please tell me why this is happening? and also how I can see that the operation above results in a datetime?</p> <p>I am a python newbie, sorry if this is a trivial thing, but I am stuck here for a while!</p> <p>Thanks</p>
python
[7]
791,562
791,563
Line 6 of this Javascript program is confusing me
<p>In the function <code>takeNormal()</code> below, there is a line that I don't understand at all. It is: </p> <pre><code>var end = reduce(Math.min, text.length, map(indexOrEnd, ["*", "{"])); </code></pre> <p>Specifically, in this function reduce, it has all these different arguments (are they arguments?). How are they processed by reduce? Are they handled one after the other? Or, for example, does <code>Math.min</code> do anything to <code>text.length</code>? How do the different parts in reduce interact and what does reduce ultimately do to them?</p> <pre><code> function splitParagraph(text) { function indexOrEnd(character) { var index = text.indexOf(character); return index == -1 ? text.length : index; } function takeNormal() { var end = reduce(Math.min, text.length, map(indexOrEnd, ["*", "{"])); var part = text.slice(0, end); text = text.slice(end); return part; } function takeUpTo(character) { var end = text.indexOf(character, 1); if (end == -1) throw new Error("Missing closing '" + character + "'"); var part = text.slice(1, end); text = text.slice(end + 1); return part; } var fragments = []; while (text != "") { if (text.charAt(0) == "*") fragments.push({type: "emphasised", content: takeUpTo("*")}); else if (text.charAt(0) == "{") fragments.push({type: "footnote", content: takeUpTo("}")}); else fragments.push({type: "normal", content: takeNormal()}); } return fragments; } </code></pre>
javascript
[3]
836,166
836,167
How to get ArrayList shuffle to produce more than one not all the same
<p>Hi complete novice with Java, this is my second assignment. I have written a method for a lottery code using array list, I have two issues:</p> <ul> <li>The same shuffled list is produced for every line requested.</li> <li>The lines print down not across.</li> </ul> <hr> <pre><code>public static void irishLottery() { Scanner input = new Scanner(System.in); double cost = 0; System.out.println("How many lines of lottery up to 10 would you like?"); int linesam = input.nextInt(); ArrayList&lt;Integer&gt; numbers = new ArrayList&lt;Integer&gt;(); //define ArrayList to hold Integer objects for (int lottonos = 0; lottonos &lt; 45; lottonos++) { numbers.add(lottonos + 1); } Collections.shuffle(numbers); System.out.print("Your lottery numbers are: "); for (int lncounter = 1; lncounter &lt;= linesam; lncounter++) { for (int j = 0; j &lt; 6; j++) { System.out.println(numbers.get(j) + " "); } } } </code></pre>
java
[1]
1,952,354
1,952,355
Using AppDomain in C# to dynamically load and unload dll
<p>In one of my application, which is related to system diagnostics, the related DLL is to be loaded and unloaded dynamically in C#. After some search I found that a separate DLL cannot be loaded dynamically its the complete AppDomain. So I have to create an AppDomain and use that DLL to be loaded unloaded dynamically. But I could not find anywhere how can I use that in code. I can not show the app code since it is against company rules.</p> <p>Can somebody tell me some application code to use it. I want to load and unload the dll dynamically using appdomain and call a specific method in that dll, the dll does not have any entry point.</p> <p>Thanks for answers. Ashutosh</p>
c#
[0]
4,291,582
4,291,583
Set of all subsets
<p>In Python2 I could use</p> <pre><code>def subsets(mySet): return reduce(lambda z, x: z + [y + [x] for y in z], mySet, [[]]) </code></pre> <p>to find all subsets of <code>mySet</code>. Python 3 has removed <code>reduce</code>.</p> <p>What would be an equally concise rewrite of this for Python3?</p>
python
[7]
772,657
772,658
Better way to do this in PHP
<p>I currently have my htaccess file set to remove the file type so</p> <pre><code>www.example.com/home.php </code></pre> <p>would become,</p> <pre><code>www.example.com/home </code></pre> <p>I need to compare the url with one that I have saved in the database, I do this by,</p> <pre><code>if ($_SERVER['QUERY_STRING']) { $pageURL = str_replace('.php', '?', 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . $_SERVER['QUERY_STRING']); } else { $pageURL = substr('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'], 0, -4); } </code></pre> <p>When I save the url in the database it gets saved as the current page url after the htaccess file has removed the .php, it is inserted using jquery ajax.</p> <p>When I come to compare it, I need this to make it match in php as php doesn't take into account the htaccess changes.</p> <p>Is there a better way to do this?</p>
php
[2]
384,102
384,103
using python to encapsulate part of a string after 3 commas
<p>I am trying to create a python script that adds quotations around part of a string, after 3 commas</p> <p>So if the input data looks like this:</p> <pre><code>1234,1,1/1/2010,This is a test. One, two, three. </code></pre> <p>I want python to convert the string to:</p> <pre><code>1234,1,1/1/2010,"This is a test. One, two, three." </code></pre> <p>The quotes will always need to be added after 3 commas</p> <p>I am using Python 3.1.2 and have the following so far:</p> <pre><code>i_file=open("input.csv","r") o_file=open("output.csv","w") for line in i_file: tokens=line.split(",") count=0 new_line="" for element in tokens: if count = "3": new_line = new_line + '"' + element + '"' break else: new_line = new_line + element + "," count=count+1 o_file.write(new_line + "\n") print(line, " -&gt; ", new_line) i_file.close() o_file.close() </code></pre> <p>The script closes immediately when I try to run it and produces no output</p> <p>Can you see what's wrong?</p> <p>Thanks</p>
python
[7]
4,219,325
4,219,326
Why would you choose the Java programming language over others?
<p>Why would you choose java over others? Why did you choose java to program your application?</p> <p>Please include what you are using java for (desktop application/ web application/ mobile).</p>
java
[1]
4,464,339
4,464,340
C++: is instance descendant of class
<p>Assume we have three classes A, B and C. B is derived from A and C is derived from B. Now we have a pointer that points to an object of class A. Due to Polymorphism it can actually point to instances of all three classes.</p> <p>With typeid() i can check what type the pointer actually refers to. But I'm trying to determine if it points to any descendant of class B. That is to say I'm looking for some kind of IsDescendantOf(unkownclass, baseclass) function. Is there a why to do so in C++?</p>
c++
[6]
2,337,323
2,337,324
How do I get the navigation bar in a UINavigationController to update its position when the status bar is hidden?
<p>I have a <code>UINavigationController</code> with a visible Navigation Bar. I have one particular <code>UIViewController</code> which I'd like to hide the status bar when pushed into the navigation stack. Once this viewController is popped I'd like to show the status bar again.</p> <p>I'm hiding the bar in the <code>viewWillAppear</code> method of my <code>UIViewController</code> like this:</p> <pre><code>- (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController setWantsFullScreenLayout:YES]; [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES]; } </code></pre> <p>Note that I'm setting <code>setWantsFullScreenLayout:YES</code> here for clarity, but I'm actually just setting this property in Interface Builder.</p> <p><strong>The problem:</strong> The navigation bar of the NavigationController doesn't move up to take the space of the now hidden status bar.</p> <p><strong>A hacky solution</strong> The only thing I found that worked to refresh the position of the nav bar was to hide it and show it again, like this:</p> <pre><code>[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES]; [self.navigationController setNavigationBarHidden:YES animated:NO]; [self.navigationController setNavigationBarHidden:NO animated:NO]; </code></pre> <p>but this is clearly a hack, there has got to be a better way.</p> <p><strong>Other things I tried:</strong></p> <ol> <li><p>I tried calling the <code>[super viewWillAppear]</code> after hiding the status bar, i.e. at the end of my method.</p></li> <li><p>I tried setNeedsLayout on the navigationController.view like this:</p> <pre><code>[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES]; [self.navigationController.view setNeedsLayout]; </code></pre></li> </ol> <p>but that doesn't seem to work.</p> <p>Any help appreciated. Thanks</p>
iphone
[8]
2,371,843
2,371,844
How to prevent events from being bound multiple times
<pre><code> $('.ajax').click ( function() { // If been bound then we need to return here. alert(':D'); } ) $('.ajax').click ( function() { // If been bound then we need to return here. alert(':D'); } ) </code></pre> <p>In this case, I have called duplicate code. How do I detect if the event has been bound to prevent it from triggering two alert boxes?</p>
jquery
[5]
5,306,879
5,306,880
Is there a way in asp.net that can prevent some users from registeration?
<p>I would like to know if I can block <strong>users from specific countries</strong> from being able to register in an asp.net website. So I want the website automatically recognise where the vistor is located, in which conuntry, then if the user from the alloed countries then he can register otherwise an error appears tell the user something like 'sorry we don't accept accounts from your country yet.'.</p>
asp.net
[9]
4,884,736
4,884,737
Why the destructors in that instance’s inheritance chain are called, in order, from most derived to least derived?
<p>Base on the C# specification, 10.13 Destructors</p> <blockquote> <p>" When an instance is destructed, the destructors in that instance’s inheritance chain are called, in order, from most derived to least derived."</p> </blockquote> <p>My questions are:</p> <p>why destructors are called, in order, from most derived to least derived? why not are called, in order, from least derived to most derived or other order?</p>
c#
[0]
3,800,450
3,800,451
specify callback on jquery bounce?
<pre><code>Data.BouncePrompt.effect("bounce", {times:3, mode:"hide"}, 300); </code></pre> <p>I want to let it continue displaying after the 3 bounces for like 2 seconds then hide it. Is that possible?</p>
jquery
[5]
189,874
189,875
Interface referencing another interface but class referencing another class in C#
<p>I have a very simple question, but I haven't had this problem before.</p> <p>Take a look at this code:</p> <pre><code>interface IFoo { IBar MyBar { get; } } interface IBar { String Test { get; } } class Foo : IFoo { public Bar MyBar { get; set; } } class Bar : IBar { public String Test { get; set; } } </code></pre> <p>The problem is that Foo doesn't implement IFoo since it returns Bar rather than IBar. But I don't see the problem since Bar is implementing IBar. Do I miss something?</p> <p>I want my application to use the class Foo but expose IFoo to other parts of the solution.</p> <p>This is a way around it, but it seems like an ugly solution:</p> <pre><code>class Foo : IFoo { public Bar MyBar { get; set; } IBar IFoo.MyBar { get { return this.MyBar; } } } </code></pre> <p>Is this the way to go, or is it a better way?</p>
c#
[0]
2,396,485
2,396,486
Date vs new Date in JavaScript
<p><code>new Date()</code> takes an ordinal and returns a <code>Date</code> object.<br> What does <code>Date()</code> do, and how come it gives a different time?</p> <pre><code>&gt;&gt;&gt; new Date(1329429600000) Date {Fri Feb 17 2012 00:00:00 GMT+0200 (Jerusalem Standard Time)} &gt;&gt;&gt; Date(1329429600000) "Tue Mar 06 2012 15:29:58 GMT+0200 (Jerusalem Standard Time)" </code></pre>
javascript
[3]
4,683,569
4,683,570
what does this prototype do?
<p>Is it making a new version of the Number function and calling it something else? Is there a better way to write this?</p> <pre><code>Number.prototype.clamp = function(min, max) { return Math.min(Math.max(this, min), max); }; </code></pre> <p>Is it the same as </p> <pre><code>Number.prototype.NumberToMystring = function(n) { return n.toSTring(); }; </code></pre> <p>then NumberToMystring(5) will return "5" but as a string</p>
javascript
[3]
3,262,455
3,262,456
How do I create file on server?
<p>Let say I want create file call style.css in <code>/css/</code> folder.</p> <p>Example : When I click Save button script will create <code>style.css</code> with content</p> <pre><code> body {background:#fff;} a {color:#333; text-decoration:none; } </code></pre> <p>If server cannot write the file I want show error message <code>Please chmod 777 to /css/ folder</code></p> <p>Let me know</p>
php
[2]
4,233,433
4,233,434
ASP.net: dropdown opened for selection is displayed in front of/above Menu displayed by Mouse Hover
<p>We have a asp.net menu control placed on Master Page and and there is a DropDown on the Content Page, both these are asp.net server controls.</p> <p><b>On Master Page:</b></p> <pre><code>&lt;asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" &gt; &lt;Items&gt; .... &lt;/Items&gt; &lt;/asp:Menu&gt; </code></pre> <p>and on <b>Content Page</b></p> <pre><code>&lt;asp:DropDownList ID="DropDownList1" runat="server" CssClass="back999" &gt; &lt;asp:ListItem&gt;a&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;b&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;c&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;d&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </code></pre> <hr> <p><strong>Behavior in Browser:</strong></p> <ol> <li>Step 1- Click on Drop Down: List of items is displayed.</li> <li>Step 2- Now without clicking anywhere, hover the mouse on Menu: Menus are displayed</li> </ol> <p><strong>Result:</strong> The List of items displayed in step 1, are overridden above Menu. The portion having drop down items are displayed over Menu. <strong>Reference</strong> <a href="https://docs.google.com/open?id=0B0guWebeJArZejZGNDEweHJtOFE" rel="nofollow">Image</a></p> <p>We have changed the z-index in positive till 9999 of Menu and in negative of dropdown, but nothing seems to be working.</p> <p>All suggestions are appreciated!</p>
asp.net
[9]
88,694
88,695
Javascript basics: variable scope
<p>I am learning javascript and can someone please explain the following code snippet for me?</p> <pre> <code> var state=true; function bob(){ var state=false; } bob() </code> </pre> <p>What should be the state value and why?</p> <p>Many thanks, L</p>
javascript
[3]
335,408
335,409
tag cloud: load javascript after GetAllTagTerms
<p>On my master page i have a tag cloud web part.</p> <p>I use jquery to redirect tags to search center. I reference it in my master page:</p> <pre><code>&lt;script type="text/javascript" src="/_layouts/project/js/addons.js"&gt;&lt;/script&gt; </code></pre> <p>I tested the script with the console in firebug and it works like a charm. but it seems that the addons.js gets loaded before <a href="http://url/_vti_bin/SocialDataService.asmx/GetAllTagTerms" rel="nofollow">http://url/_vti_bin/SocialDataService.asmx/GetAllTagTerms</a> </p> <p>Therefore the redirection doesn't work.</p> <p>Any ideas on how i could load the script after <a href="http://url/_vti_bin/SocialDataService.asmx/GetAllTagTerms" rel="nofollow">http://url/_vti_bin/SocialDataService.asmx/GetAllTagTerms</a></p>
javascript
[3]
3,686,769
3,686,770
Focus into a newly replaced text field using jQuery
<p>I am using jQuery to replace the HTML of a text field when it gets focus. My code looks like this: </p> <pre><code>&lt;div id="my_field"&gt; &lt;%= f.text_field :first_name, :value =&gt; "Enter Name" %&gt; &lt;/div&gt; </code></pre> <p>My jQuery used to replace the HTML inside my_field:</p> <pre><code>$("#my_field") .delegate('#my_field input', 'focus', function(e){ if($(this).attr('type') == 'text'){ $(this).parent().html('&lt;input type="text" value="" name="..." id="name"&gt;'); } }); </code></pre> <p>Just after replacing the HTML, the newly created text box does not get the focus. What should I do to get the cursor on the text box?</p>
jquery
[5]
388,387
388,388
mouseover style change with JQuery
<p>taking the following html:</p> <pre><code> &lt;li&gt; &lt;p&gt; &lt;a href="#" class="link" &gt;&lt;img src="images/photo_cityguild_cropped.jpg" alt="Education" title="Education"&gt; &lt;span class="label"&gt;E D U C A T I O N&lt;/span&gt; &lt;/a&gt; &lt;/p&gt; &lt;/li&gt; </code></pre> <p>I want to basically change the class of the <code>&lt;span&gt;</code> on the event of the user hovering over the image link.</p> <p>I haven't got much use of JQuery under my belt and its been a while anyway, I was trying the following:</p> <pre><code>$(".link").mouseover(function() { $(this).find("span").addclass("label2"); }).mouseout(function(){ $(this).find("span").removeclass("label2"); }); </code></pre> <p>could somebody indicate to me as to what I need to correct as it is currently doing nothing.</p> <p>thanks,</p> <p><strong>EDIT</strong> updated with my solution.</p> <p>implemented this code instead:</p> <pre><code>$(".link").live("mouseover mouseout", function(event) { if ( event.type == "mouseover" ) { $(this).find("span").addClass("label2"); } else { $(this).find("span").removeClass("label2"); } }); </code></pre>
jquery
[5]
5,047,008
5,047,009
Use field values to populate another checkbox on submit.
<p>How would I go about writing a javascipt that On Submit, would check if two fields are blank, and if they are NOT blank, then it would automatically set another field to "TRUE"? Example: </p> <p>Invoice Table-- CustomerID, InvoiceID, Check, Cash#, Paid</p> <p>I want the function to check if there are any values in Cash or Check# then check the Paid checkbox.</p>
javascript
[3]
1,463,987
1,463,988
How to get the eq() value?
<p>Is this possible? For me to get the eq() value? for example, if I click the li:eq(2), var x will become '2'. Here's the code. Thank you.</p> <pre><code>$('#numbers ul li').click(function(){ x=$(this).eq().val(); alert(x); }); </code></pre>
jquery
[5]
5,521,317
5,521,318
Implement Per Property Change Tracking
<p>I am writing a C# app using the MVVM pattern and I was wondering what would be the best way to implement change tracking on a per property basis. I currently have INotofyPropertyChanged implemented and flag whether or not the whole object is dirty, but some of the requirements I have to implement is they want to be able to show an image by the text box on the UI for every property that has been changed.</p> <p>Basically my View Models all have a private field that is my class containing the data from my DataAccess Layer. So basically a class will look like this:</p> <pre><code>private BusinessObj _data public Name { get{ return _data.Name;} set { if(_data.Name != value) { _data.Name = value; PropertyChanged("Name"); IsDirty = true; } } } </code></pre> <p>My data access layer is basically serializing and deserializing XAML profiles for configuring our products.</p>
c#
[0]
2,236,674
2,236,675
PHP when writing to file, How to prepend and append text to a file with existing text?
<p>I'm creating a xml file with PHP here is some sample code.</p> <pre><code> $myFile = "example_file.xml"; $fh = fopen($myFile, 'w'); while($row = mysql_fetch_array($result)) { $stringData = "&lt;field name=\"id\"&gt;$page_id&lt;/field&gt; &lt;field name=\"url\"&gt;http://myfundi.co.za/a/$page_url&lt;/field&gt; &lt;field name=\"title\"&gt;$pagetitle&lt;/field&gt; &lt;field name=\"content\"&gt;$bodytext&lt;/field&gt; &lt;field name=\"site\"&gt;Myfundi&lt;/field&gt;"; fwrite($fh, $stringData); } fclose($fh); </code></pre> <p>What I need to do is when the first content is written to the text file, I need to prepend and append some more text. </p> <p>I need to prepend and append to the data that already exists.</p> <p>How can I do that?</p> <p>Thanks</p>
php
[2]
1,299,788
1,299,789
Creating menus by the normal user
<p>I have a problem, I need to create menu items but I want the user to be able to do that through a GUI where he/she enters the name of the menu item in an edit text and clicks a button to create it. How do I go about this. I will appreciate the help!</p>
android
[4]
5,791,800
5,791,801
Maybe This is dead-simple stupid question, but how PHP translate our code?
<p>i got this code</p> <p>` <pre><code> // // prints out "Hello World!" // hello_world(); //First call function hello_world() { echo "Hello World!&lt;br/&gt;\n"; } hello_world(); //second call ?&gt;` </code></pre> <p>Both of 'hello_world' call will print out the same result. It's easily to understand why the second call will be output 'Hello world', but how the first call output the same where it's been call before the initiation of the function hello_world itself ?</p>
php
[2]
5,489,386
5,489,387
Exit all functions from code in inner function
<p>If I have nested functions in C#, how to exit from both function at once when executing inner function code. (<code>Return;</code> only exits from executing function.)</p> <pre><code>public void Function1() { Function2(); } public void Function2() { if (1 == 1) { //Exit from both functions } } </code></pre>
c#
[0]
4,649,393
4,649,394
What conditions will trigger popup blocker?
<p>I would like to know the conditions which will trigger popup blocker.<br> I know that window.open without user clicking the page will trigger the popup blocker.<br> But if the user clicks on the flash and then the flash calls the window.open js function, will this trigger the popup blocker?</p>
javascript
[3]
1,250,120
1,250,121
Entry to android programming
<p>In the following program , when i try to run its getting error </p> <pre><code>textOut = (TextView) findViewById(R.id.tvGetInput); </code></pre> <p>in this line. Its showing error in tvGetInput. How can i fix it ? </p> <pre><code>package was.thebasics; import android.app.Activity; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class mymenu extends Activity { TextView textOut; EditText GetInput; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); textOut = (TextView) findViewById(R.id.tvGetInput); GetInput = (EditText) findViewById(R.id.etInput); Button ok = (Button) findViewById(R.id.bOK); ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub textOut.setText(GetInput.getText()); } }); // set up the button sound final MediaPlayer mpButtonClick = MediaPlayer.create(this, R.raw.button); Button bTutorial1 = (Button) findViewById(R.id.tutorial1); bTutorial1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent("was.thebasics.tutorialOne")); mpButtonClick.start(); } }); } } </code></pre>
android
[4]
3,945,891
3,945,892
What exactly does "unformatted input function" mean?
<p>After reading <a href="http://www.gamedev.net/topic/641136-stdifstreamread-failing-to-read-all-the-bytes/" rel="nofollow">this post</a> on GameDev.net, I decided to take a gander at the C++ standard. There are several <code>std::istream</code> functions that are described as "unformatted input functions" by the standard (like <code>tellg()</code>, <code>read()</code>, etc.). All this time, I had thought "unformatted input function" meant that text won't be formatted when reading (for example, <code>"\r\n" -&gt; "\n"</code>) when an "unformatted input function" is used (regardless of text mode or binary mode). Apparently, this isn't the case, as the <code>read()</code> method will still convert <code>"\r\n" -&gt; "\n"</code> (if <code>std::ios_base::binary</code> is not specified), despite it being an "unformatted input function."</p> <p>Now I'm all confused as I obviously don't understand things right. <strong>What exactly does "unformatted input function" mean?</strong> And yes, I've read section 27.7.2.3, paragraph 1, which seems to talk more about handling errors than anything else (though of course, it's possible I'm not properly understanding it, which may be part of the problem).</p> <p>I've just found the fact that <code>tellg()</code> doesn't take into account the formatting conversions, while <code>read()</code> does, to be rather confusing. To a degree, it makes sense (as <code>tellg()</code> would be O(n) if it did, and if <code>read()</code> didn't, the difference between text/binary modes would be far less significant). But to another degree, it seems... inconsistent. I think part of my confusion and the observed inconsistency likely comes from my apparent misunderstanding of "unformatted input function."</p>
c++
[6]
5,880,281
5,880,282
display picture
<p>hi everybody i'm trying to get bmp file then display it and i should do this by get header information of bmp and load it pixel by pixel in to an array then set pixel to display bmp picture without using bitmap class.</p> <pre><code>enter code here enter code here public void display(String filename) { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string headerCode = br.ReadChar().ToString() + br.ReadChar().ToString(); MessageBox.Show(headerCode); if (headerCode == "BM") { int bfSize = br.ReadInt32(); int bfReserved1 = br.ReadInt16(); int bfReserved2 = br.ReadInt16(); int bfoffbits = br.ReadInt32(); int biSize = br.ReadInt32(); int biWidth = br.ReadInt32(); int biHeight = br.ReadInt32(); int biPlanes = br.ReadInt16(); int biBitCount = br.ReadInt16(); int biCompression = br.ReadInt32(); int biSizeImage = br.ReadInt32(); int biXPelsPerMeter = br.ReadInt32(); int biYPelsPerMeter = br.ReadInt32(); int biClrUsed = br.ReadInt32(); int biClrImportant = br.ReadInt32(); int rgbRed = 0; int rgbGreen = 0; int rgbBlue = 0; Bitmap bmp = new Bitmap(biWidth, biHeight); PictureBox1.Size = new System.Drawing.Size(biWidth, biHeight); try { PictureBox1.Image = bmp; </code></pre> <p>i should do this but no with bitmap class and buffer , ishould get the header of bmp file and load it in the array then read the file to get the height and width and other information that need to display bmp pixel by oixel but without using bitmap class</p>
c#
[0]
734,542
734,543
jquery select, create input boxes?
<p>I have a dropdown selection box with the following:</p> <pre><code>&lt;select name="type" id="speedB" style="width:324px;"&gt; &lt;option value=""&gt;Please Select&lt;/option&gt; &lt;option value="9.99"&gt;1 = $9.99&lt;/option&gt; &lt;option value="19.99"&gt;5 = $19.99&lt;/option&gt; &lt;option value="39.99"&gt;10 = $39.99&lt;/option&gt; &lt;option value="199.99"&gt;All = $199.99&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Basically, what I want to do is:</p> <blockquote> <p>If value 9.99 is chosen, display 1 input box for them to enter something in to.</p> <p>If value 19.99 is chosen, display 5 input boxes for them to enter something in to.</p> <p>If value 39.99 is chosen, display 10 input boxes for them to enter something in to.</p> <p>If value 199.99 is chosen, display <strong>ONE</strong> input box with the <code>name="state"</code> for them to enter something in to.</p> </blockquote> <p>I want the newly created input boxes to have a name such as <code>name="pc1" name="pc2"</code> etc.. unless value 199.99 is chosen, I only want one input box to be shown with the <code>name="state"</code></p> <p>How would I go about doing this?</p>
jquery
[5]
3,837,998
3,837,999
How to send a mail using xampp in windows XP?
<p><br/> I am using XAMPP for localdevelopment.And I am using the mail() function for sending the mail. But unfortunately it wont sent the mail.I am not using any SMTP server in local host.If I need to sent mail what can I do?Thanks in advance.</p>
php
[2]
1,265,892
1,265,893
Is there a way to see if a control is off screen and not drawn?
<p>I have a app where on very small screens the buttommost textview is not drawn (it's off the screen). Is there a way to see if it is off the screen?</p>
android
[4]
3,674,441
3,674,442
In ASP.NET, how do I convert ~/Application/Page.aspx to http://localhost:45/MyApp/Application/Page.aspx
<p>Basically I want to convert a virtual path to an absolute path. </p>
asp.net
[9]
6,015,438
6,015,439
Application Build not loaded on device
<p>When I tried to upload a build on device it give the following error. Your mobile device has encountered an unexpected error <code>(0xE8000001)</code></p> <p>I am unable to solve this problem. Can anyone tell me why this is happening?</p>
iphone
[8]
2,703,835
2,703,836
Return multiple values from a function in C# - which of these options is better?
<p>I want my function to accept one string (file name) as input and return 2 strings: temp file and new file name</p> <p>Which option is better:</p> <ol> <li>Class</li> <li>struct </li> <li>Use output parameters (using the out or ref keywords)</li> </ol>
c#
[0]
2,196,754
2,196,755
PHP include w/o echo
<p>I'm coding a web site and I have a php fonction called site_nav.php which first define a $list array and than echos it in a json form.</p> <p>This way, I can get my web site map with ajax.</p> <p>My problem is that now, I would like to get the $list object in php, without echoing the json object.</p> <p>My question: Is there a way to include my php file without activation of the echo call which is in it?</p> <p>Thanks a lot!</p>
php
[2]
4,356,331
4,356,332
c# static variables
<p>Greetings!</p> <p>First let me explain my project in few words.I am using TouchServer which is a console application.TouchStation which is windows application.this does syncronization process.touchstation communicates with touchserver to create local database and load data from remote database.At the same time I can open TouchAdmin in browser which do all the CRUD ACTIONS and it communicate with TouchServer.Here we using dll files to communicate all these together like touchcommonlib,touchserverlib etc.and some tasklist running always.like watchdoc task,syncronizor task, touchserver task etc.</p> <p>Now let me explain my problem, The sync is running between server and station at the same time When we perform CRUD Operation in TouchAdmin ,the action gets failed.if we not running touchstation it works fine.now i thot while performing crud operation in admin i stop all tasklist.but when i access tasklist the count shows 0 so i cannot stop the tasks.</p> <p>I am writing the code to get the tasklist in syncronizer class as below.</p> <pre><code>ThingzDB.ThingzDatabase.taskList1 = TouchStation.Program.taskList; //here i am getting all tasks in tasklist. </code></pre> <p>where tasklist1 is the static object i created in ThingzDb api. as below</p> <pre><code>public static TouchCommonLib.Tasks.TaskList taskList1 = new TouchCommonLib.Tasks.TaskList(); </code></pre> <p>now i will access this tasklist when the operartion method is POST which is done through touch admin.and this post method written in touchserverlib.</p> <pre><code>if (ThingzDatabase.oper == 1) { ThingzDB.ThingzDatabase.taskList1.StopAllTasks(); ThingzDatabase.oper = 0; } </code></pre> <p>but here i am getting the tasklist count as 0.</p> <p>please anyone hellp me to find a solution for this.</p> <p>Thank you</p> <p>Jennie</p> <p>Now </p>
c#
[0]
4,969,711
4,969,712
jQuery: renumber all rows by changing first column's values
<p>I'm trying to renumber my rows, starting with a given start index, after an event. Here's the HTML for my table:</p> <pre><code>&lt;table id="table4"&gt; &lt;tr&gt; &lt;td&gt;&lt;span class='col1'&gt;6&lt;/span&gt;&lt;/td&gt; &lt;td&gt;Score&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I add rows in later with jQuery with the same format (the first column cell will always have the <code>&lt;span class='col1'&gt;&lt;/span&gt;</code> tag).</p> <p>I'm trying this with a css selector, but its not working (nothing is getting changed):</p> <pre><code>var startIndex = 6; $("span .col1").text($(this).closest("tr").index() + startIndex); </code></pre> <p>Is this the right way to do this? I'm kind of a jQuery noob. If there is a better way to do this, I'm more than happy to consider changing my code structure.</p>
jquery
[5]
2,354,979
2,354,980
Sending MMS through Intents in android to a particular number
<p>I have code to send MMS through intents.</p> <pre><code>Intent sendIntent = new Intent(Intent.ACTION_SEND); if(filename != "") sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + Environment.getExternalStorageDirectory()+ "/"+filename+".jpg")); sendIntent.setType("image/jpg"); startActivity(sendIntent); </code></pre> <p>but how come I can send MMS to a particular phone number. Looking forward to your reply. thanks.</p>
android
[4]
5,036,024
5,036,025
dynamic tree creation using jquery
<p>i Want to create dynamuc dree using jquery at client side and java(jsp/servlet) at backend using mysql database.Please suggest me how can i implemet that.I want to add further functionality like add node,add child,add leaf node.</p>
jquery
[5]
1,023,685
1,023,686
How to update the right span?
<p>On my forum-based website, I have a link below every post for reporting spam or abuse. Whenever this link is clicked, a web service is called on the server, when the call returns, the span containing the link (see the code below) is updated with something like 'Post reported' or if an error occurs it shows something like 'An error occurred while reporting the post', this is the javascript code:</p> <pre><code>&lt;script src="/js/MicrosoftAjax.js" type="text/javascript" language="javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript" language="javascript"&gt; var spanToUpdate; function ReportPost(updateSpan, postID) { if (confirm("Are you sure you want to report this post as spam or abuse?")) { spanToUpdate = updateSpan; var proxy = SiteWS.ReportPost(postID, onReportPostSuccess, onReportPostFailure); } } function onReportPostSuccess(sender, e) { spanToUpdate.innerHTML = "Post reported"; } function onReportPostFailure(sender, e) { spanToUpdate.innerHTML = "An error occurred while reporting the post"; } &lt;/script&gt; </code></pre> <p>And this is the reporting link:</p> <pre><code>&lt;div class="post"&gt; &lt;p&gt;post text here&lt;/p&gt; &lt;span&gt;&lt;a href="#" onclick="ReportPost(this.parentNode, &lt;%= post.ID %&gt;);return false;" title="Report spam or abuse"&gt;Report Post&lt;/a&gt;&lt;/span&gt; &lt;/div&gt; Other posts ... </code></pre> <p>As you can see, I use a variable, spanToUpdate, to hold a reference to the span that contains the reporting link, which means that if the user reports another post (ie. clicks another reporting link) before the call returns, the span of the last post will be updated twice and the previous one won't be updated at all, is there any workaround for this?</p> <p>Many thanks</p>
javascript
[3]
5,057,288
5,057,289
create edit text only accept or able to enter only alphabetical character from a-z only android
<p>i want to make a edit text in which can only be able to enter only alphabatical character means from a-z no other numeric or special charaacter are not allowed so how to do it?</p> <p>i had tried </p> <pre><code>&lt;EditText **android:inputType="text"** android:id="@+id/state" android:singleLine="true" android:layout_marginTop="50dip" android:layout_marginLeft="100dip" android:layout_height="40dip" android:layout_width="200dip" /&gt; </code></pre> <p>but it accept all the values means numeric and special character also.so how to restrict it means user can only enter a-z values.</p>
android
[4]
5,383,459
5,383,460
Variables Variable (Creating variable with the name of another variable)
<p>i want to create a new variable with a variable name, for example:</p> <pre><code>function preloader(imglist) { var imgs = imglist.split("|"); for (i in imgs) { var img_{i} = new Image; //this is the line where i sucked in! img_{i}.src = imgs[i]; //another line where i sucked in! } } preloader("asd.jpg|qwe.jpg|dorama.png"); </code></pre> <p>i try to use arrays but, hmm.. how can i say...</p> <pre><code>var qwe = new Array(); qwe[1] = "asd"; //or not! whatever... var qwe[1] = new Image; // it didnt work! </code></pre> <p>in php u can use like this:</p> <pre><code>$var1 = "test"; $var2_{$var1} = "test last"; echo $var2_test; //or... echo $var2_{$var1}; </code></pre>
javascript
[3]
2,096,285
2,096,286
Confirm message with javascript returns error
<p>I have problem with confirm message.... When I clicked the browser close button it shows confirm message with OK and CLOSE button....</p> <p>When I click ok button the browser get closed... If I click cancel it need to stay on the page...But when I click cancel button the browser get closed....</p> <p>MY CODE IS HERE</p> <pre><code> function doUnload() { if (!isClose) { var agree = confirm('Are you sure to close the window?'); if (agree == true) { return true; } else { return false; } } } </code></pre> <p>Please give me the solution.</p>
javascript
[3]
2,691,132
2,691,133
Why does a function have the word constant at the end even though it does change a variable
<p>My understanding of the keyword 'const' is that it says to the compiler, that the function will not modify any of the variables but in the following example it changes <code>b.d</code>. why?</p> <pre><code>myClass operator + (myClass b) const { b.d += d; return b; } </code></pre>
c++
[6]
765,179
765,180
Why is context getting passed in to this method
<p>I can't figure out why the context is getting passed in to this method: <a href="http://code.google.com/p/cloud-tasks-io/source/browse/trunk/CloudTasks-Android/src/com/cloudtasks/Util.java#119" rel="nofollow">http://code.google.com/p/cloud-tasks-io/source/browse/trunk/CloudTasks-Android/src/com/cloudtasks/Util.java#119</a></p>
android
[4]
5,786,957
5,786,958
function to get the name of any method?
<p>I would like to have a function called <strong>GetMethodName</strong> such that the following code would print "myMethod":</p> <pre><code>int myMethod(string foo, double bar) { // ... } Console.Out.WriteLine(GetMethodName(myMethod)); </code></pre> <p>This should work no matter what the method signature myMethod has. Is this possible?</p>
c#
[0]
221,452
221,453
javascript variable declarations after return statement
<p>I was looking at some minified javascript code (from github), and the code has a block that looks like</p> <pre><code>h = function(a, b, c, d) { var e, h, i, j, k, l, m = this; return i = $("#js-frame-loading-template").clone().show(), l = c === "back" ? 350 : 500, j = i.find(".js-frame-loading-spinner").hide() // more stuff here </code></pre> <p>I'm curious why/how this code works since there are variable declarations after the return statement</p>
javascript
[3]
4,338,209
4,338,210
PHP register clicks to callto: link
<p>Is there any way of registering clicks to a callto: link with the use of PHP? I've set up a site for a friend of mine and what I would like to do is to create a log of some sort to show who called who eg. if the current user clicks the callto: link I'd like to add a row to the database like "userX called numberY at hh:mm" but I've noticed you cant set variables in the callto: link as you would in ordinary links with just appending $var1=val etc...</p> <p>I figured you could make use of the onclick()-method of the a-tag but I'd rather skip javascript at the moment and just use PHP. Anyone got any ideas for this? Is it possible to use the header()-function and "redirect" to the callto: link?</p>
php
[2]
3,356,041
3,356,042
trying to calculate an estimat of e^x, where x is an integer entered by the user
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/827706/calculating-ex-without-using-any-functions">Calculating e^x without using any functions</a> </p> </blockquote> <p>my attempt</p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std; double myE(int num); int main(){ double e = myE(10); cout&lt;&lt;"e is "&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(5)&lt;&lt;e&lt;&lt;endl; return 0; } double myE(int num){ double e = 0; double factorial = 1; int x; cout&lt;&lt;"Enter a value for x in the expression e^x:"&lt;&lt;endl; cin&gt;&gt;x; for(int j = 0; j &lt;= num; j++){ for(int i = 1; i &lt;= j; i++){ factorial = factorial * i; } for(int k = 0; k &lt;= x; k++){ e = e + x / factorial; factorial = 1; }} return e; } </code></pre> <p>i keep getting the wrong answer .. what am i doing wrong</p>
c++
[6]
2,749,973
2,749,974
Hiding graphics created by 'Graphics'
<p>I have not studied much of the Graphics class in C# but have found myself needing it for my day to day fun times (coding to pass time).</p> <p>I would just like to know if there is a way to store the graphics drawn (before they are visibly seen on a form) so that I may have the whole segment drawn at the same time instead of having it drawn one by one. By segment I mean a collection of the shapes that are draw-able using the <code>Graphics</code> class.</p> <p>In other words I am trying to get all of this drawn before I attempt to show it on the screen by calling <code>.FillRectangle</code>, or equivalent. </p> <p>Also is there any known way to draw graphics without using the existing methods like GDI+ etc?</p> <p>If I have missed anything let me know.</p> <p>EDIT CODE:</p> <pre><code> using (Graphics formGraphics = df.CreateGraphics()) { this.DoubleBuffered = true; foreach (Dot d in memmap) { c = Color.FromArgb(d.r, d.g, d.b); using (SolidBrush brush = new SolidBrush(c)) { formGraphics.FillRectangle(brush, d.x, d.y, 1, 1); } } this.DoubleBuffered = false; } </code></pre>
c#
[0]
3,370,428
3,370,429
Read all text files in a folder with StreamReader
<p>I am trying to read all <em>.txt</em> files in a folder using stream reader. I have this now and it works fine for one file but I need to read all files in the folder. This is what I have so far. Any suggestions would be greatly appreciated.</p> <pre><code>using (var reader = new StreamReader(File.OpenRead(@"C:\ftp\inbox\test.txt"))) </code></pre>
c#
[0]
1,274,143
1,274,144
Adding an int, a byte, a long, and a float
<p>If you try to add an <code>int</code>, a <code>byte</code>, a <code>long</code>, and a <code>float</code>, what kind of data type is the result? (<code>float</code>, <code>long</code>, <code>byte</code>, <code>int</code> or is it even possible?)</p>
java
[1]
4,409,984
4,409,985
get text from textview .. by id that set programmatically
<p>I have 3 <strong>TextView</strong> objects, that I created programmatically</p> <p>Every <strong>TextView</strong> was repeated 7 times and <strong>ontouchlistener</strong> for the layer that contain them.</p> <p>When <strong>onTouch</strong> on the layer, I want to <strong>gettext</strong> from one of the <strong>TextView</strong> by the same view <strong>Id</strong></p> <p>I already tried .. </p> <pre><code> //tvDay is the one i want to get it text tvDay.findViewById(v.getId()); String course = tvDay.getText().toString(); </code></pre>
android
[4]
3,729,407
3,729,408
window.location affected by escape key?
<p>I have a timer to refresh the page, and it's working:</p> <pre><code>updateCountdown = function() { if (Variables.Seconds == Infinity) { } else if (Variables.Seconds == 0) { $countdown.text('Bam!'); window.location.replace(Variables.PageName); } else { $countdown.text(Variables.Seconds--); setTimeout(updateCountdown, 1000); } }; </code></pre> <p>Then I have this:</p> <pre><code>document.onkeydown=function(e) { if (e.which==27) { Variables.Seconds = 0; updateCountdown(); } }; </code></pre> <p>When I press escape, then $countdown.text says 'Bam!', but the page does not refresh like it does whenever Variables.Seconds normally decrements to 0.</p>
javascript
[3]
3,434,907
3,434,908
Immutability in Java
<p>If my class is going to be an immutable one it has to be <code>final</code> and without any method that modifies its state and all properties must be private. But why should it have properties declared as <code>final</code> (for example, <code>private final int a</code>)?</p> <p><strong>Edit</strong></p> <p>Will the class still be an immutable one if it has a reference to objects that are not immutable?</p>
java
[1]
2,500,324
2,500,325
What does * mean in Python?
<p>Does * have a special meaning in Python as it does in C? I saw a function like this in the Python Cookbook:</p> <pre><code>def get(self, *a, **kw) </code></pre> <p>Would you please explain it to me or point out where I can find an answer (Google interprets the * as wild card character and thus I cannot find a satisfactory answer).</p> <p>Thank you very much.</p>
python
[7]
275,291
275,292
Dynamic array in C# (vb.net snippet)
<pre><code>Private Function getFoo(ByVal _FileInfo As FileInfo) As foo() Dim provider As New ExcelStorage(GetType(foo)) provider.StartRow = 2 provider.StartColumn = 1 provider.FileName = _FileInfo.FullName Dim res() As foo = provider.ExtractRecords() Return res End Function </code></pre> <p>I have the above code in vb.net that i'm trying to convert to C#. I'm using FileHelper library to extract data from Excel. This is my conversion to C#.</p> <pre><code>public static foo GetFoo(FileInfo fInfo) { var provider = new ExcelStorage(typeof(foo)); provider.StartRow = 2; provider.StartColumn = 1; provider.FileName = fInfo.FullName; foo res[] = provider.ExtractRecords(); return res; } </code></pre> <p>What am I doing wrong here. I'm getting Bad array declator. Do I have to declare the size the array first?</p> <p>Thanks</p> <p>edit: I change the code as suggested. However, I'm getting this error.</p> <p>"Cannot implicitly convert type 'object[]' to 'foo[]'. An explicit conversion exists (are you missing a cast?)"</p> <p>I though I already set the type to foo in the ExcelStorage as typeof(foo). Nevermind, I did it with casting.</p>
c#
[0]
4,941,191
4,941,192
Reload page in iframe using jQuery
<p>How can I reload an aspx page in an iframe using jquery?</p>
jquery
[5]
4,762,633
4,762,634
certain output of x numbers
<p>i would like to make a program that takes an integer and gives a string of the amount of numbers of that integer. For example, if the integer is 7, it gives 7777777, or if its 3, it give 333. Thank you</p>
python
[7]
2,951,444
2,951,445
How to Send JSON String to server side in Android
<p>I creats one apps in android.I have fetch data from server side useing json but i have proble how to send json string or jso to server</p>
android
[4]
5,274,827
5,274,828
JQuery: html() is not working as expected
<p>I have a <strong>div</strong>:</p> <pre><code>&lt;div id="pageMessagesBox"&gt;&lt;/div&gt; </code></pre> <p>In a java script function I am trying to add some items inside my <strong>div</strong>:</p> <pre><code>$("#pageMessagesBox").html("&lt;a id='id'&gt;&lt;/a&gt;"); </code></pre> <p>But I've got the following result for <code>$("#pageMessagesBox").html()</code>:</p> <pre><code>"&lt;A id=id&gt;&lt;/A&gt;" </code></pre> <p>The expected is:</p> <pre><code>"&lt;A id='id'&gt;&lt;/A&gt;" </code></pre> <p>What am I doing wrong here ?</p>
jquery
[5]
2,858,340
2,858,341
Java Heap Memory error from socket
<p>I am trying to open a socket and listen. Clients written in PHP will then send XML requests. At the moment I am just send the string "test" to it and I am getting a Memory Heap Error. </p> <p>Here is my java code for the server:</p> <pre><code>import java.io.DataInputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class main { /** * @param args */ public static void main(String[] args) { server(); } public static void server() { ServerSocket MyService = null; try { MyService = new ServerSocket(3030); } catch (IOException e) { System.out.println(e); } Socket serviceSocket = null; try { serviceSocket = MyService.accept(); } catch (IOException e) { System.out.println(e); } DataInputStream in; try { in = new DataInputStream(serviceSocket.getInputStream()); System.out.println("DEV STEP 1"); int len = in.readInt(); System.out.println(len); byte[] xml = new byte[len]; in.read(xml, 0, len); //System.out.print(xml.toString()); //Document doc = builder.parse(new ByteArrayInputStream(xml)); } catch (IOException e) { System.out.println(e); } } } </code></pre> <p>The error I am getting is:</p> <pre><code>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at main.server(main.java:39) at main.main(main.java:12) </code></pre> <p>I have done a search and there are plenty of explanations of this error on here, however I can not work out why when I am sending a 4 letter String len is 1952805748.</p>
java
[1]
3,206,012
3,206,013
C++ Access violation when passing variable
<p>Heres my problem, if I pass a variable from class A to class B via function, then in class B pass that variable to other functions for testing then it works fine. But if I pass the variable from A to B then try assigning it to a variable in class B, it gives the error for no reason</p> <pre><code>//Globals.h enum TypeofObject { CIRCLE, SQUARE, RECTANGLE, DIAMOND }; //Object.h #include "Globals.h" class Object { void Update(); private: TypeofObject currentObject; CollisionDetection * gameCollision; }; //Object.cpp void Object::Update() { //Do stuff here gameCollision -&gt; testCollision(currentObject); } //CollisionDetection.h #include "Globals.h" class CollisionDetection { public: void testCollision(TypeofObject currentObject); private: void checkObjects(TypeofObject currentObject); TypeofObject currentObject; } //CollisionDetection.cpp void CollisionDetection::testCollision(TypeofObject curObject) { currentObject = curObject; //&lt;- If I have this then it gives access violation error checkObjects(curObject); //&lt;- Passing it from one function to the next works //fine but I want to assign it to currentObject so //it doesnt need to be passed } </code></pre>
c++
[6]
1,037,932
1,037,933
$ not defined using jQuery in Wordpress
<p>I know that jQuery is loaded, because I can switch out the $ for 'jQuery' and everything behaves as expected, but this will be a messy script if I can't fix this</p> <p>This script:</p> <pre><code>jQuery(document).ready(function(){ $("ul.vimeo_desc_feed li a").click(function(){ alert($(this).attr('href')); return false; }) }); </code></pre> <p>Produces the error <strong>$ is not a function</strong></p> <p>This script:</p> <pre><code>jQuery(document).ready(function(){ jQuery("ul.vimeo_desc_feed li a").click(function(){ alert(jQuery(this).attr('href')); return false; }) }); </code></pre> <p>works fine.</p>
jquery
[5]
3,287,285
3,287,286
jQuery No Conflict Mode for extra functions
<p>I'm sure this is a simple question, just can't seem to get it to work right.</p> <p>I was having some conflicts with jQuery, so I used the aliasing feature mentioned in the official documentation.</p> <pre><code>jQuery(document).ready(function($){ $('.loadmore').addClass('hidden'); // works fine! loadmore(); }); function loadmore(){ $('.loadmore').addClass('hidden'); // doesn't work! } </code></pre> <p>How do I get the aliasing to work for my code that I threw into functions for better organization and for the ability to reuse? I'm currently using <code>jQuery</code> instead of <code>$</code> for everything due to the issue presented in the sample above. Thought I could save a few bits of data and use the alias that's shown in all the tutorials.</p>
jquery
[5]
5,212,596
5,212,597
How to get rad text box value length throw javascript
<p>I am using <code>radcontrols</code> in my project. How do I get rad text box value's length. If I entered <code>12345</code>, the length should be <code>5</code>. </p>
javascript
[3]
376,599
376,600
is it necessary to set up all banking account info in the iphone dev account before submitting a paid app
<p>I just wanted to know if its necessary to set up all the banking info before proceeding with submission of the actual paid app for the binary.</p> <p>Thanks and Regards, Harikant Jammi</p>
iphone
[8]
4,083,306
4,083,307
How to shuffle and display cards so that it is only displayed once
<p>How do I shuffle and display cards in Java so that they are only displayed once?</p> <p><code>Math.random()</code> has a chance of being shown twice.</p>
java
[1]
3,797,517
3,797,518
What is the best way to copy a folder and all subfolders and files using c#
<p>I need to copy a Folder from one drive to a removable Hard disk. The Folder which needs to be copied will have many sub folders and files in it. The input will be Source Path and Target Path.</p> <p>Like..</p> <p>Source Path : "C:\SourceFolder" </p> <p>Target Path : "E:\"</p> <p>After copying is done, i shud be able to see the folder "SourceFolder" in my E: drive.</p> <p>Thanks.</p>
c#
[0]
2,607,700
2,607,701
Application pause/resume state
<p>My question is can i get to know when the entire application gets paused/resumed start/stop etc. For example if i have 5 activities in my application. Whenever any activity gets paused/resumed android notify the activity by calling the onPause/onResume methods.</p> <p>So there are two possible scenarios when my activity gets paused. 1. My activity-2 gets paused because my activity-3 gets invoked. 2. My activity-2 gets paused because of some outside activity like incoming call.</p> <p>Here I am interested only tracking when my activity gets paused by outside activities not my own application activities.</p> <p>So is there any android provided solution for this or do I have to write my customized solution.</p> <p>Thanks Dalvin</p>
android
[4]
5,770,831
5,770,832
jQuery select all link but exclude the link inside an iframe
<p>Suppose I have many links inside the the body, and many links inside an iframe, something likes:</p> <pre><code>&lt;div&gt; &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; ... &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; &lt;/div&gt; &lt;iframe src=xxx&gt; &lt;html&gt; &lt;head&gt;...&lt;/head&gt; &lt;body&gt; &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; ... &lt;a herf=xxxxxxx&gt;...&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; &lt;/iframe&gt; </code></pre> <p>How can jQuery to select all link but exclude the link inside an iframe?</p> <p>Thanks</p>
jquery
[5]
3,374,192
3,374,193
force get/set access of private variables for private properties
<p>If I have a private variable that I want to have some internal validation on, and I want to keep that validation in one place, I put it behind a getter/setter and only access it thorugh that getter/setter. That's useful when dealing with public properties, because the other code cannot access the private variable, but when I'm dealing with object inside the class itself, is there any way to enforce the getter/setter? </p> <pre><code> private int _eyeOrientation; private int eyeOrientation { get { return _eyeOrientation; } set { if (value &lt; 0) { _eyeOrientation = 0; } else { _eyeOrientation = value % 360; } } } </code></pre> <p>The issue here being that the other functions in the class may accidentally modify </p> <p><code>_eyeOrientation = -1;</code> </p> <p>which would throw the program into a tizzy. Is there any way to get that to throw a compiler error?</p>
c#
[0]
5,854,447
5,854,448
Download apk expansion file and move files into directory on sd card
<p>I'm looking into creating an apk expansion file for my application that would include files that i want to download and then move into an already existing directory in the external storage directory(SD card). But i cant find any information anywhere on how to do this or test that its working before i publish my app. The best information ive been able to find is <a href="http://docs.xamarin.com/Android/Guides/Deployment,_Testing,_and_Metrics/publishing_an_application/Part_4_-_APK_Expansion_Files" rel="nofollow">here</a>. Any insights on how to do this or references?</p>
android
[4]
3,955,149
3,955,150
Rowfilter in Asp.net?
<p>In Web application, [asp.net] i am using rowfileter, can i write two columns like...</p> <pre><code>dataView.RowFilter = "Name='sasi' and lastname='surya'"; </code></pre> <p>is this possible, can you help me.</p>
asp.net
[9]