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,025,463 | 4,025,464 | How can I give a class as argument to a Python function | <p>I have two functions in my (first!) Python program that only differ by the class that must be instanciated.</p>
<pre><code>def f(id):
c = ClassA(id)
...
return ...
def g(id):
c = ClassB(id)
...
return ...
</code></pre>
<p>To avoid repeated code, I would like to be able to write a single function that would somehow accept the class to instanciate as a parameter.</p>
<pre><code>def f(id):
return f_helper(id, ... ClassA ...)
def g(id):
return f_helper(id, ... ClassB ...)
def f_helper(id, the_class):
c = ... the_class ... (id)
...
return ...
</code></pre>
<p>I'm pretty sure this is possible, but did not find how...</p>
| python | [7] |
5,329,875 | 5,329,876 | UITableview cell value over writing again and again problem? | <p>hi
my tableview show like this when i scroll .......will u help what mistake i have done? any help please?if you see that image , the value i have selected in over writing........</p>
<p><a href="http://www.freeimagehosting.net/image.php?fa76ce6c3b.jpg" rel="nofollow">http://www.freeimagehosting.net/image.php?fa76ce6c3b.jpg</a></p>
<p>the code is</p>
<ul>
<li>(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</li>
</ul>
<p>{</p>
<pre><code>static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.font = [UIFont boldSystemFontOfSize:14.0];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
CGRect rectLbl2 = CGRectMake(75 ,1, 215, 32);
CGRect rectLbl3 = CGRectMake(75 ,28, 215, 30);
addLabel2= [[UILabel alloc] initWithFrame:rectLbl2];
addLabel3= [[UILabel alloc] initWithFrame:rectLbl3];
addLabel2.text = @"senthil";
[cell addSubview:addLabel2];
[addLabel2 release]; // for memory release
addLabel3.text= @"senthil";
[cell addSubview:addLabel3];
[addLabel3 release];
return cell;
</code></pre>
<p>}</p>
| iphone | [8] |
4,876,912 | 4,876,913 | Get Gridview Data in PDF Format in C# Windows Form? | <p>I want to convert the data of datagridview into PDF file . For Example if i press button1 i should get the datagridview data as pdf.</p>
<p>How can I do this?</p>
| c# | [0] |
3,553,825 | 3,553,826 | Different results when using WebRequest vs WebClient | <p>We have a text file that gets generated automatically and put in a web server. The task is to read the file line by line and insert the records in a database. The following code is in C#:</p>
<pre><code> WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
StreamReader r = new StreamReader(response.GetResponseStream());
while (r.Peek() > -1)
{
string s = r.ReadLine().Trim();
//insert string into a db.
}
</code></pre>
<p>When I do this I constantly get the entire file which ranges from 9000 - 10000 lines. On the other hand when I use the following sometimes I get a truncated file (less lines)</p>
<pre><code> WebClient client = new WebClient();
StreamReader r = new StreamReader(client.OpenRead(url));
while (r.Peek() > -1)
{
string s = r.ReadLine().Trim();
//insert string into a db.
}
</code></pre>
<p>Can anyone explain the difference? Why would the results be different? I was under the impression that WebClient was just a wrapper of HttpWebRequest.</p>
| c# | [0] |
1,844,201 | 1,844,202 | screen shots for app store submission | <ol>
<li>Do I have to submit both portrait and landscape screenshots? </li>
<li>Is it fine for my app to only support portrait mode?</li>
</ol>
| iphone | [8] |
5,329,119 | 5,329,120 | Python: Are `hash` values for built-in numeric types, strings standardised? | <p>I came to this question while pondering about the ordering of <code>set</code>, <code>frozenset</code> and <code>dict</code>. Python doesn't guarantee any ordering, and I guess any ordering is all down to the <code>hash</code> value. But is the hash value for a value of a numeric or string built-in type standard? In other words, would </p>
<pre><code>set( (a,b,c,d,e,f,g))
</code></pre>
<p>have a defined order, if a,b,c,d,e,f,g are numeric values or <code>str</code>?</p>
| python | [7] |
3,376,495 | 3,376,496 | C++ Question,error C2064: term does not evaluate to a function taking 1 arguments | <p>Would you please help me with this simple code in C++, I don't know what is the problem here?</p>
<pre><code>#include <iostream>
#include <string>
using namespace::std;
template <class Type>
Type binsearch (Type item,Type *table,Type n)
{
int bot=0;
int top=n-1;
int mid, cmp;
while (bot<= top)
{
mid=(bot+top)/2;
if(item==table(mid))
return (mid);
else if (item <table[mid])
top=mid-1;
else
bot=mid+1;
}
return -1;
}
int main ()
{
int nums[]={10, 12, 30, 38, 52, 100};
cout<< binsearch(52, nums, 6);
}
</code></pre>
| c++ | [6] |
4,893,910 | 4,893,911 | Get the next 4 months in a formatted string | <p>What is the most elegant way of getting the following:</p>
<p>Starting from today's date, return an enumerable that would be the following:</p>
<p>July 1st
July 15th
August 1st
August 15th
September 1st
September 15th
October 1st
October 15th</p>
<p>Should account for things like if it's the end of the year, then it goes
December 15
January 1st.</p>
| c# | [0] |
2,780,185 | 2,780,186 | How do I output Linked List which holds objects using java.util.ListIterator? | <p>Hi I got this problem with I am not sure how to deal with... I have a Linked List which stores Objects which works fine. But now I am trying to display the content of the linked list using iterator and I understand that wont be as simple as </p>
<pre><code>ListIterator<String> iterator = LibraryUser.listIterator();
iterator = LibraryUser.listIterator();
while (iterator.hasNext())
System.out.println(iterator.next());
</code></pre>
<p>because of the type... Is there way to do this ?</p>
<p>OH RIGHT! I need to override toString don't i... </p>
| java | [1] |
1,888,508 | 1,888,509 | Convert object[,] to string[,]? | <p>How would you convert <code>object[,]</code> to <code>string[,]</code> ?</p>
<pre><code>Object[,] myObjects= // sth
string[,] myString = // ?!? Array.ConvertAll(myObjects, s => (string)s) // this doesn't work
</code></pre>
<p>Any suggestions appreciated.</p>
<p>EDIT : Of course, a loop solution will obviously do it, however I was envisioning a more elegant solution both in terms of code and in performance.</p>
<p>EDIT2 : The <code>object[,]</code> contains of course <code>string</code>s (and digits, but this doesn't matter for now).</p>
| c# | [0] |
2,379,811 | 2,379,812 | onSearchRequested() result in same activity | <p>i have implement in my application the search method onSearchRequested() via list and it work well and i create 2 activity one for list data and another for the search result
in that form</p>
<p>public class acitvity1 extends InterfaceBase {</p>
<pre><code> @Override
ListAdapter makeMeAnAdapter(Intent intent) {
return(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,items));
}
}
</code></pre>
<p>and the activity 2 who include the search result </p>
<pre><code>public abstract class Acitvity2 extends InterfaceBase {
@Override
ListAdapter makeMeAnAdapter(Intent intent) {
ListAdapter adapter=null;
if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
String query=intent.getStringExtra(SearchManager.QUERY);
List<String> results=searchItems(query);
adapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,results);
setTitle("Search : "+query);
}
return(adapter);
}
private List<String> searchItems(String query) {
SearchSuggestionProvider
.getBridge(this)
.saveRecentQuery(query, null);
List<String> results=new ArrayList<String>();
for (String item : items) {
if (item.indexOf(query)>-1) {
results.add(item);
}
}
return(results);
}
</code></pre>
<p>so its there a possible to make the search result appear in callback activity mean in the activity1 and is there any change should do in the manifest file too
thx for help</p>
| android | [4] |
1,012,493 | 1,012,494 | Jquery to accept both negative and nonnegative values | <p>I have tried this. This accepts only integers. I want both negative and non negative.</p>
<pre><code> $(function () {
$('.spinner').keyup(function () {
if (this.value.match(/[^0-9]/g)) {
this.value = this.value.replace(/[^0-9]/g, '');
}
});
});
</code></pre>
| jquery | [5] |
1,264,801 | 1,264,802 | Get Specific Device Information | <p>Using just PHP, is there anyway to detect if the page is being loaded from a SPECIFIC device? Say, I would want the page to react differently if only MY iPhone was loading the page, no one else's?</p>
<p>The only solution I have so far is to use $_SERVER['REMOTE_PORT' in conjunction with $_SERVER['HTTP_USER_AGENT'], to verify iPhone, but that doesn't ensure a <strong>specific</strong> iPhone..</p>
| php | [2] |
2,999,414 | 2,999,415 | How will I get the SelectedItem? C# winforms CheckedListBox control | <p>Prior to this question, I asked <a href="http://stackoverflow.com/questions/3801290/is-there-displaymember-and-valuemember-like-properties-for-checkedlistbox-con">this</a> question on this site. (Mr Jon Skeet answered it!)</p>
<p>I'm having difficulty retrieving the <code>SelectedItem</code> of the <code>CheckedListBox</code>.
Please consider my code:</p>
<pre><code>public class StaticValues
{
private string value;
private string display;
public StaticValues(string val, string disp)
{
this.value = val;
this.display = disp;
}
public string Value
{
get
{ return value; }
}
public string Display
{
get
{ return display; }
}
}
private void Form3_Load(object sender, EventArgs e)
{
ArrayList dataSource = new ArrayList();
dataSource.Add(new StaticValues("001", "Item 1"));
dataSource.Add(new StaticValues("002", "Item 2"));
dataSource.Add(new StaticValues("003", "Item 3"));
checkedListBox1.DataSource = dataSource;
checkedListBox1.DisplayMember = "Display";
checkedListBox1.ValueMember = "Value";
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(checkedListBox1.SelectedValue.ToString()); // outputs correct SelectedValue
MessageBox.Show(checkedListBox1.SelectedItem.ToString()); // this one doesn't for SelectedItem
}
</code></pre>
<p>How will I get the <code>SelectedItem</code>?</p>
| c# | [0] |
3,622,349 | 3,622,350 | Creating a drawable rectangle in xml with one gradient on the top half and another on the bottom half | <p>I'm trying to create a drawable in xml, a rectangle with one gradient on the top half, and another on the bottom half. This is NOT the way to do it, apparently:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<gradient
android:startColor="#5a5a5a88"
android:endColor="#14141488"
android:angle="270" android:centerX="0.25"/>
</shape>
</item>
<item>
<shape android:shape="rectangle" android:top="80px">
<gradient
android:startColor="#5aff5a88"
android:endColor="#14ff1488"
android:angle="270" android:centerX="0.25"/>
</shape>
</item>
</layer-list>
</code></pre>
<p>How can I do this, preferably in a way that makes it stretchable to any height?</p>
| android | [4] |
3,269,128 | 3,269,129 | how to stop interval for animation with its own speed in jquery? | <p>I am trying to figure out how to do this... I have a function that moves a div, this function has a speed property (500 ms), and its used for animate and move the div.. so, what I basically trying to do is everytime I am over a button call that function ,the problem is that I cant stop the interval after I leave the mouse (I am using <code>mouseenter</code> and <code>mouseleave</code>) and I want to call that function delaying 500ms to call it (I tried with <code>myfunction().delay(500);</code> ) but its the same result...</p>
<p>Any idea how to do this? and how to stop my interval on mouseleave?</p>
<p>(for mouseleave I am using <code>clearInterval(myinterval);</code> ) but no result</p>
<pre><code>jQuery('#next-div').mouseenter(function() {
setInterval(function() {
var interval = images.moving; //this function has an spped of animation of 400 each transaction
}, 400);
}).mouseleave(function(){
clearInterval(interval);
});
</code></pre>
| jquery | [5] |
4,438,192 | 4,438,193 | Pass attribute, not value as parameter | <p>I would like to make this happen in JavaScript:</p>
<pre><code>function changeAttributeValue(theAttribute, numberOfPixels)
{
theAttribute = numberOfPixels + "px";
}
changeAttributeValue(myImage.style.left, 50);
changeAttributeValue(myImage.style.top, 80);
changeAttributeValue(myCanvas.width, 600);
</code></pre>
<p>The first two calls should move an image and the third should adjust the width of a canvas.</p>
<p>Like this however, just the <strong>value</strong> of the passed variables were passed, so nothing happens.</p>
<p>Does anybody know how to solve this problem?</p>
| javascript | [3] |
439,641 | 439,642 | different compiler behavior when adding bytes | <pre><code>byte b1 = 3;
byte b2 = 0;
b2 = (byte) (b2 + b1); // line 3
System.out.println(b2);
b2 = 0;
b2 += b1; // line 6
System.out.println(b2);
</code></pre>
<p>On line 3, it's a compiler error if we don't typecast the result to a byte -- that may be because the result of addition is always int and int does not fit into a byte. But apparently we don't have to typecast on line 6. Aren't both statements, line 3 and line 6, equivalent? If not then what else is different?</p>
| java | [1] |
3,540,471 | 3,540,472 | Is there any way to Get data by PHP code insted of HTML from | <p>I'm newbie in PHP.I want to know that,I taking data by html form and a .php file.
like:</p>
<pre><code><form id="form1" name="form1" method="post" action="show.php">
<strong>Please Enter the Unique id</strong><br/><br/>
Unique id:
<!-- name of this text field is "tel" -->
<input name="id" type="text" id="id" />
<p>
<input type="submit" name="Submit" value="Submit" />
</p>
</form>
</html>
</code></pre>
<hr>
<p>Then,I used show.php file to get the 'id'.like:</p>
<pre><code>$id=$_POST['id'];
</code></pre>
<hr>
<p>Is there any way to take input by php code???
Update:</p>
<p>In "C" we take ant input by this way </p>
<pre><code>scanf("%d",a);
</code></pre>
<p>is there any way to do so in PHP.I think now all you may be clear what I'm trying to say??</p>
<p>Thanks
Yasir Adnan.</p>
| php | [2] |
5,294,311 | 5,294,312 | Load module with variable path in python 2.6? | <p>My dev environment is python 2.6, so the importlib.import_module() syntax is not available to me. I'm trying to load a module with a path that is set by a variable; is this even possible in 2.6?</p>
<p>The background is that I'm polling a number of devices from different vendors, so in various directories I have wrapper classes, all with identical methods and return types, which handle the vendor-specific methods for grabbing the data I need. So based on the vendor, I might need to load "platform_foo.stats" or "platform_bar.stats", then call the same methods on the resulting module.</p>
<p>So, something like this, except this is obviously non-working code:</p>
<pre><code>vendor = get_vendor(hostname)
vendor_path = 'platform_%s.stats' % vendor
import vendor_path
stats = vendor_path.stats(constructor_args)
</code></pre>
<p>Any ideas?</p>
| python | [7] |
1,701,604 | 1,701,605 | How to click on a button, and have the item in question go to the next list using javascript? | <p>I have this problem. I have two lists. One with the items of my fridge (that's the assignment :) ) and other with the items of the shop. I want to be able to click on an item of the fridge, and have it show up on the list of the left. In javascript, that is.</p>
<p>If anyone knows how to do it, I'd be very glad to hear from you.</p>
<p>Daniel</p>
| javascript | [3] |
4,025,276 | 4,025,277 | ASP.NET button click event not working in IE | <p>in my asp.net page, The asp.net button click is not getting fired in IE,But in mozilla its working fine. Any thoughts ?</p>
| asp.net | [9] |
441,228 | 441,229 | jQuery Remove All Elements from Select with Value | <p>I have simple select that looks like this:</p>
<pre><code><select id="region">
<option value=""> -- country -- </option>
<option value="842554592">Alberta</option>
<option value="708812360">Ontario</option>
...
</select>
</code></pre>
<p>I want to clear non-blank values and am wondering if jQuery has a simple method for this. I'm using:</p>
<pre><code>$('.country').find('option[value!=""]').remove();
</code></pre>
<p>Which seems a bit ugly. Thanks!</p>
| jquery | [5] |
4,157,837 | 4,157,838 | how to encode the "&" special character in any url..? | <p>how to encode the "&" special character in any url..?</p>
| iphone | [8] |
217,672 | 217,673 | Cannot convert source type to target type | <p>I've got this subclass implementing my Interface and there are no errors in terms of satisfying the contract. However when I try to set the current session in the sub class's constructor I get this compile-time error when it tries to compare the variable type with the returned type of GetCurrentSession():</p>
<p><strong>"Cannot convert source type IAPISession to target type FacebookSession"</strong></p>
<p>Ok why? Facebook is a IAPISession... right??? polymorphism at play is my thinking so it should be happy with this comparison. Not sure here.</p>
<pre><code>public class FacebookSession : IAPISession
{
private FacebookSession currentSession;
private FacebookSession()
{
currentSession = GetCurrentSession();
}
...more code
public IAPISession GetCurrentSession()
{
// my logic is here...whatever that may be
}
... more code
}
</code></pre>
<p><strong>Updated</strong></p>
<p>here's my actual interface:</p>
<pre><code>public interface IAPISession
{
#region Properties
int SessionID { get; }
string UserID { get; }
bool SessionHasExpired { get; }
DateTime ExpirationDate { get; }
void LogOut(); // expires the session & sets SessionHasExpired
#endregion Properties
#region Methods
IAPISession GetCurrentSession();
#endregion Methods
}
</code></pre>
<p>This interface will be utilized across any API wrapper projects of ours (e.g. FlickrSession, etc.)</p>
| c# | [0] |
4,000,002 | 4,000,003 | How do I create this Table/View in Asp.Net C# | <p><img src="http://i.stack.imgur.com/rONkC.jpg" alt="enter image description here"><a href="http://i.stack.imgur.com/Kc5if.jpg" rel="nofollow">I need to create a Table as per the following Image and I'm a newbie to .Net. Please tell me which tool I should be using</a></p>
| asp.net | [9] |
4,339,660 | 4,339,661 | iPhone SDK: How can you hide an alert box? | <p>I am using the following code to show an alert box:</p>
<pre><code>UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"My Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
</code></pre>
<p>Can you tell me how to hide the alert box again when the phone changes orientation?</p>
| iphone | [8] |
1,396,659 | 1,396,660 | How can I prevent anyone from holding a reference to an object in C# | <p>I have a class like this</p>
<pre><code>internal class Report
{
public Company TargetCompany { get; private set; }
.... // other stuff
}
</code></pre>
<p>I do not want any one to be able to do this</p>
<pre><code>Report r = GetReport();
Company c = r.TargetCompany;
</code></pre>
<p>but instead always use</p>
<pre><code>r.TargetCompany
</code></pre>
<p>when they want access to the Company variable.</p>
<p>Is that possible? Does that even make sense?</p>
| c# | [0] |
612,297 | 612,298 | Does Android Speech Synthesis do not work for HTC Dream firmware version 1.6 build DRD20? | <p>I have a HTC Dream firmware version 1.6 build DRD20.
I am unable to install voice data in Menu ==> Settings ==> Speech Synthesis ==> Install voice data. The option just brings me back to previous screen of settings. I also tried installing Speech Synthesis Data Installer and many other applications for text to speech. But none works and give back Sorry! Force close error. Is there any way by which I can install voice data ? Or any way I can use text to speech ?
Can anyone also tell what is latest offical firmware available for this mobile ?</p>
| android | [4] |
2,762,806 | 2,762,807 | Has anyone ever created a way to provide a user the ability to toggle permissions within an Android app? | <p>I am creating an Android app that has many newtorking capabilites, I want to provide them with the option to toggle these permissions on and off. So far in the manfest I have these permissions:</p>
<pre><code> <uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
</code></pre>
<p>I want to create a preferences activity where the users can select a check box to allow each permission, is this possible? I know that the permissions once added, they are set, but I would really like a way for the user to have control whether a permission can be added or not added at any time.</p>
| android | [4] |
950,840 | 950,841 | PHP: Should you ever do this? | <p>If I'm creating a PHP class, should I ever have a function that looks like:</p>
<pre><code><?
class test {
public function hello() {
?>
Hello
<?
}
}
?>
</code></pre>
<p>I know it works, but is it considered to be bad programming, like, should you avoid doing things like this?</p>
| php | [2] |
1,509,968 | 1,509,969 | empty value of parameter - php | <p>I have this code:</p>
<pre><code>foreach($summary as $machine)
{
$hostname = $machine['node'];
$result = mysql_query("SELECT OS FROM machines WHERE ind='$hostname'");
while($row = mysql_fetch_array($result))
{
if($row == 'solaris')
{
$partition_os = 'export/home';
}
else
{
$partition_os = '/home';
}
}
}
<partition<?php echo $i; ?>><?php echo $partition_os; ?></partition<?php echo $i; ?>>
</code></pre>
<p>The output of the query is:(without the <code>where</code>)</p>
<pre><code>mysql> SELECT OS FROM machines;
+---------+
| OS |
+---------+
| NULL |
| solaris |
+---------+
</code></pre>
<p>My problem is that in my xml (this is for ajax) i see only <code>/home/</code> instead of <code>export/home</code>.
The <code>$hostname</code> supposed to be fine because i use it before.</p>
<p>Thank you!</p>
| php | [2] |
3,510,839 | 3,510,840 | Variable not updating its value | <pre><code>var canAssignMultiple="true";
var canWithdrawMultiple="true";
function onCheckUncheck()
{
if($(':checkbox[name^="checkedRecords"]:checked').length>0)
{
$("input[name='checkedRecords']:checked").each(function()
{
debugger;
var canAssign = $(this).attr("canAssign").toLowerCase();
var canWithdraw = $(this).attr("canWithdraw").toLowerCase();
canAssignMultiple= canAssignMultiple && canAssign;
canWithdrawMultiple= canWithdrawMultiple && canWithdraw;
if (canAssignMultiple == "false")
$("#assaignbutton").attr("disabled", "disabled");
else
$("#assaignbutton").removeAttr("disabled");
if (canWithdrawMultiple == "false")
$("#withdrawbutton").attr("disabled", "disabled");
else
$("#withdrawbutton").removeAttr("disabled");
});
}
else
{
$("#assaignbutton").attr("disabled", "disabled");
$("#withdrawbutton").attr("disabled", "disabled");
}
}
</code></pre>
<p>The variable canAssignMultiple is becoming true when each() function is called the second time though its value has changed to false in the first iteration.It should retain its value evrytime the loop runs.How to do this?</p>
| javascript | [3] |
4,389,147 | 4,389,148 | Kepler Memory Usage | <p>I am using Kepler 2.3 and it looks like my Kepler got killed when I tried to launch it on a cluster machine. The default heap space alloted to kepler is 512m. Is there any way that we can increase the heap size.</p>
<p>Thanks!</p>
| java | [1] |
5,087,644 | 5,087,645 | What is the difference between window, screen, and document in Javascript? | <p>I see these terms used interchangeably as the global environment for the DOM. What is the difference (if there is one) and when should I use each one?</p>
| javascript | [3] |
745,667 | 745,668 | Define php function and use without () | <p>Is it possible to define a function and use without ()?</p>
<p>Like <code>require("a.php")</code> and <code>require "a.php"</code>. </p>
<pre><code>function getNameById($id){}; /*and use it like*/ $id = getNameById "1";
</code></pre>
<p>Thanks.</p>
| php | [2] |
961,667 | 961,668 | Suggest your thoughts on this design | <p>I am working on a business layer functionality.</p>
<p>There are two layers :-
1) Entity Data Model Layer which is the logical layer</p>
<p>This logical layer maps to a storage layer.</p>
<p>There are different classes in each of this layer.</p>
<p>The data storage layer has subject, test and result as objects
The logical layer has entity as objects.</p>
<p>I am writing a code which accepts an object of logical layer and converts it to storage layer objects.
It does so by reading the schema of the logical layer. </p>
<p>The schema of the logical layer is stored in an xml file and it has attributes which map to physical layer.</p>
<p>My code will interpret this schema and convert to appropriate physical layer objects.</p>
<p>The class which I have written is as follows :- </p>
<pre><code>DataModelToStorageTranslator
{
IStorageLayerObject TranslateToStorageLayer(ObjectOfLogicalLayer);
}
</code></pre>
<p>The different classes of the storage layer are derived from the IStorageLayerObject.</p>
<p>The client will check the type of object at runtime.</p>
<p>Is there a better way to achieve the same ?</p>
<p>My implementation is in C#</p>
<p>Thanks,
Vivek</p>
| c# | [0] |
5,688,701 | 5,688,702 | Why do the following expanded if shorthand statements not work in javascript? | <p>This is my first attempt to write shorthand if statements however am befuddled by why the expanded versions don't work quite the way I imagined they would.</p>
<p><strong>Code 1</strong> - Does not work</p>
<pre><code>if(document.getElementById == true) {
alert("The document object model is supported by: " + navigator.appName);
}
</code></pre>
<p><strong>Code 2</strong> - Does work</p>
<pre><code>if(document.getElementById != false) {
alert("The document object model is supported by: " + navigator.appName);
}
</code></pre>
<p><strong>Code 3</strong> - The shorthand that does work</p>
<pre><code> if(document.getElementById) {
alert("The document object model is supported by: " + navigator.appName);
}
</code></pre>
<p>Why is that if I expand the shorthand in 3 to the first code sample not work and why does it work if I have it equal to <code>!= false</code>?</p>
| javascript | [3] |
2,087,670 | 2,087,671 | PHP Script - Get Server Proccessor | <p>I have done a couple hours of research and have found a solution, however I would prefer a solution without using the exec command. </p>
<p>Currently I have this code:</p>
<pre><code>exec ("cat /proc/cpuinfo", $details);
$string= $details[4];
</code></pre>
<p>I basically would like it to pull the first processor's type, like that code does, but without using the system or exec command. </p>
<p>I would prefer to read directly from /proc/cpuinfo. </p>
<p>Any suggestions?</p>
| php | [2] |
4,866,384 | 4,866,385 | How to find variables dynamically created, but not with extract? | <p>I'm working on an old site, written by somebody else, and they've done something equivalent to <code>extract($_POST)</code> somewhere in there code. But they didn't use the function extract.</p>
<p>The application was originally designed for PHP3 (yes, old), then it was ported to PHP4, and now I'm porting it to PHP5. </p>
<p>Does anyone know of what function it could be? Or, any way of finding it out? I've tried using PHPStorm's 'GoTo -> Declaration' but that wasn't it....</p>
<p>I've scanned the documents for the variable and there is no other reference to it, so its being generated by a function equivalent to extract.</p>
| php | [2] |
4,409,596 | 4,409,597 | how to updatePeriod for widgets based in a selection from a spinner programmatically? | <p>I'm using the following code to select the time from the spinner but Im unable to update it for widget </p>
<p>adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(adapter);
spinner2.setOnItemSelectedListener(
new OnItemSelectedListener() {</p>
<pre><code> public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
int index = arg0.getSelectedItemPosition();
Toast.makeText(getBaseContext(),
"You have selected item : " + vals[index],
Toast.LENGTH_SHORT).show();
}
{
}
</code></pre>
<p>//vals[index] contains the time period selected from the spinner </p>
<p>//im using the following code to update the widget time but in unable to make it </p>
<p>final Intent intent = new Intent(context, UpdateWidgetService.class);
final PendingIntent pending = PendingIntent.getService(context, 0, intent, 0);
final AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.cancel(pending);
long interval = 1000*60;
alarm.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),interval, null);</p>
| android | [4] |
281,502 | 281,503 | How to access the String when creating a new method for String.prototype in javascript | <p>I'm trying to learn how to add new methods in the String.prototype in JavaScript. But I can't figure out a way on how to access the string specified in the new method:</p>
<pre><code>String.prototype.new_method = function(){ THE_STRING; };
</code></pre>
<p>So that it will return "abc" when I call it:</p>
<pre><code>"abc".new_method();
</code></pre>
<p>I know this can easily be done by doing:</p>
<pre><code>function returnstring(str){
return str;
}
</code></pre>
<p>But I really want to learn how prototypes in JavaScript works.</p>
| javascript | [3] |
3,791,920 | 3,791,921 | How can I call the .apk file of PDF Viewer through intent of my application? | <p>I have only .APK file of PDF Viewer and my requirement is to use pdf viewer for reading document called through Web API . Is there any possibility to integrate these two in same package apart from source code ?</p>
| android | [4] |
4,958,583 | 4,958,584 | jQuery Accordion drop down not working | <p>Repost of old question with cleaner code:</p>
<p>Trying the make <a href="http://jsfiddle.net/rexonms/Bchjk/3/" rel="nofollow">this</a> accordion work. But the conditional statement is not working. The li > li suppose to show up when a user hover overs li. </p>
<p>Thanks in advance</p>
<p><a href="http://jsfiddle.net/rexonms/Bchjk/3/" rel="nofollow">http://jsfiddle.net/rexonms/Bchjk/3/</a></p>
| jquery | [5] |
266,508 | 266,509 | A simple C# connection string to a flat file , txt | <p>Could any one help me with a connection string to a Microsoft flat file , extension txt ?
I simply want to read a txt document delimited with | .</p>
<p>Get the data and load it into a DataTable via a DataAdapter if possible, the first row on the file should be the columns name on the DataTable, finally DataType is not important on the DataTable</p>
| c# | [0] |
2,585,040 | 2,585,041 | How to get the last part in href or grandparent's id with jquery? | <p>A list is created dynamically. Now I want to get 93 or 94 etc which will be used for php function.</p>
<p>For example I added 93 in two ways as you can see below. In li class="93" or href="http://127.0.0.1/ci_backendpro2/index.php/messages/admin/changestatus/93"</p>
<p>Can anyone tell me how to get this number with jquery please?</p>
<p>Thanks in advance.</p>
<pre><code>...
...
<li class="93">
<div class="listbox">
<span class="user"><strong>Administrator</strong></span>
<span class="date">2010-01-28 15:33:53</span>
<a href="http://127.0.0.1/ci_backendpro2/index.php/messages/admin/changestatus/93"
class="todo">to do</a><span class="msg">test</span></div></li>
...
</code></pre>
<p>I am working on the following code.</p>
<pre><code>//on todo event. this changes the status to compeleted
$(".todo").live('click', function(event){
event.preventDefault();
// alert("hei");
loading.fadeIn();
});
</code></pre>
<p>This is a follow up question <a href="http://stackoverflow.com/questions/2155298/how-to-execute-another-action-after-generated-by-ajax-with-jquery">from here</a>. But the question itself is different.</p>
| jquery | [5] |
3,960,256 | 3,960,257 | Assign object properties to list in a set order | <p>How can I iterate over an object and assign all it properties to a list</p>
<p>From</p>
<pre><code>a = []
class A(object):
def __init__(self):
self.myinstatt1 = 'one'
self.myinstatt2 = 'two'
</code></pre>
<p>to</p>
<pre><code>a =['one','two']
</code></pre>
| python | [7] |
598,170 | 598,171 | Javascript now working | <p>HEllo Geeks :) Sponsor gave me JS script with variables. I have integrated code in my website
and i'm getting direct link from server. This code should take variables and sponsor server should return *.exe file (it's like wizard with offers on final step it takes download link and saves that file on computer. Let's say it works like download manager" Here is my code:</p>
<pre><code> <script type="text/javascript">
window.bi_source_slug = 'scraperpartnerstvsoi';
window.bi_affiliate_id = 'fileneo';
window.bi_unique_identifier = '<TMPL_VAR file_name>';
window.bi_software_name = 'Download Wizard';
window.bi_software_filename = '<TMPL_VAR file_name>';
window.bi_software_download_url = '<TMPL_VAR direct_link>';
window.bi_auto_download = false;
window.bi_download_link_ids = ['first_download'];
(function() { var bi_js_sc = document.createElement('script'); bi_js_sc.type = 'text/javascript'; bi_js_sc.async = true; bi_js_sc.src = 'http://installer.betterinstaller.com/js/betterInstaller_generic.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(bi_js_sc, s); })();
</code></pre>
<p></p>
<pre><code> <a id="ooo" href="<TMPL_VAR direct_link>">link</a>
</code></pre>
<p>Sadly after clicking link i'm get file instantly from server</p>
<p>Working code should give *.exe from sponsor server</p>
<p>Any ideas folks ? :)</p>
| javascript | [3] |
23,697 | 23,698 | loading gridview with hyperlink column | <p>I have a gridview and added a column "Hyperlink" to all records by enabling autogeneratefields.
When this gridview is loaded and when I click the hyperlink across any record I want to redirect to some other page with entire record passed as query string to that page?
can anybody help me on this?</p>
| asp.net | [9] |
2,475,849 | 2,475,850 | $browser not defined | <p>I am trying to use jquery for browser detection but it says </p>
<blockquote>
<p>Uncaught ReferenceError: $browser is not defined</p>
</blockquote>
<p>the code is like </p>
<pre><code>if(!$browser.msie){
condition
}
</code></pre>
| jquery | [5] |
3,681,775 | 3,681,776 | How to enumerate through IDictionary | <p>How can I enumerate through an IDictionary? Please refer to the code below.</p>
<pre><code> public IDictionary<string, string> SelectDataSource
{
set
{
// This line does not work because it returns a generic enumerator,
// but mine is of type string,string
IDictionaryEnumerator enumerator = value.GetEnumerator();
}
}
</code></pre>
| c# | [0] |
2,526,874 | 2,526,875 | Jquery replace not working for inner strings | <p>I need to replace <code>|||</code> from all the input fields using jquery. But it is only replacing the first item. I need to use regex but I don't know how to add that to the string.</p>
<pre><code>$(document).ready(function() {
$("#layerPaper").children("div").each(function() {
$val = $(this).children('input:text');
$val.val($val.val().replace('|||', '\"'));
});
});
</code></pre>
<p>Thanks.</p>
| jquery | [5] |
3,105,378 | 3,105,379 | Passing data in JavaScript | <p>Having a problem understanding what I will call a variable scope question for lack of a better description. </p>
<p>Say I have a page with two functions, <code>one()</code> and <code>two()</code>. The first function has a locally-scoped variable <code>x</code> with an object in it. This function builds an element, below, in the DOM and this element contains an <code>onClick</code>, which calls the second function, and needs to pass <code>x</code> to the second function as an argument. I.e. the second function needs access to the data that is scoped to the first function.</p>
<p>I have tried:</p>
<pre><code><something onClick="two(x);">
</code></pre>
<p>but this doesn't seem to work. I know that there is a way to make <code>x</code> global but I have found in my other languages that globally-scoped variables are discouraged as being dangerous.</p>
| javascript | [3] |
3,989,535 | 3,989,536 | how can show UpdateProgress bar during the page loading | <pre><code><asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" DynamicLayout="true"
AssociatedUpdatePanelID="update1">
<ProgressTemplate>
<div class="TransparentGrayBack">
</div>
<div class="Sample5PageUpdate">
<img src="../RadControls/Ajax/Skins/Default/ajax-loader4.gif" alt="" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</code></pre>
<p>I am using the updateprogress. And it is working fine. But now i want that the update progress show during the page load. would you suggest what should i do.</p>
| asp.net | [9] |
3,755,790 | 3,755,791 | python filename=None | <p>I'm new to Python. I heard that when we initialize a function we should always start by self but I didn't get the <code>fileName=None</code>. What does this argument stand for?</p>
<pre><code>def __init__(self, fileName=None):
</code></pre>
| python | [7] |
619,804 | 619,805 | passing a function as a string in php | <p>I'm just starting to learn PHP and am using the W3 Schools tut. In the error handling section there is this code:</p>
<pre><code><?php
function customError($errno,$errstr) {
echo '<b>Error:</b> [$errno] $errstr<br />';
}
set_error_handler('customError');
echo($test);
?>
</code></pre>
<p>Why is the customError() function being passed as a string? Is this a mistake in the tut?
Also, why isnt <code>$test</code> defined?</p>
| php | [2] |
5,078,509 | 5,078,510 | changing the background color of custom cell | <p>It looks simple thing but i dont know why i am not able to change the background color of a custom tag on which i am working. Please check my code below for the custom cell.</p>
<pre><code>- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
self.textLabel.backgroundColor = [UIColor clearColor];
self.textLabel.textColor = [UIColor orangeColor];
self.textLabel.text = @"lklklk";
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.contentView.backgroundColor = [UIColor blackColor];
self.accessoryView.backgroundColor = [UIColor blackColor];
}
return self;
}
</code></pre>
<p>The cell is only displaying the above text with white backgroud</p>
<p>Thanks in advance</p>
| iphone | [8] |
4,908,670 | 4,908,671 | How to detect input string is not in correct format in c# codes? | <p>is there any way to easily implement to scan through the C# web application codes to see if the input fields has handled the error: "input string is not in correct format "?</p>
<p>Logically it should display a user friendly error message instead of redirect user to a server error page displaying: "input string is not in correct format "</p>
| c# | [0] |
3,909,813 | 3,909,814 | How-to kill my app without killing the service it sarted (debugging) | <p>My android application starts a service when runned for the first time. That service handles network connection.</p>
<p>If the device is out of free space, my application can be killed, but the service will remain alive (except on certain extreme case, I know.). When the app will be restarted, it will need to restore it state according to the service state (no problem for that).</p>
<p>Here's my question: How can I kill my application, but not the associated service ? That's only for debugging purpose, I would like to test if the state is correctly restored.</p>
<p>When I try to kill the app with adb, ddms or advanced task killer, the service is killed too.</p>
<p>Any ideas ?</p>
<p>Thanks,</p>
<p>Code: I start my service like that:</p>
<pre><code>final Intent intent = new Intent(this, Service.class);
mStartServiceResult = startService(intent);
mIsBound = bindService(intent, mConnection, 0);
</code></pre>
<p>and use startForeground / setForeground to prevent my service to be killed.</p>
| android | [4] |
4,219,502 | 4,219,503 | Operation inside when we add two Integer objects? | <p>Can some one explain me how the internal behavior when we add two Integer objects in java? (like it is unbox Object into primitives and then add two integers and finally boxed it in to Integer object)</p>
<pre><code>Integer sum = new Integer(2) + new Integer(4);
</code></pre>
| java | [1] |
2,183,584 | 2,183,585 | can't catch java.lang.VerifyError | <p>I'm getting this error:
"Uncaught handler: thread main exiting due to uncaught exception java.lang.VerifyError"</p>
<p>It's only happening on 1.6. Android 2.0 and up doesn't have any problems, but that's the main point of all.</p>
<p>I Can't catch the Error/Exception (VerifyError), and I know it's being caused by calling isInitialStickyBroadcast() which is not available in SDK 4, that's why it's wrapped in the SDK check. I just need this BroadcastReceiver to work on 2.0+ and not break in 1.6, it's an app in the market, the UNDOCK feature is needed for users on 2.0+ but obviously not in 1.6 but there is a fairly amount of users still on 1.6.</p>
<p>How to fix?</p>
<p>Thanks!</p>
<pre><code>private BroadcastReceiver mUndockedReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent)
{
//FROM ECLAIR FORWARD, BEFORE DONUT THIS INTENT WAS NOT IMPLEMENTED
if (Build.VERSION.SDK_INT >= 5)
{
if (!isInitialStickyBroadcast()) {
int dockState = intent.getExtras().getInt("android.intent.extra.DOCK_STATE", 1);
if (dockState == 0)
{
finish();
}
}
}
}
};
</code></pre>
| android | [4] |
6,026,403 | 6,026,404 | How to check a form is available or not by using its id - jquery | <p>Is it possible to check weather a form is available or not using jquery.</p>
<p>For example :</p>
<p><strong>1. I am having a form ID called form1</strong></p>
<p><strong>2. I need to check in the page weather the id contains a form or not.</strong></p>
<p><strong>3. How can i achieve it using jquery.</strong></p>
<p>Thanks in advance....</p>
| jquery | [5] |
898,194 | 898,195 | Google maps get latitude and longitude having city name? | <p>I want to get latitude and longitude of a city by providing the api with the city name. It should work for most cities regardless how the user inputs the city.</p>
<p>E.G:</p>
<p>city can be 'miami, US' or city can be 'miami, united states'</p>
<p>How do I print it's latitude?</p>
| javascript | [3] |
1,890,781 | 1,890,782 | how to avoid this error | <p>In my page, if i refer
using System.windows.forms;
using System.web.webcontrols..... </p>
<p>Textbox ambiguos refernece error is occured from webcontrols and forms, </p>
<p>how can i rectify this error... but i need those two namespaces in my asp.net page.</p>
| asp.net | [9] |
3,530,830 | 3,530,831 | PHP how to remove the html tags(<DIV></DIV>,<P></P>,<SPAN></SPAN>) from the string | <p>Am using the strip_tags() to remove the HTML tags from one content . but i wants to remove the html (<code><DIV></DIV>,<P></P>,<SPAN></SPAN></code>) tags apart from the <code><img></code> tag and <code><a></code> , i don't want to remove the <code><img ><a></code> tag from that . but need to remove other all html tags from that content how can i do help me.</p>
<p>thanks </p>
| php | [2] |
5,924,177 | 5,924,178 | how to jquery onclick append text to end of TINYMCE textarea | <p>I'm trying to click a word in the page that will append a word at the end of a <code><textarea></code>. What I have works fine on normal textareas but I can't find the proper way to do this in TinyMce.</p>
<pre><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script>
<Idea2>Idea2</Idea2>
<script language="JavaScript" type="text/JavaScript">
$('Idea2').click(function() {
$('#DiscussionX1').val($('#DiscussionX1').val()+'\n\r newCharter');
});
</script>
</code></pre>
<p>I've been told this below would be something like what I need but, I don't know how to deploy it to my code.</p>
<pre><code> $('.mceContentBody').tinymce().execCommand('mceInsertContent',false);
</code></pre>
<p>Thank you for your assistance.</p>
| jquery | [5] |
2,329,538 | 2,329,539 | C# how to populate a string, IList, or Array through if statement | <p>I have the following code:</p>
<pre><code>foreach (string file in FleName)
if (!ActualFiles.Any(x => Path.GetFileName(x).Equals(file)))
{
IList<string> MissingFiles = file;
}
</code></pre>
<p>I have 3 if statements that access this method. At the end of the if statements I need to show the entire IList. </p>
<p>So heres what I want. First if statment goes into the method and returns every file with the word "EqpFle -" before each value</p>
<p>The second if statemenet I want it to return all those items with "DPFle-" in front of all the names, and simialr for the third.</p>
<p>At the end of all the if statements (this is in a for each) I want it to read the entire list.</p>
<p>how owuld I do this?</p>
<p>the ifs basically look as follows:</p>
<pre><code> foreach (string file in files)
{
if
{
Check <----thats the method
}
if
{
Check <----thats the method
}
if
{
Check <----thats the method
}
}
</code></pre>
| c# | [0] |
3,003,866 | 3,003,867 | Example of lightweight and heavy weight thread? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2236412/heavy-weight-and-light-weight-thread">Heavy weight and light weight thread</a> </p>
</blockquote>
<p>Can any body give a example in java how light weight thread differs from heavy weight?</p>
| java | [1] |
2,500,746 | 2,500,747 | setImageResource - Strings and Ints when reading from XML-file | <p>I had this, which was working fine:</p>
<pre><code>public static Integer[] photos = new Integer[]
{R.drawable.photo1,R.drawable.photo2,R.drawable.photo3};
this.setImageResource(photos[mCellNumber]);
</code></pre>
<p>But I decided I wanted to put the filenames in an XML file instead, which I did, like this:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<resources>
<array name="Red">
<item>R.drawable.photo1</item>
<item>R.drawable.photo2</item>
<item>R.drawable.photo3</item>
</array>
</resources>
</code></pre>
<p>And tried stuff like this:</p>
<pre><code>String[] month = getResources().getStringArray(R.array.Red);
this.setImageResource(month[mCellNumber]);
</code></pre>
<p>..and..</p>
<pre><code>String[] month = getResources().getStringArray(R.array.Red);
int bla = Integer.parseInt(month[mCellNumber]);
this.setImageResource(bla);
</code></pre>
<p>I understand why it's not working (strings/ints), but I haven't found any simple way of handling the string to integer conversion part or alternatively, using setImageResource with a string as parameter. Any suggestions?</p>
| android | [4] |
3,614,869 | 3,614,870 | Call by reference vs Pointer argument | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2139224/how-to-pass-objects-to-functions-in-c"><strong>FAQ</strong>: How to pass objects to functions in C++?</a><br>
<a href="http://stackoverflow.com/questions/114180/pointer-vs-reference">Pointer vs. Reference</a> </p>
</blockquote>
<p>Hi all,<br>
in c/c++,
we can pass a object as call by reference or passing pointer of the object.<br>
for example:<br>
i want to create a function which will take string vector as input and output a map that contains some value for each string. the return value of the function is bool, which indicate success or failure.</p>
<p><b>function (call by reference)</b><br/></p>
<pre>
bool calculateSomeValue( vector<string> input, map<string, double>& result)
{
//// bla bla bla
return true/false;
}
</pre>
<p><b>function (using pointer )</b></p>
<pre>
bool calculateSomeValue( vector<string> input, map<string, double>* result)
{
//// bla bla bla
return true/false;
}
</pre>
<p>which one is best? does any one have any idea of the pros and cons of these two options?</p>
<p>thanks in advance.</p>
| c++ | [6] |
2,432,288 | 2,432,289 | c# writing to spreadsheet using XmlWriter | <p>I'm using an <code>XmlWriter</code> to create a spreadsheet and have been successful with the basic setup. The documentation is available here <a href="http://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx#odc_xmlss_span" rel="nofollow">doc</a></p>
<p>and I'm trying to use some advanced features like making a cell span several columns, change font color, cell color, etc. I can see the xml tags needed for this but I dont know how to convert this to the format that <code>XmlWriter</code> required. Can someone help me out a little.</p>
| c# | [0] |
270,278 | 270,279 | adb device missing | <p>I am developing an android app and am now ready to publish it to my device (HTC Desire). The only thing is I am using ubuntu and I am having trouble doing so. I have found some help on the internet regarding installing the drivers, only I need something called "adb devices", however in the latest android sdk it has been moved and now I can't find it. The SDK is up to date. Has anyone else had trouble getting linux to recognize their HTC device?</p>
<p>Cheers!</p>
| android | [4] |
1,144,219 | 1,144,220 | Testing if javascript is enabled | <p>Is there a way to test to see if javascript is enabled to ensure an application that required javascript is not initiated when it is disabled or otherwise not available?</p>
| javascript | [3] |
2,195,024 | 2,195,025 | Concise way of pronouncing :: in C++? | <p>How do you pronounce <code>::</code> in C++ in a concise way?</p>
| c++ | [6] |
2,446,793 | 2,446,794 | How we can make multiple syntax? | <p>How we can make multiple counters? The first counter should count from 1 to 10 and the second counter should count from 4 to 20.</p>
<p>Is it possible (Using <code>For</code> or <code>While</code> methods)? </p>
| java | [1] |
4,355,156 | 4,355,157 | how failed constructor roll over to destroy the completed objects? | <p>I know that when a constructor fails, the completed member objects will be destroyed. There is no memory leak.</p>
<p>My question is that how does compiler do that? How can compiler know what member is constructed? Does it make any record of it? Does the compiler really destroy everything in this case? How does it guarantee this?</p>
| c++ | [6] |
1,882,037 | 1,882,038 | How can I increase 0000 by 1 and keep formatting? | <pre><code>$i=0000;
while($i<=1231)
{
print "$i";
$i++;
}
</code></pre>
<p>I want it to display <code>0001</code>,
<code>0002</code>,
<code>0003</code>,
<code>0004</code>,
but instead it prints:
<code>0</code>,
<code>1</code>,
<code>2</code></p>
<p>Does anyone know why this isn't working?<br>
Thank you in advance.</p>
| php | [2] |
1,902,146 | 1,902,147 | Using "google api java client" android | <p>I want to use "google api java client" to create event "google calendar".
In the event, I want add "Description" and Reminders
Help me.
Thanks</p>
| android | [4] |
34,313 | 34,314 | get the content of an image object in PHP | <p>I'm trying to get the raw data that is created by imagejpeg() in PHP. I need to cache the content since the function generating the image is kind of slow. I know I can provide a 2nd parameter, but that's not what I want.</p>
<p>Thx</p>
| php | [2] |
1,470,821 | 1,470,822 | whats the best way to find multiple appearance of string within a list in python? | <p>Lets say i have the following list:</p>
<blockquote>
<p>['ab=2','bc=5','ab=1','cd=6','ab=7']</p>
</blockquote>
<p>whats the best (efficient) way to find all appearance of the word 'ab' in this list</p>
| python | [7] |
5,892,243 | 5,892,244 | How to do a spinning animation while downloading a file | <p>I have a program that copies a file to the sd card. The program takes a while to run, and now it just freezes while the file is being copied.</p>
<p>I saw some other programs that have a animation of a wheel spinning in the center of the screen while the file is being down loaed.</p>
<p>I tried to google spin control, but this brought up animation about a selector control using spinning wheels.</p>
<p>Is this feature built into the android?</p>
| android | [4] |
907,770 | 907,771 | ArrayAdapter goes beyond bounds | <p>I have an <code>ArrayAdapter</code> with <code>ArrayList</code> filled. Each time I click on any of its item I re-fill the <code>ArrayList</code> and send <code>notifyOnDataSetChange()</code> to the <code>adapter</code>. But for unknown for me reason it goes out of <code>ArrayList</code> bounds in it's <code>getView()</code> method where it populates its items. I don't understand why this happens. Can you guys explain the theory of <code>getView()</code> invokation so I understand why this going on. Thanks in advance!</p>
<p>Here it is:</p>
<pre><code>class MAdapter extends ArrayAdapter<String> {
public MAdapter(Context context, int textViewResourceId, List<String> objects) {
super(context, textViewResourceId, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.file_explorer_row, null);
} else {
}
String txt = itemsList.get(position); // Out of bounds happens here
if (!txt.equals("")) {
TextView tt = (TextView) v.findViewById(R.id.file_explorer_tv_filename);
tt.setText(txt);
}
return v;
}
</code></pre>
<p><code>itemsList</code> is declared in Outer Class.</p>
| android | [4] |
5,435,597 | 5,435,598 | how to write sqlite query using coredata | <p>Please help me,</p>
<p>I want to write query(mentioned below) using coredata.</p>
<pre><code>select primKey, ( primKey - 5 ) as **d** from TABLE Order by **d** limit 1.
</code></pre>
| iphone | [8] |
1,191,756 | 1,191,757 | how to show liked link with image using fb-like button in asp.net | <p>i am facing a problem since 3 days.</p>
<p>I have fb-like button on my webpage, when i click on it, it posts a message on facebook. but doesnt show given image in that like post.</p>
<p>I refer some posts and got answers that add the open graph meta tags, so that the fb will show the images.
But its not working</p>
<p>I added following meta tags than also i failed.</p>
<p><code>
<meta property="og:title" content="FMTest6 Play Floa: http://tinyurl.com/827adl9" />
<meta property="og:type" content="activity" />
<meta property="og:url" content="http://floa.staging.perpetuating.com" />
<meta property="og:image" content="http://floa.staging.perpetuating.com/Floas/FMTest6/mojopreview.png" />
<meta property="og:site_name" content="Floa" />
</code></p>
<p>I also tried to debug my page using facebook/lint tool, in that tool the page shows image as passed, but while clicking on fb-like on my webpage, it doesnt show the given image, instead it shows another image from my webpage.
Help needed to fix this.
<img src="http://i.stack.imgur.com/lRD7B.png" alt="enter image description here"></p>
| asp.net | [9] |
5,721,071 | 5,721,072 | send data to a bluetooth module using python qt | <p>In python-qt i have created a form with for buttons.I have to send data to a bluetooth module.On pressing one button one particular data have to be send.When another button is clicked another data have to send.for this i have opened a socket and tried to send the requried data using sock.send.during all the time the socket is open.but this method is showing me an error.the error is "bluetooth.btcommon.BluetoothError 107 :Transport endpoint not connected".
how i can i solve this problem??can anyone help me out?? </p>
| python | [7] |
5,876,699 | 5,876,700 | Load image before rendering for JavaScript slideshow for mobile browser | <p>Can someone please tell me what is wrong with this code (other than the fact that it is probably poorly written...)? I am trying to create a slideshow in JavaScript for a mobile browser. The "seamless" thing is to load the image before switching the background image. I tested a previous version of the script on my iPhone and the screen became white for 2 seconds while the image was loading. I am trying to solve that problem. </p>
<pre><code><script>
var i = 1;
var imgnumber = 112;
function randomimage() {
if(i <= 200) {
var imgnumber = Math.ceil(Math.random() * 800);
var loadimage = document.getElementById("seamless");
loadimage.setAttribute("src", 'http://www.url.com/images/' + imgnumber + '.jpg');
timer = setTimeout("changebackground()", 3500);
i++;
}
}
function changebackground() {
var bg = 'http://www.url.com/images/' + imgnumber + '.jpg';
document.body.background = bg;
}
</script></head>
<body background="http://www.url.com/images/543.jpg" onload="randomimage()">
<img id="seamless" src="http://www.url.com/images/543.jpg" height="1" width="1" style="z-index:-1;" /></body>
</code></pre>
| javascript | [3] |
5,316,645 | 5,316,646 | RaphaelJS for Directory Board Navigation | <p>I am developing a directory board for my own school with touch navigation using JS. I would like to apply a feature where users can see a navigation line when he touch a particular destination from the directory listings. Says from the Parking Lot to the Laboratory. </p>
<p>I have done few readings on RaphaelJS and it seems not so easy to apply, is there any other solutions other than using RaphaelJS?</p>
| javascript | [3] |
1,281,871 | 1,281,872 | Javascript: Image to Base64? | <p>Is there any way how to encode a png/jpeg/gif image to base64 using Javascript (can't use canvas toDataURL)? Thank you.</p>
| javascript | [3] |
5,934,938 | 5,934,939 | Are onTouch(), onClick() running sequentially in the same thread? | <p>Are onTouch(), onClick(), runOnUiThread() running in the same UI thread sequentially? Or do I have to worry about synchronization issue among them?</p>
<p>Thanks.</p>
| android | [4] |
2,121,067 | 2,121,068 | parsing html data in android | <p>I am making an application in which i have to parse HTML data. I have got data that i want. But data is repeating five to six times. I m saving data into string, but when i am printing this string there is no repeated data. e.g data having 23 values and it is repeating five or six times. I have entered static string it is displaying fine.<br>
Here is code:</p>
<pre><code>doc = (Document) Jsoup.connect("http://altoona.craigslist.org/search/cta?query=Ford+WINDSTAR&srchType=T&minAsk=&maxAsk=").get();
System.out.println("*****DOC*****"+doc);
s1=doc.getAllElements().text().toString();
System.out.println("**************S1*************"+s1);
</code></pre>
<p>Please help me where m doing something wrong.</p>
| android | [4] |
364,337 | 364,338 | passing custom data from <a> to jQuery to show confirmation message before delete | <p>How can I pass custom data to the jQuery event handler, specifically from the <code>$(this)</code> element? In HTML5, I probably can legally write:</p>
<p><code><a class="delete" href="delete.php?id=5" data-id="5">delete</a></code></p>
<p>although I still feel a bit awkard about that. How about prior to that?</p>
<pre><code>$(".delete").click(function() {
return confirm("Do you really want to delete " + $(this).attr("data-id"));
});
</code></pre>
<p>Any best practices?</p>
| jquery | [5] |
908,477 | 908,478 | Android check internet connection | <p>I want to create an app that uses the internet and I'm trying to create a function that checks if a connection is available and if it isn't, go to an activity that has a retry button and an explanation. </p>
<p>Attached is my code so far, but I'm getting the error <code>Syntax error, insert "}" to complete MethodBody.</code></p>
<p>Now I have been placing these in trying to get it to work, but so far no luck... Any help would be appreciated.</p>
<pre><code>public class TheEvoStikLeagueActivity extends Activity {
private final int SPLASH_DISPLAY_LENGHT = 3000;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
private boolean checkInternetConnection() {
ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
// ARE WE CONNECTED TO THE NET
if (conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected()) {
return true;
/* New Handler to start the Menu-Activity
* and close this Splash-Screen after some seconds.*/
new Handler().postDelayed(new Runnable() {
public void run() {
/* Create an Intent that will start the Menu-Activity. */
Intent mainIntent = new Intent(TheEvoStikLeagueActivity.this, IntroActivity.class);
TheEvoStikLeagueActivity.this.startActivity(mainIntent);
TheEvoStikLeagueActivity.this.finish();
}
}, SPLASH_DISPLAY_LENGHT);
} else {
return false;
Intent connectionIntent = new Intent(TheEvoStikLeagueActivity.this, HomeActivity.class);
TheEvoStikLeagueActivity.this.startActivity(connectionIntent);
TheEvoStikLeagueActivity.this.finish();
}
}
}
</code></pre>
| android | [4] |
2,261,880 | 2,261,881 | Page View Counter like on StackOverFlow | <p>What is the best way to implement the page view counter like the ones they have here on the site where each question has a "Views" counter?</p>
<p>Factoring in Performance and Scalability issues.</p>
| asp.net | [9] |
1,684,851 | 1,684,852 | Scaling image anchored at cetain point | <p>Is it possible to scale an image by using a specified point as the anchor, i.e. the image "grows" out from this point?</p>
| iphone | [8] |
704,724 | 704,725 | When should a music player gain and give up audio focus? | <p>I'm writing an Android music player, and is stuck on audio focus issue.</p>
<p>It seems like audio focus mainly affects media button receiving, but after reading the document I have no idea about when to gain and give up focus.</p>
<p>My music app will run in background, and need to detect play/pause button <strong>every time</strong>. That is, even when my app is not running, a user should be able to press headset's play button and start music.</p>
<p>It seems I should never give up audio focus, so why should I implement it?</p>
<p>Does anyone know practically how audio focus should be used? Thank you!</p>
| android | [4] |
465,694 | 465,695 | Sort array using another array | <p>I have an array of products and i want to sort them with another array.</p>
<pre><code>$products = array(
0 => 'Pro 1',
1 => 'Pro 2',
2 => 'Pro 3'
);
$sort = array(1,2,0);
array_multisort($products, $sort);
</code></pre>
<p>Array <strong>should</strong> now be ...</p>
<pre><code>$products = array(
0 => 'Pro 2',
1 => 'Pro 3',
2 => 'Pro 1'
);
</code></pre>
<p>I don't seem to be using array_multisort correctly. Ive tried different ways for 2 hours now...</p>
| php | [2] |
4,723,812 | 4,723,813 | second click beats first animate complete callback function | <p>I have a button, when clicked, animates a div.</p>
<p>I am trying to make use of the <a href="http://api.jquery.com/animate/" rel="nofollow">$.animate()</a> [complete] callback function, but running into a situation where clicking the button twice really fast causes the animation to run twice before the first animation's [complete] callback runs.</p>
<p>Please see this link for demo.
<a href="http://jsfiddle.net/zs2uf/3/" rel="nofollow">http://jsfiddle.net/zs2uf/3/</a></p>
<p>Any ideas how to prevent the second click from beating the first's callback?</p>
| jquery | [5] |
5,503,516 | 5,503,517 | How do you reference another one of your classes in java? | <p>in Class1 I have a private float float1</p>
<p>I have two public methods to access this variable.</p>
<pre><code>public float getFloat1(){
return float1;
}
public void setFloat1(float f){
float1 = f;
}
</code></pre>
<p>How do I use these methods in Class2?</p>
| java | [1] |
1,712,324 | 1,712,325 | Null pointer expection | <pre><code>String graphNameUsed = graphName.getName();
if (graphType.equals("All") || graphType.equals("ALL"))
graphNameUsed += "_ALL";
</code></pre>
<p>If my String is null, then will it throw Null Pointer expection when i am checking whether it equals or not. To Avoid this expection, how should i check.</p>
| java | [1] |
3,382,845 | 3,382,846 | in android how to develop an hotel bill application with different categories of items? | <p>here there will be list of categories in first page we have to select the categories and in particular category we have to select list of items on clicking the items these items and and their bill amount should be added to the bill page then the bill page should has 3 buttons one for ok other for clear if we press ok the amount should be added and total has to be shown. return button for going to the categories menu page</p>
<p>in the list of items (context menus) there should be 3 buttons one for viewing the bill page and other button for clearing the selection and other button for going to categories menu</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.