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,167,359 | 4,167,360 | Android multi lined text with virtual keyboard suggestion off | <p>I need to disable the soft keyboard suggestion.</p>
<p>I have found this:<br>
<code>inputtype="textNoSuggestion"</code><br>
But when I set this, I'm not able to type the multi lined text?</p>
| android | [4] |
1,216,881 | 1,216,882 | Where to store currently selected item id? | <p>I'm trying to write an asp.net app which searches a sql db and returns/updates the data.</p>
<p>I want to be able to hold the currently selected id of the item my user has selected. For example a doctors surgery would select a patient record then be able to browse the app without having to re-select that patient on each page.</p>
<p>What would be the best way to do this. Ideally I need to be able to get this ID application wide. the only thing i can think of is to create a public class, store the id and make it public but this seems quite messy</p>
<p>Thank you </p>
| asp.net | [9] |
4,974,952 | 4,974,953 | pagerAdapter reference a programmed layout android | <p>I'm usually use pager adapter to scroll through different layouts, but this time my layouts were created with java code instead of xml. Normally when choosing the resource id I reference R.layout.file. Having created the layout with java code, I'm not aware how to reference the resource. Does anyone know how to do this?</p>
<p>Sample code of a layout I created that I want to reference:</p>
<pre><code>LinearLayout ParentLayout = new LinearLayout(getApplicationContext());
ParentLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
ParentLayout.setOrientation(LinearLayout.VERTICAL);
</code></pre>
<p>Normally for a pager adapter I have something like this:</p>
<pre><code>public class MyPagerAdapter extends PagerAdapter {
@Override
public int getCount() {
return 3;
}
public Object instantiateItem(View collection, int position){
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int resId = 0;
switch (position) {
case 0:
resId = R.layout.xmlfile1; //I want to reference the ParentLayout I created above
break;
case 1:
resId = R.layout.xmlfile2;
break;
case 2:
resId = R.layout.xmlfile2;
break;
}
View view = inflater.inflate(resId, null);
((ViewPager) collection).addView(view, 0);
return view;
}
...
}
}
</code></pre>
| android | [4] |
2,340,567 | 2,340,568 | What am I doing wrong? PHP script with nothing visibly wrong | <pre><code><?php
$file = fopen("configuration.conf","w+");
$settings['LogEnabled'] = "true";
$settings['Pass'] = "pass";
$settings['ShowWarning'] = "true";
fwrite($file,serialize($settings));
$path = "configuration.conf";
$file2 = file_get_contents($path);
$settings2=unserialize($file2);
echo($settings2['LogsEnabled']);
?>
</code></pre>
<p>It ought to show "true" when run. Whats wrong?</p>
<p>I tried fread and fopen for $file2, but neither work.</p>
<p>EDIT: It does not throw an error.</p>
<p>The file has permissions 0740</p>
| php | [2] |
4,510,109 | 4,510,110 | How to get image of barcode? | <p>I am using ZXing api to read barcode from a image and i can read barcode using below code but i want also image of barcode which capture by api please let me know how to get it. </p>
<p>IntentIntegrator.initiateScan(Activity);</p>
<p>Thanks</p>
| android | [4] |
4,584,839 | 4,584,840 | Error starting executable, no provisioned ios device is connected | <p>Why am I seeing this error? Is it looking for my real iphone device to be connected to install it on their?</p>
<p>I just downloaded the views sample code from: <a href="http://www.sunsetlakesoftware.com/sites/default/files/Fall2010CourseNotes/views%20and%20controllers.html" rel="nofollow">http://www.sunsetlakesoftware.com/sites/default/files/Fall2010CourseNotes/views%20and%20controllers.html</a></p>
| iphone | [8] |
2,770,579 | 2,770,580 | Render a static html page or html markup in a file somewhere inside a asp.net page | <p>I am using asp.net 3.5 and want to render the contents of a static html file into an asp.net page that contains a master page in one of the contentplaceholders. I have considered using an iframe but would like to avoid that if possible. Alternatively, if it's simpler I would like to just read in some text in a file that's html like:</p>
<p><hr /></p>
<pre><code><table>
<tr>
<td>
Hey dude
<td>
</tr>
</table>
<div>
<span>I am special! </span>
</div>
</code></pre>
<p><hr /></p>
<p>and render that into that contentplaceholder in the page. I have thought about a literal control to do this but am not sure if that will work either. The problem I am trying to solve is that I want to be able to give a user access to an html page or text file and have them update it with content. Then at runtime render the html markup from this file. This is the only page in the application I need this functionality so something like a CMS system or html editor control is overkill. I just need to read a in a file and render the html markup in an asp.net page. Also I would like the markup that's rendered to use the css we already have but I think that's a gimme either way.</p>
| asp.net | [9] |
479,777 | 479,778 | Looping a Background Worker Task | <p>I have some code inside a background worker <code>DoWork</code> event which check if a process is running or not. The code in the <code>DoWork</code> does the following:<br/>
-> If the process is not running, check again twice<br/>
-> If the process is running, check if it is responding<br/>
-> If the process is running and respoding, do nothing<br/>
-> If the process is running and not responding, restart the process<br/></p>
<pre><code> void bgworker_DoWork(object sender, DoWorkEventArgs e)
{
int numberTrials = 0;
bool isNotRunning = false;
while (isNotRunning = (someProcess.Length == 0) && numberTrials < 3)
{
Debug.WriteLine(String.Format("numTrial = {0}", numberTrials.ToString()));
Thread.Sleep(3000);
++numberTrials;
}
if (isNotRunning)
{
Debug.WriteLine("Start Task");
someProcess.Start();
}
else
{
if(!someProcess.IsKioskResponding)
{
Debug.WriteLine("Kill Task");
}
}
}
</code></pre>
<p>The above thing runs fine but I have to loop the above <code>DoWork</code> task for every 3 minutes. Would it be a good thing to keep the above looping task in a timer that has an interval of 3 minutes? (In that way I would have to take care of <code>Thread.Sleep x numberTrials</code> not to exceed the Timer's interval). Any thoughts on this?</p>
| c# | [0] |
5,439,156 | 5,439,157 | What does "EGPCS" mean in PHP? | <p>I found the following code in <code>php.ini</code>. what does that mean?</p>
<p>And "PHP registers" -- what is that?</p>
<pre>
; This directive describes the order in which PHP registers GET, POST, Cookie,
; Environment and Built-in variables (G, P, C, E & S respectively, often
; referred to as EGPCS or GPC). Registration is done from left to right, newer
; values override older values.
variables_order = "EGPCS"
</pre>
| php | [2] |
2,720,156 | 2,720,157 | "un"toggling a div with jQuery | <p>I'm using jQuery's .toggle method to create a menu that opens and closes when a div is clicked. Here is my code: </p>
<pre><code>$(".header").toggle(function() {
$(this).find(".parent").fadeIn("fast");
$(this).css("background-color","red");
}, function() {
$(this).find(".parent").fadeOut("fast");
$(this).css("background-color","white");
});
$(document).click(function() {
$('.parent').fadeOut("fast");
$(".header").css("background-color","white");
});
$(".parent").click(function(event){
event.stopPropagation();
});
</code></pre>
<p><a href="http://jsfiddle.net/bmcmahen/X9S5C/8/" rel="nofollow">http://jsfiddle.net/bmcmahen/X9S5C/8/</a></p>
<p>This works well until I click outside of the pop-up menu to close it, and then try to click on the menu button again. It then requires a double click. What I need to be able to do is to untoggle the click on the div from the $(document).click function. Any idea on how I'd do this? </p>
| jquery | [5] |
5,264,932 | 5,264,933 | How can I have my page access functions from a .vb file in App_Code? | <p>I made a new page in our website that needs to access some functions that are in App_Code/modFunctions.vb. I tried simply calling the functions but it says not found in current context. So here are the file locations, starting at the root of the site:</p>
<pre><code>/App_Code/ModFunctions.vb
/users/export.aspx
</code></pre>
<p>export.aspx is my C# page that I need to call the functions in ModFunctions.vb, how can I link them together?</p>
| asp.net | [9] |
1,628,984 | 1,628,985 | full path of a folder in c# | <p>i need to get the full folder path in a windows project using c#.I tried with path.getFulPath(filename).bt it returns the application path+filename.how can i get the actual path like "D:\eclipse_files\ads_data"?</p>
| c# | [0] |
2,067,024 | 2,067,025 | Interpolating an angle counter clockwise? | <p>Right now 'm using linear bezier to interpolate angles:</p>
<pre><code> float CardAnimation::valueAt( float valueA, float valueB, float t ) const
{
return (1.0f - t) * valueA + t * valueB;
}
....
if(m_startCard.m_angle != m_endCard.m_angle)
{
m_targetCard->m_angle =
valueAt(m_startCard.m_angle, m_endCard.m_angle,m_interval);
}
</code></pre>
<p>This works as expected. But here is my problem. If your start angle is 0.5f and you want to go to 6.0f (in radians) then it will go clockwise from 0.5f to 6.0f when really since 6.0f - 0.5f > 3.14f it would be much smarter to go counter clockwise from 0.5f to 6.0f (resulting in moving only 0.78 radians rather than 5.5). What should I do to interpolate counter clockwise if abs(endAngle - startAngle > PI) ?</p>
<p>Thanks</p>
| c++ | [6] |
5,899,423 | 5,899,424 | How can I execute a specific chunk of code when my application crashes? | <p>Is there a way that I can execute a specific chunk of code when my application crashes? (i.e. If my application crashes, I would like to safely close some streams) </p>
| c# | [0] |
3,669,889 | 3,669,890 | Using Directory.GetFiles with regex-like filter | <p>I have a folder with two files:</p>
<ul>
<li>Awesome.File.20091031_123002.txt</li>
<li>Awesome.File.Summary.20091031_123152.txt</li>
</ul>
<p>Additionally, a third-party app handles the files as follows:</p>
<ul>
<li>Reads a <code>folderPath</code> and a <code>searchPattern</code> out of a database</li>
<li>Executes <code>Directory.GetFiles(folderPath, searchPattern)</code>, processing whatever files match the filter in bulk, then moving the files to an archive folder.</li>
</ul>
<p>It turns out that I have to move my two files into different archive folders, so I need to handle them separately by providing different searchPatterns to select them individually. Please note that I can't modify the third-party app, but I can modify the searchPattern and file destinations in my database.</p>
<p><strong>What <code>searchPattern</code> will allow me to select <code>Awesome.File.20091031_123002.txt</code> without including <code>Awesome.File.Summary.20091031_123152.txt</code>?</strong></p>
| c# | [0] |
3,380,489 | 3,380,490 | When are views drawn in android? | <p>I want to get the size of a view that is in my activity but I am not able to get that information in any of the activity lifecycle callbacks (onCreate, onStart, onResume). I'm assuming this is because the views have not been drawn yet. At what point are views drawn and is there a callback I can put my code so I can get the size of the view?</p>
<pre><code>findViewById(R.id.header).getHeight();
</code></pre>
| android | [4] |
4,315,450 | 4,315,451 | Python: Max retries exceeded with url: /x.php (Caused by <class 'socket.gaierror'>) | <p>I have set up a database and php file running on my host and I run a python code that uploads a json file every 5 minutes using the Requests module. After about 6-8 hours, the app crashes and produces this error:</p>
<pre><code>Max retries exceeded with url: /rpitest2.php (Caused by <class 'socket.gaierror'>: [Errno -2] Name or service not known)
</code></pre>
<p>What could be the reason for this?</p>
| python | [7] |
2,215,090 | 2,215,091 | Error C++ | ISO C++ forbids assignment of arrays | <p>I have a problem which I can not solve.
If this query is answered as "yes", then should anrede = female.</p>
<p>Dev++ gives me this error:
ISO C++ forbids assignment of arrays</p>
<hr>
<pre><code>char anrede[10];
printf("Anrede: female?? Yes/No");
scanf("%s", &anrede);
if(anrede == "Yes"){
anrede = "female";
} else{
anrede = "male";
}
</code></pre>
<p>Can someone help me?</p>
| c++ | [6] |
3,804,857 | 3,804,858 | How to enable element using siblings jquery | <p>Looking below i would like to get the value of the cnhor element and if its equal to
"Guide" enable the corresponding button.
Tried the below but couldn't get it to work.:(
Have a feeling i'm almost there.
Thanks</p>
<pre><code> $("button").siblings("a").each(function () {
var b = $(this).text();
var n = $.trim("Guide");
if ($.trim(b) == n) {
$("button").removeAttr("disabled");
}
<button id="Toggle5" disabled="disabled">
Show </button>
<a href="#" id="docsID5" target="_blank">
Guide
</a>
</code></pre>
| jquery | [5] |
5,919,209 | 5,919,210 | Preventdefault working on Google Chrome but not on Firefox for <select> element | <p>So if you try the following code: <a href="http://jsfiddle.net/LNfZT/29/" rel="nofollow">http://jsfiddle.net/LNfZT/29/</a></p>
<p>It works perfectly on Chrome but not at all on firefox. Does anyone have any idea why?</p>
| jquery | [5] |
4,315,995 | 4,315,996 | Change a website's directory names per installation | <p>Is there a way that I can have different directory names per installation of a website? As in I would need to rename the directories at build time or some similar solution. I am currently using MSBuild with CruiseControl.NET.</p>
<p>An example would be I have a module in my website called Bug Tracking which is then in <a href="http://mysite.com/BugTracking/" rel="nofollow">http://mysite.com/BugTracking/</a>.</p>
<p>One installation wants to leave it as BugTracking and another would like to call it "Issue Tracking" for whatever reason and have it in <a href="http://theirsite.com/IssueTracking/" rel="nofollow">http://theirsite.com/IssueTracking/</a>.</p>
| asp.net | [9] |
4,449,635 | 4,449,636 | What is the correct syntax for `.live()` binding of the 'hover' method? | <p>We call a <code>.live()</code> method like this:</p>
<blockquote>
<pre><code>$('.link').live('click', loadContent);
</code></pre>
</blockquote>
<p>But what about if I'm binding to <code>hover</code> instead, which calls for two functions separated by a comma? When I put in this:</p>
<blockquote>
<pre><code>$('.thumb.dim').live('hover', function(){$(this).removeClass('dim');}, function(){$(this).addClass('dim');});
</code></pre>
</blockquote>
<p>The <code>mouseenter</code> event does trigger the first function above (<code>removeClass('dim')</code>), but on <code>mouseleave</code> nothing happens. Is there a correct way to write this?</p>
| jquery | [5] |
1,842,464 | 1,842,465 | How to allow user to install apk file one once on android phone? | <p>Hi i have develop an android application in which i want to prevent user to create multiple account on our ftp server from one android device for which i create configuraton file and store boolean value which is by defult one but when user create account its value change to true. but there is an issue when user uninstall the apk file our configuration file also delete and user can create account again and boolean value lost.</p>
<p>My queston is that in android there is any registry like concept (same in windows) that we store value in android registry and when it try install it 2nd time it not allow it. or any another way which it more simple. any help in this regard is greatly apprecialted thanks in advance </p>
| android | [4] |
5,383,815 | 5,383,816 | jQuery new added inputs are not submitted | <p>I have a lot of PHP generated input fields. Once I add new fields with jQuery they are not submitted if they are empty. However the static ones are sent even if they are empty.</p>
<p>How should I fix that ?</p>
<p><strong>CODE:</strong></p>
<pre><code><form id="sendform" action="pdf.php" method="post">
<input type="text" name="to1" />
<input type="text" name="to2" />
<input type="text" name="to3" />
<input type="submit" value="send" />
</form>
</code></pre>
<p>Now jQuery part is:</p>
<pre><code>var clone = $('input[name="to2"]').clone();
$(clone).attr('name', 'to4');
$('#sendform').append(clone);
</code></pre>
<p><strong>Screenshots:</strong>
<img src="http://i.stack.imgur.com/gNLfw.png" alt="This is what I see through DOM inspector">
<img src="http://i.stack.imgur.com/HzC6h.png" alt="This is what I see in the headers when submitted"></p>
<p>You can see that there's Note1, Note2, Note3, Note4. I have added Note2 dynamically. You can see from the screenshot that it is in the dom, however it is not sent(yes, there's data inputted).</p>
<p><strong>SOLUTION</strong>
In conclusion the problem was in <strong></strong> element placed inside the table(<code><table><form></code>). When <strong></strong> became parent of a table(<code><form><table></code>) - everything works fine.</p>
| jquery | [5] |
1,888,033 | 1,888,034 | Simple add function to a adjacency matrix | <p>I'm developing an adjacency matrix so i can try and use a DFS to solve the euler circuit problem.
This is the relevant code to my question:</p>
<pre><code>public class Graph {
private int numVertex;
private int numEdges;
private boolean[][] adj;
public Graph(int numVertex, int numEdges) {
this.numVertex = numVertex;
this.numEdges = numEdges;
this.adj = new boolean[numVertex][numVertex];
}
public void addEdge(int start, int end){
if(!adj[start][end])
numEdges++;
adj[start][end] = true;
adj[end][start] = true;
}
</code></pre>
<p>When i try and test run this code by adding some edges i get:</p>
<pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at Graph.addEdge(Graph.java:18)
at Graph.main(Graph.java:66)
</code></pre>
<p>I'm using this to test the code:</p>
<pre><code> public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int numVertices = input.nextInt();
int numLinks = input.nextInt();
int startNode = input.nextInt();
Graph g = new Graph(numVertices, numLinks);
for(int i = 0; i<numLinks; i++){
g.addEdge(input.nextInt(),input.nextInt());
}
</code></pre>
<p>I think the problem is in the addEdge function. What am i doing wrong?</p>
| java | [1] |
1,733,013 | 1,733,014 | How to change the date formet in datatables columfilter plugin(date filter)? | <p>I am using datatables column filter plugin:-</p>
<pre><code>It has default date filter as this formet:-24/07/2012
But I have to filter the data in this format:-24-07-2012..??
</code></pre>
| jquery | [5] |
2,241,284 | 2,241,285 | Is it possible to build an iphone view WITHOUT using Interface Builder? | <p>So Interface Builder does things to save time but what if I want to do without it ? In C# all code generated is clear and understandable, in interface builder this is hidden so I'd like at least during learning phase do things from scratch: any sample code to do so ?</p>
<p>Seems Apple makes things very hard so as you cannot easily use alternative to Xcode :)</p>
<p><a href="http://cocoawithlove.com/2009/02/interprocess-communication-snooping.html" rel="nofollow">http://cocoawithlove.com/2009/02/interprocess-communication-snooping.html</a></p>
| iphone | [8] |
5,306,347 | 5,306,348 | Getting "Indirect modification of overloaded property has no effect" notice | <p>I want to use a Registry to store some objects. Here is a simple Registry class implementation. </p>
<pre><code><?php
final class Registry
{
private $_registry;
private static $_instance;
private function __construct()
{
$this->_registry = array();
}
public function __get($key)
{
return
(isset($this->_registry[$key]) == true) ?
$this->_registry[$key] :
null;
}
public function __set($key, $value)
{
$this->_registry[$key] = $value;
}
public function __isset($key)
{
return isset($this->_registry[$key]);
}
public static function getInstance()
{
if (self::$_instance == null) self::$_instance = new self();
return self::$_instance;
}
}
?>
</code></pre>
<p>When I try to access this class, I get "Indirect modification of overloaded property has no effect" notification.</p>
<pre><code>Registry::getInstance()->foo = array(1, 2, 3); // Works
Registry::getInstance()->foo[] = 4; // Does not work
</code></pre>
<p>What do I do wrong?</p>
| php | [2] |
4,993,918 | 4,993,919 | Will the pointer ever be different than expected in this case? | <p>Say I have a Listener class.</p>
<p>I have class A and class M which both implement the listener class.
Class A has 4 M's.</p>
<p>Each M has 1 A, but not as an A, as a Listener base class. (So downcasted A because M knows nothing about A).</p>
<p>When A gets a message from 1 of them M's it needs to be able to know which M sent it.</p>
<p>Therefore, every method in the Listener class has a Listener* parameter.</p>
<p>so if I have something like this:</p>
<pre><code>void A::someListenerMethod(Listener* l, MsgEnum msg)
{
if(l == m_mInstance[0])
{
//will this work if the caller was indeed the M instance in question?
}
}
</code></pre>
<p>So essentially what I'm asking is, do I need to downcast the M's to Listeners before comparing them?</p>
<p>I read that sometimes C++ will make a separate object for a sub class for multiple inheritance. There is no multiple inheritance in this case, but I want to make sure this will work.</p>
<p>Thanks</p>
| c++ | [6] |
4,801,835 | 4,801,836 | How can I save captured images from webcam with different file names in C# | <p>How can I save images captured from webcam to my <code>c:/</code> drive with different file names? </p>
<p>I have been able to capture image webcam and save it on my c:/ drive, but am having slight problems. I want each time an image is saved,it should not overwrite the old captured one already saved on my c:/ </p>
<p>(i.e images saved will be different from previous ones left untouched with different names <code>pix1.jpg</code>, <code>pix2.jpg</code>, <code>pixs3.jpg</code>, <code>pix4.jpg</code> etc).</p>
| c# | [0] |
6,014,566 | 6,014,567 | Assets Confusion | <p>I'm utterly confused. There's an 'assets' folder in my project, but the AssetManager does not refer to this folder. So I have three questions:</p>
<p>First, where is the folder that AssetManager refers to?</p>
<p>Second, how do I put files into that folder?</p>
<p>Third, how do I access the files that I put into my project's 'assets' folder? (Corollary question: what is the purpose of this folder if it's not used by AssetManager?)</p>
<p>The docs completely fail to clarify these issues. Very frustrating.</p>
| android | [4] |
443,075 | 443,076 | Removing word + wildcard number from string | <p>I have a string that is</p>
<pre><code>$str = "testingSUB1";
</code></pre>
<p>How can I strip out <code>SUB*</code> from the string? I assume using <code>preg_replace</code> but I'm not good with matching what I want with regex.</p>
<p>Does anyone know how I can do this?</p>
<p>Thank you</p>
| php | [2] |
6,032,115 | 6,032,116 | How many widgets per application are supported in Android? | <p>Can I have more than one widget per app on home screen of Android for the same application? That is to display at once on home.</p>
| android | [4] |
5,731,302 | 5,731,303 | jQuery .append Issue | <p>This is my code:</p>
<pre><code>$('.add').click(function(){
$('#test').append("<div class='tab selected'>TEST</div>");
});
$('.tab').click(function(){
$('.tab').removeClass('selected').addClass('unselected');
$(this).removeClass('unselected').addClass('selected');
});
<input type='button' value='add' class='add' />
<div id='test'>
<div class='tab unselected'>TEST</div>
</div>
</code></pre>
<p>This is my issue:</p>
<p>When I click the <code>.tab</code> div that was already defined in html, the function works fine.
But, if I add another <code>.tab</code> div using the <code>.add</code> input, the function does not work.</p>
<p>What exactly am I doing wrong here?</p>
| jquery | [5] |
2,914,590 | 2,914,591 | Android push notifications - how can I extract the device id? | <p>From the Google cloud push tutorials, I am running this code when a user first starts the app:</p>
<pre><code> GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals(""))
{
GCMRegistrar.register(this, "566530471892");
}
else
{
//Log.v(TAG, "Already registered");
}
</code></pre>
<p>But what I don't understand is how to send that regId variable to the server so I can save it along with the new user id.</p>
<p>Or am I misunderstanding how this is supposed to work? Is that not the correct thing to do here?</p>
<p>Thanks!</p>
| android | [4] |
1,744,251 | 1,744,252 | zed shaw's exercise 15 open function | <p>I am a little stuck with zed shaw's exercise 15.
Actually I had no problem with the original program,
but the problem is when I try out the extra credit
where he asks us to use raw input instead of argv.</p>
<p>so, this is the code I used</p>
<pre><code>filename=raw_input("enter filename :")
print "here's your file %r" % filename
txt=open(filename)
print txt.read()
</code></pre>
<p>when it asks for filename, I give the path e:\python\ex15_sample.txt
I am getting the following error in
this line --> txt = open(filename)
and it further says
no such file or directory</p>
<p>So, what do I do?</p>
| python | [7] |
2,072,939 | 2,072,940 | How to place listview inside a scroll view | <p>I have a <code>RelativeLayout</code> and below that i have a <code>ListView</code>. I have to place these inside a <code>ScrollView</code>. Any help will be deeply appreciated.</p>
| android | [4] |
5,060,732 | 5,060,733 | Service architecture, continuously running vs. wake up | <p>I have an application that wakes up at frequent intervals (once per minute) to do some stuff in the background. I will be using the <code>AlarmManager</code> to schedule the wake ups.</p>
<p>I am looking at two different ways of structuring a <code>Service</code> to do the background work:</p>
<ol>
<li>keep the service continuously running in the foreground with <code>setForeground()</code>. This is attractive since the application state will remain in memory between wake-ups.</li>
<li>use <code>stopSelf()</code> to destroy the <code>Service</code> after it has finished running the background task. This will require persisting some non-trivial objects between each wake up.</li>
</ol>
<p>What are the pros and cons of each approach? How costly is persistence? What is the recommended approach for storage for case 2?</p>
| android | [4] |
4,013,785 | 4,013,786 | C# Threading arguments are invalid | <p>i got this Code from an Old post</p>
<pre><code>public delegate void Worker();
private static Thread worker;
public static void Init(Worker work)
{
worker = new Thread(new ThreadStart(work));
worker.Start();
}
public static void Work()
{
string result = testing;
}
</code></pre>
<p>I modify the code by adding parameters , when i try to call Init("AA") I am getting an error "Best overload method has some invalid arguments"</p>
<p>The following is the edited code</p>
<pre><code> public delegate void Worker();
private static Thread worker;
public static void Init(Worker work)
{
worker = new Thread(new ThreadStart(work));
worker.Start();
}
public static void Work(string testing)
{
string result = testing;
}
</code></pre>
| c# | [0] |
1,481,935 | 1,481,936 | Android AudioTrack cannot be INITIALIZED | <p>I have a problem with initializing android AudioTrack. I have Nexus One with android 2.3.3.</p>
<p>Here is my code:</p>
<p>int _rate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM);</p>
<p>int buffersize = AudioRecord.getMinBufferSize(_rate,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT);</p>
<p>AudioTrack atrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
_rate,
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT,
buffersize,
AudioTrack.MODE_STREAM);</p>
<p>if (atrack.getState() == AudioTrack.STATE_UNINITIALIZED)
...</p>
<p>So the state of the atrack is always AudioTrack.STATE_UNINITIALIZED</p>
<p>The application manifest is </p>
<p>
</p>
<pre><code><application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name="BigLeftEarActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<uses-sdk android:minSdkVersion="10" />
</code></pre>
<p></p>
<p>Could you help me? What could be wrong?</p>
<p>Thanks!</p>
| android | [4] |
2,452,740 | 2,452,741 | Remove class using javascript | <p>I need to remove the specific class attribute from all the element in the page. That is we need to remove the particular class from all the elements of the current html page. We only have the class name as the reference (which we need to remove from that page) and nothing else.</p>
<p>Please note that <strong>i cannot use anything as reference like id or another class</strong> and also i cannot use any JavaScript libraries for this also...</p>
<p>Any suggestion on this would be greatly appreciated.</p>
<p>Please note that the class we need to remove will not be there more than twice.</p>
| javascript | [3] |
1,814,695 | 1,814,696 | n00b needs some PHP syntax guidance | <p>If you look at <a href="http://www.cruc.es/?paged=12/" rel="nofollow">http://www.cruc.es/?paged=12/</a> and go to the bottom of the page you'll see the bottom navigation with the next and previous options. I've been able to make the page numbers work by changing <em>page</em> to <em>paged=</em> in the code. I don't know enough about PHP to get the previous/next options to work. Any advice would be appreciated and I've pasted the code below.</p>
<p>Thank you</p>
<pre><code> if ( $query->found_posts > $query->query_vars["posts_per_page"] ) {
echo '<ul class="paging">';
// Previous link?
if ( $page > 1 ) {
echo '<li class="previous"><a href="'.$baseURL.'/page/'.($page-1).'/'.$qs.'">previous</a></li>';
}
// Loop through pages
for ( $i=1; $i <= $query->max_num_pages; $i++ ) {
// Current page or linked page?
if ( $i == $page ) {
echo '<li class="active">'.$i.'</li>';
} else {
echo '<li><a href="'.$baseURL.'/?paged='.$i.'/'.$qs.'">'.$i.'</a></li>';
}
}
// Next link?
if ( $page < $query->max_num_pages ) {
echo '<li><a href="'.$baseURL.'/page/'.($page+1).'/'.$qs.'">next</a></li>';
}
echo '</ul>';
}
</code></pre>
| php | [2] |
627,317 | 627,318 | Extract a substring up to 1000th comma | <p>I have a string (comma seperated)</p>
<p>For example: </p>
<pre><code>a,bgf,sad,asd,rfw,fd,se,sdf,sdf,...
</code></pre>
<p>What I need is to extract a substring up to the 1000th comma.</p>
<p>How to achieve this in Java?</p>
| java | [1] |
1,500,372 | 1,500,373 | What is the javascript code to know whether the browser has mp3,audio encoding,video encoding and printing capability? | <p>I want a javascript code to know whether our browser has Mp3,audio encoding,video encoding and Printing capability or not.For example if i will click a button on 1st page on the next page i want to see the output like</p>
<p>Mp3 Capable:True/False
Audio Encoding Capabilty: True/False
Video Encoding Capability: True/False
Printing Capabilty: True/False</p>
| javascript | [3] |
3,285,852 | 3,285,853 | How to delete an image from sd-card in android if uri of the image is available? | <p>The image the uri is available. i want to delete the image using that uri. please help.</p>
| android | [4] |
4,470,120 | 4,470,121 | Does Process.StartInfo.FileName accept long file names? | <p>Looks like it's not.</p>
<p>If I convert the file name to its short value, then Process.Start() works.</p>
<pre><code>Process runScripts = new Process();
runScripts.StartInfo.FileName = @"C:\long file path\run.cmd";
runScripts.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
runScripts.StartInfo.UseShellExecute = true;
runScripts.StartInfo.RedirectStandardOutput = false;
runScripts.Start();
</code></pre>
<p>The above code fails. But...</p>
<pre><code>Process runScripts = new Process();
runScripts.StartInfo.FileName = @"C:\short\file\path\run.cmd";
runScripts.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
runScripts.StartInfo.UseShellExecute = true;
runScripts.StartInfo.RedirectStandardOutput = false;
runScripts.Start();
</code></pre>
<p>succeeds.</p>
<p>I managed to get around this by converting the long path name to a short path name.
But I am a bit surprised to find this.
Any reasons or background info on this?</p>
<p>Thanks.</p>
<p><b>Update 1</b><br>
Microsoft .NET Framework Version 2.0.50727</p>
| c# | [0] |
1,844,331 | 1,844,332 | Copy constructor for a generic doubly-linked list | <pre><code>template <class T>
class list
{
public:
//stuff
list(const list &cctorList); //cctor
private:
struct node
{
node *next;
node *previous;
T *info;
}
node *firstNode; //pointer to the first node (NULL if none)
node *lastNode; //pointer to the last node (NULL if none)
}
</code></pre>
<p>I'm now trying to define <code>list(const list &cctorList); //cctor</code> but I'm running into trouble.</p>
<p>Here's what I have so far:</p>
<pre><code>template <class T>
list<T>::list(const list &cctorList)
{
node *another = new node;
firstNode = another;
another->previous = NULL;
another->info = new T(*(cctorList->info));
// ...
}
</code></pre>
<p>Is everything up to this point correct? Is there a way for me to recursively assign <code>another->next</code>? Also, is there an easier way to accomplish this using iterators?</p>
| c++ | [6] |
5,628,168 | 5,628,169 | self.title vs self.navigationItem.title | <p>What is the purpose of the <code>title</code> property of UIViewController, can't the title already be set with <code>navigationItem.title</code> ?</p>
<p>Both seem to work, I'm just wondering why there's this seemingly duplicated functionality.</p>
| iphone | [8] |
3,546,775 | 3,546,776 | Thread dump showing Runnable state, but its hung for quite a long time | <p>We are facing an unusual problem in our application, in the last one month our application reached an unrecoverable state, It was recovered post application restart.</p>
<p>Background : Our application makes a DB query to fetch some information and this Database is hosted on a separate node.</p>
<p>Problematic case : When the thread dump was analyzed we see all the threads are in runnable state fetching the data from the database, but it didn't finished even after 20 minutes.</p>
<p>Post the application restart as expected all threads recovered. And the CPU usage was also normal.</p>
<p>Below is the thread dump</p>
<blockquote>
<p>ThreadPool:2:47" prio=3 tid=0x0000000007334000 nid=0x5f runnable
[0xfffffd7fe9f54000] java.lang.Thread.State: RUNNABLE at
oracle.jdbc.driver.T2CStatement.t2cParseExecuteDescribe(Native Method)
at
oracle.jdbc.driver.T2CPreparedStatement.executeForDescribe(T2CPreparedStatement.java:518)
at
oracle.jdbc.driver.T2CPreparedStatement.executeForRows(T2CPreparedStatement.java:764)
at ora</p>
</blockquote>
<pre><code>All threads in the same state.
</code></pre>
<p>Questions: </p>
<ol>
<li>what could be the reason for this state?</li>
<li>how to recover under this case ?</li>
</ol>
| java | [1] |
1,482,235 | 1,482,236 | What is the native keyword in Java for? | <p>While trying <a href="http://www.sporcle.com/games/robv/java_keywords">this puzzle</a> I came across the <code>native</code> keyword. I have never seen nor used it earlier. What is it used for?</p>
| java | [1] |
5,388,803 | 5,388,804 | how convert ILIST<string> to ILIST <object> at C#? | <p>I want to convert <code>ILIST<string> to ILIST <object></code></p>
<p>How can achieve this using C#? </p>
| c# | [0] |
3,313,127 | 3,313,128 | An update question! | <p>Here's the problem I'm facing: trying to do my own application update I download the update apk from a web server on the sd card and then I launch the Package Installer with the downloading path (while the old application is running). So far after the package installer starts and the user agrees to install the application I get the following message "MyApp Could not be installed on this phone" and in the logcat then following message is printed:
"No package identifier when getting value for resource number 0x00000000". I could not find a reason for this behaviour, so please if there is something that I'm missing do point it to me!</p>
<pre><code>try
{
BufferedInputStream getit = new BufferedInputStream(new URL("http://mywebserver:8080/myapk.apk").openStream());
FileOutputStream saveit = new FileOutputStream(path);
BufferedOutputStream bout = new BufferedOutputStream(saveit,1024);
byte data[] = new byte[1024];
int readed = getit.read(data,0,1024);
while(readed != -1)
{
bout.write(data,0,readed);
readed = getit.read(data,0,1024);
}
bout.close();
getit.close();
saveit.close();
}
catch(Exception e)
{
e.printStackTrace
}
</code></pre>
| android | [4] |
1,158,783 | 1,158,784 | Can anyone know how to setting cross web browser cookie | <p>I'm a php developer but not experience in training now and got a task that if someone open website from firefox then cookie must be saved in chrome, opera and other browsers too.</p>
| php | [2] |
4,701,733 | 4,701,734 | Create a calendar from scratch | <p>My aim is to create a calendar from scratch that displays 30 days as onclickable values so when a user presses the 2nd it should display fields where the user can type information. It would then store it into a SQLite table. </p>
<p>I thought about some solutions. I can make a calendar by creating textview with 30 buttons for each month, but that would be slightly ridiculous. </p>
<p>How can this be done?</p>
| android | [4] |
3,628,359 | 3,628,360 | Error when trying to use DroidBox | <p>I am researching how to analyze the application Android use <a href="http://code.google.com/p/droidbox/" rel="nofollow">DroidBox</a>. But when start analyzing :</p>
<p><code>./droidbox.sh file.apk</code> </p>
<p>get error as follows:</p>
<pre><code>android@honeynet:~/tools/droidbox$ ./droidbox.sh a.apk
./droidbox.sh: line 3: adb: command not found
./droidbox.sh: line 3: adb: command not found
Traceback (most recent call last):
File "scripts/droidbox.py", line 233, in <module>
call(['adb', 'logcat', '-c'])
File "/usr/lib/python2.6/subprocess.py", line 480, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child
raise child_exception
0SError: [Errno 2] No such file or directory
</code></pre>
<p>What's the problem?
Thanks!</p>
| android | [4] |
4,635,312 | 4,635,313 | Extract letters from a field and make it on another | <pre><code>public class Driver {
// fields
private String Id;
Id = name.substring(0, 3);
public Driver(String f1, String f2, int f3, String f4) {
// constructor
}
}
</code></pre>
<p>Well, I've changed the code. It's much clear.
I want to extract the first three letters from nomC, the first letter from prenomC and the last two digit from anneeEC and make them on a new field. Why it shows an error on line « private String numId; »: Syntax error on token ";",, expected?</p>
| java | [1] |
3,755,270 | 3,755,271 | listView.addHeaderView() giving "null pointer exception" | <p>I have a requirement that I need to add header to my list view .</p>
<p>Below is my code for achieve the same..</p>
<pre><code> ListView listView;
listView = (ListView) findViewById(R.id.list_view);
//View header = View.inflate(this , R.layout.header, null);
LayoutInflater ll = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v2 = ll.inflate(R.layout.header, null, false);
listView.addHeaderView(v2);
</code></pre>
<p>But "listView.addHeaderView(v2)" this line giving "null pointer exception"</p>
<p>Please let me know what can be done to resolve this issue.</p>
| android | [4] |
1,953,446 | 1,953,447 | use of equals() method in comparator interface? | <p><code>equals()</code> method is available to all java collection classes from the <code>Object</code> class. This method is also declared in <code>Comparator</code> interface, so what is the purpose of declaring this method in Comparator? in which case is it used and how?</p>
| java | [1] |
1,703,634 | 1,703,635 | How to change default Android's Desktop application? | <p>I hear that the Android's desktop is an application that I can change.
I'm searching for some information about how to do that.</p>
| android | [4] |
5,054,028 | 5,054,029 | adding rating system to detailviewcontroller | <p>hello does anyone know a rating system that can be implemented for iphone detail view that allows user to rate the services offered.
ive used touchcustoms however i cant figure out how to implement it...</p>
| iphone | [8] |
4,688,392 | 4,688,393 | Cut a line out of a string with Regex | <p>I'm looking for a solution for removing line 2 out of a string in C#. Of course, I could just read line by line, but with a regex, it would be much better and more elegant. As an example:</p>
<p>Before:</p>
<pre><code>this is line 1
this is line 2
this is line 3
this is line 4
</code></pre>
<p>After:</p>
<pre><code>this is line 1
this is line 3
this is line 4
</code></pre>
<p>Does someone have a good hint about how to do this with Regex?
Thanks.</p>
| c# | [0] |
4,042,401 | 4,042,402 | Android TabSpec.setIndicator New Line | <p>hey just wondering how I can put a new line in the TabSpec.setIndicator(char sequence)
method?</p>
<p>"\n" doesn't seem to work, here is my code:</p>
<pre><code>TabHost.TabSpec spec5=host.newTabSpec("tag5");
Intent in5=new Intent(this, GridList.class);
spec5.setIndicator("Trip\nLogger");
spec5.setContent(in5);
</code></pre>
| android | [4] |
5,981,959 | 5,981,960 | Display image through JavaScript function | <p>I'm writing a javascript function that basically flips the coin and I'm trying to get it to return image but so far no luck. I use img src tags to assign value to a variable but somehow I suspect that does not work and I wanted to check with you guys on how this is actually done?</p>
<p>Here is my code:</p>
<pre><code><script type = text/javascript>
var headsCount = 0;
var tailsCount = 0;
function start()
{
var buttonTwo = document.getElementById("coinButton");
buttonTwo.addEventListener("click", coinResult, false);
}
function flip()
{
var faceValue = Math.floor((Math.random()*2)+1);
if (faceValue == 1)
{
headsCount++;
return true;
}
else
{
tailsCount++;
return false;
}
}
function coinResult()
{
var result = document.getElementById("coinToss");
var coinCount = document.getElementById("countNumber");
<img name = "Heads" src = "images/Heads.png" />
if (flip() == true)
{
result.innerHTML = <img src = "images/Heads.png" alt = "Heads" />
}
else
{
result.innerHTML = <img src = "images/Tails.png" alt = "Tails" />
}
coinCount.innerHTML = "Heads Count: " + headsCount + " Tails Count: " + tailsCount;
}
window.addEventListener("load", start, false);
</script>
</code></pre>
| javascript | [3] |
2,641,029 | 2,641,030 | Setting new value in a grid | <p>I have a strange issue with an exercise I'm doing (game of life). In the middle bit of code, the line nextgeneration.set(livex, livey, live); causes the program to stop running. Any ideas? </p>
<pre><code>int lifeGenerator(Grid<int>& nextgeneration, Grid<int>& birthsanddeaths) {
for (int deadx = 0; deadx < nrows; deadx++) {
for (int deady = 0; deady < ncols; deady++) {
int dead = birthsanddeaths.get(deadx, deady);
if (dead == -3) {
nextgeneration.set(deadx, deady, 0);
}
}
}
for (int livex = 0; livex < nrows; livex++) {
for (int livey = 0; livey < ncols; livey++) {
int live = nextgeneration.get(livex, livey);
if (live > 0 && live < kMaxAge) {
live++;
nextgeneration.set(livex, livey, live);// this doesnt work....
}
}
}
for (int newx = 0; newx < nrows; newx++) {
for (int newy = 0; newy < ncols; newy++) {
int born = birthsanddeaths.get(newx, newy);
if (born == 3) {
nextgeneration.set(newx, newy, 1);
}
}
}
return 0;
}
</code></pre>
| c++ | [6] |
3,240,205 | 3,240,206 | query co-ordinates | <p>Hi I've got a DIV that holds a sprite that has around 40 emoticons on it. Its 200px * 100px and each emoticons is around 25*25px.</p>
<p>I want to be able to use a mouse over to explain each emoticon - eg: ':) smile'.</p>
<p><img src="http://i.stack.imgur.com/DygVC.png" alt="this one"></p>
<p>I've been advised to use this code for co-ordinates:</p>
<pre><code>$("#div").mousemove(function(e)
{
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
});
</code></pre>
<p>and this works great - it shows the mouse position very well - very happy with this.</p>
<p>I'm unsure how to alter this code so that I can pin point areas....</p>
<p>I've tried:</p>
<pre><code>$("#div").mousemove(function(e)
{
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
if(x < 1 && x > 25) && (y < 1 && y > 25) {
alert('captured mouse over');
}
});
</code></pre>
<p>but this doesn't work - how can I capture specific area events?</p>
<p>thx</p>
| jquery | [5] |
592,289 | 592,290 | How to know where the input/element goes to after the blur event? | <p>I tried this, but it is undefined:</p>
<pre><code>alert($(ev.relatedTarget).attr('name'));
</code></pre>
<p>I have a combobox (textbox and a button), I don't want the code to continue processing if the input goes to its partner control(button). I want to detect from textbox blur that it is leaving the whole combobox not just the textbox. Textbox's blur will naturally trigger when I click its partner button. The only ideal logic I can think of is to detect from textbox's blur that the focus destination is not its partner button, if the relatedTarget is its partner button don't continue processing.</p>
| jquery | [5] |
4,925,666 | 4,925,667 | Calling html javascipt function from external javascript | <p>In my project i am using external javascript file.
but my requirement is i need to call the xhtml file's javascript function from the external javascrit function.</p>
<p>Please provide some suggestion</p>
<p>Thanks in Advance.</p>
| javascript | [3] |
5,622,772 | 5,622,773 | NullPointerException on NetworkInfo | <p>I am programming a service that runs when you boot the phone, but you need an Internet connection and connection to send SMS operator.
I wrote a function to <code>ConnectionManager</code> as in other post appears, but I always get the same answer: <code>NullPointerException</code>, when I do the following:</p>
<p>I define <code>cm</code> as <code>ConnectionManager</code> and </p>
<pre><code>NetworkInfo NetInfo = cm.getNetworkInfo();
</code></pre>
<p>Is it not because of this?</p>
<p>How can I fix it?</p>
<p>Sorry if I did not put all the code ...</p>
<p>I have the following in the OnStart () method of a service that is activated by ACTION_BOOT_COMPLETED ...</p>
<pre><code>@ Override
public void OnStart (Intent intent, int start) {
Context aplCtx = getApplicationContext ();
IsConnected boolean = false;
while (! IsConnected) {
try {
IsConnected = IsOnline (aplCtx);
} Catch (Exception e) {
Log.d (e.toString ());
}
}
.....
}
private boolean IsOnline (Context ctx) {
boolean result = false;
try {
ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService (Context.CONNECTIVITY_SERVICE);
cm.getActiveNetworkInfo NetworkInfo ni = ();
if (ni! = null) {
if (ni.getState () == NetworkInfo.State.CONNECTED) {
result = true;
}
}
return result;
}
</code></pre>
<p>Since this is a background function and after starting the Smartphone, the operating system to force kill the process, before we get an Internet connection. How I can resolve this?,
How do I get the operating system does not kill the process and have an Internet connection to perform the following actions?</p>
| android | [4] |
2,209,786 | 2,209,787 | Jquery repeat div on click not clone | <p>I need to repeat a div on click under the initial div that is on the page, ie a div with a class exists with a button within it that when clicked repeats the div directly after the div that is already there, this is in a form so needs to be written to the page and submitted if it exists. JQuery clone wont manage this, does anyone have a solution</p>
| jquery | [5] |
3,760,236 | 3,760,237 | How change the page on page init or load events depends on mobile device (iPhone)? | <p>I have an asp.net C# website. Because of iPhone doesn't support flash i want to change a theme of my site on page load or init if user using it. Could any one show me (code in c#) how to determine that user is browsing my website using iPhone or iPad, not a blackberry, or android etc. Thanks</p>
| asp.net | [9] |
3,835,611 | 3,835,612 | Exporting to excel probelm in exporting number feiled | <p>Hi
i have one grid which contain phone numbers..and whike am exporting to it phone number field is automatically taken as numeric filed and phone number is displaed as exponential ..
do any one know to solve it??
thanks in advance</p>
| c# | [0] |
1,700,484 | 1,700,485 | NodeList value does not get updated? | <p>This statement simply would not update the value of the node in question! Could you please tell me why this is the case or if I'm doing something wrong here?!?</p>
<pre><code>for (int i = 0; i < list.getLength(); i++) {
temp = list.item(i).toString();
System.out.println(temp.substring(temp.indexOf("\"")+1, temp.lastIndexOf("\"")));
list.item(i).setNodeValue(temp.substring(temp.indexOf("\"")+1, temp.lastIndexOf("\"")));
System.out.println(list.item(i));
}
</code></pre>
<p>Thanks </p>
| java | [1] |
2,443,376 | 2,443,377 | C++ optimise away private variable | <p>Does ISO C++ (11) permit a private non-static class member variable to be optimised away?
This could be detected:</p>
<pre><code>class X { int x; };
assert (sizeof(X) >= sizeof(int));
</code></pre>
<p>but I am not aware of a clause that demands the assertion above. </p>
<p>To clarify: (a) Is there a clause in the C++ Standard that ensure the assertion above.</p>
<p>(b) Can anyone think of any other way to detect the elision of x?
[offsetof?]</p>
<p>(c) Is the optimisation permitted anyhow, despite (a) and (b)?</p>
<p>I have a feeling the optimisation could be possible if the class is local to a function but not otherwise (but I'd like to have a definitive citation).</p>
| c++ | [6] |
2,266,621 | 2,266,622 | Compare Datatable with another to see if it has right format | <p>I have 2 DataTables: TableNumber containing mobile numbers and TableCode which contains a mix of all possible mobile codes which is 6 digits long all. i want to create a list to have only numbers which its 6 first digits are from TableCode, so any number which its first digits are not in TableCode will not be considered. i have tried this with foreach, .Contains(), IndexOf() but all are slow because records in numbers are more than 100,000 and it takes too long to loop through all items. and compare with another table. i use 2 nested foreach loop. i'm doing something stupid i think with 2 foreach because that will be 3 billion searches for a 30,000 members from TableCode and it takes me 5 minutes to give me result. my code is like this:</p>
<pre><code>foreach(string codetable in TableCode)
{
foreach(string grouptable in TableNumber)
{
if(grouptable.IndexOf(codetable)!=-1)
{
//work here
}
}
}
</code></pre>
<p>here i have added tables' Number rows to a list which contains only numbers so here i am searching lists but similar to this when trying to compare DataTables again it takes too long.</p>
| c# | [0] |
3,860,851 | 3,860,852 | Activator.CreateInstance needs another object to be instantiated | <p>I am instantiating my objects with the classical</p>
<pre><code>object myObject = Activator.CreateInstance(myType);
</code></pre>
<p>code and if works fine.
The thing is that, now, Id like to instantiate an object and in its constructor, there is a reference to another object.
So if I just do the code above, I got a <code>NullReferenceException</code> exception :</p>
<pre><code>Object reference not set to an instance of an object.
</code></pre>
<p>I tried to instantiate the concerned object (with Activator.CreateInstance) but I got the same exception...
I feel like instantiating the problematic object before my 2nd CreateInstance call is not enough. What should I do ?</p>
<p>EDIT : here's the code of the problem</p>
<pre><code>//A regionManager in needed by MainView as far as I understand the Exception's details
var regionManager = Assembly.LoadFrom("RegionView.dll");
Type rmType = regionManager.GetType("Framework.Hmi.RegionManager");
object obj = Activator.CreateInstance(rmType);
//This works !
var shellViewLibrary = Assembly.LoadFrom("ShellView.dll");
Type svType = shellViewLibrary.GetType("Framework.ShellView.MainView");
object objjj = Activator.CreateInstance(svType);
</code></pre>
<p>The last line fails and the error is a <code>NullReferenceException</code> with the details :</p>
<pre><code>at Hmi.RegionManager.get_RegionFactory()
at Hmi.RegionManager.CreateRegion(DependencyObject element)
at Hmi.RegionManager.OnSetRegionNameCallback(DependencyObject element, DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
[...]
</code></pre>
<p>I call c/c the 30/40 other error lines but I don't think it is that usefull...</p>
| c# | [0] |
5,841,094 | 5,841,095 | System stop responding and throws yami i/o error | <p>I need suggestion about YAMI library . I have a system which receives Json string from external interface and parse that received string and send that message to internal ip address for the required action.
The exchange of messages within the internal ip address has been taken care by Yami library. everything works fine but occasionally it displays yam i/o error and system doesn't response unless it is restarted.
The whole software is written in C++ and C and development os is fedora 11.</p>
<p>I have tried to investigate the problem but I am bit clueless as I have not found much help on internet and my testing method doesn't work.</p>
<p>its strange that system works for few hours and then crash . For example If I leave system idle for half an hour and then try to send message via external interface it crashes producing yami i/o error or even while sending continuos command it crashes.</p>
<p>Any help or suggestion will be of great help.</p>
<p>Thanks and regards,<br>
Sam</p>
| c++ | [6] |
5,163,551 | 5,163,552 | how can i cast Long to BigDecimal | <p>hi can any tell me how to cast <code>Long</code> to <code>BigDecimal</code></p>
<p>thanks In Advance</p>
| java | [1] |
1,177,796 | 1,177,797 | Problem using elem.dataset with IE and JSFiddle | <p>In this JSFiddle I created on Chrome, I find that it's unable to work on IE (I'm using IE9). Any reason as to this: <a href="http://jsfiddle.net/ZSB67/" rel="nofollow">http://jsfiddle.net/ZSB67/</a>.</p>
<pre><code>var backImage = [
"http://alm7.wikispaces.com/file/view/RedBackground.bmp/144018347/RedBackground.bmp",
"http://www.time2man-up.com/wp-content/uploads/2011/07/black-background.jpg",
"http://1.bp.blogspot.com/--GorNQoEUxg/TfWPyckVeMI/AAAAAAAAAHk/0208KqQf3ds/s1600/yellow_background.jpg",
""
];
function changeBGImage(whichImage) {
if (document.body) {
document.body.style.background = "url(\"" + backImage[whichImage] + "\")";
}
}
var buttons = document.querySelectorAll('.bg_swap'),
button;
for (var i = 0; i < buttons.length; i++) {
button = buttons[i];
button.onclick = function() {
changeBGImage(this.dataset.index);
};
}
</code></pre>
| javascript | [3] |
4,799,048 | 4,799,049 | jQuery Convert a div's text into vertical | <p>Lets say i got this div</p>
<pre><code><div>
Convert This into a vertical Text
</div>
</code></pre>
<p>While searching for a way in which i can convert this text into a vertical text.</p>
<p>I found out something like this :</p>
<pre><code>$('div').html($('div').text().replace(/(.)/g,"$1<br />"));
</code></pre>
<p>This works.<br />
But is there a better way of doing this ?</p>
| jquery | [5] |
1,116,292 | 1,116,293 | App always showing landscape mode in tablet | <p>I have made an app which is working fine in emulator as well as small and medium size phones.But while running in tablet,it always shows landscape mode only.I have also used separate layout and layout-land layouts.I am not getting the reason behind it.This is the code:</p>
<pre><code>public class SplashActivity extends FragmentActivity
{
public void onCreate(Bundle paramBundle)
{
super.onCreate(paramBundle);
requestWindowFeature(1);
getWindow().setFlags(1024, 1024);
FragmentManager fragmentmanager = getSupportFragmentManager();
FragmentTransaction fragmenttransaction = fragmentmanager.beginTransaction();
if (getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE) {
setRequestedOrientation(0);
}
else
{
setRequestedOrientation(1);
}
fragmenttransaction.commit();
setContentView(R.layout.welcome);
new Handler().postDelayed(new SplashThread(), 2000L);
}
class SplashThread implements Runnable
{
SplashThread()
{
}
public void run()
{
SplashActivity.this.startActivity(new Intent(SplashActivity.this, McqHomePage.class));
SplashActivity.this.finish();
}
}
}
</code></pre>
<p>Please help me.Thanks in advance.</p>
| android | [4] |
4,468,207 | 4,468,208 | Java Plotting Graphs | <p>I recently asked about how to plot graphs in Java and I was recommended JFreeChart. After researching it I couldn't find a way to do what I want to (simply plot some Point objects that are listed in an ArrayList and then draw a line through them as they are listed in the list). I would appreciate it if someone could help me get started with some code and if you could explain it to show me how to do this as I have looked around and can't find what I am looking for. I don't necessarily need JFreeChart code just preferably Swing/ JPanel. Thanks for your help.</p>
| java | [1] |
1,861,723 | 1,861,724 | How to block the main thread until all the other threads finish executing? | <p>This is a newbie question. I start 10 threads from my main thread. How do I stop the main thread from continuing until all the other threads finish?</p>
| python | [7] |
3,172,295 | 3,172,296 | what is ... mysql_real_escape_string? dangerous? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php">Why shouldn’t I use mysql_* functions in PHP?</a> </p>
</blockquote>
<p>hye, Can i use a code in php like this:</p>
<pre><code>$s_username = addslashes(strip_tags($_POST['username']));
$s_password = addslashes(strip_tags($_POST['password']));
</code></pre>
<p>before this is use this</p>
<pre><code>$email = mysql_real_escape_string(strip_tags($_POST['email']));
$username = mysql_real_escape_string(strip_tags($_POST['username']));
</code></pre>
<p>...because many said that mysql_real_escape_string is dangerous to use? </p>
| php | [2] |
1,049,731 | 1,049,732 | Don't overwrite in <div> but add to <div> | <p>I have made a script which shows content in a < div > when you push a button, but when i push another button (while there is already content in the < div >) it overwrites the content. So only the new content shows and the old content disapears. </p>
<pre><code>function HandleResponse(response)
{
document.getElementById('test123').innerHTML = response;
}
</code></pre>
<p>So the question is: How can I ADD content to a < div > instead of overwriting the content in the < div >? This way I can show multiple content in one < div >.</p>
| javascript | [3] |
4,271,358 | 4,271,359 | is this a correct way to make sectioned list in android? | <p>i have to make a sectioned list in my application. For this i am using the following approach:</p>
<ul>
<li>make a listview to contain the headers of each sections</li>
<li>the xml inflated in the getview of each item in the above list consists of a textview and a tablelayout</li>
<li>the custom adapter used to make the views for the above listview, i fill the textview with the header and add rows into the tablelayout until all the section is filled.</li>
</ul>
<p>Naturally i maintain two arrays: 1) for the headers 2) for the section details(actually for this i use a hashmap with the section header index in its array as the key, this is my of identifying which header belongs to which section).</p>
<p>for some reason the above code is not working and the data is being repeated in different sections...eg. the second section contains data of the 1st and the 2nd section combined?</p>
<p>why is this happening?</p>
<p>Doesn't the idea mentioned above seem correct?</p>
<p>what is going wrong over here?</p>
<p>thank you in advance.</p>
| android | [4] |
27,435 | 27,436 | Basic question on Java's int | <p>Why does the below code prints 2147483647, the actual value being 2147483648? </p>
<pre><code> i = (int)Math.pow(2,31) ;
System.out.println(i);
</code></pre>
<p>I understand that the max positive value that a int can hold is 2147483647. Then why does a code like this auto wraps to the negative side and prints -2147483648?</p>
<pre><code>i = (int)Math.pow(2,31) +1 ;
System.out.println(i);
</code></pre>
<p>i is of type Integer. If the second code sample (addition of two integers) can wrap to the negative side if the result goes out of the positive range,why can't the first sample wrap?
Also ,</p>
<pre><code>i = 2147483648 +1 ;
System.out.println(i);
</code></pre>
<p>which is very similar to the second code sample throws compile error saying the first literal is out of integer range?
My question is , as per the second code sample why can't the first and third sample auto wrap to the other side?</p>
| java | [1] |
1,334,982 | 1,334,983 | How do I change the time to Taipei? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/10087819/convert-date-to-another-timezone-in-javascript">Convert date to another timezone in javascript</a> </p>
</blockquote>
<p>How to make this program get Taipei's time? Is their something to fix? or do I need to add some code for it?</p>
<pre><code>var yudan = "";
var now = new Date();
var month = now.getMonth() + 1;
var date = now.getDate();
var year = now.getFullYear();
if (year < 2000) year = year + 1900;
document.write(year + "." + yudan + month + "." + date + ".");
</code></pre>
<hr>
<pre><code>document.write("<span id=\"yudan_clock\"><\/span>");
var now,hours,minutes,seconds,timeValue;
function yudan_time(){
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? " " : " ";
timeValue += ((hours > 12) ? hours - 0 : hours) + ":";
timeValue += ((minutes < 10) ? " 0" : " ") + minutes + ":";
timeValue += ((seconds < 10) ? " 0" : " ") + seconds + "";
document.getElementById("yudan_clock").innerHTML = timeValue;
setTimeout(yudan_time, 100);}
yudan_time();
</code></pre>
| javascript | [3] |
3,338,424 | 3,338,425 | Android: How to set the name of the compiled APK? | <p>This question seems embarassingly simple, yet it vexes me still. I am using the standard ADT and Eclipse Android environment to build my Android app. The apk is named after the project name in Eclipse, but I want to name the apk something different...How can I customize the name of the apk artifact that is produced when the project builds? </p>
| android | [4] |
6,801 | 6,802 | Loop until steady-state of a complex data structure in Python | <p>I have a more-or-less complex data structure (list of dictionaries of sets) on which I perform a bunch of operations in a loop until the data structure reaches a steady-state, ie. doesn't change anymore. The number of iterations it takes to perform the calculation varies wildly depending on the input.</p>
<p>I'd like to know if there's an established way for forming a halting condition in this case. The best I could come up with is pickling the data structure, storing its md5 and checking if it has changed from the previous iteration. Since this is more expensive than my operations I only do this every 20 iterations but still, it feels wrong.</p>
<p>Is there a nicer or cheaper way to check for deep equality so that I know when to halt?</p>
<p>Thanks!</p>
| python | [7] |
5,226,197 | 5,226,198 | Reading string from vector until whitespace in C++ | <p>This is probably easy but im not sure how. I tried searching multiple websites and yes Google and couldn't find anything on this. </p>
<p>My vector <code>result[0]</code> looks like this</p>
<pre><code>A3 * * B4 * *
</code></pre>
<p>Declaration</p>
<pre><code>vector<string> result = v.formVectorFile("Prj3 Config.txt");
</code></pre>
<p>I know that <code>cin</code> reads until whitespace so I was trying to use this to figure it out.
If I read straight from <code>fstream</code> I can read until whitespace, but im trying to do this with a string inside a vector and something like <code>result[0] >> s;</code> obviously doesnt work.</p>
<p>I need to read until it hits a whitespace then read the next one until whitespace. Etc...
So extract <code>A3</code> by itself. Operate on it then extract <code>*</code> etc...</p>
| c++ | [6] |
1,601,427 | 1,601,428 | What it means: Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetAllowResponseInBrowserHistory(false); | <p>While searching for authentication ,i found above two line written .what it means? please tell me.</p>
| asp.net | [9] |
3,498,796 | 3,498,797 | C++ Error Reporting Interface | <p>I'm designing an interface that can be used to report errors in C++. (I'm working with a legacy system where exceptions are out of question.) In my youthful naivety, I started along these lines while designing my API:</p>
<pre><code>bool DoStuff(int amount, string* error);
</code></pre>
<p>Return value signals success/failure, while <em>error</em> is used to report a human readable explanation. So far so good. Subroutine calls passed along the <em>error</em> pointer and everything was hunky-dory.</p>
<p>I ran into the following problems with this design (so far):</p>
<ol>
<li> Cannot report warnings.
<li> Not thread-safe.
</ol>
<p>Next, I decided to go with the following interface, instead of plain <em>string</em>:</p>
<pre><code>class Issues {
public:
void Error(const string& message);
void Warning(const string& message);
void Merge(const Issues& issues);
}
</code></pre>
<p>So that I can change my API like this:</p>
<pre><code>bool DoStuff(int amount, Issues* issues);
</code></pre>
<p>I'm wondering, is there a more generic/standard API out there that deals with this problem? If yes, I'd like to take a look.</p>
<p><strong>UPDATE</strong>: I'm not looking for a logging library. For those who are curious, imagine you're writing a query engine that includes a compiler. The compiler issues warnings and errors, and those need to be returned to the user, as part of the response. Logging has its place in the design, but this is not it.</p>
| c++ | [6] |
95,308 | 95,309 | Implementing jQuery "closest" | <p>I am using this jQuery function to find the parent element with class name "viewCommentsExp".</p>
<pre><code> $('.viewCommentsExpBtn').click(function(e){
e.preventDefault();
var trackid= $(this).parent().find(".trackidField2").val();
var parent = $(this).parent().parent().parent().find(".viewCommentsExp");
$.ajax({
type: "POST",
data: "trackid="+trackid,
url: "http://rt.ja.com/viewcomments.php",
success: function(data)
{
$(".newUserComment").html(data);
$(parent).slideToggle();
}
});
});
</code></pre>
<p>I have this function working on about 90% of the clicks. But, randomly, sometimes all divs with this classname are selected rather than the closest. </p>
<p>Can I clean this up to work more reliably using jQuery "closest"? </p>
<pre><code>$(this).parent().parent().parent().find(".viewCommentsExp");
</code></pre>
<p>Not sure how to implement this.</p>
| jquery | [5] |
5,975,045 | 5,975,046 | MapView in TabActivity | <p>In my application I am using tabHost and TabWidget with 5 tabs..On Tab1, I want to show Map with current locaion..Here my </p>
<pre><code> currentActivity extends TabActivity
</code></pre>
<p>But in Tab1(daeafult tab1), I want to show map with current location...Pls help</p>
| android | [4] |
4,191,970 | 4,191,971 | How to pass array element one by one in text box in php | <p>i am Reading the file contents and passed it in explod function("=",$string) ,it gives me two array parts[0].parts[1] seprated by = .parts[1] array displays all the values of the variable .now how can i use these values one by one to pass in the text box .The variable value comes in this way (value1
value2
value3
value4...)</p>
<p>my code also throws the <strong>undefined offset :1</strong> notice when i prints the parts[1]arrray</p>
| php | [2] |
4,163,798 | 4,163,799 | Android HttpPost socket timeout when android goes to sleep in background service | <p>I have an android app that uses a background service for uploading data.</p>
<p>When we go upload data, everything works fine. Even when we make the display sleep, everything works.</p>
<p>However, this was while we were connected to Eclipse via USB. Once we disconnected the device, started to send the data and made the screen 'sleep,' we got a socket timeout exception.</p>
<p>Is there a special setting in the Service I need to make to allow it to continue to send data when the display sleeps?</p>
| android | [4] |
4,921,124 | 4,921,125 | android Call Forwarding programatically | <p>I want to forward any calls received to another predefined phone number. I have searched forums and found some contradictary answers. so i m confused.</p>
<p>First I looked at this post <a href="http://stackoverflow.com/a/5735711">http://stackoverflow.com/a/5735711</a> which suggests that it is not possible through android.
But another post has some solution. <a href="http://stackoverflow.com/a/8132536/1089856">http://stackoverflow.com/a/8132536/1089856</a></p>
<p>I tried this code from second post, but i m getting the following error message: "Call Forwarding connection problem or Invalid MMI Code." </p>
<pre><code>String callForwardString = "**21*5556#";
Intent intentCallForward = new Intent(Intent.ACTION_CALL);
Uri uri2 = Uri.fromParts("tel", callForwardString, "#");
intentCallForward.setData(uri2);
startActivity(intentCallForward);
</code></pre>
<p>Where 5556 is the number of emulator (for testing) where i want to forward call. </p>
<p>plz help.</p>
| android | [4] |
5,352,638 | 5,352,639 | What is a light python library that can eliminate HTML tags? (and only text) | <p>I know that NLTK has it. But any else?</p>
| python | [7] |
3,340,169 | 3,340,170 | global variable is undefined | <pre><code>import socket
import sys
import urllib
port = 6669
mac = "e448c7a96170"
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = socket.gethostbyname( mac + '.rtn.iptv.svt.sciatl.com')
sock.connect((ip, port))
print(ip)
sock.send("getdom;ipg")
print "Message Sent"
while True:
global m;
m=sock.recv(10000)
print(m)
sock.close()
except:
print sys.exc_info()
</code></pre>
<p>Hi folks I am new to the python.I am trying to print the 'm' value.But it is not printing it since the print statement is outside the loop.
I am trying to store the received data in a global variable and use it in the later part.But I am not able to do as the 'm' variable is not visible outside.Any help is appreciated.
Thank you</p>
| python | [7] |
2,528,121 | 2,528,122 | Pass associative array to Javascript function | <p>How can I pass associative array in the below code. I dont wish to create a variable </p>
<pre><code>uiDialog([MyURL,null,'GET'],false);
</code></pre>
<p>Some thing like this</p>
<pre><code> uiDialog([url:MyURL,data:null,method:'GET'],false);
</code></pre>
<p>I know I can do something like </p>
<pre><code>var arr = new Array(5);
arr["000"]="Rose";
arr["4"]="Ltd";
</code></pre>
<p>And pass this array but I am not interested in that I want a one line code</p>
<p><strong>UPDATE</strong>
It seams there is no one line solution but if object is not a problem i.e u cant use array function or length you can try this answer <a href="http://stackoverflow.com/questions/6888921/pass-associative-array-to-javascript-function/6888938#6888938">Pass associative array to Javascript function</a></p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.