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 |
|---|---|---|---|---|---|
4,522,123 | 4,522,124 | Getting a value in a textbox from a dropdown list | <p>I have a textbox named textbox1 and a dropdownlist. Dropdownlist contains the list of branches and i want that when i select a branch from dropdown i want to get the respective branch code to be generated in a textbox from the Database or from c# coding. How will it be possible ?</p>
| c# | [0] |
1,429,418 | 1,429,419 | How to use extern keyword? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration">What is the difference between a definition and a declaration?</a> </p>
</blockquote>
<p>In my A.h file:</p>
<pre><code>extern int a,b;
private: int x,y;
public: A():x(1),y(2){}
void total();
</code></pre>
<p>In my B.h file:</p>
<pre><code>private: int a,b;
public: A():a(1),b(2){}
</code></pre>
<p>In my C.cpp file:</p>
<pre><code>#include "A.h"
void total(){
int total = a + b + x + y;}
</code></pre>
<p>When I build the program, It said that :<br/></p>
<pre><code>undefined reference to `a';
undefined reference to `b';
</code></pre>
<p>Can anybody tell me why ? Thank you.</p>
| c++ | [6] |
2,063,205 | 2,063,206 | detect distance scrolled from top jquery | <p>How can I detect the number of pixels scrolled in a browser window?
I need this to dynamically adjust the height of a 100% height div... </p>
<p>I'm using jQuery.</p>
<p>EDIT: I cannot just use scrollTop() because I'm working with a 100% height div with overflow set to auto. Firefox does not detect browser scrolling due to this, the only thing scrolling is a 100%x100% div...</p>
| jquery | [5] |
3,982,025 | 3,982,026 | Why does Int32.TryParse reset the out parameter when not able to convert? | <p>if I run this C# code</p>
<pre><code>int realInt = 3;
string foo = "bar";
Int32.TryParse(foo, out realInt);
Console.WriteLine(realInt);
Console.Read();
</code></pre>
<p>I get 0. And I would like to know why! Cause I cannot find any reason why it would. This forces me to make temp variables for every parsing. So please! Great coders of the universe, enlighten me! </p>
| c# | [0] |
2,560,349 | 2,560,350 | How to create post thumbnail | <p>I am working on the WordPress Twenty Ten theme, and I want to display post thumbnails. I have followed the steps below:</p>
<ul>
<li><p>Added following code in functions.php file:</p>
<pre><code>if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
</code></pre></li>
<li><p>I have also defined post thumbnail size,</p>
<pre><code>set_post_thumbnail_size( 150, 150 );
</code></pre></li>
<li><p>And I configured the media settings from the admin panel of WordPress to not to crop image. but this is cropping the image.</p></li>
<li><p>Using this in loop.php file,</p>
<pre><code>the_post_thumbnail(array(150,150);
</code></pre></li>
</ul>
<p>I do not want to crop the image. How can I do this? Please help where I am wrong in my process.</p>
<p>Thanks in advance.</p>
| php | [2] |
30,079 | 30,080 | PHP: Work out duration between two times | <p>Ok, a really simple question but I am too thick to figure it out. I want to get the difference between two times. For example, "1:07" (1 minute and 7 seconds) and "3:01" (3 minutes and 1 second). It will only be ever minutes and seconds. I have been trying to make use of this:</p>
<pre><code>function timeDiff($firstTime,$lastTime)
{
// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);
// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;
// return the difference
return $timeDiff;
}
</code></pre>
<p>But I think I am running in the wrong direction?</p>
<p>Thank you for any help. </p>
<h2>EDIT</h2>
<p>I tried this: echo timeDiff('1:07','2:30');</p>
<p>I got this output "4980"</p>
<p>What is the above? Is it seconds? I have no idea how to get it as "1:23" which is the difference.</p>
<h2>EDIT 2</h2>
<p>Thank you all, I learnt so much just from this one thread, esp. Paul's. It works very well and I like the defensiveness!</p>
| php | [2] |
958,104 | 958,105 | JavaScript date from string? | <p>Novice question. I've got a string in the following format:</p>
<pre><code>var dateStr = '2012-4-14';
</code></pre>
<p>I want to make it into a JavaScript Date object. The following creates a Date object in Chrome, but is NaN in IE8:</p>
<pre><code>var myDate = new Date(dateStr);
</code></pre>
<p>What should I be doing differently - should I split the string?</p>
<p>Thanks!</p>
| javascript | [3] |
5,192,966 | 5,192,967 | Not able to push next view after clicking a uibutton which is on the top right of the view | <p>i am having a view consisting of a tableview and a uibutton like this<img src="http://i.stack.imgur.com/hBfKf.png" alt="enter image description here"> </p>
<p>when i click on button "add" a new class/xib named "Locsetting" should be open.which i am not able to do.
my code: .h file</p>
<pre><code> @interface LocationViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>
{
UITableView *table;
NSMutableArray *menuList;
LocSetting *locSetting;
IBOutlet UIButton *addbutton;
}
@property (nonatomic,retain) NSMutableArray *menuList;
@property (nonatomic,retain) IBOutlet UITableView *table;
@property (nonatomic,retain) LocSetting *locSetting;
@property (nonatomic, retain) IBOutlet UIButton *addbutton;
-(IBAction)gotoLocSetting:(id) sender;
@end
My .m :
@synthesize addbutton;
-(IBAction)gotoLocSetting:(id) sender {
NSLog(@"gotoLocSetting Entered");
locSetting = [[LocSetting alloc]
initWithNibName:@"LocSetting"
bundle:nil];
//locationViewController.menuList = [menuList objectAtIndex:indexPath.row];
[self.navigationController pushViewController:locSetting
animated:YES];
[locSetting release];
}
</code></pre>
<p>what wrong i am doing?or please guide me!
Thanks</p>
| iphone | [8] |
2,892,237 | 2,892,238 | adding map in xml slow down the app | <p>As soon as I add a map into my layout XML, the activity will be loaded very slow. After a long time, it will jump to the activity and display the map. I'm fresh about this, any help will be good.</p>
<p>I found a web link that says I should try <strong>delay load</strong>. I understand it as it will go to the activity first and then load the map. But I'm not sure how to realize this.</p>
<p>Could anyone provide an example?</p>
<pre><code><com.google.android.maps.MapView
android:id="@+id/location_map"
android:layout_toRightOf="@id/rl_personaltrip_departure_times"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:enabled="true"
android:clickable="true"
android:apiKey="@string/maps_api_key"
/>
</code></pre>
| android | [4] |
4,877,556 | 4,877,557 | jQuery. Call custom function with single $ | <pre><code>(function ($) {
$.fn.test = function () {
console.log('works');
};
})(jQuery);
$(document).ready(function () {
var var1 = $().test(); // works
var var1 = $.test(); // error: $.test is not a function
});
</code></pre>
<p>Is it possible to call like this $.test() ?
Thank you.</p>
| jquery | [5] |
2,176,580 | 2,176,581 | string a line to new line and do not add newline at the end? | <p>I have a string </p>
<pre><code>$str = 'aaaaabbbbbcccccdddddeeeeefffffggggghhhhhjjjjj';
$pos = 0;
$tmp = 0;
while($pos<strlen($str)) {
$tmp .= substr($str,$pos,5)."\n";
$pos += 5;
}
</code></pre>
<p>I dont want to add a <code>"\n"</code> at the end of produced <code>$str</code></p>
<pre><code>aaaaa
bbbbb
ccccc
ddddd
eeeee
fffff
ggggg
hhhhh
jjjjj //No new line here
</code></pre>
| php | [2] |
4,472,618 | 4,472,619 | Get only the first result of a foreach loop | <p>I am trying to display all the links that are located in <code><div class="post"></code>. There are many <code><div class="post"></code> inside my page (it is a blog). However there are many links in every <code><div class="post"></code> but I want to display the first of every div.
My question is how can I limit my code to show only the first one and continue to the next div?
Below is my code that gets and displays all the links. Gracias!</p>
<pre><code><?php
$dom = new DOMDocument;
libxml_use_internal_errors(TRUE);
$dom->loadHTMLFile('http://www.mydomain.com/');
libxml_clear_errors();
$xPath = new DOMXPath($dom);
$links = $xPath->query('//div[@class="post"]/a/@href');
foreach($links as $link) {
printf("%s \n", $link->nodeValue);
}
?>
</code></pre>
| php | [2] |
5,606,364 | 5,606,365 | Javascript check for Max/Min/Average number from a record set | <pre><code>function lab09unknownLoopCountPart2() {
//Constants
var ONE_HUNDRED = 100;
var ZERO = 0;
//Variables
var employeeHourlyWage;
var hourlyMaximum = ZERO;
var hourlyMinimum = ZERO;
var totalHourlyWage = ZERO;
var records;
var counter = ZERO;
var average;
records = openEmployeePayrollRecords();
while (records.readNextRecord()) {
employeeHourlyWage = records.getEmployeeHourlyWage();
totalHourlyWage += employeeHourlyWage;
counter++;
average = totalHourlyWage / counter;
if (employeeHourlyWage < ONE_HUNDRED) {
hourlyMaximum = employeeHourlyWage;
}
if (employeeHourlyWage < ONE_HUNDRED) {
hourlyMinimum = employeeHourlyWage;
}
}
document.write("Average Hourly Wage: " + average + "<br />");
document.write("Maximum Hourly Wage: " + hourlyMaximum + "<br />");
document.write("Minimum Hourly Wage: " + hourlyMinimum + "<br />");
</code></pre>
<p>}</p>
<p>The record set is simply numbers from 15 - 30. I have to sort through them and find the Maximum, Minimum and Average.</p>
<p>I know that my two IF statements are incorrect and I'm wondering how to check this, <strong>without</strong> using Math.min and Math.max.</p>
<p>Thanks.</p>
| javascript | [3] |
5,273,081 | 5,273,082 | Reading and Parsing a PDF File using XML parser from server in Android | <p>How to read and parse a PDF file URL inside parser from server in Android?</p>
| android | [4] |
3,509,456 | 3,509,457 | Using .hide() instead of .remove() | <p>The output should be like in this <a href="http://jsfiddle.net/SpB3m/3/" rel="nofollow">demo</a>. The problem is that I need to use .hide() instead of .remove(). Does anyone have any idea to solve it?</p>
<pre><code>$('td').parents('tr:contains(John)').remove();
$('tr').parents('tbody').not(':has(td)').after('<tr><td> Perfect!! </td> </tr>');
</code></pre>
<p>How can i resolve the same problem where <code>.hide()</code> is in the place of <code>.remove()</code>?</p>
<hr>
<pre><code><table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>John</td>
</tr>
<tr>
<td>Max</td>
</tr>
</table>
</br></br>
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>John</td>
</tr>
</table>
</code></pre>
| jquery | [5] |
5,720,236 | 5,720,237 | How to change an arrayList once a app is deployed? | <p>I would like to change the value of a ArrayList once a application is deployed. I want to be able to change it monthly. </p>
<p>I thought hosting a text document on my website.. Reading from it through the application and set the values to variables and set the variables to the ArrayList.</p>
<p>Would this be a good way to go about doing this?
Or is there a better way?</p>
| android | [4] |
5,913,406 | 5,913,407 | Send mail using My Outlook Account | <p>I tried to send mail form C# using my outlook account but I don't want the notification pop up window to be appeared when trying to send mails.</p>
<p>Any idea to disable the notifications windows?</p>
<p>Here my code snippent:</p>
<pre><code> public static void SendEmail(string _ToEmail, string _Subject, string _EmailBody)
{
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)(oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem));
email.Recipients.Add(_ToEmail);
email.Subject = _Subject;
email.Body = _EmailBody;
((Microsoft.Office.Interop.Outlook.MailItem)email).Send();
}
</code></pre>
| c# | [0] |
403,674 | 403,675 | Error in selecting multiple rows by checkbox error Undefined index: checkbox | <p>I want to select multiple rows from <code>checkbox</code> and want to update them all at once by button click..I tried in several ways..but not work..can you give a help please? it shows an error as <code>Undefined index: checkbox</code></p>
<pre><code><td>
<input type="hidden" name="id" id="id" value="<?php echo $row["file_serial_id"]; ?>" />
<input type="checkbox" name="checkbox[]" id="checkbox[]" value="<?php echo $row['file_serial_id']?>" />
</td>
if(isset($_POST['send_btn']) and $_POST['send_btn']=="Send"){
$checkbox = $_POST['checkbox']; //from name="checkbox[]"
$countCheck = count($_POST['checkbox']);
for($i=0;$i<$countCheck;$i++){
$del_id = $checkbox[$i];
$sql2 = "UPDATE retained_file_mst SET mark_to_dispose=1 WHERE file_serial_id='$del_id'";
$result2 = mysql_query($sql2,$conn);
}
// if successful redirect to delete_multiple.php
if($result2){
echo "success";
}else{
echo "error";
}
}
</code></pre>
| php | [2] |
3,919,722 | 3,919,723 | Pythonic representation of a list of values with optional flags | <p>What first pops into my head is a dictionary with keys acting as list values and dictionary values defaulting to <code>None</code>, but this feels sub-optimal to me. Can anyone propose a single-structure (i.e. no separate 'options' dict) alternative where <code>dict[key]</code> on an item with no flags set returns <code>None</code> and otherwise returns a list of flags? Apologies if I am overlooking some obvious convention.</p>
<p>A simple use for this structure could be an <code>order</code> instance where each item can optionally contain modifications (i.e. no nuts).</p>
| python | [7] |
3,379,195 | 3,379,196 | Get data from another form | <p>I have a listview in my Mainform and I need to get the value in the textbox and label in the other form name Add_Order?</p>
<pre><code>Add_Order add = new Add_Order();
ListViewItem item = new ListViewItem();
item.Text = add.textBox3.Text;
item.SubItems.Add(add.label6.Text);
item.SubItems.Add(add.textBox2.Text);
item.SubItems.Add(add.textBox1.Text);
item.SubItems.Add(add.textBox3.Text);
mainform.listView2.Items.Add(item);
</code></pre>
| c# | [0] |
5,267,245 | 5,267,246 | Forcing referencing assembly | <p>Is there any way to tell compiler not to remove some of the referenced assemblies that are not used by target assembly without writing dummy code?</p>
<p>For example I have 2 references:</p>
<pre><code>MyAssembly
-> MyLoggingAbstraction
-> MyLoggingAbstraction.NLog
</code></pre>
<p>However my assembly is using only types from <code>MyLoggingAbstraction</code> which scans current <code>AppDomain</code> for assemblies and their references and attempts to find implementation. This may sound like overcomplicating things, but I'd really want to make sure that it's enough to download package from nuget and not to write any aditional code to use that package.</p>
| c# | [0] |
1,757,244 | 1,757,245 | How to use javascript templating rather than raw HTML in javascript string? | <p>I am creating a web app that requires me to render new elements on the page many, many times. It is getting out of hand for me to add HTML by putting it into a Javascript string. Mostly because it's hard to edit it especially when it spans multiple ways. What's the best solution for this? And what's the best way to organize this stuff because I feel like I am going to have a huge page full of JS "subelements".</p>
| javascript | [3] |
4,680,852 | 4,680,853 | Conditional expression inside Convert.ToString() evaluating wrong? | <p>I'm stumped. Why wouldn't the first and fourth lines evaluate to null?</p>
<p><img src="http://i.stack.imgur.com/Z7E32.png" alt="null wut"></p>
<p><strong>Post-answer edit:</strong></p>
<p>For the benefit of others, the desired behavior would be created by using:</p>
<pre><code>boolFoo ? null : Convert.ToString(DBNull.Value)
</code></pre>
<p>This works because <code>Convert.ToString()</code> and <code>null</code> imply a common type of <code>string</code>.</p>
| c# | [0] |
4,188,887 | 4,188,888 | Custom title bar with ListView | <p>I have a Activity Extend ListActivity
I want add a LinearLayout or RelativeLayout on top of the list
like a action title
But when I add in XML
List not Display,Why?</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="1111"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"/>
</RelativeLayout>
<ListView android:id="@id/android:list" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"
android:drawSelectorOnTop="false" android:padding="4dip" />
<TextView android:id="@id/android:empty" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:text="No_data" />
</LinearLayout>
</code></pre>
| android | [4] |
335,560 | 335,561 | Does stop() Only Work With animate()? | <p>I've got a simple setup where when one hovers over the #ProductLink li, #ProductListing ul opens, then closes when the mouse moves away.</p>
<pre><code>$(document).ready( function() {
$("#ProductLink").hover(
function() {
$('#ProductListing').slideDown(200);
},
function() {
$('#ProductListing').slideUp(200);
}
) } )
</code></pre>
<p>This works but the predictable side effect is that multiple passes over and out of #ProductLink cue the sliding up and down. I have tried to use stop() to keep this from happening without success and am wondering if stop() only works with animate().</p>
<p>If stop() does work in this instance then I would appreciate a pointer in the right direction.</p>
<p>Thanks -</p>
<p>george</p>
| jquery | [5] |
939,081 | 939,082 | Simple regular expression pattern for php | <p>How to write a regular expression that will pass a numbers from 60 to 99?</p>
| php | [2] |
3,467,090 | 3,467,091 | PHP var_dump($_SESSION); | <p>I am working on a project and the <code>$_SESSION['username']</code> was not echoing I used the var_dump and this is what I got back from that result my question is how do I fix it.</p>
<pre><code> array(4) {
["SESS_ID"]=> string(1) "2"
["SESS_FIRST_NAME"]=> string(7) "Kevin"
["SESS_LAST_NAME"]=> string(6) "Outerbridge"
["username"]=> string(0) "" }
</code></pre>
<p>I am sort of new to this var_dump so I am not sure if it is in your forum I will relook at all that is posted.</p>
| php | [2] |
216,288 | 216,289 | Get the higher result(s) from a questionnaire with jQuery | <p>I'm trying to build a questionnaire / personality test with jQuery.
I have an object in the end :</p>
<pre><code>results = {
quality1 : 2,
quality2 : 3,
quality3 : 0,
quality4 : 3,
etc
}
</code></pre>
<p>I then want to retrieve the key with the higher value. No problem if there is only one matching result :</p>
<pre><code> topScore = 0;
$.each(results, function(i,val) {
if ( results[i] > topScore ) {
topScore = results[i];
topQuality = i;
}
});
console.log('Higher quality : ' + topQuality)
</code></pre>
<p>but what if there are many ? (for instance, in the example, quality2 and quality4)</p>
<p>I'm kind of lost, here...</p>
| jquery | [5] |
5,919,229 | 5,919,230 | getting div current placement | <p>How can I get the div's current postion with jQuery or divs current placement with jQuery</p>
| jquery | [5] |
2,406,885 | 2,406,886 | How to create a ghost mode like app? | <p>I have an android app that needs to hide and only appear when the user dials a specific number. Can I please know exactly how it is done? I have searched and no success. Thanks in advance.</p>
| android | [4] |
5,190,538 | 5,190,539 | how to deal with asynchronous function? | <p>I have two asynchronous objects fn1 and fn2 and sometimes I want to run them synchronously.</p>
<p>For simplicity I wrote the code in this way:</p>
<pre><code>var fn1 = function () {
setTimeout(function () {
console.log("fn1");
},200);
};
var fn2 = function () {
setTimeout(function () {
console.log("fn2");
},100);
};
fn1();
fn2();
</code></pre>
<p>but let's suppose is not possible to modify the fn1 and fn2 object. </p>
<p>What is the best way to run fn2 only when fn1 has finished to be executed?</p>
| javascript | [3] |
3,217,410 | 3,217,411 | Get the selected value when changing the selected value with jQuery | <p>I'd like when I selected a value in a dropdown get the value selected.</p>
<p>Any idea ?</p>
<p>Thanks,</p>
| jquery | [5] |
658,009 | 658,010 | Button as last item in ListView Android | <p>I need to place a <code>Button</code> to be the last item in the <code>ListView</code>. For example you are scrolling the list view and when you are reaching the end there is a <code>Button</code>, you are clicking it and the list is loading more items and the button is still at the end of that list.</p>
| android | [4] |
800,062 | 800,063 | How do I used values declared in XML on my custom layout? | <p>Im creating a custom layout and I want to use the text declared in the <code>layout.xml</code> file in my layout.</p>
<p>Like when I create a <code>TextView</code> in XML and set <code>android:text=@string/text1</code> when I run the app text view automatically loads the text from android:text. So how can I access attributes declared in the layout XML file in my custom component.</p>
| android | [4] |
4,487,239 | 4,487,240 | PHP Take a Variable in an If statement literally | <p>I was wondering if it would be possible to do this:</p>
<pre><code>$var = '$something == $somethingelse';
if ($var) { // Say hello }
</code></pre>
<p>and have it mean the same thing as this:</p>
<pre><code>if ($something == $somethingelse) { // Say hello }
</code></pre>
<p>I know this will not work at the moment, because <code>if ($var)</code> checks to see if <code>$var</code> is set or not. But what I'm asking is: is there a method to allow this? Would appreciate an answer.</p>
<p>EDIT:
Basically I feel I should explain why I am doing this.
I want users to be able to control when they get a notification, based off some data that one of their "channels" has saved.</p>
<p>For instance, a user only wants to get a notification when their collected data is bigger than 60. So I would get them to choose two fields:</p>
<p>First field input of their number (int or float)</p>
<p>Second field choises (equals, <, >, =<, =>)</p>
<p>The last thing in this if statement would be their data collected by their "channel".</p>
<p>I then want to be able to save their choice in a database, somehow, and then later act upon their choices.</p>
| php | [2] |
1,214,635 | 1,214,636 | session object design pattern | <p>I'm looking to build an ajax page; it's a reporting page. By default, load today's report. On the page there's a calendar control and when the user clicks on a date, reload the gridview with the corresponding data. Is it considered good practice to do the following:</p>
<pre><code>1) on the first page load, query the data for the page
2) put the query result in the session object and display it in a gridview
3) if the user requests new data, get new data from the query with different parameters
4) put the result of the second query in the session object and display it
5) if the user then requests the data from the first query, get it from the session object
6) do the sorting and paging with the data held in the session.
</code></pre>
<p>Note: the data of each query will contain about 300-500 rows and about 15 columns. I'd like to do all this with ajax calls. What are some suggestions and pitfalls to avoid.</p>
<p>Thanks.</p>
| asp.net | [9] |
4,407,433 | 4,407,434 | Defining as constants in Java | <pre><code>list.loadRequestParms(request, 'a', 20);
</code></pre>
<p>This method takes three parameters</p>
<ol>
<li>a request object.</li>
<li>a char</li>
<li>an integer</li>
</ol>
<p>Now how to define these as constants somewhere and use it in this method.</p>
| java | [1] |
5,147,465 | 5,147,466 | What is wrong with this PHP code? | <p>I've got a piece of code that keeps failing.</p>
<pre><code> if (isset($_GET ['id']) && $rawdata) {
if ($_SERVER["REQUEST_URI"] != $rawdata ['htmltitle']) {
header("Location: http://".$_SERVER['SERVER_NAME'].".$rawdata['htmltitle'].");
}
}
</code></pre>
<p>The line that fails, is the one with the header in it, and fails with:</p>
<pre><code>PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
</code></pre>
<p>Any ideas on what's wrong?</p>
| php | [2] |
2,839,975 | 2,839,976 | Get the maximum time of a date | <p>How can I get the maximum time of a DateTime value selected from datetimepicker?
For example '08/21/2011 23:59:59'</p>
| c# | [0] |
2,031,573 | 2,031,574 | learning how to do basic image processing | <p>what are the best tools for c# to do image processing? i am a beginner and want to learn the basics</p>
| c# | [0] |
3,837,040 | 3,837,041 | Deploy Windows Applications with Visual Studio.NET | <p>I have created a window setup file for my window project in visual studio 2008. This setup file is running properly and installed the software in computer. But I want to add a external <code>exe</code> file into my setup project. But this external <code>exe</code> should not be installed on computer. How can I add this another <code>exe</code> file in my setup not for installing?</p>
| c# | [0] |
3,872,191 | 3,872,192 | Textview updation | <p>I have array of 15 elements...mObjects and have 7 textviews to display. At first I am loading 7 in the TextView array and then as user goes on click text view should get update i.e. if user got the third element then it should update the 3rd Texvire with the next mObject in a list kind of manner.... My logic works with the first 7 elements populated but how will I keep on adding the elements from mObjects ......</p>
<p>to explain more : if 3rd element of textview is found then 4th textview becomes 3rd...5th becomes 4th and 7th should add the new text from mObjects .. till the 15 elements of the array</p>
<p>here is the logic for 7 elements but not getting how will i add the 8th element to 15 element from the mObjects</p>
<pre><code>public void onClick(View pressed){
boolean tvFound = false;
for(int i=0;i<mTextViews.length;i++){
if(pressed.getId() == mTextViews[i]){
tvFound = true;
}
if(tvFound){
if(i<mTextViews.length-1){
mTextViews[i].setText(mTextviews[i+1].getText());
}else{
mTextViews[i].setText("");
}
}
}
}
</code></pre>
| android | [4] |
2,695,631 | 2,695,632 | Why they created a timeout | <p>if u add this to web.config, then if a page have gone through long process, the client will not have a timeout exception.</p>
<pre><code><httpRuntime maxRequestLength="1024000" executionTimeout="36000"/>
</code></pre>
<p>they are timing out things for a purpose, what is it?, I tried to create a website with two pages I make a button in default1.aspx wait for 5 minutes. the other page requesting is not affected by that.</p>
<p>thanks</p>
| asp.net | [9] |
2,862,801 | 2,862,802 | ASIHTTP: addOperation when other threads are running | <p>I have a project using ASIHTTP to multi download files from a site</p>
<p>when I add a new request:</p>
<pre><code>[networkQueue cancelAllOperations];
[networkQueue setDownloadProgressDelegate:a];
[networkQueue setDelegate:self];
[networkQueue setRequestDidFinishSelector:@selector(requestDone:)];
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
[networkQueue addOperation:request];
[networkQueue go];
</code></pre>
<p>it reported:</p>
<p><strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[ASINetworkQueue addOperation:]: operation is executing and cannot be enqueued'</p>
<p>It looks like I can not add a new request when others are running.</p>
<p>Welcome any comment</p>
<p>Thanks</p>
<p>interdev</p>
| iphone | [8] |
3,960,255 | 3,960,256 | Android: how to kill an external application and reset its data | <p>I have seen bits and pieces around but nothing complete (or that worked). Essentially I want to kill an external application and wipe all of its data, essentially resetting the program back to its initial install state. </p>
<p>I am trying this for skype (for example):</p>
<pre><code>try {
Process proc = Runtime.getRuntime().exec("su");
proc = Runtime.getRuntime().exec("pidof com.skype.raider");
BufferedReader reader = new BufferedReader( new InputStreamReader(proc.getInputStream()),8192);
char[] buffer = new char[8192];
StringBuffer output = new StringBuffer();
int read = 0;
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
proc.getErrorStream().close();
proc.getOutputStream().close();
proc.waitFor();
proc = Runtime.getRuntime().exec("kill " + output.toString());
proc.waitFor();
proc = Runtime.getRuntime().exec("rm -r /data/data/com.skype.raider/*");
proc.waitFor();
} catch (Exception ex) {
//Log.i(TAG, "Error", ex);
}
</code></pre>
<p>BTW: All of those commands work fine in ADB...</p>
| android | [4] |
2,017,404 | 2,017,405 | What does this line of python mean? | <p>Hey if you look at the following code (that works)</p>
<pre><code>old = 0
new = 2
sel = 4
print 'OnPageChanged, old:%d, new:%d, sel:%d\n' % (old, new, sel)
</code></pre>
<p>It doesnt really make any sense, how can you use mod on a string? And how does (old, new, sel) work. Also, why is the person putting %d in the string?</p>
<p>Sorry if this isn't in the right place, I didn't know where else to ask this question.</p>
<p>Thanks to anyone who reads.</p>
| python | [7] |
1,615,009 | 1,615,010 | GCJ cannot find GCCMain class | <p>I am new to linux and programming in general and I can't even seem to get the simple Hello World code to run. Below is what i have done and the error I am receiving, I am using Cygwin. Can anyone help me? </p>
<pre><code>theys@THEYS1 ~/java
$ vim test.java
theys@THEYS1 ~/java
$ ls
helloworld.java test.java
theys@THEYS1 ~/java
$ uname -a
CYGWIN_NT-6.1-WOW64 THEYS1 1.7.15(0.260/5/3) 2012-05-09 10:25 i686 Cygwin
theys@THEYS1 ~/java
$ cat test.java
public class test {
public static void main (String [] args) {
System.out.println ("Hello World!");
}
}
theys@THEYS1 ~/java
$ gcj --main=test -o test test.java
Exception in thread "main" java.lang.NoClassDefFoundError:
org.eclipse.jdt.internal.compiler.batch.GCCMain
at gnu.java.lang.MainThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
org.eclipse.jdt.internal.compiler.batch.GCCMain not found in
gnu.gcj.runtime.SystemClassLoader{urls=[],
parent=gnu.gcj.runtime.ExtensionClassLoader {urls=[], parent=null}}
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at gnu.java.lang.MainThread.run(Unknown Source)
</code></pre>
| java | [1] |
4,091,130 | 4,091,131 | In C++ books, array bound must be constant expression, but why the following code works? | <pre><code>#include <iostream>
using namespace std;
int main(){
int n=10;
int a[n];
for (int i=0; i<n; i++) {
a[i]=i+1;
cout<<a[i]<<endl;
}
return 0;
}
</code></pre>
<p>worked fine in Xcode4 under Mac </p>
<p>as said in books, it should be wrong, why?</p>
<p>so confused~</p>
| c++ | [6] |
2,817,276 | 2,817,277 | Maintain count in python list comprehension | <p>In Python, is there any <code>counter</code> available during the list comprehension as it would be in case of a <code>for</code> loop?</p>
<p>It would be more clear why I need a counter, with this example:</p>
<p>I wish to achieve the following:</p>
<p>Initial List: <code>['p', 'q', 'r', 's']</code></p>
<p>Desired List: <code>[(1, 'P'), (2, 'Q'), (3, 'R'), (4, 'S')]</code></p>
<p>In the desired list, first element of every tuple are ordinal numbers. If it were just flat list, I could have used <code>zip</code> to achieve this. But however, the list I am dealing with is nested, three level deep (think of hierarchical data), and it is generated through list comprehension.</p>
<p>So, I was wondering is there any way to introduce those ordinal numbers during list comprehension. If not, what would be the best possible solution.</p>
<p>P.S. : Here the lower case letters are converted to uppercase, but that is not a part of problem, think of it as just a data conversion.</p>
<p>Code:</p>
<pre><code>allObj = Category.objects.all()
tree =[(_, l1.name, [(__, l2.name, [(___, l3.name) for l3 in allObj if l3.parentid == l2.categoryid]) for l2 in allObj if l2.parentid == l1.categoryid]) for l1 in allObj if l1.parentid == None]
</code></pre>
<p><code>allObj</code> contains data from table category, which in turn contains hierarchical data represented in the form of Adjacency List.</p>
<p>I have put <code>_</code> where I need ordinal numbers to be. Notice that the list is nested, so there will be a separate counter at each level represented by 1, 2 & 3 <code>_</code>s.</p>
| python | [7] |
4,610,733 | 4,610,734 | Java set accessed date on file | <p>Is there a way in java to set the access time without setting the date modified time as well?</p>
<p>This will be in essence a touch -a command.</p>
<p>the setLastModified method in File updates both the access time as well as the date modified.</p>
<p>We are currently using java 6. Moving to 7 wouldn't be out of the question.</p>
| java | [1] |
4,362,628 | 4,362,629 | Is Instagram's Feed View based on UIWebView or UITableView? | <p>It looks like UIWebView, but how do they implement that download progress bar and the section bar(very smooth scroll)...?</p>
| iphone | [8] |
5,584,394 | 5,584,395 | Is this really saving allocation? | <p>I've got the following in a static Utility class:</p>
<pre><code>static int[] MonthDays = new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
public static int[] GetListOfAllDaysForMonths()
{
return MonthDays;
}
</code></pre>
<p>Is this efficient in that now by calling GetListOfAllDaysForMonths() in several places in code, that I am saving myself from having to allocate and create a new int[] each time this method is called?</p>
<p>Updated: Lets make it readonly</p>
<pre><code> static readonly int[]
</code></pre>
| c# | [0] |
1,838,604 | 1,838,605 | Can we autocopy the *.dll.config? | <p>when refering to a library assembly, it is auto copied to the final bin directory. However the *.dll.config is not, is there a way to automatically copy this config file?</p>
| c# | [0] |
1,789,841 | 1,789,842 | App.config does not work? | <p>Config Like this :</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add
name="MyProject.Properties.Settings.Default.dataConnection"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=address;
Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
</code></pre>
<p>and when i want to use following code to get connection string , "Error 1 'Weather.Properties.Settings' does not contain a definition for 'dataConnection' and no extension method 'dataConnection' accepting a first argument of type 'Weather.Properties.Settings' could be found (are you missing a using directive or an assembly reference?) " error rises ,</p>
<pre><code>string connectionString =
global::MyProject.Properties.Settings.Default.dataConnection;
</code></pre>
| c# | [0] |
1,782,642 | 1,782,643 | android application not working on all versions | <p>I have just worked on my first android application and introduced it in google play. But the application is not working on some android versions. I tried it on Sony Xperia with android 2.3.7 it did not downloaded. But when I tried it on another Sony Xperia phone which was having android 2.3.6 it downloaded and worked perfectly. I am amazed that why is it not working on all of android versions. Can anyone please help me to resolve it?<br>
<strong>Update:</strong> I am sorry last time I mentioned wrong version.</p>
<p>Regards<br>
Pankaj</p>
| android | [4] |
1,215,664 | 1,215,665 | how to get returned text from a php page | <p>very simple php question,</p>
<p>for example, demo.php just returns a text like this "hello".</p>
<p>how can i get this text from an another php page ?</p>
<p>UPDATE:</p>
<p>actually i meant page is outputting it like this "print 'hello';"</p>
| php | [2] |
3,973,439 | 3,973,440 | WebForms view engine documentation? | <p>I have maybe very very Simple Question:</p>
<p>Where i can find documentation about expressions and syntax of WebForms view engine?</p>
<p>And what is the difference between </p>
<pre><code><%: expression %>
</code></pre>
<p>and </p>
<pre><code><%= expression %>
</code></pre>
<p>?</p>
<p>in advance thanks for reply</p>
| asp.net | [9] |
5,553,255 | 5,553,256 | How to target android applications to a particular country? | <p>I had developed an application and the app targets only to a specific country.</p>
<p>Is the selection of country in developer console is enough to target the specific country or do I have to do any other settings ??</p>
| android | [4] |
4,470,066 | 4,470,067 | How to show server images in tableVIew? | <p>i am developing a new project. And i am using the JSON Parsing. It required to show images in tableView. but i am using asynchronization Images in my project. but one problem is regard their, when cell is reused, at that time the images is again reload to that cell.
How can we remove the asynchronization in my project. and how to remove the reload problem of images.</p>
<p>please give me proper guide with tutorial...</p>
<p>thanks in advance...</p>
| iphone | [8] |
229,110 | 229,111 | int to unsigned int conversion | <p>I'm just amazed to know that i can't convert signed to unsigned int by casting!</p>
<pre><code>int i = -62;
unsigned int j = (unsigned int)i;
</code></pre>
<p>I thought i already knew this since i started to use casts but i can't do it!</p>
| c++ | [6] |
362,338 | 362,339 | Are Javascript typed arrays initialized to 0? | <p>I need a typed array, specifically a Float32Array, of all zeros. I was thinking that I would have to clear it manually, but I noticed that when I declared it, it was already zeroed out. Is this something that is specified in the spec? Can I rely on this behavior?</p>
| javascript | [3] |
2,207,365 | 2,207,366 | Android PRL update | <p>Would it be possible to do this programatically? So far we are opening the dialer and dialing *228... but would prefer another method. Any ideas, or possible other directions?</p>
| android | [4] |
6,014,096 | 6,014,097 | java.lang.OutOfMemoryError: bitmap size exceeds VM budget? | <p>friends,</p>
<p>i am using following code to display bitmap on screen and having next and previous buttons to change images.</p>
<p>and getting out of memory error</p>
<p><strong>New Code</strong></p>
<pre><code>HttpGet httpRequest = null;
try {
httpRequest = new HttpGet(mImage_URL[val]);
} catch (Exception e) {
return 0;
}
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
Bitmap bm;
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream is = bufHttpEntity.getContent();
try
{
bm = BitmapFactory.decodeStream(is);
}catch(Exception ex)
{
}
is.close();
</code></pre>
<p><strong>Old Code</strong></p>
<pre><code>URL aURL = new URL(mImage_URL[val]);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = null;
try
{
is= conn.getInputStream();
}catch(IOException e)
{
}
BufferedInputStream bis = new BufferedInputStream(is);
bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
img.setImageBitmap(bm);
</code></pre>
<p>and it was giving me error decoder->decode return false.</p>
<p>on images of size bigger than 400kb.</p>
<p>so after googling i got new code as answer
the old code was not giving me out of memory error on those images but decoder->decode return false, so i choosed new code.</p>
<p>any one guide me what is the solution and which is the best approach to display live images?</p>
| android | [4] |
4,000,433 | 4,000,434 | How to draw a line based on mouse move | <p>I am looking for a way to draw a line on mouse start to end. For example I have DIV and I have moved the mouse in circular way. But I want a line to be drawn in the path mouse is moved. </p>
<p>I am not looking for any HTML5 solution. I want it to be worked even in all modern browsers.</p>
<p>Please help me on this.</p>
| javascript | [3] |
2,477,450 | 2,477,451 | How to read location only once with locationManager (GPS and NETWORK PROVIDER) and not any more looking for updates of location? | <p>How to read location only once with locationManager (GPS and NETWORK PROVIDER) and not any more looking for updates of location, to save battery?</p>
| android | [4] |
3,750,938 | 3,750,939 | PHP URL Generation | <p>I have a set of data being returned to a table using PHP and MySQL and I would like to put a link at the end of this data using elements from the row to build the link with some static elements.</p>
<p>i.e. $urlStart/name-installer-date-email-gno$urlEnd</p>
<pre><code><tr>
<th>Installer Ref:</th>
<th>Fitter</th>
<th>Guarantee</th>
<th>Equipment</th>
<th>Installed</th>
<th>Options</th>
</tr>
</thead>
<?php
$i=0;
while ($i < $num) {
/* $f1=mysql_result($result,$i,"installer"); */
$f2=mysql_result($result,$i,"fitter");
$f3=mysql_result($result,$i,"guarantee_no");
$f4=mysql_result($result,$i,"equipment");
$f5=mysql_result($result,$i,"certificate_no");
$f6=mysql_result($result,$i,"install_date");
?>
<tbody>
<tr>
<td><?php echo $f5; ?></td>
<td><?php echo $f2; ?></td>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
<!-- <td><?php echo $f5; ?></td> -->
<td><?php echo $f6; ?></td>
</code></pre>
| php | [2] |
147,671 | 147,672 | What's the right way to exchange variables between classes? | <p>I have class Config:</p>
<pre><code>class Config
{
public:
Config();
~Config();
void Read();
CData var; //CData - some config structure
};
</code></pre>
<p>What's the right way to access the values from other classes? There are a few options:</p>
<ol>
<li>make it global</li>
<li>transfer reference to other classes</li>
<li>your variant</li>
</ol>
<p>In my system, <code>config.var.some</code> is needed in 90% of classes.</p>
| c++ | [6] |
2,005,126 | 2,005,127 | regular expression to the following string | <p>let me know I can use that expression to extract the url in the following code</p>
<pre><code><div class="bg-movie alpha omega">
<img class="alignnone size-full wp-image-7282"
title="CineMundo Tu Mejor Lugar El Caballero de la Noche Asciende"
src="http://www.cinemundo.cl/sitio/wp-content/uploads/2012/05/cinemundo_batman_el-caballero-de-la-noche-asciende_estrenos-2012.jpg"
alt="Película El Caballero de la Noche Asciende - Estrenos 2012"
width="117" height="173">
</div>
</code></pre>
<p>and come to this but I do not work well</p>
<pre><code>preg_match_all('/<img [class="bg-movie alpha omega"]*src=["|\']([^"|\']+)/i', $html, $images);
</code></pre>
| php | [2] |
1,539,934 | 1,539,935 | How to append a DIV Banner Block to a HTML Page using jQuery | <p>I am using jQuery 1.3.2 and I was wondering if I could pls get some assistance on whether the following is achievable and if so, how can it be done - examples would be great.</p>
<p>Basically, I have an iframe src page that displays a report to a user. Now because it's in an iframe, there is no banner on that page but I do allow the user to detach the iframe into a new browser window using window.open, so that they can see more info.</p>
<p>My question is, as I am opening the iframe page into a new browser, I need to manipulate the html and append, at body part of the page, a div section, that contains a banner.</p>
<p>Basically, in this div, I have my company's banner (logo and name), I just need a means of attaching this to the top of the page when a user detaches the page from the iframe.</p>
<p>Would appreciate some help on how to do this.</p>
<p>Thanks.</p>
| jquery | [5] |
4,530,950 | 4,530,951 | how to turn off buttons within a variable? | <p>I have a piece of code below where it contains 26 buttons from A-Z. Each button can be turned on and turned off.</p>
<pre><code><?php
$a = range("A","Z");
?>
<?php
$i = 1;
foreach($a as $key => $val){
if($i%7 == 1) echo"<tr><td>";
echo"<input type=\"button\" onclick=\"btnclick(this);\" value=\"$val\" id=\"answer".$val."\" name=\"answer".$val."Name\" class=\"answerBtns answers answerBtnsOff\">";
if($i%7 == 0) echo"</td></tr>";
$i++;
}
?>
</code></pre>
<p>Below is the code where I am trying to turn on and off the correct buttons but the problem is that it is not turning off the buttons it should be turning off.</p>
<pre><code>var answers = '#answer'+btn;
$('.answers.answerBtnsOn').find('answerBtnsOn').addClass('answerBtnsOff');
</code></pre>
<p>Now if I change the last line of code to code below:</p>
<pre><code>$('.answerBtnsOn').find('answerBtnsOn').addClass('answerBtnsOff');
</code></pre>
<p>then it works but the problem is that all my buttons have the class ".answerBtnsOn", I only want the buttons within the "answers" variable to be turned off when it should be. So how can I turn off buttons within the "answers" variable?</p>
| jquery | [5] |
5,535,993 | 5,535,994 | What should I be aware of when building my own HMVC PHP framework? | <p>I am in the process of building my own glue php framework. I like the way that Codeigniter and Nette is working, however they lack a couple of things and some of the things I need to be done differently.</p>
<p>I am planing to study Zend Framework 2 and Symfony2 how they are doing things.</p>
<p>However, I will probably need to check some other frameworks in different languages to get the best perspective available.</p>
<p>So, my question is... Should I study e.g. Django, Ruby on Rails, Monk or should rather focus on study as much PHP frameworks as possible.</p>
<p>I think the process will take at least 2-3 years to build a solid framework. I think I can learn a lot by building my own php framework. maybe I will give up and stay with Zend and maybe not. Who knows, at least I will learn something.</p>
<p>@Moderators I am not asking which framework is the best, rather what are the best practicess in their opinion and what should I be aware of and what principles to follow. I am sure that a lot of people are building a php framework or have done it in the past, so I am excited to hear their advice, what mistakes they made etc. so I can eventually progress faster in my struggle to build my own glue php framework</p>
<p>Thanks for your advice how should I be moving in these muddy waters ;)</p>
| php | [2] |
3,391,283 | 3,391,284 | Python list traversal with gaps | <p>Hi I have a multidimensional list such as:</p>
<pre><code>my_list = [[1,2,3,1,2],[1,0,3,1,2],[1,0,0,0,2],[1,0,3,0,2]]
</code></pre>
<p>where 0 represents a gap between two pieces of data. </p>
<p>What I need to do is iterate through the list and keep track of how many gaps are in each sublist and throw away the zeros. I think the best way is to break each sublist into chunks where there are zeros so I end up with smaller lists of integers and a number of gaps. Ideally, to form a new list which tells me the length of each chunk and number of gaps (i.e. chunks -1), such as:</p>
<pre><code>new_list = [[5, 0], [[1, 3], 1], [[1, 1], 1], [[1, 1, 1], 2]]
</code></pre>
<p>or probably better:</p>
<pre><code>new_list = [[5], [1, 3], [1, 1], [1, 1, 1]]
</code></pre>
<p>and I will know that the gaps are equal to len(chunk).</p>
<p><strong>EDIT:</strong>
However, leading and trailing zeros do not represent gaps. i.e. [0,0,1,2] represents one continuous chunk.</p>
<p>Any help much appreciated.</p>
| python | [7] |
671,851 | 671,852 | Generics Vs Object in C# clarification | <p>I tried to create class with similar implementation.
One using boxing/unboxing at constructor, while other using Generics.</p>
<p>Then tried to create the object for both class 1,000,000 times.
when i run the 'for loop' for Obj class first i am always getting longer time for Obj creation, But when i run the 'for loop' for Gen class first 75% times i am getting longer time for Obj. Please help me why this behavior.
Here is the code:-</p>
<pre><code> class Obj
{
public string _t;
public int _u;
public Obj(Object t, Object u) //Boxing taking place implicitly
{
_t = (string)t;
_u = (int)u; //unboxing
}
}
class Gen<T, U>
{
public T _t;
public U _u;
public Gen(T t, U u)
{
_t = t;
_u = u;
}
}
static void Main(string[] args)
{
long before_Obj = DateTime.Now.Ticks;
for (int i = 0; i < 1000000; i++)
{
new Obj("hi", i);
}
long after_Obj = DateTime.Now.Ticks - before_Obj;
Console.WriteLine(after_Obj);
long before_Gen = DateTime.Now.Ticks;
for (int i = 0; i < 1000000; i++)
{
new Gen<string, int>("hi", i);
}
long after_Gen = DateTime.Now.Ticks - before_Gen;
Console.WriteLine(after_Gen);
}
</code></pre>
<p>OUTPUT:
2656250
1406250</p>
| c# | [0] |
4,619,573 | 4,619,574 | Has anyone used ThumbsUp PHP voting script? | <p>I'm trying to use a PHP voting script called ThumbsUp: <a href="http://www.geertdedeckere.be/shop/thumbsup/" rel="nofollow">http://www.geertdedeckere.be/shop/thumbsup/</a></p>
<p>Also I'm using MediaTemple for the hosting.</p>
<p>I was curious if anyone else has used this script because i'm having some problems and can't figure them out.</p>
<p>Any help would be appreciated.</p>
<p>Here's the url that I'm trying to make it work on. <a href="http://andrewlohman.com/eatdrink/" rel="nofollow">http://andrewlohman.com/eatdrink/</a></p>
<p>Thanks,
Andrew</p>
| php | [2] |
5,931,767 | 5,931,768 | RealTimeExample needed on static field without final keyword | <p>Could you please explain me any real time scenario (or) JAVA API examples for static field without final keyword ?</p>
<p>I have seen in Runtime.java; to make singleton They have declared like below </p>
<p>private static Runtime currentRuntime = new Runtime(); </p>
<p>But here also we need final right ? </p>
| java | [1] |
1,152,890 | 1,152,891 | Can two variables be used in a function at once? | <p>The function <code>check_porn_terms</code> below checks to see if a variable contains terms that are not family friendly, and it it does, then re-directs the user back to the main page. </p>
<p>As listed below, it checks to see if the variable <code>$title</code> has non-family friendly terms. I would like to perform this check on another variable, <code>$cleanurl</code>. Could I just replace <code>check_porn_terms($title)</code> below with <code>check_porn_terms($title, $cleanurl)</code> or something like that? If not, how should I do it?</p>
<p>Thanks in advance,</p>
<p>John</p>
<pre><code>if(!check_porn_terms($title))
{
session_write_close();
header("Location:http://www.domain.com/index.php");
exit;
}
</code></pre>
| php | [2] |
891,384 | 891,385 | Glitch in my script moving images | <p>I'm getting a strange glitch in my javascript (logic error) i'm not sure if its my maths or the way i have structured my code.</p>
<p>The idea i have is to left click and drag to scroll around a map on a canvas. It works perfectly except, when i mouse down to scroll a second time, the map resets back to its x0y0 offset.</p>
<p>So essentially i can't keep scrolling because as soon as i let go of the mouse and mousedown again its back to the start.</p>
<p>So this is how i did it:</p>
<pre><code>//this is in the init function called on body load
canvas.addEventListener("mousedown", mousePos, false);
</code></pre>
<hr>
<pre><code>//relevant functions
function mousePos(e){
mousex = e.pageX;
mousey = e.pageY;
canvas.addEventListener("mousemove", movePos, false);
}
function movePos(e){
canvas.addEventListener('mouseup',onMouseUp,false);
offset_x = e.pageX - mousex; //pixels to move the map along x
offset_y = e.pageY - mousey; //pixels to move the map along y
}
function onMouseUp(){
// on mouse up stop moving the map
canvas.removeEventListener('mousemove',movePos,false);
}
</code></pre>
<p>Any ideas?</p>
| javascript | [3] |
4,781,424 | 4,781,425 | jQuery, Toggle within toggle | <p>I'm trying to create some sort of "spoiler" for a forum. It's pretty simple, though i'm fairly new to jquery. But now i got this problem when placing a toggle div element inside another toggle div element, the 2nd toggle doesn't work. Can anyone point me in the right direction?</p>
<p>Jquery</p>
<pre><code>$(document).ready(function(){
$('.head').click(function() {
$('.body').toggle('slow')
});
});
</code></pre>
<p>HTML </p>
<pre><code><div class="head">
Show Content
</div>
<!--1st toggle div-->
<div class="body" style="display:none;">
Content
<div class="head">
Show Content
</div>
<!--2nd toggle div-->
<div class="body" style="display:none;">
Content
</div>
</div>
</code></pre>
<p><a href="http://jsfiddle.net/ufC5B/" rel="nofollow">Jsfiddle here.</a></p>
<p>Thanks to everyone that's trying to help :)</p>
<p>EDIT:</p>
<p>Right after i posted i've seen that i was using multiple ID's in the HTML code.
I've changed the div id's to classes, but now when i click to show content1, content2
also shows up. Can someone help me with it?</p>
| jquery | [5] |
3,534,231 | 3,534,232 | Best PHP training? | <p>I'm striving to be a good programmer, I used to be among the best around people who were learning at the same time I was, but I reached a plateau and I don't understand why other programmers know so much more than I do. I can't be useful anymore, I fail all tests for good jobs, etc. </p>
<p>Should I get php training? Like courses? I'd like to know what are the best around. I feel there is so much money to be earned by being a good programmer but I just cannot be one. Any input will be appreciated. Thanks.</p>
| php | [2] |
1,124,944 | 1,124,945 | How to define my own js function in jsfiddle? | <p>I want to test how my own function <code>update</code> works on <a href="http://jsfiddle.net/radek/cguQR/2/" rel="nofollow">jsfiddle</a> but when I click the button I get an error that update is not defined.</p>
<p><strong>How can I use my own functions on jsfiddle?</strong></p>
| javascript | [3] |
2,134,739 | 2,134,740 | Asp.net Update Panel | <p>I am working in asp.net 3.5 and have some issue of update panel.I have some html content and Formview control in a page. I want to hide the html content when there is no data in the Formview and to show when there is data in the Formview control. My Formview control is in the updatepanel and it it is bind to SqlDataSource and Formview binds on some criteria.
If somebody know how to solve this issue then please help me.</p>
| asp.net | [9] |
2,676,360 | 2,676,361 | memory management for vector of pointers | <p>Suppose I have a class like this:</p>
<pre><code>class MyClass : private vector<AnotherClass*> {
//some codes
}
</code></pre>
<p>How do I implement its destructor? I am new to C++ and have totally no clue on this.</p>
<p>Thanks in advance!</p>
<p>edit: fixed the syntax,thx for remaindering me!</p>
| c++ | [6] |
2,122,205 | 2,122,206 | python how to parse "user:12345 location:ny search" | <p>I want python to parse string ""user:12345 location:ny search"</p>
<p>Then I can use:</p>
<pre><code>if "user" in string:
....
if "location" in string:
...
</code></pre>
<p>Any existing way to do this?</p>
| python | [7] |
4,383,834 | 4,383,835 | Is this uploading script correct? | <p>I have a folder known as "Mobile_App" and in that folder is a html page which contains a file input, a php script which uploads files, and a folder known as "ImageFiles".</p>
<p>The problem is that the files are not being uploaded into the "ImageFiles". What I want to know is that is the code below correct when it comes to uploading a file into the "Imagefiles" folder or is it incorrect and how can I get it working correctly?</p>
<p>Below is the php script which uploads a file (the file input is known as "fileImage"):</p>
<pre><code><?php
$destination_path = $_SERVER['DOCUMENT_ROOT']."/ImageFiles";
$result = 0;
$target_path = $destination_path . basename( $_FILES['fileImage']['name']);
if(move_uploaded_file($_FILES['fileImage']['tmp_name'], $target_path)) {
$result = 1;
}
sleep(1);
?>
</code></pre>
| php | [2] |
3,505,133 | 3,505,134 | fetch the list of location with a particular location as center and radius (say 50km) , using google location API | <p>I need the list of locations (areas/subareas) in a particular city.</p>
<p>I thought, google api might be a possible option to fetch this. if i pass city's lat/long and radius then there must be some way to fetch the list of locations.</p>
<p>however i could not find any possible solution?</p>
<p>Can any one help me out?</p>
| javascript | [3] |
4,825,606 | 4,825,607 | Need a Sample Application to connect, retrieve and Send data to health vault site | <p>Hi need a sample Application to connect to the <strong>Microsoft HealthVault</strong> platform where I need the Following things to be done:</p>
<ol>
<li>Application should Send and store the data in the health vault site.</li>
<li>Application should retrieve the data from the health vault site to my application.</li>
</ol>
| asp.net | [9] |
5,301,745 | 5,301,746 | C++ desktop applications framework | <p>I am not new to c++,but i have not found a c++ desktop applications framework.I have found one and it seems to complex.Are there other frameworks available for c++ out there?.</p>
| c++ | [6] |
5,912,988 | 5,912,989 | Iterate through all the properties of an object skipping first one | <p>Is there any method to skip iterating first element like gt(0) in jQuery<br>
This is the code I am using </p>
<pre><code> for(var prop in item){
alert(prop + " = " + item[prop]);
}
</code></pre>
| javascript | [3] |
2,101,271 | 2,101,272 | What would cause IE to error Object doesn't support property or method 'removeChild'? | <p>I'm trying to remove 2 divs and append them at the same time. This is my script. </p>
<pre><code> parent = document.getElementById("wrap");
if(parent){
child = document.getElementById("chart1b");
parent.removeChild(child);
var g = document.createElement('div');
g.id = "chart1b";
parent.appendChild(g);
}
parent2 = document.getElementById("pollwrap");
child2 = document.getElementById("chart2");
parent2.removeChild(child2);
var h = document.createElement('div');
h.id = "chart2";
parent2.appendChild(h)
</code></pre>
<p>In FireFox it works good. In Google Chrome it works awesome. In Safari it works Amazingly. In IE it crashes, burns, and errors start flying across my screen. Both parent divs are in the html so neither of them are missing. What could be the problem?</p>
| javascript | [3] |
4,022,642 | 4,022,643 | Only certain rows on select list | <p>I have a dropdown select form which is based on a "brand" table that has more than 150 brand_name(s) with corresponding brandid(s).</p>
<p>As you can see in the code below, I all the brands/rows will appear in the dropdown form. I'd like to know if there is a way to exclude certain brands (without deleting them from the table; for example: they are temporarily out of stock). And not just LIMIT 1 to 7.</p>
<p>If for example, I want brand_names with brandids 9, 27, 50 etc. not to appear in the select option, how can it be done? Is there an EXCEPT() function of some sort?</p>
<pre><code><?php
echo "<form action=\"chosen_brand.php\" method=\"get\">\n";
echo "<select name=\"brand_name\">\n";
$stmt = mysqli_stmt_init($link);
if($stmt=mysqli_prepare($link,"SELECT `brandid`,`brand ` FROM `brand ` WHERE `brandid`"))
{
mysqli_stmt_bind_param($stmt,"i", $brandid);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt,$brandid, $brand_name);
while(mysqli_stmt_fetch($stmt))
{
echo "<option value=\"$brandid\"> $brand_name </option>";
}
echo "</select>\n";
echo "<input name=\"submit\" type=\"submit\" id=\"brandid\" value=\"submit\" />\n";
echo "</form> \n";
mysqli_stmt_close($stmt);
mysqli_free_result($result);
}
?>
</code></pre>
<p>Thanks,
Jen</p>
| php | [2] |
4,274,038 | 4,274,039 | How to scan QRCode in android | <p>Hi I found <a href="http://code.google.com/p/zxing/wiki/ScanningViaIntent" rel="nofollow">a tutorial </a> How to scan a barcode. But In my application I have to scan QRcode. How to scan QRcode in android. </p>
| android | [4] |
4,358,097 | 4,358,098 | Difference between "Build Target SDK" in Eclipse and android:targetSdkVersion in AndroidManifest.xml? | <p>As I'm importing an existing Android project into Eclipse, I am asked to select an SDK build target as part of the process.</p>
<p>Why do I need to enter this information?
How is this different from the android:targetSdkVersion/android:minSdkVersion values specified in AndroidManifest.xml?</p>
<p>For example, in the Google IO sample app, its AndroidManifest android:targetSdkVersion=11, but the README says the Eclipse project needs to target API level 13 or higher, or compile errors will occur.</p>
| android | [4] |
5,968,152 | 5,968,153 | How to convert a string to a Guid | <p>I did not find the TryParse method for the Guid. I’m wondering how others handle converting a guid in string format into a guid type.</p>
<pre><code>Guid Id;
try
{
Id = new Guid(Request.QueryString["id"]);
}
catch
{
Id = Guid.Empty;
}
</code></pre>
| c# | [0] |
5,580,266 | 5,580,267 | whats wrong with this code? I am not able to extend the Number object | <pre>
<code>
Number.prototype.xx = function(){
alert("hi");
}
5.xx();
</code>
</pre>
<p>I am trying to extend Number using prototype.</p>
| javascript | [3] |
3,452,199 | 3,452,200 | Does an Android package store a developer/company/author name? | <p>I've just been trying out creating a list of applications installed on Android. I want to do this so I have a list of applications I've installed before I backup and reset my phone to factory settings. </p>
<p>It's going well so far, I have this information: </p>
<ul>
<li>package Name</li>
<li>friendly name</li>
<li>version number/code</li>
<li>if its a system package (FLAG_SYSTEM)</li>
<li>if its a persistent app (FLAG_PERSISTENT)</li>
<li>and the application description</li>
</ul>
<p>The last thing that I would like to have but that does not seem to exist is the name of the person/group/company etc that created the application. That way I can see if I have multiple applications by the same creator.</p>
<p>Is there a specific place this is stored in Android packages or does it just not exist?</p>
<p>I've had a good search around but I can not find anything, but I thought I would try a specific query about it before I give up.</p>
<p>Thanks in advance</p>
| android | [4] |
3,157,251 | 3,157,252 | EOD not ending? | <p><img src="http://i.stack.imgur.com/cs5fw.jpg" alt="alt text"></p>
<pre><code><?php
// Page class
class Page {
// Declare a class member variable
var $page;
var $title;
var $year;
var $copyright;
// The Constructor function
function Page($title, $year, $copyright){
// Assign values to member variables
$this->page = '';
$this->title = $title;
$this->year = $year;
$this->copyright = $copyright;
// Call the addHeader() method
$this->addHeader();
}
// Generates the top of the page
function addHeader(){
$this->page .= <<<EOD
<html>
<head>
<title>$this->title</title>
</head>
<body>
<h1 align="center">$this->title</h1>
</body>
EOD;
}
}
?>
</code></pre>
<p>Thanks in advance</p>
| php | [2] |
5,475,129 | 5,475,130 | Catching runtime errors in application executed by os.system | <p>In my application, os.system is used to execute another program.</p>
<pre><code>os.system('./appln')
</code></pre>
<p>Is there any way to detect if a runtime error occurs in the program being executed [ for example, like a SIGSEGV]?</p>
| python | [7] |
140,956 | 140,957 | getting values with preg_match_all | <p>How can i get each value returned by PHP preg_match_all using for each loop, because i want to insert each value in database.
Thanks</p>
| php | [2] |
113,216 | 113,217 | Setting a nibble of a 32-bit integer to a certain value | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/14427737/setting-the-nibble-for-an-int-java">Setting the nibble for an int - java</a> </p>
</blockquote>
<p>I am stuck on how to replace a 4-bit value to a certain position of an original 32-bit integer. All help is greatly appreciated!</p>
<pre><code>/**
* Set a 4-bit nibble in an int.
*
* Ints are made of eight bytes, numbered like so:
* 7777 6666 5555 4444 3333 2222 1111 0000
*
* For a graphical representation of this:
* 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |Nibble3|Nibble2|Nibble1|Nibble0|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Examples:
* setNibble(0xAAA5, 0x1, 0); // => 0xAAA1
* setNibble(0x56B2, 0xF, 3); // => 0xF6B2
*
* @param num The int that will be modified.
* @param nibble The nibble to insert into the integer.
* @param which Selects which nibble to modify - 0 for least-significant nibble.
*
* @return The modified int.
*/
public static int setNibble(int num, int nibble, int which)
{
int shifted = (nibble << (which<<2));
int temp = (num & shifted);
//this is the part I am stuck on, how can I replace the original
// which location with the nibble that I want? Thank you!
return temp;
}
</code></pre>
| java | [1] |
1,083,928 | 1,083,929 | JQuery modal dialog HTML not updating | <p>After clicking a button in my modal JQuery dialog, I want to update the html in the dialog to show text and an image indicating that work is in progress (spinner, etc.). When I do in the example below, the html doesn't update. It's as if that code never executes, or executes too late so the change isn't visible. However if I uncomment the alert('hey'); code, it does. What are good ways to achieve what I'm after?</p>
<pre><code>$dialog.dialog( "option", "title", 'Do lengthy work' );
$dialog.dialog( "option", "buttons", {
"Cancel": function() { $(this).dialog("close"); },
"Start Work": function() {
$(this).html('Working...<p/><img src="http://mydomain.com/progress.gif"');
//alert('hey');
doLengthyWorkFunction();
$(this).dialog('close');
}
} );
$dialog.html('Click the Start Work button to begin.');
$dialog.dialog('open');
</code></pre>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.