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,768,741
4,768,742
Does Java have a libraries or functionality capable of evaluating arbitrary arithmetic expressions using BODMAS order of evaluation
<p>Can we make calculator program using <a href="http://en.wikipedia.org/wiki/Order_of_operations" rel="nofollow">BODMAS</a> rule by something like this in Java :</p> <pre><code>String valfromtextbox = "2(2*2)+5"; long total = Long.parseLong(valfromtextbox); </code></pre> <p>Can we do something like above or we have to make entire logic to do this.</p> <p>If we have to make entire logic then please give me hint.</p>
java
[1]
828,345
828,346
In mono for android on c# Resource.id dose not exist why?
<p>I have this code:</p> <pre><code>using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Speech.Tts; using System.Collections.Generic; namespace SayItAndroid{ [Activity (Label = "SayItAndroid", MainLauncher = true)] public class Activity1 : Activity, TextToSpeech.IOnInitListener { int count = 1; TextToSpeech mTts; public void OnInit (int status) { Console.WriteLine ("Listening to text to speech"); } protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle);// Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); Intent checkIntent = new Intent(); checkIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData); StartActivityForResult(checkIntent, 100); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById&lt;Button&gt; (Resource.Id.myButton); button.Click += delegate { string myText1 = "Did you sleep well?"; string myText2 = "I hope so, because it's time to wake up."; mTts.Speak(myText1, QueueMode.Add, new Dictionary&lt;string, string&gt;()); mTts.Speak(myText2, QueueMode.Flush, new Dictionary&lt;string, string&gt;()); }; } protected override void OnActivityResult (int requestCode, Result resultCode, Intent data) { base.OnActivityResult (requestCode, resultCode, data); if(requestCode == 100) { mTts = new TextToSpeech(this, this); } } }} </code></pre> <p>But on the two places i have Resource im getting red line error under the Resource:</p> <p>Error 1 The name 'Resource' does not exist in the current context </p> <p>How can i solve it ?</p> <p>Thanks.</p>
c#
[0]
176,242
176,243
Capture Video in iPhone
<p>I used the following code to record video.</p> <pre><code> UIImagePickerController *m_objpicker;=[[UIImagePickerController alloc] init]; m_objpicker.sourceType = UIImagePickerControllerSourceTypeCamera; m_objpicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; // hide the camera controls //picker.showsCameraControls=NO; m_objpicker.delegate = self; //picker.allowsImageEditing = NO; m_objpicker.allowsEditing=NO; // and put our overlay view in //picker.cameraOverlayView=m_objOverlayView; [self presentModalViewController:m_objpicker animated:YES]; </code></pre> <p>When we finish recording </p> <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSURL *m_objMediaURL=[info objectForKey:UIImagePickerControllerMediaURL]; [m_objpicker dismissModalViewControllerAnimated:YES]; } </code></pre> <p>My doubt is, how to save the captured video to a location we specify. Also how to use UISaveVideoAtPathToSavedPhotosAlbum . </p> <p>What all things i need to change in my code so that i can save video to a specified location</p> <p>Thanks,</p>
iphone
[8]
4,476,717
4,476,718
Please explain this Javascript variable?
<p>Could you guys please explain the difference between the two following variables?</p> <pre><code>var test = {}; var test2 = []; </code></pre> <p>Are they not both declaring an array variable? If not, when to use which?</p>
javascript
[3]
3,146,478
3,146,479
Communication between classes in an android project
<p>I've been struggling to solve a problem for over a week.</p> <p>I have a main activity with 3 child classes which extends View. When a touch event happens at a View class, calling a certain method in other 2 View classes synchronize with the event. But I have no idea how to call the certain method. In other words, I don't know how to communicate between classes extends View.</p> <p>Does anyone know how to figure it out ? Any comments would be highly appreciated. Thanks.</p>
android
[4]
1,293,351
1,293,352
Done is not working in softKeyboard in Autocomplete TextView in android
<p>I have One AutocompleTextView and I want to make the virtual keyboard disappear when he hits "DONE" at the AutocompleTextView. So far, the buttons "NEXT"/"DONE" do nothing at all.... Unfortunately I found no resources addressing this problem.</p> <p>Any suggestions? thanks in advance</p>
android
[4]
823,031
823,032
PHP include path sub-folder files not included
<p>I have a site where the PHP include path is /usr/share/php Within this path I have a sub-folder containing some utility files, e.g. /usr/share/php/utils. my_session.php is one of these utility files.</p> <p>My application calls </p> <pre><code>require ("my_session.php"); </code></pre> <p>and this works even though the file is actually within the utils folder.</p> <p>I am trying to replicate this site in another installation and I am getting the error:</p> <pre><code>Failed opening required 'my_session.php' (include_path='.:/usr/share/php) </code></pre> <p>My question is:</p> <p>Should the php include path also include files in sub-folders in the include path? This appears to be the case on my original site and I don't know why the behaviour seems to be different on the second site.</p>
php
[2]
4,751,864
4,751,865
How to print object ID?
<p>`I need to know if two references from completely different parts of the program refers to the same object. I can not compare references programaticaly because they are from the different context (one reference is not visible from another and vice versa).</p> <p>Then I want to print unique identifier for each object using <code>Console.WriteLine()</code>. But <code>ToString()</code> method doesn't return "unique" identifier, it just returns "classname".</p> <p>Is it possible to print unique identifier in C# (like in Java)?</p>
c#
[0]
115,785
115,786
jQuery script conflicting
<p>I'm creating a horizontally scrolling website using jQuery and I also want to add this hide and show function. However, after I insert another jQuery script for the hiding function, the easing effect for horizontally scrolling is not working! So that when I click the navigation of the site, it jumps to another section.</p> <p>Here's my code of the jQuery: </p> <pre><code>&lt;link rel="stylesheet" href="styles/style.css" type="text/css" media="screen" /&gt; &lt;script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'&gt;&lt;/script&gt; &lt;script src="js/jquery.localscroll-min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="js/jquery.scrollTo-min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $.localScroll.defaults.axis = 'x'; $.localScroll(); }); &lt;/script&gt; &lt;!-----------------------hiding div------------------------------------&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $(".slidingDiv").hide(); $(".show_hide").show(); $('.show_hide').click(function () { $(".slidingDiv").slideToggle(); }); }); &lt;/script&gt; </code></pre> <p>Does anybody know how to solve this?</p>
jquery
[5]
5,210,918
5,210,919
PHP file_exists is lying to me (saying file exists but it doesnt)
<p>Doing this:</p> <pre><code>php -r 'unlink("path"); clearstatcache(); echo file_exists("path");' </code></pre> <p>Where path is a full absolute path to a file on my linux machine. Command is returning '<code>1</code>' even though the file is clearly not there. You can run this command a million times, it will always tell you the file is there.</p> <p>Running:</p> <pre><code>ls path </code></pre> <p>Tells you there's no such file.</p> <p>what gives?</p> <p>Update: I know about clearstatcache(). That does not help in this case. Additionally, I'm running this with the cli. Nothing changes from run to run. I'm also on a 64-bit VM running ubuntu 11.10.</p> <p>Path is just a path on the filesystem: /var/www/yo.txt. www is a nfs shared mount, not sure if that has something to do with it. The file was removed from a remote machine, but the local machine seems to know its not there. 'ls' on the directory shows no files, and ls with the path claims says that the file is not there. The file was just a few kb, nothing huge.</p>
php
[2]
5,505,382
5,505,383
Adding numbers to a string?
<p>I have strings that look like "01", "02". Is there an easy way that I can change the string into a number, add 1 and then change it back to a string so that these strings now look like "02", "03" etc. I'm not really good at C# as I just started and I have not had to get values before. </p>
c#
[0]
1,467,972
1,467,973
marking and selecting items from a listview
<p>I want to get contacts from the phone and display it as a list view by that, I want to select a few and it should added to a database. The thing is I don't want to select one by one, instead of that</p> <p>I want to mark the contact and select as a whole.</p> <p>Is it possible in android? If yes please help me. </p>
android
[4]
2,246,370
2,246,371
Adding events to control arrays within a user control
<p>I have a user control with a stack panel on it and the ability to dynamically add checkboxes to that stack panel, what i would like to do is add a RoutedEventHandler for these new Checkboxes but I'm not too sure how its done. The usual way I add these handlers to static controls is:</p> <p>public event RoutedEventHandler CheckboxClicked {</p> <pre><code> add { CheckBox.Checked += value; } remove { Checkbox.Checked -= value; } </code></pre> <p>}</p> <p>with the dynamic list of controls I did this:</p> <p>public event RoutedEventHandler CheckboxClicked {</p> <pre><code> add { foreach (CheckBox c in LayoutRoot.Children) { c.Checked += value; } } remove { foreach (CheckBox c in LayoutRoot.Children) { c.Checked -= value; } } } </code></pre> <p>however, this does NOT work, so if anyone can help, i'll really appreciate it,</p> <p>thanks</p>
c#
[0]
453,830
453,831
Why is it a good programming practise to check whether a value exists before using it?
<p>Suppose using a isset() function, we checked whether an ID did exist or the user did submit an ID, before assigning it to variables or using it some place in the code that follows.</p> <pre><code> &lt;?php if(isset($_GET['Id'])) { $Id=$_GET['Id']; } ?&gt; </code></pre> <p>Now I understand, it's good to do this </p> <p>1)So the code as per the expected behavior i.e. does what it's expected to accomplish. For Example - if id was going to be used in some query which would return a row based on that id, it's always a good idea to provide a valid id to be sure that the query indeed returns a row as a result... This avoids the unexpected behavior that the query fails if it wasn't provided with a valid id.</p> <p>2)And as obvious, minimizing any runtime errors that our code might generate.</p> <p>So, I'm looking for more relevant examples and context as to why this is always a good programming practise.</p> <p>Basically more examples to help me sink in my understanding why it's really good to do so ... Many Thanks.</p>
php
[2]
4,933,083
4,933,084
How do I filter out only items from a list which is in an even position?
<p>Instead of processing items based on its value, I need to run a function based on the item's position. This is an example of filtering based on the content of the list.</p> <pre><code>only_words = filter(str.isalpha, my_list) </code></pre> <p>I want to create a slice of the list that contains only items in the even position, that is:</p> <pre><code>new_list = [] pos = 0 for item in my_list: if pos % 2 == 0: new_list.append(item) </code></pre> <p>This is way too ugly. Better suggestions ?</p>
python
[7]
2,827,758
2,827,759
Symbol not found: _CFXMLNodeGetInfoPtr
<p>Adding Exception breakpoint and when i set breakpoint on my own to see what is wrong. I see this same error</p> <p><code>2012-02-05 14:12:09.589 imageview[579:1d03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn: dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: _CFXMLNodeGetInfoPtr</code></p> <p>Anyone have any ideas about this error.</p>
iphone
[8]
919,245
919,246
Amateur attempt at auction script
<p>I have the following code that i don't suppose for one moment is complete for the purpose of an auction yet it should work at this stage, nevertheless, as far as i can see. But i doesn't. Just wondered if somebody could point my mistake. The broswer says that the else in the php script is unexpected. Removing it leaves the browser not expecting the closing html tag at the end. Many thanks in advance for any suggestions. Cheers</p> <pre><code>&lt;?php $hostuser = $_GET['user']; $auc = $_GET['auc']; //Connect to database $con = mysql_connect('localhost', 'root', 'password'); $db = mysql_select_db("users"); $auction = mysql_query(" SELECT * FROM auction WHERE host = '$hostuser' "); $row = mysql_fetch_array ($auction); $current_bid = $row['current_bid']; $current_bid_user = $row['current_bid_user']; $time_started = $row['time_started']; if ($current_bid == 0) { $current_bid = "No bids have yet been submitted. Be the first to make a bid."; } include ('auction_1.php'); if ($bid &gt; $current_bid) { $current_bid = $bid; $bidsubmitted = ""; { else $bidsubmitted = "Your bid must exceed the current bid"; } ?&gt; &lt;html&gt; &lt;form action = 'auction_1.php' method ='POST'&gt; &lt;br&gt; Current bid: &lt;?php echo $current_bid; ?&gt; &lt;br&gt; &lt;br&gt; Time Left: &lt;table&gt; &lt;br&gt; &lt;br&gt; &lt;tr&gt; &lt;td&gt; Your bid: &lt;/td&gt; &lt;td&gt; &lt;input type = 'text' name = 'userbid'&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; &lt;input type='submit' name='bid' value='Bid'&gt; &lt;?php echo $bidsubmitted; ?&gt; &lt;/html&gt; </code></pre>
php
[2]
606,552
606,553
How can i share data/text with other apps that will accept it?
<p>I have an app that creates a new data entry in a sqlite db with several columns. I would like to have a simple <em>share</em> button on the final activity so they can share the results (or even a simple text field) with apps that accept it (email, mms, twitter, etc..).</p> <p>I did some reading on ContentProviders but the more I read, the more I'm thinking i'm heading down the wrong path. Any help is appreciated.</p> <p>Thanks!</p>
android
[4]
4,994,378
4,994,379
Accessing GUI components in thread on android
<p>I want to access the component of GUI such as to change the textview from the thread how it can be done???</p>
android
[4]
2,732,476
2,732,477
How to remove a selected file from the input file?
<p>I have seen a flaw with the file input in html. When the user uses the file input to select a file then that is fine, but if the user wants to remove the selected file and want a blank file input, then the user cant do this. Does anyone know how to remove a selected file from the file input?</p> <p>Below is my file input code in jquery:</p> <pre><code>var $imagefile = $('&lt;input /&gt;') .attr({ type: 'file', name: 'imageFile', id: 'imageFile' }); </code></pre>
jquery
[5]
5,541,103
5,541,104
Get number of occurrences of a character in JavaScript
<p>I have a string that devides some data using <code>','</code>. Now I want to count the occurences of <code>','</code> in that string. I tried:</p> <pre><code>var match = string.match('/[,]/i'); </code></pre> <p>But this gives me null If I try to get the length of the match array. Any ideas?</p>
javascript
[3]
1,176,304
1,176,305
How to stop android from redrawing the entire screen whenever something changes?
<p>I've got an app that allows users to build complicated screen layouts from a set of predefined controls. Then those controls talk to each other to generate the final functionality. The problem I'm seeing is that no matter what I do it seems that any redrawing caused by a change in one control is forcing the entire screen to redraw (as seen by enabling "Show Screen Changes"). Because I've got a lot of custom controls without much XML behind them, this redrawing can be pretty slow.</p> <p>For instance, one control might be a calculator which is built from a few linear layouts. Another might be a dynamically generated command grid build from linear layouts. Each of these is then added to a parent relative layout when the screen is loaded. Pressing a key on the calculator forces the command grid to redraw even though nothing has changed in any of its views.</p> <p>I've tried turning on hardware acceleration and changing all of the views' layer types to LAYER_TYPE_HARDWARE with no luck. </p> <p>How do I ensure that only a specific subsection of the screen gets redrawn? At this point I'm not doing any calls to invalidate myself, but I've got my own themable versions of buttons, layouts, and other UI components so if I need to go down to that level of control at least there's already a framework in place for it.</p>
android
[4]
3,623,060
3,623,061
ASPNet Windows Token Role Provider Issue
<p>I am trying to use the default aspnetwindowstoken provider to authorize users in an application that I am using windows impersonation to log users in. If I add a IsInRole to the code behind the page in the page load, I can see the user is in the proper roles, but when I add the authorization to the web.config, I am getting 401 unauthorized errors. Not sure if I am missing something or not, but any help you can give would be appreciated. Below is my web.config.</p> <pre><code>&lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;customErrors mode="Off" defaultRedirect="Error.aspx" redirectMode="ResponseRewrite" /&gt; &lt;profile&gt; &lt;providers&gt; &lt;clear /&gt; &lt;add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /&gt; &lt;/providers&gt; &lt;/profile&gt; &lt;authentication mode="Windows" /&gt; &lt;roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" /&gt; &lt;authorization&gt; &lt;deny users="?" /&gt; &lt;allow roles="DOMAIN\Group" /&gt; &lt;/authorization&gt; &lt;/system.web&gt; </code></pre> <p>Any help you can give will be appreciated.</p> <p>Thanks Nick</p>
asp.net
[9]
4,374,389
4,374,390
Trouble with / vs ./ vs ../ and absolute and relative paths
<p>I have many PHP files in</p> <pre><code>/ /client/ /user/ /config/ etc... </code></pre> <p>I want all my files to include <code>/user/codestart.php</code>. (Lots of functions etc)</p> <p>Therefore:</p> <ul> <li>All files in <code>/</code> have <code>include("./user/codestart.php");</code></li> <li>All files in <code>/user/</code> have <code>include("codestart.php");</code></li> <li>All files in <code>/client/</code> have <code>include("../user/codestart.php");</code></li> </ul> <p>The problem is that <code>/user/codestart.php</code> has <code>include("../config/config.php");</code> (The MySQL ID and password)</p> <p>When a file in <code>/</code> runs, such as <code>/index.php</code>, it includes <code>./user/codestart.php</code>. Then <code>/user/codestart.php</code> includes <code>../config/config.php</code>, but it cannot see it, because it thinks it is calling it from <code>/</code>, instead of from <code>/user/</code>.</p> <p>If I change <code>include("../config/config.php")</code> to be <code>include("./config/config.php")</code> that fixes it for <code>/</code> files, but breaks it for<code>/user/</code> and<code>/client/</code> files.</p> <p>Bottom line is that when one PHP file includes another file, PHP thinks it is operating from the location of the original file, not the calling file.</p> <p>I need to use relative paths, not absolute paths. Absolute paths will not work in my situation.</p> <p>Is there any way to solve this?</p>
php
[2]
1,538,577
1,538,578
russian language not properly coming in android
<p>I have a file with data that contain values in english and russian. But when I try to print russian data in logcat, its not shown in the way its there in the file. Its coming as some special characters. What may be the reason? </p> <p>For the above question, below answer worked....</p> <p>Added new thing to the question:</p> <p>I have search functionality in my app. So when I search this russian data, its not showing any results..if the data is english, it works perfectly...What could be the reason?</p>
android
[4]
4,935,714
4,935,715
Android- Using DexClassLoader to load apk file
<p>I've hit a bit of a wall. Any help would be appreciated. I have an app that I want to use DexClassLoader to load another apk file.</p> <p>Here is my code:</p> <pre><code>DexClassLoader dLoader = new DexClassLoader("/sdcard/download/test.apk","/sdcard/download",null,ClassLoader.getSystemClassLoader().getParent()); Class calledClass = dLoader.loadClass("com.test.classname"); Intent it=new Intent(this, calledClass); it.setClassName("com.test", "com.test.classname"); startActivity(it); </code></pre> <p>Now I had already installed test.apk so when I ran the above code it worked fine and launched the application. However I want to be able to run this without test.apk being installed already (as that would defeat the entire point of the application) . So I uninstalled it and when I ran the my app again I get this error:</p> <pre><code>android.content.ActivityNotFoundException: Unable to find explicit activity class {com.test/com.test.classname}; have you declared this activity in your AndroidManifest.xml. </code></pre> <p>So I'm a bit stumped here. This activity is declared in the Manifest of the apk I am trying to run. I can't declare it in my applications Manifest. Any ideas?</p> <p>Thanks, Craig </p>
android
[4]
1,456,863
1,456,864
jquery resize on mousemove not working
<p>I have this js:</p> <pre><code>var clicking = false; $('.drag-me').mousedown(function(){ clicking = true; $('.status').text('mousedown'); }); $(document).mouseup(function(){ clicking = false; $('.status').text('mouseup'); $('.status').text('click released, no more move event'); }) $('.drag-me').mousemove(function(e){ if(clicking == false) return; // Mouse click + moving logic here $('.status').text('mouse moving'); var change=lastx-e.pageX; var lastx= e.pageX; $(this).css('width',$(this).width+change+'px') $('.cords').html('x:'+e.pageX+' y: '+e.pageY); }); </code></pre> <p>And html:</p> <pre><code>&lt;div class="drag-me"&gt;Drag me&lt;/div&gt; &lt;div class="status"&gt;Nothing&lt;/div&gt; &lt;div class="cords"&gt;Cords&lt;/div&gt; </code></pre> <p>css:</p> <pre><code>.drag-me { background:blue; width:100px; height:30px; } </code></pre> <p><a href="http://jsfiddle.net/kmEGF/17/" rel="nofollow">demo</a></p> <p><strong>QUESTION</strong>: Now when i move the mouse inside <code>.drag-me</code> i want it to increase/decrease its size. But it doesnt happens so. Why ? Where have i been going wrong ?</p>
jquery
[5]
3,580,463
3,580,464
jQuery image swap on nav hover
<p>I'm trying to use jQuery to do an image swap on the navigation when a user hovers over a menu item. It needs to load a different image depending on the height of the element.</p> <p>So far I have this, which works to some extent:</p> <pre><code>$(document).ready(function() { $('a.mainlevel').hover(function() { if ($(this).height() &gt; 15) { $('a.mainlevel').mouseenter(function() { $('a.mainlevel:hover').css('background-image','url(/images/menuHoverBig.gif)'); }); $('a.mainlevel').mouseleave(function() { $('a.mainlevel').css('background','#505051'); }); } else { $('a.mainlevel').mouseenter(function() { $('a.mainlevel:hover').css('background-image','url(/images/menuHover.gif)'); }); $('a.mainlevel').mouseleave(function() { $('a.mainlevel').css('background','#505051'); }); } }); }); </code></pre> <p>The problem I'm having is that if I hover over element of size X, it loads the correct image but then when I hover over element of size Y, it loads the image for X. If you then hover over Y again it works correctly. Going back to X, the Y image loads until a second hover.</p> <p>I'm not really that up on jQuery so it's probably something obvious, but I can't work it out.</p> <p>Cheers </p>
jquery
[5]
1,556,205
1,556,206
Whats the {} tag do in php?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2596837/curly-braces-in-string">curly braces in string</a> </p> </blockquote> <p>Just came across this piece of code and it got me curious...</p> <pre><code>$msg .= "–{$mime_boundary}–n"; </code></pre> <p>The $mime_boundary var was specified earlier to be output as a string. </p> <p>Did a quick test....</p> <pre><code>$var = "XmytextX"; $str ="some wrapper{$var}end of"; echo $str; </code></pre> <p>and it does indeed output into the string. I've just never seen this way of outputting a var before.</p> <p>Couldn't find any documentation on it - can anyone enlighten me?</p>
php
[2]
5,523,665
5,523,666
Java: Can multicast data get affected by system call
<p>I am receiving some multicast data and trying to record it. It's able to work properly. But today, I made some changes to the code and added a function to create the directory if it does not exist.</p> <p>This call started affecting the sequence of bytes received. I think so because as soon as I commented out the part, the process works fine.</p> <p>Is it really possible ?</p> <pre><code> StringBuffer dirPath = new StringBuffer(); dirPath.append(FileBaseDir); dirPath.append(FilePathSeparator); dirPath.append(date); File file = new File(dirPath); if (!file.exists()) { file.mkdir(); } ` </code></pre>
java
[1]
4,573,666
4,573,667
How to move image on touch,Android
<p>i created a iphone app in which, i hv few images. If i tap on an image for example a boy standing, than it moves from point a to point b. I used imageview with array of images, and having 6-8 images in different positions, so when user taps, it looks like boy is moving.</p> <p>The same thing i wanted to implement in ANDROID.</p> <p>kindly guide me, how can i, move one image from 1 point to another, on touch event.</p> <p>Suggestions are always appreciated.</p>
android
[4]
3,804,013
3,804,014
Notification when app not used for more than certain period
<p>Is there a way to send a notification to the user that app has been downloaded but a certain task from the app is not yet complete even after certain period - say a month. One way is a background service which should come alive every month in this case, check the app state (in sharedprefs) and then send a notification. Is there some other easier way in Android without writing custom service. </p>
android
[4]
4,584,660
4,584,661
how to create a setup file with launch condition
<p>i don't have basic knowledge of .net</p> <p>but i have assigned a work to create a setup file for a project which must satisfy the condition such the setup file must check the present of the .net and sql while installing if not it should automatically install it</p> <p>so guide by step by step for 1.registry key 2.prerequisites 3.launch condition </p> <p>.net3.5 and sql server2005 using vs 2008</p> <p>pls help me friends</p>
c#
[0]
1,908,832
1,908,833
How to convert a String to a unique INTEGER in php
<p>how can i convert a string(i.e. email address) to unique integers, to use them as an ID.</p>
php
[2]
4,154,292
4,154,293
Counting the number of times a character occurs in a very large text file
<p>I would like to count the occurrence of all commas in a very large text file (its has comma delimited data). Size is 28mb. I thought of loading up the text file and doing something like this:</p> <pre><code>substr_count($text, ','); </code></pre> <p>Good idea? Will it work?</p> <p>The overall task is to find out how many rows of data it has. When I count the number of commas, I will divide this by the number of columns which will give me the number of rows. If there is a better way of doing this, let me know!</p> <p>Thanks all</p> <h2>EDIT</h2> <p>The below worked but is it efficient as the suggestions?</p> <pre><code>$lines = file('C:\wamp\CE.txt'); $number = 0; foreach($lines as $line){ $number = $number + substr_count($line, ','); } echo $number; </code></pre>
php
[2]
3,041,297
3,041,298
How to get the graphics context of an UIView?
<p>For example, I want to draw something directly to an UIView. I need an CGContextRef, but I don't want to make a new one since that would eat up too much memory. Can I obtain the CGContextRef from an UIView?</p>
iphone
[8]
277,258
277,259
Error printing xml nodes using \n
<p>I want to print each element of an xml document on a new line without using <code>&lt;br/&gt;</code>.</p> <p>Here is the code I'm using but it skips the "\n". Please help</p> <pre><code>&lt;?php $xmlstr= '&lt;Address&gt;&lt;to&gt;James&lt;/to&gt;&lt;from&gt;Jani&lt;/from&gt;&lt;heading&gt;Reminder&lt;/heading&gt;&lt;body&gt;Please check your mail.&lt;/body&gt;&lt;/Address&gt;' ; $xml = simplexml_load_string($xmlstr); echo $xml-&gt;getName() . "\n"; foreach($xml-&gt;children() as $child) { echo $child-&gt;getName() . ": " . $child . "\n"; } ?&gt; </code></pre> <p>The required output:</p> <pre> Address to: James from: Jani heading: Reminder body: Please check your mail. </pre>
php
[2]
2,538,518
2,538,519
Remove first 3 characters from title
<p>I need to remove first 3 characters from title. I used:</p> <pre><code>$(".layered_subtitle").each(function() { var text = $(this).text(); text = text.replace('06.', ''); $(this).text(text); </code></pre> <p>I have dynamicly loaded titles with numbering:</p> <blockquote> <p>01.title</p> <p>02.title</p> <p>03.title ..</p> </blockquote> <p>How to to separate characters to be removed? </p>
jquery
[5]
517,219
517,220
Is there a good general purpose options class for c++?
<p>Each time I write another one of my small c++ toy programs, I come across the need for a small, easy-to-use options/parameter class. Here is what it should be able to do:</p> <ul> <li>accept at least ints, doubles, string parameters</li> <li>easy way to add new options</li> <li>portable, small and fast</li> <li>free</li> <li>read options from a file and/or command line</li> <li>upper and lower bounds for parameters </li> <li>and all the other neat useful things I am not thinking of right now</li> </ul> <p>What I want to do is pass a pointer to this class to the builder and all of my strategy objects, so they can read the parameters of the algorithm I am running (e.g. which algorithm, maximum number of iterations etc.)</p> <p>Can someone point me to an implementation that achieves at least some of these things?</p>
c++
[6]
5,751,041
5,751,042
How do I set opacity of form 1 by a slider in form 2?
<p>I have 2 forms and in form 1 there is a slider. How can I get form2's opacity to be set by form1's slider?</p> <p>I have already tried: form2.Opacity = form1.trackbar1.value; but that doesn't seem to work.</p>
c#
[0]
366,711
366,712
Recommended way to Learn PHP
<p>What are some of the best PHP tutorials/sites/resources/books or blogs which I can refer to learn PHP ?</p>
php
[2]
4,287,988
4,287,989
Null Pointer Exception
<p>I am working on some project in java. Here I'm stuck at this problem and not able to figure out where I am going wrong. </p> <p>I have made two classes: <code>Test</code> and <code>Child</code>. </p> <p>When I run the code I am get a NullPointerException.</p> <pre><code>package test; public class Test { child newchild = new child(); public static void main(String[] args) { new Test().method(); } void method() { String[] b; b = newchild.main(); int i = 0; while (i &lt; b.length) { System.out.println(b[i]); } } } </code></pre> <hr> <pre><code>package test; public class child { public String[] main() { String[] a = null; a[0] = "This"; a[1] = "is"; a[2] = "not"; a[3] = "working"; return a; } } </code></pre>
java
[1]
1,639,448
1,639,449
iPhone:How to get real ads showing in iAds banner in iPhone application?
<p>I have integrated iAds in my iOS 4.0 application developed using the following tutorial: <a href="http://www.raywenderlich.com/1371/how-to-integrate-iad-into-your-iphone-app" rel="nofollow">http://www.raywenderlich.com/1371/how-to-integrate-iad-into-your-iphone-app</a></p> <p>Currently it is showing only Test Banner page. I would like to know how would i get real Ads showing there and what is the procedure to get it. I couldn't find any help on this. Could someone please point me out ?</p> <p>Thank you.</p>
iphone
[8]
1,689,033
1,689,034
JavaScript: `var x = (function() {... return something;})();` vs `var x; {... x = something;}`
<p>Are following snippets exactly equal? If no what is the deference?</p> <pre><code>var x = (function() { ... //a return function(){ ... //b }; })(); </code></pre> <p>vs.</p> <pre><code>var x; { ... //a x = function(){ ... //b }; } </code></pre>
javascript
[3]
2,747,792
2,747,793
Download part of HTML page as text (PHP)
<p>So I have an 'export' application that arrives the user at an end page with a textarea with lots of text. Now the workflow is to copy and paste that text from the textarea into a file.</p> <p>The exported code is getting larger, and we want to encourage users to do this more often, so the copy/paste route is no longer desirable. (Not to mention that my xterm->ssh->screen->vi chain doesn't paste 250K characters so well) </p> <p><strong>So the problem is this: I have a textarea that has exported code in it, and I want to provide a button that is 'Download this Code to a file'</strong></p> <p>I'm fairly sure that I will have to hit the server again, but I just want to check all my bases. The ways I can think of doing this (sending generated textarea value as a file ot the browser)</p> <ul> <li><p>Create a script that receives said text as a POST and sends it back with the right Content Headers. This is no desirable because we would be POSTing 250k, which would be slower than:</p></li> <li><p>Create a script that regenerates the text area and provide a button the original page that hits the scripts and downloads the file. <em>This is the option I am leaning towards</em></p></li> <li><p>Use Javascript somehow and perhaps beable to skip the server all together and just send the $('.exported').val() to the browser with the right headers? Not sure how to do this atm.</p></li> </ul> <p>So if anyone has suggestions that'd be great, maybe I'm overlooking something. Thanks!</p> <p>edit: <a href="http://stackoverflow.com/questions/609530/download-textarea-contents-as-a-file-using-only-javascript-no-server-side">http://stackoverflow.com/questions/609530/download-textarea-contents-as-a-file-using-only-javascript-no-server-side</a></p> <p>This question says the JS route is not possible (probable)</p>
php
[2]
4,824,737
4,824,738
Where should i store uploaded files in server?
<p>i am learning php as well as doing a project that involves uploading files to the server. My goal is to make it as secure as possible so where do you recommend saving all the uploaded files. The files to be uploaded will all be pdf files. I read somewhere it's better to save uploaded files outside document root and in some other place i read it's not easy to access files outside document root from php so i am very confused. Any help towards best practice to overcome this situation is appreciated! Thanks!</p>
php
[2]
2,396,743
2,396,744
Datalist itemcommand design?
<p>in my application i am using datalist to display the images, i put properties of repeatcolumn=4 and reapeatdirection=horizontal. It is displaying good when there r more than or 4 images if there r only one or two or three images the gap between images r too long. if i have only one image the image displayed in datalist in the middle of the datalist. how can i solve this problem. i think you people understand my problem this is my datalist source code... datalist width="100%"</p> <p> </p> <pre><code> &lt;ItemTemplate &gt; &lt;table width="100%" &gt; &lt;tr&gt; &lt;td &gt; &lt;asp:ImageButton ID="imgeFrien" runat ="Server" Width="110px" Height ="100px" CommandName ="Image" CommandArgument ='&lt;%# Eval("userid") %&gt;' ImageUrl ='&lt;%# "~/Userimages/"+ Eval("myimage") %&gt;' /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td &gt; &lt;asp:Label ID="lblFrieNam" runat ="Server" Font-Names ="verdana" Text ='&lt;%# Eval("username") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/ItemTemplate&gt; &lt;/asp:DataList&gt; </code></pre> <p><img src="http://yfrog.com/jastackoverp" alt="alt text"></p> <p><img src="http://img694.imageshack.us/img694/8949/stackover.png" alt="alt text"></p>
asp.net
[9]
2,390,613
2,390,614
php email discussion
<p>I have a contact form on my site. The information from the form is saved to the database.</p> <p>When a user signs up an email is sent from the website to validate the users email. That sent email information is saved in the database.</p> <p>If a user sends me an email, that email information is in the email. If I reply to that email, that email information is in the email.</p> <p>You see where I'm going? I now have two places for email information. In the websites database and in the email address server.</p> <p>So if I want to review all the contact information for the user, I have to look in two different places to determine timeline of events.</p> <p>Is there a way to place my sent emails from the website into the email address server?</p> <p>Should I be looking for a way to get all the email information for the user from the email server and place that information in the database?</p>
php
[2]
2,602,072
2,602,073
Server-side code working with JavaScript using ASP.NET
<p>I am trying to get a server side code working with JavaScript. What am I doing wrong?</p> <pre><code>function openUp(name) { document.getElementById(name).style.display = &lt;%if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("FireFox"))Then %&gt; response.write('table-row'); &lt;%else%&gt; response.write('block'); } </code></pre>
asp.net
[9]
3,325,837
3,325,838
What is the difference in php5 between $this and &$this
<p>I have some confusion about $this and &amp;$this, please describe this point .</p> <h3>Update:</h3> <p>Thanks for reply. I know about pass by value and pass by reference. Please see the following program.</p> <pre><code>///////////////////////////////////////////////////// class my_class { var $my_var; function my_class ($var) { global $obj_instance; $obj_instance = $this; $this-&gt;my_var = $var; } } $obj = new my_class ("something"); echo $obj-&gt;my_var; echo $obj_instance-&gt;my_var; //////////////////////////////////// </code></pre> <p>In this program <code>$obj_instance = $this;</code> is copy the variable but output of this somethingsomething but when I am using <code>$obj_instance = &amp;$this;</code> the output is somethings. Why is it different?</p> <p>Thank you.</p>
php
[2]
115,857
115,858
Endless Adapter with custom listview adapter in android
<p>I am using <a href="https://github.com/commonsguy/cwac-endless" rel="nofollow">this link</a> to create custom listview in my app. </p> <p>First I want to display listview with 5 items. As I scroll the list it should parse data and load listview for next 5 items.</p> <p>Listview row contains 5 textviews.</p> <p>How can I achieve this? </p> <p>Please help me.</p> <p>Thanks in advance </p>
android
[4]
791,899
791,900
Built in prime checking function
<p>Does C++ have any built in function to check if the number is prime or not. If yes, then in which library?</p> <p>Below is my implementation. But was just looking if there is any built in function. Searching on Google just gives user based implementations.</p> <pre><code>int isprime(int N){ if(N&lt;2 || (!(N&amp;1) &amp;&amp; N!=2)) return 0; for(int i=3; i*i&lt;=N; i+=2){ if(!(N%i)) return 0; } return 1; } </code></pre>
c++
[6]
1,320,130
1,320,131
Webview and Css3
<p>Does Android 2.2 supports all the Css3 tags? On ICS:</p> <pre><code>background: -webkit-linear-gradient(left, #64615E, #B6B0AB, #64615E); background: -moz-linear-gradient(left, #64615E, #B6B0AB, #64615E); background: -o-linear-gradient(left, #64615E, #B6B0AB, #64615E); </code></pre> <p>those are rendered correctly. On Android 2.2 and android 3 they are not. Am I doing something wrong or those tags are not supported? </p>
android
[4]
2,615,506
2,615,507
What is the purpose of __EVENTVALIDATION __VIEWSTATE in aspx
<pre><code>Content-Disposition: form-data; name="__VIEWSTATE" /wEPDwUKMTQxNzIxMTc0MQ9kFgICAw8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YWRkflsROmXoLo8ar8ukWWYDh1Wr2BCwmhiAAqpX/xwqLq8= Content-Disposition: form-data; name="__EVENTVALIDATION" /wEWBgKJ1KD6AwKH3P+GBQLr/4HeAgKWoZqyCQLinqurDALt3oXMA0YLgb/Mt6KGihl+8ixYoY9A24wgHGGoPAINhuyP7nEl </code></pre> <p>We make a site where users can upload photos.</p> <p>Latter we decided that users can also upload photos via other apps and we like to have a uniform interface. So the other apps work with the same page.</p> <p>We notice that we cannot upload photos unless we know the value of __EVENTVALIDATION and __VIEWSTATE</p> <p>Of course the app can just load the uploading image but that's kind of a hassle.</p> <p>What are those for anyway? Is there a way to upload images to aspx upload web without specifying things.</p>
asp.net
[9]
5,526,198
5,526,199
auto increment numbers in c# windows app
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4897658/auto-generating-numbers">auto generating numbers</a> </p> </blockquote> <p>how to increment a numbers in textbox control in c# windows app.samples like s001 and should be increment always when i come to form it should be like s002.where should i have to write a code either in textbox or forml_load event.</p>
c#
[0]
2,387,526
2,387,527
Intent's intended class can't read extended information from said intent
<p>I am trying to send information from my main activity class to another class in my app package. The information is used to update an AlertDialog automatically. Here is the code I've been working with:</p> <pre><code>//This is in MainActivity.class //Tests to see if SyncDialog will update itself with new intents. public void testLoop() { int n = 0; Intent intent = new Intent(this, SyncDialog.class); while (n != 10) { intent.putExtra(TEST_NUMBER, n); n++; } } //This is in SyncDialog.class //This method should get the int value from MainActivity protected void onNewIntent(Intent intent) { int n = intent.getIntExtra(TEST_NUMBER, 0); showNextDialog(n); } </code></pre> <p>TEST_NUMBER is defined as a public constant at the top of MainActivity, and I even tried importing MainActivity into SyncDialog.class.</p> <p>Is there any way to fix this?</p>
android
[4]
5,758,025
5,758,026
Can I use jquery to alternate the color of these fonts?
<p>I am using this function to change the font-size on the class "tag-link," which is numbered like</p> <p>"tag-link-1" "tag-link-2" etc.</p> <p>So that's why it's using <code>^</code></p> <pre><code> $(function () { $('a[class^="tag-link"]').css('fontSize', '1em'); }); </code></pre> <p>What I would like to do, however, is also make this function change the font-color of every other tag. Right now, the font-color is blue, but I want it to alternative blue and red for example. It will make the fonts easier to read if they're not all the same color side by side. </p> <p>Do you know how to alter this function to make that happen?</p>
jquery
[5]
5,359,944
5,359,945
base() and this() constructors best practices
<p>Under what conditions am I supposed to make the :base() and :this() constructor calls following my constructor's parentheses (or even in other places in the code). When are these calls good practices and when are they mandatory ?? </p>
c#
[0]
4,443,801
4,443,802
Empty specific div with the same class of several others on JQuery
<p>I have this problem, I generate a window (a div with the 'window' class) every time a link is clicked, this is the code for that:</p> <pre><code>$(".getWindow").live('click',function(){ $('#desktop').append('&lt;div class="window"&gt;&lt;span class=\"close\"&gt;x&lt;/span&gt;Well '+$(this).attr('well')+'&lt;div id="screen"&gt;&lt;img src="assembled_colors.jpeg" class="drag-image" id="draggable"/&gt;&lt;/div&gt;&lt;/div&gt;'); $('.drag-image').draggable(); $('.window').draggable(); }); </code></pre> <p>Then, every time the 'x' in the second line of my code is pressed, I try to close the window, by doing this:</p> <pre><code>$('.close').live('click', function(){ $(this).parent().empty(); }); </code></pre> <p>This only closes what is inside of the window, but not the window itself, my next approach was to do this:</p> <pre><code>$('.close').live('click', function(){ $(this).parent().parent().empty(); }); </code></pre> <p>Which closes all the opened windows. Could you please help me on how to close only the window containing the pressed x button?</p> <p>Thanks in advance!</p>
jquery
[5]
5,649,858
5,649,859
Android Snake example: Can not change tilesize in XML file
<p>In the Android snake example, the layoyut file snake_layout.xml file suggests that you can define the tilesize of a tile. However, whatever tilesize you enter in this xml-file, the real tile size will always be the default value of 12, as programmed in TileView class(line 70 and 80).</p> <p>Is something wrong with the xml file or the implementation of the TileView class? Or do I misunderstand something?</p>
android
[4]
2,584,890
2,584,891
How to programmatically add bindings to the current class scope in Python?
<p>Though the question is very specific, I'd also really appreciate general advice and other approaches that would make my question moot. I'm building <strong>a collection</strong> of AI programs, and many of the functions and classes need to deal with a lot of different states and actions that cause transitions between states, so I need a way to represent states and actions. Please note that I'm not building a simple state machine, but rather a number of different programs (agents) that all take states and return actions as a way of interacting with an environment.</p> <p>I could use strings, but that's messy if a particular algorithm needs to associate additional information with a state or action, and comparing strings over and over again in long-running programs is wasted overhead. The same sorts of problems arise with other kinds of constants. So my initial idea is to use nested classes, like so:</p> <pre><code>class DerivedAgent(Agent): class StateA(State): pass class StateB(State): pass ... def do_something(state): if state is self.StateA: ... </code></pre> <p>This works fairly well, but if there are a number of states and actions, it can take up a lot of space to declare them all, and all of the pass statements are annoying. I'd like to be able to do something like...</p> <pre><code>class DerivedAgent(Agent): states("StateA", "StateB", "StateC", ...) </code></pre> <p>But I don't see a way to have the <code>states</code> method add the newly-created types to the <code>DerivedAgent</code> class. I think I might be able to do it with the <code>inspect</code> module, but that feels like it's going too far for a small convenience. Is using types like this a bad idea? Is there a much more elegant approach? Code outside of the agent classes will need to be able to access the states and actions, and putting states into the module namespace isn't a good option because a given module might have several agents in it.</p>
python
[7]
2,069,321
2,069,322
appendTo() is not a function?
<p>I thought this code should work but it didnt, can someone explain?</p> <pre><code> $("#addLinkLayout input.comment, #addLinkLayout input.link").each(function() { $(this).val().appendTo('div#links'); }); </code></pre> <p>It says <code>$(this).val().appendTo()</code> is not a function.</p>
jquery
[5]
5,582,361
5,582,362
STL name for the "map" functional programming function
<p>I would like to be able to write something like</p> <pre><code>char f(char); vector&lt;char&gt; bar; vector&lt;char&gt; foo = map(f, bar); //Strikingly functional. </code></pre> <p>in the STL.</p> <p>But, as we all know, the STL has the map class as a collection.</p> <p>Rummaging around, the <code>transform</code> function appears to be similar, but it will not cleverly autogenerate the size of the resultant collection. </p>
c++
[6]
4,740,225
4,740,226
jQuery inner html from select option
<p>I am writing a fancy select box with jquery, and have run into a little problem.</p> <p><a href="http://jsfiddle.net/kYhXn/" rel="nofollow">http://jsfiddle.net/kYhXn/</a></p> <pre><code>&lt;select&gt; &lt;option&gt; Shocka &lt;br&gt; Zooloo &lt;/option&gt; &lt;/select&gt;​ alert($('option').html()+'');​ </code></pre> <p>For whatever reason the <code>&lt;br&gt;</code> tag does not show up in the alert! How can I get the html with the <code>br</code> tag?</p> <p>Pure js <a href="http://jsfiddle.net/z4Wb9/" rel="nofollow">http://jsfiddle.net/z4Wb9/</a> same problem.</p>
jquery
[5]
1,771,850
1,771,851
get data from the strings.xml
<p>How can I get text from the strings.xml file into my .setmessage?</p> <pre><code>show = new AlertDialog.Builder(mContext).setTitle("moria") .setMessage("R.string.erroroik") .setPositiveButton("OK", null).show(); </code></pre>
android
[4]
3,302,958
3,302,959
Matching strings based upon part match
<p>Im pulling in data from a 6 live feeds which is sometimes have slightly different formatting, ie. i might have </p> <ul> <li>'arsenal' and 'arsenal fc'</li> <li>'T Walcot' and 'Theo Walcot' and 'T. Walcot'</li> </ul> <p>What i was wandering was, is there a simple way to check if the strings match each other on the basis of if they have a certain % of letters in the same order they would be considered the same.</p> <p>I susppose i could setup a list of related words and terms, but this would mean having to setup it up in advance, but i was wandering if there was an easier, on the fly automated way as i wont be able to compile a full list for a long time. </p>
php
[2]
4,536,344
4,536,345
How to create object names java
<p>Lets say I need to create lot of class objects for my main class so I was wondering if there was any way to create a loop that creates a new class object many times but each time it changes the name if the class object.</p> <p>Hey I know you might be thinking why would you want to have multiple class objects that are the same for a program but I want to do something similar but I dont want to release my code for it. I will give a sample of the code if it is needed though</p> <p>EDIT:I want my class classnamehere to take user input and every time they type something like "open that thing" It would create a new class object</p>
java
[1]
5,500,355
5,500,356
Share data between threads and JOptionPane needs thread to run!
<pre><code> public void aMethod(){ new Thread(new Runnable() { public void run() { int decide = JOptionPane.showConfirmDialog(null, confirmName?, JOptionPane.YES_NO_OPTION); } }).start(); System.out.println("Number of decison " + decide); //Can't find symbol "decide" } </code></pre> <p><hr/> JOptionPane can't run without being put to a thread(I don't know why). Yet when put it to a thread, I can't get the varible decide from that. P/s: This is a method in callbackImplement Java RMI. Thank you. happy new year :P</p>
java
[1]
829,867
829,868
Accessing object properties by variable
<p>I've seen this asked before, but my particular case appears to be someone odd, and I'm unable to resolve it - any insight would be appreciated.</p> <p>I'm trying to access an object property with a variable value, ie.</p> <pre><code>$foo = new Object(); $foo-&gt;first = 'bar'; $array = array(0 =&gt;'first', 1 =&gt;'second'); $var = 0; return $foo-&gt;{$array[$var]}; </code></pre> <p>This is throwing an error "Notice: Undefined property: stdClass::$first". Removing the braces returns an identical result.</p> <p>What don't I understand? (Actual code and error below - the error is as recorded in a Drupal Watchdog log.)</p> <pre><code>private function load_questionnaire_queue($type, $comparator_id, $comparing_id_array) { $queue = array(); $type_map = array( 0 =&gt; "field_portfolio_district['und'][0]['nid']", 1 =&gt; "field_time_period['und'][0]['tid']", ); foreach ($this-&gt;questionnaires as $q) { // The commented code below works as expected // if ($q-&gt;field_portfolio_district['und'][0]['nid'] == $comparator_id &amp;&amp; // in_array($q-&gt;field_time_period['und'][0]['tid'], $comparing_id_array)) // This returns an identical error, with or without braces: if ($q-&gt;{$type_map[$type]} == $comparator_id &amp;&amp; in_array($q-&gt;{$type_map[!$type]}, $comparing_id_array)) { $queue[] = node_view($q, $view_mode = 'full'); } } $this-&gt;queue = $queue; } </code></pre> <blockquote> <p>Notice: Undefined property: stdClass::$field_portfolio_district['und'][0]['nid'] in ComparisonChart->load_questionnaire_queue()</p> </blockquote>
php
[2]
5,103,973
5,103,974
is 'giving out' a reference to 'this' inside the constructor ok?
<p>my code :</p> <pre><code>Scene::Scene(const std::string &amp;scene_file) : ambient_light(0, 0, 0), background(0, 0, 0){ scene_parser parser(*this); parser.parse(scene_file); } </code></pre> <p>scene_parser is a friend of Scene, and in the parse method it accesses(r/w) the members of Scene. Is this going to cause any problems?</p>
c++
[6]
546,446
546,447
Use heterogeneous arrays to store different child classes?
<p>I have a file that contains a list of names, colors, and some statistics about them. For example:</p> <pre><code>John black 10 15 Adam black 19 18 Jake brown 13 51 56 62 Rich brown 13 09 98 84 </code></pre> <p>I want to be able to store those names, colors, and numbers in their respective objects based on their colors. So John and Adam, would be stored in the class Black, Jake and Rich would be stored in class Brown.</p> <p>How can I store each person in their respective objects since they are different types?</p> <pre><code>class Color{ public: Color(string FIRST, string COLOR); protected: string FirstName; string ColorType; }; class Black : public Color{ public: Black(string FIRST, string COLOR, int A, int B); private: string FirstName; string ColorType; int number1, number2; }; class Brown : public Color{ public: Brown(string FIRST, string COLOR, int A, int B, int C, int D); private: string FirstName; string ColorType; int number1, number2, number3, number4; }; </code></pre>
c++
[6]
3,150,588
3,150,589
how to loop all rows in jquery grid
<p>I have this code right now to get the row value from jquery grid..</p> <pre><code>$("#table1").click(function(e) { var row = jQuery(e.target).parent(); value = row.attr("id"); </code></pre> <p>i need to loop all the rows to get the values cany anyone help me out.. that is if I click on second row I need get second row value if I click on first row I need to get first row value.</p> <p>thanks</p>
jquery
[5]
5,122,943
5,122,944
C# loop question
<p>I have two textboxes with a integer value in each textbox. I need to find all even values between the start and stop box using a loop. </p> <p>How would I do this?</p>
c#
[0]
3,202,546
3,202,547
Unit Testing in C#
<p>Junior Web Developer and I have been tasked with creating Unit Test for a project. </p>
c#
[0]
939,226
939,227
How to determine which configuration is read at run time
<p>I have several configuration entries for application. Identical entries are stored in Machine.config/Web.config etc.. How would I determine which one is read at run time..</p>
asp.net
[9]
4,949,697
4,949,698
PHP String into array keyed by word start
<p>Say I have the following string</p> <pre><code>$str = "once in a great while a good-idea turns great"; </code></pre> <p>What would be the best solution to creating an array with the array key being the string count of where the word(s) starts?</p> <pre><code>$str_array['0'] = "once"; $str_array['5'] = "in"; $str_array['8'] = "a"; $str_array['10'] = "great"; $str_array['16'] = "while"; $str_array['22'] = "a"; $str_array['24'] = "good-idea"; $str_array['34'] = "turns"; $str_array['40'] = "great"; </code></pre>
php
[2]
5,325,799
5,325,800
Curious: Why is the "throws <SomeSpecific>Exception" syntax required in Java alone?
<p>We all know it is needed.</p> <p>But WHY is it needed in Java alone, when other similar languages that have exception handling capablities don't require us to write "throws Exception"? Is there anyone who knows what was happening when Java language was designed and why they made it that way? Just curious.</p> <p>P.S. This may not be a practical or really necessary question - it might not help me in anyway with my ongoing projects. But certain language features kindle my curiosity :D</p> <p><strong>Edit</strong> Looks like my question was very vague! I think I worded the question wrongly. We need to use the "throws Exception" kind of syntax at some points during programming when dealing with Java code. But something like that is never needed in C# or C++ or even VB.Net and PHP. So why Java alone insists on this?</p>
java
[1]
1,788,194
1,788,195
Reaching all entries of ListView
<p>I'm using ListView to show all records from the database. Each row of the list has an additional checkbox. I want to make a button that when pressed will delete all checked records. However, when I'm iterating through the list and trying to get the reference to the rows with getChildAt(index), I can reach only 3 initial entries because the rest of them are hidden and in the application I have to use scrollbar for them. </p> <p>How can I reach them that something like that worked fine:</p> <pre><code>for( int i = 0; i &lt; taskList.size(); i++ ){ View row = list.getChildAt(i); CheckBox checkBox = (CheckBox)row.findViewById(R.id.checkbox) } </code></pre>
android
[4]
781
782
java.util.UUID.fromString not checking length
<p>When I looked into the implementation of <code>java.util.UUID.fromString</code>, I found that it doesn't check for the UUID length. Is there any particular reason for this? It only checks the components separated by "-".</p> <pre><code>String[] components = name.split("-"); if (components.length != 5) throw new IllegalArgumentException("Invalid UUID string: "+name); </code></pre> <p>Should it also throw IllegalArgumentException when length is not 36?</p> <p>Currently, without the length checking, numbers are automatically prepended with 0's if less than the component length or shifted if more. The downside is, if one entered a UUID string with a missing digit, it is accepted as valid and prepended with 0. This is hard to debug.</p> <p>For example, this "12345678-1234-1234-1234-123456789ab" becomes "12345678-1234-1234-1234-0123456789ab". Notice the '0' added? And this "12345678-1234-1234-1234-123456789abcd" becomes "12345678-1234-1234-1234-23456789abcd" with the '1' removed.</p> <p>To push this even further, the string "1-2-3-4-5" will also be treated as valid and becomes "00000001-0002-0003-0004-000000000005".</p> <p>Edit: To clarify my question, is this a bug or done on purpose to follow some standard or principle?</p>
java
[1]
3,811,510
3,811,511
Response.write results in CS0116: A namespace does not directly contain members such as fields or methods
<p>System.Web.HttpContext.CurrentContext.Response.Write result in this error, when used in an aspx.cs file</p>
asp.net
[9]
4,219,111
4,219,112
C#, How to Consistantly bring a form to the front?
<p>I have a <code>MainForm</code> Class Instance, I bring up another form like so;</p> <pre><code>InputForm MyInput= new InputForm("Enter a Number"); MyInput.ShowDialog(); </code></pre> <p>I close <code>MyInput</code> form from within itself like this;</p> <pre><code> private void Button_Click(object sender, EventArgs e) { //Do things here this.Hide(); } </code></pre> <p>Flow resumes in the MainForm and using either</p> <pre><code>this.Show(); </code></pre> <p>or</p> <pre><code>this.Activate(); </code></pre> <p>neither will consistantly bring the <code>MainForm</code> to the front. How can I do this?</p>
c#
[0]
5,205,123
5,205,124
Why does this not work when split onto 2 lines?
<p>This line:</p> <pre><code>std::auto_ptr&lt;Ogre::Root&gt; lRoot (new Ogre::Root(lConfigFileName, lPluginsFileName, lLogFileName)); </code></pre> <p>works fine. However when I do this it doesn't:</p> <pre><code>std::auto_ptr&lt;Ogre::Root&gt; lRoot; lRoot (new Ogre::Root(lConfigFileName, lPluginsFileName, lLogFileName)); </code></pre> <p>And it reports: <code>error: no match for call to ‘(std::auto_ptr&lt;Ogre::Root&gt;) (Ogre::Root*)’</code> As far as my limited understanding goes shouldn’t these do the same thing? Or am I missing something major?</p>
c++
[6]
5,013,678
5,013,679
Using array elements to assign “id=” values returns: TypeError: document.getElementById(...) is null
<p>I'm trying to write calculated values to table cells referencing them by their <code>id=</code> tag that are chosen using array elements. All attempts to get this working such as where <code>“ “</code> are coded, and first trying <code>spans[index]= spans[index].toString();</code> and using <code>window.setTimeout(function () { code.. }, 0);</code> gives the above error.</p> <p>The many of the similar questions that I have found posted have responses suggesting that the error is related to page loading.</p> <p>I am either misunderstanding the solutions given or what I'm attempting is different. It would be appreciated if someone could give an example of how this is accomplished. </p> <pre><code>function outputResults() { var spans = ['span1', 'span2', 'span3']; var outputs = ['output1', 'output2', 'output3']; for (var index = 0; index &lt; spans.length; index++) { outputs[index] = (outputs[index] * 13) / 100; (document.getElementById('\'spans[index]\'').innerHtml = outputs[index]); }; }; </code></pre> <pre><code>&lt;table BORDER="1" width="300" /&gt; &lt;tr /&gt; &lt;td /&gt; &lt;span id="span1"&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;td /&gt; &lt;span id="span2"&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;td /&gt; &lt;span id="span3"&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br /&gt; &lt;input type="button" value="Click to fill cells" onclick="outputResults();" /&gt; </code></pre>
javascript
[3]
2,639,365
2,639,366
Handling LinkClicked event for the richtextbox; the code runs twice inside the event handler
<p>I've a windows form with richtextbox in it.There is a link which when clicked triggers the LinkClicked Event handler which is something like,</p> <pre><code>private void textSampleResults_LinkClicked(object sender, LinkClickedEventArgs e) { CallSomeMethod1; CallSomeMethod2; } </code></pre> <p>When I started debugging, I was expecting the code inside the event handler to run once only but it started Calling CalleSomethod1 and CallSomeMethod2 again.In summary, for every click, the code under the event handler is executed twice. Is it something expected? How to make it behave so that the code under the event handler gets executed only once?</p>
c#
[0]
4,282,135
4,282,136
Android GraphicsView enbbeded in layout
<p>How to enbbed a GraphicsView into a layout? Or how do I add buttons and textViews to a GraphicsView? Could some one post a simple working example?</p> <p>-Henry</p>
android
[4]
4,228,903
4,228,904
How can I change character Case?
<p>how can I change character case so result be like :</p> <pre><code>"hello" = "Hello" "hello germany" = Hello Germany" </code></pre> <p>regards</p>
c#
[0]
4,665,065
4,665,066
Issue with php syntax on href link
<p>I have this code which i want to use in order to access a page, with the id of the product.</p> <p>The issue is, i don't get the id on the link.. what am i doing wrong here?</p> <pre><code> echo'&lt;a href="pershkrim.php?id="'.$row["id"].'""&gt;"'.$row["id"].'"&lt;/a&gt;'; </code></pre> <p>Thanks.</p>
php
[2]
1,676,206
1,676,207
Can Android App be embedded in Web page like old plain java applet?
<p>I know nothing about android platform and can't find answer to this basic question on internet.</p> <p>Update: OK I cannot embed Android App per se. But can I embed something in Java in Android Webbrowser ?</p>
android
[4]
3,679,897
3,679,898
initialising multiple empty lists
<p>Simple syntactic c# question is this.</p> <p>Given this code:</p> <pre><code>List&lt;string&gt; Columns = new List&lt;string&gt;(); List&lt;string&gt; Parameters = new List&lt;string&gt;(); List&lt;string&gt; Values = new List&lt;string&gt;(); </code></pre> <p>It can be reduced to:</p> <pre><code>List&lt;string&gt; Columns = new List&lt;string&gt;(), Parameters = new List&lt;string&gt;(), Values = new List&lt;string&gt;(); </code></pre> <p>But can I get it shorter still, since they're all being initialised to an empty list?</p> <p>Thank you all!</p>
c#
[0]
2,896,274
2,896,275
More fluent C# / .NET
<p>A co-worker of mine came up with this and I wonder what others think? Personally, I find it interesting but wonder if it is too big a departure? Code examples below. Extension methods at the bottom.</p> <p>General thoughts please. Other extension methods that could be added?</p> <pre><code>var ddl = Page.FindControl("LocationDropDownList") as DropDownList; ddl.Visible = true; ddl.SelectedValue = "123"; if(isAdmin) ddl .SelectedValue = "111"; </code></pre> <p>Becomes:</p> <pre><code>Page.FindControl("LocationDropDownList") .CastAs&lt;DropDownList&gt;() .With(d =&gt; d.Visible = true) .With(d =&gt; d.SelectedValue = "123") .WithIf(isAdmin, d =&gt; d.Items.Add(new ListItem("Admin", "1"))); </code></pre> <p>Or:</p> <pre><code> Page.FindControl("LocationDropDownList") .CastAs&lt;DropDownList&gt;() .With(d =&gt; { d.Visible = true; d.SelectedValue = "123"; }) .WithIf(isAdmin, d =&gt; d.SelectedValue = "111"); </code></pre> <p>Extension methods:</p> <pre><code>public static TResult CastAs&lt;TResult&gt;(this object obj) where TResult : class { return obj as TResult; } public static T With&lt;T&gt;(this T t, Action&lt;T&gt; action) { if (action == null) throw new ArgumentNullException("action"); action(t); return t; } public static T WithIf&lt;T&gt;(this T t, bool condition, Action&lt;T&gt; action) { if (action == null) throw new ArgumentNullException("action"); if (condition) action(t); return t; } </code></pre>
c#
[0]
2,932,370
2,932,371
How to call get service in android?
<blockquote> <p>I am new to <strong>android.</strong></p> <p>How to call the get method in android? i am using drupal service module to get json.</p> </blockquote>
android
[4]
3,744,518
3,744,519
Factory function returning const
<p>I have a factory for creating containers based on ugly containers </p> <pre><code>template&lt;class T&gt; std::vector&lt;T&gt; containerFactory(const UglyContainer* uglyContainer) { std::vector&lt;T&gt; container(uglyContainer-&gt;count); Getter getter; for(unsigned int i=0;i&lt;uglyContainer-&gt;count;++i) { getter(container[i], uglyContainer-&gt;values[i]); } return container; } </code></pre> <p>How might I go about complementing containerFactory with a factory function which returns const std::vector? </p>
c++
[6]
3,107,009
3,107,010
analyze how many threads in application and what are they doing?
<p>I have some c# application which I have to modify. When I'm modifing some method I need to know if I should make it thread-safe. How can I check if the particular method could be called from different threads? Are there any static-analyzing utilities?</p> <p>I've tried to run my application and discovered in Task Manager that it contains 5 threads. I've scanned sources and so far the application is supposed to be single-threaded. Why there are 5 threads? Probably .net contains some "service" threads? How can I check who created these 5 threads and what are they doing? Are there any runtime analyzing utilities?</p> <p>Thanks</p>
c#
[0]
3,474,585
3,474,586
Unable to compute product, quotient, and difference in java
<p>I'm trying to computing a few things in a simple java application for school. A user must into 2 integers and once you input those variables in it will spit out the sum, product, quotient and difference. I am only able to get the program to spit out sum but not product, quotient and difference. any suggestions? here is my code:</p> <pre><code>// This is for HW problem #3 // An application that asks the user to enter two // integers, obtains them from the user and prints their sum, // product, difference and quotient (division). import java.utl.Scanner; //program uses class Scanner public class Solution { // main method begins execution of Java application public static void ( String ags [] ) { // create Scanner to obtain input from command window Scanner input = new Scanner ( System.in ); int number1; //first integer to add int number2; //second integer to add int sum; // sum of number1 and number2 int product; //product of number 1 and number2 int differnec; //difference of number1 and number2 int quotient; //quotient of number1 and number2 System.out.print( "Enter first integer: " ); // prompt number1 = input.nextInt(); // read first number from user System.out.print( "Enter second integer: " ); // prompt number2 = input.nextInt(); // read second number from user sum = number1 + number 2; // add numbers product = number1 * number2; // multiply numbers difference = number1 - number2; // subtract numbers quotient = number1 / number2; // divide numbers System.out.printf( " Sum is %d\n ", sum ); //display sum System.out.printf( " Product is %d\n ", product ); //display prouduct System.out.printf( " Difference is %d\n ", difference ); //display difference System.out.printf( " Quotient is %d\n ", quotient ); //display quotient } // end method main } // end class Addition </code></pre>
java
[1]
1,815,961
1,815,962
Why is instance variable undefined?
<p>I dont understand one thing: </p> <pre><code> var comein = document.getElementById("comein"); var enter = new Expand({ elem : comein }); function Expand (options) { this._elem = options.elem; console.log(this._elem); // i have a div element } Expand.prototype = { check : function () { var comInClassName = this._elem.className; // i have an error: this._elem is undefined if (comInClassName == "open"){ this.close(); } if (comInClassName == "close"){ this.open(); } } } log_in.addEventListener("click", enter.check, false); </code></pre> <p>Why I have an error in prototype method if in Expand i have a normal element? Thanks</p>
javascript
[3]
2,681,209
2,681,210
Android - Fixed / Stationary Background between Activities?
<p>In my app, I want to have a single background image that I use for all pages/activities. When I switch activities, say clicking a button to goto another activity, all the elements on the screen, as well as the background, slides off the screen to the left. At the same time, all the new elements from the new activity and it's background slide onto the screen from the right.</p> <p>Is it possible to keep the background stationary so that it doesn't slide off and on the screen when switching between activities? Is this where Themes come into play? Or do I need to just have a single layout that is dynamically altered whenever I want to do something else?</p>
android
[4]
780,551
780,552
Android Programatically Close Out App1 and Start App2 from App1
<p>My app needs to close itself out but before doing so initiate the startup of another app. What is the best way to 1) issue startup request of second app (via broadcast or just startup activity), and 2) what is the best way to close out the first app. Finish comes to mind but I want to close out the whole app and not just the current activity. Thanks</p>
android
[4]
2,281,346
2,281,347
Why doesn't this PHP if statement work?
<p>I have a parameter in the url for birthday <code>?user_birth_day=05</code>, and I have the following codes:</p> <pre><code>&lt;?php echo $_REQUEST['user_birth_day']; ?&gt; // this outputs 5 &lt;?php for ($i = 1; $i &lt;= 31; $i++) : ?&gt; &lt;?php if($_REQUEST['user_birth_day'] === $i){ echo 'BINGO'; } ?&gt; &lt;?php endfor; ?&gt; </code></pre> <p>The if statement simply prints nothing. Please help!</p>
php
[2]
4,675,790
4,675,791
javascript max size
<p>I have a local html-site (on CD, memory stick or disk). In this site I perform extensive search operations which need a lot of data, about 10 MB. Storing the data in HTML-code and keeping them invisibly works, but makes loading very slow (presumably because of the parsing time needed by the browser).</p> <p>An alternative are javascript objects in .js-files. But I found with different browsers (FF, Opera, Safari), if a javascript file has more than 100 KB, the data are no more recognized. This size is far insufficient for my case. Is there a possibility to extend that limit?</p>
javascript
[3]
180,672
180,673
Elegantly iterating over string replacement
<p>Say I have a string that looks like</p> <pre><code>'one, two, three,' </code></pre> <p>What is a pythonic way of iterating through replacing <strong>','</strong> with <strong>'.'</strong> one at a time? Ideally the return value of the function would look like:</p> <pre><code>['one. two, three,' , 'one, two. three,' , 'one, two, three.'] </code></pre> <hr> <p>Reasoning for selected answer, thanks for contributing!</p> <pre><code>import timeit def one(s): b = ["%s.%s" % (s[:i], s[i+1:]) for i, c in enumerate(s) if c == ","] def two(s): b = [s[:i] + "." + s[i+1:] for i in range(len(s)) if s[i] == ","] def thr(s): b = [s[:i] + "." + s[i+1:] for i, c in enumerate(s) if s[i] == ","] def fou(s): ss = s.split(',') b = [','.join(ss[:i]) + '.' + ','.join(ss[i:]) for i in range(1,len(ss))] a = 'one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,' print(timeit.timeit('one(a)', 'from __main__ import one, a', number = 1000000)) print(timeit.timeit('two(a)', 'from __main__ import two, a', number = 1000000)) print(timeit.timeit('thr(a)', 'from __main__ import thr, a', number = 1000000)) print(timeit.timeit('fou(a)', 'from __main__ import fou, a', number = 1000000)) # C:\dev\goddangit&gt;python timin.py # 14.3008527857 # 11.8759967856 # 13.3739626708 # 18.8536401851 </code></pre>
python
[7]