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
1,704,919
1,704,920
Using jquery, how can I select all the DIVs in my document with ID names containing specific text?
<p>Using jquery, how can I select all the DIVs in my document with ID names containing specific text?</p> <p>I want to select all the elements that contain 'parent', the problem is the string parent might be in the middle of the string.</p> <p>I've been trying to use:</p> <pre><code>var allcontent_collection = $('div[id^=.*parent.*]') </code></pre> <p>It is not working. Should it or am I completely wrong in my approach?</p>
jquery
[5]
303,122
303,123
hierarchy is not working for my device
<p>when I run hierarchy in terminal. it can show the interface of it, but can not connect to my device.And it can connect to virtual emulator. It remind me in terminal like that,</p> <ol> <li>Adb rejected forward command for device 172.18...... unknown host service</li> <li>missing forward port for 172.18.....</li> <li>unable to get view server protocal version from device 172.18....</li> </ol> <p>How can it show my view structure of my device in the hierarchy viewer. Can anyone help me ?or anyone who knows where to find the knowledge of the hierarchy. thanks in advance.</p>
android
[4]
4,855,126
4,855,127
Constant value calculation
<p>I have an hpp file with following code:</p> <pre><code>const float PixelsPerMeter = ConfigManager-&gt;Get&lt;float&gt;("koef", 100.0f); inline const float Meters2Pixels(float meters) { return meters * PixelsPerMeter; } inline const float Pixels2Meters(float pixels) { return pixels / PixelsPerMeter; } const float ScreenArea = Pixels2Meters(ScreenSizeX) * Pixels2Meters(ScreenSizeY); </code></pre> <p>It worked before, but now <code>ScreenArea</code> = <code>inf</code> somehow. I use it from static function. I put a breakpoint in that function and print out the value of <code>PixelsPerMeter</code>(100.0), <code>ScreenSizeX</code> and <code>ScreenSizeY</code>. Everything is okay, but <code>ScreenArea</code> is calculated wrong.</p> <p>When I write directly <code>Pixels2Meters(ScreenSizeX) * Pixels2Meters(ScreenSizeY)</code> instead of using <code>ScreenArea</code> constant everything works.</p> <p>How it could be?</p>
c++
[6]
197,977
197,978
How do I get first element rather than using [0] in jquery
<p>I'm new to JQuery, appologies if this is a silly question. When I use it find an element using the id, I know theres always one match and in order to access it I would use the index [0]. Is there a better way of doing this? For e.g.</p> <pre><code>var gridHeader = $("#grid_GridHeader")[0]; </code></pre>
jquery
[5]
2,747,104
2,747,105
PHP - get everything after the #?
<p>I've got a flash file (that I can't edit) that is making erroneous requests to a file ending in a #. So the link where the file is being accessed is /files/flash/, so the requests are being made for /files/flash/#</p> <p>Is there any way for me to detect the # in the link so that I can have those pages not load?</p>
php
[2]
2,761,722
2,761,723
buttons and levels
<p>I have a class where I add some buttons in code. I am adding this button click on my second button. I want to adding this buttons one above second. I mean: I cick on the button and first button is adding to layout, I click second time and this second button add but he must be uder this first. Under I mean that first button cover second and I can't see second.. I don't want to see that second button. I click third time and third button is adding under second button. How I can do that in code? I know How add buttons but I don't know how to do first button was above second.</p>
android
[4]
3,323,410
3,323,411
How to get a object from another module?
<p>A.py</p> <pre><code># logging object logger = "" def log(): """ a log handle """ global logger, doc_log import logging.handlers logger = logging.getLogger("autons_log") logger.setLevel(logging.DEBUG) MAX_SIZE = 800 * 1024 * 1024 LOG_PATH = doc_log + "/autons_log.log" fh = logging.handlers.RotatingFileHandler(LOG_PATH, maxBytes=MAX_SIZE, backupCount=8) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) logger.addHandler(fh) def get_log(): """ get the object of logger """ global logger return logger </code></pre> <p>and B.py</p> <pre><code>def hello(): """ """ import autons_nc print autons_nc.get_log() print type(autons_nc.get_log()) autons_nc.get_log().debug('hello') </code></pre> <p>I want to use the object of logger in B.py,But this way can't work. the type of get_log() is "type 'str'" not "class 'logging.Logger'".</p> <p>So, another way can solve it? Thank you</p> <p>By the way, autons_nc.py is A.py</p>
python
[7]
3,250,966
3,250,967
System.ServiceModel disappear
<p>After installing .Net Framework 4.0 it seems like I cannot find System.ServiceModel in .Net tab through "Add Reference..." by using VS2008. But you can see it and add it in VS2010 version.</p> <p>Can someone tell me why, and how I can have both version, and still can use it in VS2008?</p> <p>Thanks</p>
c#
[0]
4,319,995
4,319,996
How to get mp3 file details from remote folder file using php?
<p>I want to know how to get mp3 file details like artist, title, album etc.</p>
php
[2]
2,143,530
2,143,531
Limit number of results for glob directory/folder listing
<p>How would I go about limiting the number of directory results/pdfs to, say 8, in the following code?</p> <pre><code>$counter = 0; foreach (glob("/directory/*.pdf") as $path) { //configure path $docs[filectime($path)] = $path; } krsort($docs); // sort by key (timestamp) foreach ($docs as $timestamp =&gt; $path) { echo '&lt;li&gt;&lt;a href="/directory/'.basename($path).'" class="'.($counter%2?"light-grey":"").'" target="_blank"&gt;'.basename($path).'&lt;/a&gt;&lt;/li&gt;'; $counter++; } </code></pre> <p>This is probably really easy but I can't seem to be able figure it out - thanks in advance, S.</p>
php
[2]
5,639,073
5,639,074
How do I access an object property with a string variable that has the name of that property?
<p>How do I do this in C#?</p> <pre><code>using System; namespace TestProperties28373 { class Program { static void Main(string[] args) { Customer customer = new Customer { FirstName = "Jim", LastName = "Smith", Age = 34}; Console.WriteLine(customer.FirstName); string propertyName = "FirstName"; Console.WriteLine(customer.&amp;&amp;propertyName); //PSEUDO-CODE Console.ReadLine(); } } class Customer { public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; } } } </code></pre>
c#
[0]
4,605,369
4,605,370
Event handling not working in Python 3.3.0?
<p>I tried running the chapter 15 programs that came with Object-Oriented Programming in Python by Goldwasser &amp; Letscher. Chapter 15 deals with event handling. For some reason, it won't work. It always crashes the program when I run it. My Python version is 3.3.0 and the specific code is the following:</p> <pre><code>from cs1graphics import * class BasicHandler(EventHandler): def handle(self, event): print( 'Event Triggered') if __name__ == '__main__': simple = BasicHandler() paper = Canvas() paper.addHandler(simple) </code></pre> <p>When I run this program, it crashes Python immediately. Why's that?</p> <p>EDIT: I downloaded Python 2.7.3 just to try this out in that version and it worked! So the problem is that there's something different in Python 3.3.0 that's causing this program to crash, but I haven't got a clue as to what is or should be different. Please help!</p>
python
[7]
5,145,637
5,145,638
calling resource menu into other activity
<p>Please help me how can i call a menu resource in other activity . Here is code of main activity </p> <pre><code>public class ControlMenu extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings: Intent intent = new Intent(this, ShowSettings.class); startActivity(intent); break; case R.id.services: Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show(); break; case R.id.another: } return true; } </code></pre> <p>here is menu resource </p> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:id="@+id/Quit" android:title="Quit" android:icon="@drawable/icon" /&gt; &lt;item android:id="@+id/settings" android:title="Settings" android:icon="@drawable/icon" /&gt; &lt;item android:id="@+id/services" android:title="Services" android:icon="@drawable/icon" /&gt; &lt;/menu&gt; </code></pre> <p>i can call it in the other activity by writing the main activity code but for that i have rewrite the case statements as well so guide me how can i solve it out .</p>
android
[4]
1,774,383
1,774,384
Remove single quote character escaping
<p>I have a string like this</p> <pre><code>This is\' it </code></pre> <p>I would like it to look like this</p> <pre><code>This is' it </code></pre> <p>Nothing I do seems to work</p> <pre><code>&gt; "This is\' it".replace(/\\'/,"'"); 'This is\' it' &gt; "This is\' it".replace("'",/\\'/); 'This is/\\\\\'/ it' &gt; "This is\' it".replace("\'","'"); 'This is\' it' &gt; "This is\' it".replace("'","\'"); 'This is\' it' </code></pre> <p>UPDATE: This is a little hard to wrap my head around but I had my example string inside an array something like.</p> <pre><code>&gt; ["hello world's"] [ 'hello world\'s' ] </code></pre> <p>It automatically happens like so:</p> <pre><code>&gt; var a = ["hello world's"] undefined &gt; a [ 'hello world\'s' ] &gt; a[0] 'hello world\'s' &gt; console.log(a[0]) hello world's undefined &gt; console.log(a) [ 'hello world\'s' ] undefined &gt; </code></pre>
javascript
[3]
1,910,239
1,910,240
How to get data using SAX parsing in android
<p>Can any body show how to get the data from xml document using SAX parsing for below XML example.</p> <pre><code>&lt;root&gt; &lt;parent&gt; &lt;child1&gt;xyz&lt;/child1&gt; &lt;child2&gt;abc&lt;/child2&gt; &lt;/parent&gt; &lt;/root&gt; </code></pre> <p>for this how can we write the sax parsing code in android.</p> <p>Thanks for helping...</p>
android
[4]
4,898,595
4,898,596
Using jQuery to get a select box value with the selectedindex
<p>Is it possible with jQuery to get the value of a select box item based on the selected index? I ask because what I actually need is the value of the items before and after the current selectedindex for next/previous buttons. This is the code I tried but it did not work.</p> <pre><code>var my_value = $('#my_element_id').attr("selectedIndex").val(); </code></pre>
jquery
[5]
2,371,515
2,371,516
Display AlertDialog as system overlay window from Service
<p>I have issue with displaying AlertDialog from Service. I am able to display custom layout window using Toast or using WindowManager(TYPE_SYSTEM_ALERT or TYPE_SYSTEM_OVERLAY). But, I do not want to use custom layout, I prefer to use nice AlertDialog GUI directly.</p> <p>Scenario:</p> <ul> <li>Running Service. No active Activity present.</li> <li>On some external event, Service sends Notification</li> <li>When user press Notification, Service is informed via PendingIntent and AlertDialog should be displayed (created with <code>AlertDialog.Builder(this)</code>)</li> </ul> <p>Error:</p> <pre><code>ERROR/AndroidRuntime(1063): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application </code></pre> <p>Searching for the answer lead me to impression that I am trying something that is currently not possible (Android 2.2). Or maybe it is.</p>
android
[4]
1,065,063
1,065,064
How to set the Password Hint when setting Windows Account Password using C#
<p>I have .NET application, that is intended to set password or change password for existing Windows User Account. I have done the coding to Set/Change password and it works fine. My problem is that , while we Set new password for User Account, we need to create Password Hint, but is there any way to save Password Hint in my C#.NET Application?</p> <p>Can I make this coding OS independent i.e. work on both Win7 and WinXP?</p>
c#
[0]
2,502,468
2,502,469
python problems with integer comparision
<p>I'm using a function in a card game, to check the value of each card, and see if it is higher than the last card played.</p> <pre><code>def Valid(card): prev=pile[len(pile)-1] cardValue=0 prevValue=0 if card[0]=="J": cardValue=11 elif card[0]=="Q": cardValue=12 elif card[0]=="K": cardValue=13 elif card[0]=="A": cardValue=14 else: cardValue=card[0] prevValue=prev[0] if cardValue&gt;prevValue: return True elif cardValue==prevValue: return True else: return False </code></pre> <p>The problem is, whenever I get a facecard, it doesnt seem to work. It thinks 13>2 is True, for example</p> <p>edit: sorry, I meant it thinks 13>2 is False</p>
python
[7]
627,105
627,106
How to assign utube video url to android media player
<p>I want that when i will pass the <strong>utube url</strong> to media player it will automatically load the video and play in it. Example: <a href="http://www.youtube.com/watch?v=WAG8e_53le4" rel="nofollow">http://www.youtube.com/watch?v=WAG8e_53le4</a> This type of url i want to play in android media player</p>
android
[4]
274,941
274,942
Beginning Python printing out standard deviation
<p>I'm trying to figure out what's wrong with my code. Could anyone fix it?</p> <pre><code>def main(): fname = input("Enter filename:") infile = open(fname, "r") SD() def SD(): b= [] a = 5.0 r = len(b) for n in range(r-1): b.append((r[n] -a)**2) m = (float(b)/r)**0.5 print("The standard deviation is", m) main() </code></pre>
python
[7]
2,753,974
2,753,975
How to check alertview values
<p>This is my code :</p> <pre><code>self.myAlert = [[[UIAlertView alloc] initWithTitle:@"MNB" message:@"R u want to delete" delegate:self cancelButtonTitle:@"OK",nil otherButtonTitles:@"Cancel",nil] autorelease]; [myAlert show]; </code></pre> <p>Here I would like to process if OK button click and also for cancel button, I would like to redirect the page if OK button clicked....I need the coding, IF condition statement when OK button clicked.....pls help me....</p>
iphone
[8]
5,093,264
5,093,265
How do I convert a string to an array name (php)?
<p>I have 4 arrays, each with a question and answer. I want to select a random question/answer array. Here is my code:</p> <pre><code>&lt;?php $query_1 = array("What is two plus three?", "5"); $query_2 = array("What is four plus two?", "6"); $query_3 = array("What is seven plus one?", "8"); $query_4 = array("What is six plus three?", "9"); $rand_key = rand(1,4); $current_query = ('$query_'.$rand_key); $question = $current_query[0]; print $question; ?&gt; </code></pre> <p>$question simply prints "$" rather than the first element of the array. How do I get $question to print the first element of the array?</p> <p>-- yes, I'm a php noob.</p>
php
[2]
2,100,448
2,100,449
Statistical funcation in C#
<p>I am doing some work in C# to calculate the binomial probability density function of some variables. Just wandering is there any package I can use?</p> <p>Thanks in advance</p>
c#
[0]
983,051
983,052
A variable references bug?
<p>I have a cannot understand problem, the following code why is print Array ( [a] => 1 [b] => 2 [c] => 3 [d] => ) , I didn't change the $info variable but why it changed?</p> <pre><code>&lt;?php function ifSetOr(&amp;$a, $b = null) { return isset($a) ? $a : $b; } $info = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3); ifSetOr($info['d']); print_r($info); //Array ( [a] =&gt; 1 [b] =&gt; 2 [c] =&gt; 3 [d] =&gt; ) ?&gt; </code></pre>
php
[2]
2,803,215
2,803,216
Why is the second variable passed as a reference and const
<p>Why isn't <code>first</code> passed as a reference and const as well?</p> <pre><code>template &lt;typename Iterator&gt; int distance(Iterator first, const Iterator &amp; last) { int count; for ( ; first != last; first++) count++; return count; } </code></pre>
c++
[6]
4,362,016
4,362,017
how can i save a text file without typing ".txt" at the end?
<p>My Program (c++):</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;cstdlib&gt; using namespace std; float x, y, z; char d[20]; int main() { cin.getline &gt;&gt;d; x=111; y=222; z=333; ofstream meuarquivo; meuarquivo.open (d".txt"); meuarquivo &lt;&lt; x &lt;&lt; "\n"; meuarquivo &lt;&lt; y &lt;&lt; "\n"; meuarquivo &lt;&lt; z &lt;&lt; "\n"; meuarquivo.close (); return 0; } </code></pre> <p>I want to write something like "ThatsMyProgram", and I want the program to save this file as "ThatsMyProgram.txt". How can I do that?</p>
c++
[6]
5,366,574
5,366,575
Using jQuery to toggle DIV in next row
<p>I'm trying to toggle the build_files_toggle classed div in the next row when you click the build_files_toggld classed link above it. I can get the next row to collapse with $(this).parent().parent().next().slideToggle(30), but when I add the '.build_files_toggle' it doesn't work... and it's killing me. I even tried $(this).parent().parent().next().children('.build_files_toggle').slideToggle(30); But no luck! Any idea here would be great.</p> <p>Hell even a really good tutorial on all the jquery selectors would be nice!</p> <pre><code> $(".build_files_toggle").click(function() { $(this).parent().parent().next('.build_files_toggle').slideToggle(30); }); &lt;div class="buildGroup" id="RecentBuilds"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt; Build Date &lt;/th&gt; &lt;th&gt; Built By &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Aug 22nd 3:11 pm &lt;/td&gt; &lt;td&gt; &lt;a href="#" class="build_files_toggle" &gt;View&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;div id="build_files1" class="infoBox_build_files"&gt; This is a block of text. This is a block of text. This is a block of text. This is a block of text. This is a block of text. This is a block of text. This is a block of text. This is a block of text. &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
jquery
[5]
3,169,662
3,169,663
Java Class<T> static method forName() IncompatibleClassChangeError
<pre><code>private static Importable getRightInstance(String s) throws Exception { Class&lt;? extends Importable&gt; c = Class.forName(s).asSubclass(Importable.class); Importable i = c.newInstance(); return i; } </code></pre> <p>which i can also write</p> <pre><code>private static Importable getRightInstance(String s) throws Exception { Class&lt;? extends Importable&gt; c = (Class&lt;? extends Importable&gt;)Class.forName(s); Importable i = c.newInstance(); return i; } </code></pre> <p>or</p> <pre><code>private static Importable getRightInstance(String s) throws Exception { Class&lt;?&gt; c = Class.forName(s); Importable i = (Importable)c.newInstance(); return i; } </code></pre> <p>where Importable is an interface and s is a string representing an implementing class. Well, in any case it gives the following:</p> <pre><code>Exception in thread "main" java.lang.IncompatibleClassChangeError: class C1 has interface Importable as super class </code></pre> <p>Here is the last snippet of the stack trace:</p> <pre><code> at java.lang.Class.forName(Class.java:169) at Importer.getRightImportable(Importer.java:33) at Importer.importAll(Importer.java:44) at Test.main(Test.java:16) </code></pre> <p>Now, class C1 actually implemens Importable and i totally don't understand why it complaints.</p> <p>Thanks in advance.</p>
java
[1]
2,440,479
2,440,480
activate events onclick of browser's back button in jquery
<p>Im looking for a simple cross-browser plugin or method that can help me do this :</p> <pre><code>$('#clear_window').click(function(){ $('#window').fadeOut(50); var activeTab = $("ul.tabs li.active").find("a").attr("href"); $(activeTab).fadeIn(50); }); </code></pre> <p>but on the click of the browsers back button not on the #clear_window click</p>
jquery
[5]
4,997,843
4,997,844
HTML Format in .Net TextBox
<p>How I can display HTML formatted text in .Net TextBox?</p>
asp.net
[9]
2,979,478
2,979,479
Changing the value of a RadioButtonList using jQuery
<p>I've searched around and found multiple answers for this, but none of them have worked for me. I'm using a RadioButtonList inside a repeater control. Here is my jQuery function.</p> <pre><code>$("[name$='$PlanSelectionRbtnLst']").click(function () { alert($(this).val()); //this works $("[name$='$PlanSelectionRbtnLst']").find("input[value='-1']").attr("checked", true); // this doesn't }); </code></pre> <p>This is correctly alerting me the value I selected when I click on any radio button, but I am not able to change all of the RadioButtonList's selected button to the -1 value. If it matters, my script is in a master page.</p> <p>EDIT: As requested, here a small snippet of the rendered html:</p> <pre><code>&lt;table id="MainContent_BenefitsRpt_PlanSelectionRbtnLst_2&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt; &lt;input name="ct100$MainContent$BenefitsRpt$ct103$PlanSelectionRbtnList" id="MainContent_BenefitsRpt_PlanSelectionRbtnLst_2_0_2" type="radio" value="9"/&gt; &lt;/td&gt; &lt;tr&gt; &lt;/tbody&gt; </code></pre>
jquery
[5]
3,266,057
3,266,058
upload image out side site root directory
<p>I want to upload image out side site root directory using php? can any one tell me that how I give path of directory out side root for image upload ????</p>
php
[2]
620,620
620,621
C# naming conventions
<p>Regarding C# naming, if I was writing a library related to the Windows API is there any strong convention toward either WindowsApi or WindowsAPI or is it just personal preference?</p>
c#
[0]
2,844,499
2,844,500
Add timeout in receiving message - socket
<p>I have method for sending message over socket and receiving answer. How to put timer, if there is no answer for example 1 sec to put information timeout ?</p> <pre><code>public boolean SendForceMessage(final ForceMessageTCP message) { boolean result = true; System.out.println("******************SendForceMessage**********************************"); new Thread() { public void run() { try { System.out.println("IPADDRESS="+ipAddress); System.out.println("PORT="+port); System.out.println("Is reachable="+Ping()); for(int i=0;i&lt;message.ToBytes().length;i++) System.out.println("FRAGMENT["+i+"]="+message.ToBytes()[i]); socket = new Socket(ipAddress, port); OutputStream socketOutputStream = (OutputStream) socket .getOutputStream(); socketOutputStream.write(message.ToBytes()); InputStream socketInputStream=(InputStream)socket.getInputStream(); byte[] buffer=new byte[256]; int numberReceived=socketInputStream.read(buffer); if(numberReceived!=-1) new FDResponseMessage(buffer); socket.close(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }.start(); return result; } </code></pre>
java
[1]
336,597
336,598
jQuery - Change color on click
<p>I'm looking at some jQuery because I want to create a div that changes color when you click it. </p> <p>And I've done that with: </p> <pre><code>$(function() { $('.star').click(function(){ $(this).css('background', 'yellow'); }); }); </code></pre> <p>And it works perfectly! But I want it to remove the background color, when you click it one more time. Is that possible, and how would you do something like that? </p>
jquery
[5]
2,063,915
2,063,916
How to show the default alert message in JQGrid while implementing custom buttons?
<p>In form editing in jqgrid if we do not select any row for editing an message box show automatically asking to select any row for editing.</p> <p>I want to show the same message window while doing some custom fucntions by implementing the custom button in my jqgrid?</p> <p>Is there any way to call any method or implement any event to show the message window?</p> <p>Thanks in advance :)</p>
jquery
[5]
5,614,962
5,614,963
Final keyword in for statement
<p>I was reading some code found on the web and fell on these lines (java):</p> <pre><code>private List&lt;String&gt; values; [...] for (final String str : values) { length += context.strlen(str); } </code></pre> <p>What is the advantage of declaring a variable final in a for loop ? I thought the variable specified in the for loop was already read-only (e.g. can't assign something to 'str' in the above example). </p> <p>Thx</p>
java
[1]
2,217,724
2,217,725
Summing columns of a txt file in java
<p>I have a text file that reads:</p> <p>1 2 3 4 5</p> <p>6 7 8 9 1</p> <p>8 3 9 7 1</p> <p>9 3 4 8 2</p> <p>8 7 1 6 5</p> <p>where each number is separated by a tab.</p> <p>My question is, is there a simple way to sum the columns of numbers using java? I want it to sum 1+6+8+9+8, 2+7+3+3+7, etc. I am reading the file using:</p> <pre><code> public static boolean testMagic(String pathName) throws IOException { // Open the file BufferedReader reader = new BufferedReader(new FileReader(pathName)); // For each line in the file ... String line; while ((line = reader.readLine()) != null) { // ... sum each column of numbers } reader.close(); return isMagic; } public static void main(String[] args) throws IOException { String[] fileNames = { "MyFile.txt" }; </code></pre> <p>}</p>
java
[1]
1,696,063
1,696,064
How to associate each item in ListView with id from database
<p>I have a <code>ListView</code> object with <code>Adapter</code> extended from <code>CursorAdapter</code>. There are only <code>(ListView l, View v, int position, long id)</code> parameters in <code>onListItemClick()</code> method. I need to query my database with <code>_id</code> for currently chosen list's <code>item</code>. But I don't want the <code>_id</code> of the row from <code>database</code> to be shown in the list's row. So I created additional <code>TextView</code> in <code>list_item.xml</code> and made it invisible by setting its <code>width</code> and <code>height</code> to <code>0px</code>. So on <code>newView()</code> I can associate the list's item with it's <code>_id</code> in <code>database</code>.</p> <p>I find this approach to be ugly a bit. Might be there are any other more neat solution? </p>
android
[4]
3,694,595
3,694,596
How to determine if end of URL matches "/my-phrase"
<p>I need to execute conditional code if the last part of the URL string is /my-phrase</p> <p>How can I parse the URL for a match after the last "/" character in the URL string?</p> <pre><code>if(end of URL is "/my-phrase") { //dosomething;} else {//something else;} </code></pre>
php
[2]
5,603,640
5,603,641
possible to extract functions from a javascript file?
<p>Not sure if this is the right approach of if this even a "good" question, but I'm loading a javscript as part of a plugin style architecture and I have the following problem:</p> <p>If a particular node has a reference to a plugin, I want to load that plugin per the url provided via the json description of that plugin. the description will have something like the following (or a functional equivalent):</p> <pre><code>{ "pluginSrc" : "http://mysite.com/plugins/1204.js", "configData" : { "someData", "someValue", "someMoreData", "etc" } } </code></pre> <p>When the javascript loads, I'll have an onload handler that will check to see if a function name exists on the window object and if so, create a new instance of that function and pass it the config data (more or less), this part works very well, with a few exceptions.</p> <p>Sometimes I do not have a reference to the name of the function that I need to invoke and there is no way to get it from the json. What would be ideal, is if I could tell which function was added to the window object on the script's onload callback and create an instance of that function. Is this possible? I only need to worry about modern browsers, particularly webkit. Apologies if the question isn't clear, I'd be happy to clarify, but producing a fiddle might be difficult as there's a lot of code to write to reach a minimal example.</p> <p>What I'm thinking about so far is to create some kind of global variable in the loaded script file like</p> <pre><code>function MediaAnalytics(){}; var LoadedClass = MediaAnalytics; </code></pre> <p>and just creating an instance of LoadedClass when the script is loaded, but this falls short of a panacea because I will not always be writing the plugin.</p> <p>EDIT: These scripts will most likely not be from the same domain.</p>
javascript
[3]
2,777,822
2,777,823
Android Eclipse: Class File Editor - Source not found
<p>i am working on Android project using Eclipse </p> <pre><code>Eclipse IDE for Java Developers Version: Indigo Service Release 1 Build id: 20110916-0149 </code></pre> <p>so when i try to debug the code after few step over (f6) the code i get this windows and after that it does not do anything... what should i do to fix this? anybody?</p> <p><img src="http://i.stack.imgur.com/AJLAp.png" alt="enter image description here"></p>
android
[4]
2,664,910
2,664,911
OnItemClickListener With OnItemLongClickListener
<p>how can i use both OnItemClickListener and OnItemLongClickListener or just disable longclick on a list view? i've override OnItemLongClickListener and when i return true on onItemLongClick the longclick will disable but OnItemClickListener wont respond anymore.</p> <pre><code>DailyReportList.setOnItemLongClickListener(new OnItemLongClickListener(){ @Override public boolean onItemLongClick(AdapterView parentView, View childView, int position, long id) { return true;}}); registerForContextMenu(DailyReportList); DailyReportList.setOnItemClickListener(new OnItemClickListener(){ @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { arg1.showContextMenu(); FillTxtWithListItems(arg1); }}); </code></pre>
android
[4]
461,523
461,524
Copy value from one textbox to another using submit button
<p>I know this can be accomplished by Javascript, and I am learning so please tell me, when I click an update button I want the text from a textbox to be copied into another one.</p>
javascript
[3]
4,141,910
4,141,911
Server Side Push In PHP (Commet)
<p>I have banged my head loads of time but couldn't find any good commet example. Me and my friend are developing a small chat software in PHP, I need the commet thing urgently please guys if anybody can explain that in simple words. I will be grateful. Thank you</p>
php
[2]
2,139,320
2,139,321
Apply BROWSABLE intent category to a broadcast receiver
<p>I looked up the following intent filter for an activity in <a href="https://github.com/commonsguy/cw-advandroid/blob/master/Introspection/URLHandler/AndroidManifest.xml" rel="nofollow">commonsware samples</a></p> <pre><code>&lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;category android:name="android.intent.category.BROWSABLE" /&gt; &lt;data android:host="www.this-so-does-not-exist.com" android:path="/something" android:scheme="http" /&gt; &lt;/intent-filter&gt; </code></pre> <p>However, the same intent filter doesn't work when applied to a broadcast receiver.</p> <p>Could you point out whether it's possible to apply it to a broadcast receiver and if so where to look for a fix?</p> <p>Thanks.</p>
android
[4]
5,474,675
5,474,676
how to parse the array of json string using gson in android
<pre><code>{ "serviceType":"IMAGE_ANDROID", "parameters":[ [ { "itemId":"it003376", "itemNameInEng":"8th Chennai International Film Festival Photos", "itemSmallImage":"http://122.183.217.134:8080/sivajitv/photos/20101216001017.jpg", "count":"110" }, { "itemId":"it003375", "itemNameInEng":"Actress Aishwarya Rai Special Photos", "itemSmallImage":"http://122.183.217.134:8080/sivajitv/photos/20101215230917.jpg", "count":"7" }, { "itemId":"it003374", "itemNameInEng":"Actor Srikanth Flag off The Avon Greenathon Bicycle Rally ", "itemSmallImage":"http://122.183.217.134:8080/sivajitv/photos/20101215212620.jpg", "count":"43" }, { "itemId":"it003373", "itemNameInEng":"Kadamai Kanniyam Kattupadu Movie Launch Photos", "itemSmallImage":"http://122.183.217.134:8080/sivajitv/photos/20101213001908.jpg", "count":"32" }, { "itemId":"it003372", "itemNameInEng":"Kanden Audio Launch Photos", "itemSmallImage":"http://122.183.217.134:8080/sivajitv/photos/20101210044334.jpg", "count":"126" } ] ] } </code></pre> <p>this is my response</p> <p>i want to parse the parameters from this response and i need to parse all data in parameter</p> <p>please provide me correct solution </p>
android
[4]
5,487,363
5,487,364
How would I represent the following menu structure in JavaScript?
<pre><code>Soccer Australia Melbourne Sydney New Zealand Christchurch Tennis United Kingdom Kensington London Manchester </code></pre> <p>I have tried multidimensional arrays however it becomes awkward because of the different lengths. I have also experimented with key/value pairs however again I encountered difficulty because in a way there are only values and no keys. I have tried to represent the hierarchy visually. To clarify Sydney is a child of Australia. Australia is a child of Soccer. Soccer is a sibling of Tennis and so on.</p> <p>Edit: I'm looking for a solution that does not require any knowledge of the actual data. In other words I could swap out "Soccer" with "Baseball" and a simple algorithm which just prints out the data structure should not break.</p>
javascript
[3]
327,634
327,635
Best way of capturing user email address on website
<p>I currently have a form that on a coming soon page on my web server that I need to capture entered email addresses and send it to my email address e.g. <em>[email protected]</em>. </p> <p>What would be the best way of accomplishing this using PHP?</p> <pre><code>&lt;form method="post"&gt; &lt;input class="emailsubscribe mobile clearfix" type="text" name="mail" placeholder="Enter your email" onFocus="if(!this._haschanged) {this.value=''};this._haschanged=true;"/&gt; &lt;input class="emailsubscribe desktop clearfix" type="text" name="mail" placeholder="Enter your email to stay up to date" onFocus="if(!this._haschanged) {this.value=''};this._haschanged=true;"/&gt; &lt;input class="emailsubmit clearfix" type="submit" name="submit"/&gt; &lt;/form&gt; </code></pre> <p>Thanks in advance!</p>
php
[2]
4,140,584
4,140,585
How to access specific object in an array of DOM objects in jQuery?
<p>Ok so I wanna ask a simple jQuery question about arrays of objects. </p> <p>If I get all elements (for example all paragraphs) from an html page and store them in an array how can I access one of them to do stuff with it?</p> <p>For example let's say I have this html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Paragraph 1&lt;/p&gt; &lt;p&gt;Paragraph 2&lt;/p&gt; &lt;p&gt;Paragraph 3&lt;/p&gt; &lt;button id="myButton"&gt;Click here&lt;/button&gt; &lt;script src="jquery-1.6.2.min.js"&gt;&lt;/script&gt; &lt;script src="script.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is my script.js:</p> <pre><code>$(document).ready(function(){ $("#myButton").click(function(){ var $paragraphs = $("p"); $paragraphs.detach(); //Works fine, removes all elements //$paragraphs[0].detach(); //Doesn't work! }); }); </code></pre> <p>I'm trying to call detach on the first element of the array, so that I can remove the first paragraph but it doesn't seem to work...</p> <p>Is there any way to access the first paragraph without using id attributes?</p>
jquery
[5]
855,202
855,203
file.exists() returns false on Android
<pre><code> String filename = "file:///android_asset/Help_ja.html"; File f = new File(filename); if (!f.exists()) filename="file:///android_asset/Help_us.html"; webView.loadUrl(filename); </code></pre> <p>i load an HTML out of the assests folder, both files are there, when i tried this code:</p> <pre><code>filename="file:///android_asset/Help_us.html"; webView.loadUrl(filename); </code></pre> <p>it worked, but for some reason f.exists() returns false, i was thinking maybe its because a URL, but then how do i check if the file exists before i load it to the webView?</p>
android
[4]
558,957
558,958
How to deallocate pointer-to-pointer-types that point to pointer-types in heap that point to other objects in heap?
<p>So I decided to have some pointer fun tonight :)</p> <pre><code>CursorHBList::CursorHBList(UINT iNumHB) :m_ppCursorHB(nullptr) ,m_iNumHB(iNumHB) { if (iNumHB != 0) { m_ppCursorHB = new CursorHitBox* [iNumHB]; } } </code></pre> <p>so you can see, I've now dynamically allocated pointer-types.</p> <p>Those pointers will each point to another (single) object in the heap. (later on, not in code sample)</p> <p>So I've been wondering if I should delete all the pointer-to-object-types pointed to by the pointer-to-pointer-type first, and then delete[] the pointer-to-pointer-type?</p> <p>Or is there a better way?</p> <p>EDIT: Without using smart pointers...</p>
c++
[6]
5,364,069
5,364,070
how to convert array of live dom elements into live NodeList?
<p>For example I have this array object: <code>Object [object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement],[object HTMLDivElement]</code> and I need to change it to a kind of value that getElementsByTagName method returns, but without moving the nodes out of node tree into my new node list that is a live NodeList. My html elements in array ale already live and pointing to real elements in page, so for example adding an event is reflected in the page.</p>
javascript
[3]
5,489,974
5,489,975
Don't allow changing document.domain value
<p>I need to deny changing <code>document.domain</code>. Say, if I run this code at <em>foo.boo.com</em></p> <pre><code>Object.defineProperty(document, 'domain', { get: function () { return 'foo.boo.com'; } }); </code></pre> <p>and then will it be possible to set <code>document.domain</code> to <em>boo.com</em>? I ask because I want to deny changing <code>document.domain</code> by untrusted code. </p>
javascript
[3]
937,110
937,111
operator new with negative size
<p>In C++11 if we try to allocate array with negative size using global operator new, it will throw std::bad_array_new_length, but what about C++98 / C++03? Is it UB or will throw std::bad_alloc?</p> <pre><code>int main() { int* ptr = new int[-1]; } </code></pre>
c++
[6]
3,880,599
3,880,600
Problems with onResume()
<p>I am developing the typical RSS application. In the method onCreate define the layout to paint the screen and in the method onResume do a query to a URL to extract the data. Should paint the screen and then check the URL, right? because I do not paint the screen until the request to the URL has been answered.</p> <p>How do I get paint the screen and before refer to the URL? Thanks a lot.</p>
android
[4]
206,020
206,021
stop to go on onPostExecute() if parsing exception onpreexecute() occurs
<p>am using asynchronous task for hitting the web service url and retrieve the result from server but some time in onPreExecute() method if parsing exception occurs i handle it on catch() method,now i want to Halt the processing next means execution not go to OnpostExecute() method ,so how to stop execution process for going it to OnPostExecute() my code are below </p> <pre><code> @Override protected void onPreExecute() { dialog = new ProgressDialog(MainMenu.this); dialog.setMessage("Processing..."); dialog.setIndeterminate(true); dialog.setCancelable(false); dialog.show(); } @Override protected void onPostExecute(final Boolean success) { if (dialog.isShowing()) { dialog.dismiss(); } Intent i = new Intent(MainMenu.this, filterpagetabs.class); startActivity(i); } @Override protected Boolean doInBackground(final String... args) { try{ try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); URL sourceUrl = new URL( "http://www.mobi/iphonejh/output.php?estado=1"); MyXMLHandler myXMLHandler = new MyXMLHandler(); xr.setContentHandler(myXMLHandler); xr.parse(new InputSource(sourceUrl.openStream())); } catch (Exception e) { System.out.println("XML Pasing Excpetion = " + e); } </code></pre> <p>}</p>
android
[4]
2,913,339
2,913,340
How would i figure out the price difference efficiently with PHP?
<p>I have this <a href="http://posnation.com/shop_pos/step2/Bakery" rel="nofollow">page</a> and if you scroll to the second "Customize" in the middle of the page and you click you will see my print_r() for the products and the thing i am trying to do is figure out the difference in price between the selected and the other two products....all three products are in the array and if you look just below that you will see the radio buttons that i need....here is my php which looks awful...any suggestions </p> <pre><code>$current_price = $product[$selected_product]['product_price']; $standard_price = $product["standard"]['product_price'] - $current_price; $business_price = $product["business"]['product_price'] - $current_price; $premium_price = $product["premium"]['product_price'] - $current_price; if($standard_price == 0){ $standard_price = "included"; } if($standard_price &gt; 0){ $standard_price = "subtract " . $standard_price; }else{ $standard_price = "add " . $standard_price; } if($business_price == 0){ $business_price = "included"; } if($business_price &gt; 0){ $business_price = "subtract " . $business_price; }else{ $business_price = "add " . $business_price; } if($premium_price == 0){ $premium_price = "included"; } if($premium_price &gt; 0){ $premium_price = "subtract " . $premium_price; }else{ $premium_price = "add " . $premium_price; } </code></pre>
php
[2]
5,388,523
5,388,524
Android New layout wants to replace the old
<p>I'm new to android. When I try to create a new (landscape) layout in <code>layout-land folder</code>, it says:</p> <blockquote> <p>do you want to OVERWRITE the file res/layout/main.xml</p> </blockquote> <p>Why does it want to REPLACE another layout? In eclipse, I right click the layout-land folder and choose New -> Others -> XML layout file. But it wants to replace this with my original layout file. How come? Though I used the same name for landscape layout as main.xml but I know that shouldnt conflict.</p>
android
[4]
5,952,512
5,952,513
Animation : multiple/parallel transformations
<p>The animation class can achieve animations by transform graphs. The example:</p> <pre><code> Animation myAnimation_Translate; myAnimation_Translate=new TranslateAnimation(30.0f, -80.0f, 30.0f, 300.0f); startAnimation(myAnimation_Translate); </code></pre> <p>But, how do I achieve multiply transformation at same time? Maybe I need the graph moving and scaling at same time.</p>
android
[4]
4,713,262
4,713,263
Extending Linenarlayout height
<p>I have problem in displaying content in Linearlayout,how to extend layout height.when large number layout used for displaying content..</p>
android
[4]
2,653,940
2,653,941
date format yyyy-MM-ddTHH:mm:ssZ
<p>I assume this should be pretty simple, but could not get it :(. In this format Z is time zone. <br/> T is long time pattern <br/> How could I get a date in this format except by using </p> <pre><code>DateTime dt = DateTime.Now; Console.WriteLine(dt.ToString("yyyy-MM-ddTHH:mm:ssZ")); </code></pre> <p>in C#</p>
c#
[0]
3,620,362
3,620,363
DateTime getting todays Month in if statement
<p>I want to do an if statement if month == january for example load something else if month == april load something else. Can someone help please Thanks</p>
c#
[0]
2,093,535
2,093,536
I need some pointer tasks/challenges
<p>I struggle with learning. I have to practice, and keep practicing, in order for something to stick. I don't do much C++ (once every month maybe) so I am constantly going over the same stuff.</p> <p>I need some tasks to do so I can really understand pointers and their uses in the real world, rather than reading scenarios. I've created my own link list, but I want more advanced stuff like using pointer arithmetic and pointers and functions.</p> <p>If anyone could provide some real world tasks to deepen my knowledge and experience with pointers I would be thankful.</p> <p>I'm ok with data types because of my Java experience.</p> <p>Look forward to some challenges (not too hard mind).</p>
c++
[6]
3,320,705
3,320,706
Printing out each array element
<p>I have an array and I use <code>print_r</code> and this what happen:</p> <pre><code>Array ( [141] =&gt; 1 [171] =&gt; 3 [156] =&gt; 2 [241] =&gt; 1 [271] =&gt; 1 [256] =&gt; 1 [341] =&gt; 1 [371] =&gt; 1 [356] =&gt; 1 [441] =&gt; 1 [471] =&gt; 1 ) </code></pre> <p>How can I print out the index [141] and so on?</p>
php
[2]
2,070,848
2,070,849
C++ primitive for Handle
<p>I am implementing an opaque data structure that is internally an array of opaque data structures. Let's call them records. There will be multiple queries to different fields of a record each with the same key. I have a list of APIs of this form:</p> <pre><code>QueryFieldX(KEY key, FieldX&amp; Data) </code></pre> <p>Each query currently searches through the records with the key and then gets the Data.</p> <p>I want to change it to the following form:</p> <pre><code>GetHandleToRecord(KEY key, MYHANDLE handle); QueryFieldX(MYHANDLE handle, FieldX&amp; Data); </code></pre> <p>The advantage is that searching every single time through the records is eliminated. I can implement a MYHANDLE myself but I want to know if there is a good library / data structure / primitive in C++ that gives me an opaque handle that I can use.</p>
c++
[6]
3,585,295
3,585,296
Python function
<p>Here's my function: I need it to return False when it is not an integer or when it is not a number...now it still returns True both instances.</p> <pre><code>def isInt(x): if str(x): print "True" else: print "False" </code></pre>
python
[7]
1,081,563
1,081,564
How to Increment the cursor values?
<p>My database have 12 values i use the table layout with list view but in the second row its again started to show second value from the database </p> <pre><code> class NoteHolder { private Button b1 = null; private Button b2 = null; private Button b3 = null; NoteHolder(View row) { b1 = (Button) row.findViewById(R.id.one); b2 = (Button) row.findViewById(R.id.two); b3 = (Button) row.findViewById(R.id.three); } void populateFrom(Cursor c, NoteHelper helper) { b1.setText(helper.getNote(c)); c.moveToNext(); b2.setText(helper.getNote(c)); c.moveToNext(); b3.setText(helper.getNote(c)); } } </code></pre>
android
[4]
4,331,972
4,331,973
How to set Ringtone from raw folder resource
<p>I see multiple threads about doing this but they all differ in their approaches. Can someone tell me the definitive way to take a raw resource (i.e. "song.mp3") and set it as the ringtone on a phone? I know it goes something like: 1. Push the song to external storage. 2. Set ringtone using the absolute path of where the song saved in external storage.</p> <p>But if someone has some java that shows how this plays out, that would be great.</p>
android
[4]
3,529,078
3,529,079
How to access object
<p>I want alert object <code>key</code> name and its <code>value</code>. But it is not working.</p> <pre><code>$(function() { var james = {first: '1,2,3', second: '4,5,6' } $('a').click(function(){ alert(james[first]) }) }) </code></pre>
javascript
[3]
483,487
483,488
Loading user controls dynamically
<p>I have an aspx page and therein I have a dropdown control. Depending on the selected value, I need to load the user control that many times in the page. E.g..if first item is selected, I need to query DB and get how many subsections are their for this value and then load the user control that many times. It is working fine if I load the user controls in Page Load. However, If I want the view state to persist in these dynamically added user controls, I need to load them before load in Page_init event. However, when I try to do this in Page_Init, the viewstate for the dropdown has not been restored and I dont know how many usercontrols to load.</p> <p>Any suggestions?.</p>
asp.net
[9]
2,777,640
2,777,641
How to split WriteLine over multiple lines?
<p>This is an example of the syntax I tried and don't want to use <code>\n</code>.</p> <pre><code>Console.WriteLine("x" "x" "x" "x" "x"); </code></pre> <p>One call should yield:</p> <pre> x x x x x </pre>
c#
[0]
4,938,145
4,938,146
How I can use a handler to change the ImageView's picture after 2 sec, and 5?
<p>I have an ImageView, what shows one picture . I tried to use a thread, but it doesn't change the picture. Then I tried a handler, but it doesn't treat the sleep(int) method, so I can't increase the time, what elapsed. How can I make it? Can you write an example please?</p> <p>Here is my original code: </p> <pre><code>@Override public void onClick(View v) { // TODO Auto-generated method stub Thread timer = new Thread() { public void run() { int time = 0; while (time &lt;= 7000) { try { sleep(100); time =+ 100; if(time == 2000) { radar.setImageResource(R.drawable.radar_full); } if(time == 5000) { radar.setImageResource(R.drawable.radar_50); } if(time == 7000) { radar.setImageResource(R.drawable.radar_found); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }; timer.start(); }; }; </code></pre>
android
[4]
1,555,595
1,555,596
Python string function to strip the last comma
<p>Input</p> <pre><code>str = 'test1,test2,test3,' </code></pre> <p>Ouput </p> <pre><code>str = 'test1,test2,test3' </code></pre> <p>Requirement to strip the last occurence of ','</p>
python
[7]
4,194,190
4,194,191
Abstract getter with concrete setter in C#
<p>I'm trying to write an abstract base class for read-only collections which implement <code>IList</code>. Such a base class should implement the set-indexer to throw a <code>NotSupportedException</code>, but leave the get-indexer as abstract. Does C# allow such a situation? Here's what I have so far:</p> <pre><code>public abstract class ReadOnlyList : IList { public bool IsReadOnly { get { return true; } } public object this[int index] { get { // there is nothing to put here! Ideally it would be left abstract. throw new NotImplementedException(); } set { throw new NotSupportedException("The collection is read-only."); } } // other members of IList ... } </code></pre> <p>Ideally <code>ReadOnlyList</code> would be able to implement the setter but leave the getter abstract. Is there any syntax which allows this?</p>
c#
[0]
3,692,564
3,692,565
How to enforce that classes's instances only be allocated on the stack, but not on the heap
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/124856/how-do-i-prevent-a-class-from-being-allocated-via-the-new-operator-id-like-t">How do I prevent a class from being allocated via the &#39;new&#39; operator? (I&#39;d like to ensure my RAII class is always allocated on the stack.)</a> </p> </blockquote> <p>For C++, how to enforce that classes's instances only be allocated on the stack, but not on the heap, at compile-time?</p> <p>I think all data members and functions are allocated in stack unless they are declared by new operator. </p> <p>right ? </p> <p>Any help is really appreciated. </p>
c++
[6]
2,076,859
2,076,860
push notification for RSS Feed?
<p>I want to send push notification to my user,when will i update some information in my RSS Feed,Now i am using third party tool like urbanairship,but did not support RSS Feed,Have any third party tool for notification,please give some idea about that.</p> <p>Thanks, John</p>
android
[4]
2,991,896
2,991,897
TypeConverter/InstanceDescriptor failing when ASP.NET project with my user control is compiled/run
<p>I am having problem with TypeConverter/InstanceDescriptor.</p> <p>I have a class called MyClass</p> <pre><code>public class MyClass { private ICollection&lt;Color&gt; _colors; public MyClass(ICollection&lt;Color&gt; colors) { _colors = colors; } public MyClass(string colors) { if("MyColors".equals(colors)) { . . . } } . . . } </code></pre> <p>MyUserControl has property MyProperty of type MyClass.</p> <p>Now, when i drag and drop this property, and change its value so that xml code is generated. Now, i compile and end up with this error "Object reference not set to an instance of an object"</p> <pre><code>public static ColorGenerator FromString(object value) { TypeConverter tc = TypeDescriptor.GetConverter(typeof(MyClass)); if (tc.CanConvertFrom(typeof(string))) return tc.ConvertFrom(null, null, value) as MyClass; else return null; } . . . if(destinationType == typeof(InstanceDescriptor)) { MethodInfo mi = typeof(MyTypeConverter).GetMethod("FromString", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string) }, null); return new InstanceDescriptor(mi, new object[] { "MyColors" }, true); } . . . </code></pre> <p>If my logic is as follows, then i end up with "Unable to generate code for a value of type 'MyNamespace.MyClass'. This error occurred while trying to generate the property value for MyClass." error when compiled.</p> <pre><code>. . . if(destinationType == typeof(InstanceDescriptor)) { ConstructorInfo ci = typeof(MyClass).GetConstructor(new Type[] { typeof(string) }); InstanceDescriptor descriptor = new InstanceDescriptor(ci, new object[] { "LightColors" }); return descriptor; } . . . </code></pre> <p>Can anyone please explain to me what these errors mean, and why they are happening?</p> <p>Thanks a million in advance, Anony.</p>
c#
[0]
3,437,483
3,437,484
Convert input to a string in Python
<p>I want to wrap the colour input in quotes within python:</p> <pre><code>def main(): colour = input("please enter a colour") </code></pre> <p>So if I enter red into the input box it automatically makes it "red"</p> <p>I'm not sure how to do this, would it be something along the lines of:</p> <pre><code>def main(): colour = """ + input("please enter a colour") + """ </code></pre> <p>Kind regards</p>
python
[7]
1,970,465
1,970,466
Code for parsing an html file
<p>I want a java code for parsing a table from a html page.</p> <p>Can someone help me on this?</p>
java
[1]
2,436,699
2,436,700
Passing optional number of arguments into another function
<p>Say I have a function called <code>addUp</code> which takes any number of decimal arguments and returns the result of them all added together.</p> <p>If I have the following function:</p> <pre><code>function myTest(){ $args = func_get_args(); return addUp($args); } </code></pre> <p>If I call <code>myTest(1,2,3)</code> obviously this will not work as I'm only passing one argument to <code>addUp</code> and that is an array.</p> <p>Is there a way to pass all the arguments passed into <code>myTest</code> on into the <code>addUp</code> function (without editing the <code>addUp</code> function)?</p>
php
[2]
3,998,031
3,998,032
Signed INT Conversion of MSB ->LSB and LSB->MSB in C++
<p>I checked out the SWAR algorithm (<strong>S</strong>IMD <strong>W</strong>ithin <strong>A</strong> <strong>R</strong>egister) for reversing bit order of <code>unsigned int</code>s. Is there something similar for <code>signed int</code>?</p>
c++
[6]
2,629,186
2,629,187
Encrypt query string
<p>Iam trying to send EmployeeId in another page using query string but i want to send it in encrypted format.If anyone knows the answer pls send it soon.Any help is a great help.</p> <p>Thanks and Regards Sanjay Sharma </p>
asp.net
[9]
2,939,877
2,939,878
Problem with SimpleCursorAdapter
<p>I'm trying to create a list activity that uses a SimpleCursorAdapter, but it just won't work. I know I'm getting the cursor correctly because when I have it print out to text all the values are there and I know there's nothing wrong with the SimpleCursorAdapter class because when I used it with the Image Content Provider it displayed correctly. However, when I try to put the two together my application crashes when I try to open the activity. My source code is below.</p> <pre><code>package com.mao.crypt; </code></pre> <p>import android.app.ListActivity;</p> <p>import android.content.Intent;</p> <p>import android.database.Cursor;</p> <p>import android.database.sqlite.SQLiteDatabase;</p> <p>import android.os.Bundle;</p> <p>import android.view.View;</p> <p>import android.widget.ListView;</p> <p>import android.widget.SimpleCursorAdapter;</p> <p>public class OpenActivity extends ListActivity{</p> <pre><code>Cursor cursor; @Override public void onCreate(Bundle icicle){ super.onCreate(icicle); SQLiteDatabase db = new NotesDBHelper(getApplicationContext()).getReadableDatabase(); cursor = db.rawQuery("SELECT _id,title,text FROM notes ORDER BY title ASC", null); startManagingCursor(cursor); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, new String[]{"title","text"}, new int[]{android.R.id.text1, android.R.id.text2}); setListAdapter(adapter); } public void onDestroy(){ cursor.close(); } @Override public void onListItemClick(ListView l, View v, int position, long id){ cursor.moveToPosition(position); String title=cursor.getString(0); Intent data = new Intent(); data.putExtra("title", title); setResult(RESULT_OK,data); finish(); } </code></pre> <p>}</p>
android
[4]
5,224,962
5,224,963
Itunes conversion to HTC Android Thunderbolt - how to achieve
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://superuser.com/questions/47137/sync-android-with-itunes">Sync Android with iTunes</a> </p> </blockquote> <p>Just purchased HTC Thunderbolt: is there a program through Google that I can convert and manage my Tunes without using Itunes?</p>
android
[4]
5,034,252
5,034,253
What is the difference between ref and out
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/135234/difference-between-ref-and-out-parameters-in-net">Difference between ref and out parameters in .NET</a> </p> </blockquote> <p>I know that ref is used for passing the changed value of the variable outside of the function, but how is it different from out?</p>
c#
[0]
5,119,650
5,119,651
Get Rid of Duplicate Information in PHP
<p>Ok, so I've got a bit of a problem.</p> <p>I am scraping a site, and it will scrape two address boxes - each of which may have minor differences.</p> <p>One of the addresses is like this:</p> <pre><code>ONE MICROSOFT WAY REDMOND WA 98052-6399 425-882-8080 </code></pre> <p>And the other is like this:</p> <pre><code>ONE MICROSOFT WAY REDMOND WA 98052-6399 </code></pre> <p>I save the entire string for both (there's HTML tags around them in the original but I didn't think it was necessary to illustrate my point), and then separate based on those HTML tags. This means it processes each newline (i.e. ONE MICROSOFT WAY) as a separate variable.</p> <p>What I want to do is to see if there are duplicates between the addresses, the problem is that they're separate values in the first array, and then in the internal array (I'm not sure the terms for PHP, so bare with me), it is separating each of the two addresses line by line.</p> <p>So basically, is there a way to check for duplicate values?</p> <p>Here is sample data:</p> <pre><code>&lt;div class="mailer"&gt; Mailing Address &lt;span class="mailerAddress"&gt;ONE MICROSOFT WAY&lt;/span&gt; &lt;span class="mailerAddress"&gt;REDMOND WA 98052-6399&lt;/span&gt; &lt;div class="mailer"&gt; Business Address &lt;span class="mailerAddress"&gt;ONE MICROSOFT WAY&lt;/span&gt; &lt;span class="mailerAddress"&gt;REDMOND WA 98052-6399&lt;/span&gt; &lt;span class="mailerAddress"&gt;425-882-8080&lt;/span&gt; </code></pre>
php
[2]
349,781
349,782
cursor.rowcount gives 'int' object is not callable error
<p>i selected values from sqlite3 database and print the count of cursor.then it gives an error " 'int' object is not callable"</p> <pre><code> strq="select * from tblsample1" self.con = sqlite3.connect('mydb.sqlite') self.cur = self.con.cursor() self.cur.execute(strq) print(self.cur.rowcount()) </code></pre> <p>gives an error</p> <pre><code>TypeError: 'int' object is not callable </code></pre>
python
[7]
2,161,844
2,161,845
Open file from server and send to browser
<p>Hey, In my asp.net application I create pdf file and save it in App_Data folder on server. Next I want to open this file that user can print it.</p> <p>How to open this file in browser ? Send it in http header etc ? Someone have some examples?</p> <p>Please help ;)</p>
asp.net
[9]
5,534,920
5,534,921
Is there a way to call a function every time a jquery basic function is called?
<p>I would like everytime I call a jquery load function:</p> <pre><code>$("#div").load("file.php"); </code></pre> <p>To then call a separate function:</p> <pre><code>function secondFunction() { //do stuff } </code></pre>
jquery
[5]
3,750,130
3,750,131
Basic questions about RAII, STL pop, and PIMPL
<p>While reading proggit today, I came upon this comment in a <a href="http://www.reddit.com/r/programming/comments/b9iiv/for_all_you_haters_of_c_take_a_look_at_the/" rel="nofollow">post</a> about how the top places in the Google Ai challenge were taken by C++. User <code>reventlov</code> declares</p> <blockquote> <p>The biggest problem I have with C++ is that it's waaay too easy to think that you're a "C++ programmer" without really understanding all the things you need to understand to use C++ acceptably well.</p> <p>You've got to know RAII, and know to use namespaces, and understand proper exception handling (for example, you should be able to explain why the pop() methods in the STL do not return the values they remove). You've got to know which of the three generations of functions in the standard library is the right one. You should be familiar with concepts like PIMPL. You need to understand how the design of the standard library (especially the STL) works. You need to understand how macros interact with namespaces, and why you usually shouldn't use macros in C++, and what you should use instead (usually templates or inlines, rarely a class). You need to know about boost.</p> </blockquote> <p>I think I'm one of those clueless C++ programmers he mentions. To keep this brief, my questions are</p> <ol> <li>Can you give an example of a typical RAII oversight mistake, e.g. where best practices dictate the use of RAII but programmers have implemented using some other way?</li> <li><em>Why</em> doesn't the pop() methods in STL return the value they remove? </li> <li>I read the Wikipedia entry for PIMPL, didn't understand any of it. Can you give an example of a typical usage of the PIMPL idiom.</li> </ol>
c++
[6]
5,776,321
5,776,322
how to change the themes and icons of Android 2.2 OS?
<p>I am Optimizing the Android 2.2 OS to make it in such a way that it can be ported to the tablet. Can anyone suggest me how to change the themes and icons of Android 2.2 OS.</p>
android
[4]
2,518,361
2,518,362
Why does file_get_contents() return the error "Filename cannot be empty"?
<p>I'm pretty much a complete newbie to PHP. My background is C/C++ and C#. I'm trying to object orient-ify some simple PHP code, but I'm doing something wrong.</p> <p>Class code:</p> <pre><code>class ConnectionString { public $String = ""; public $HostName = ""; public $UserName = ""; public $Password = ""; public $Database = ""; function LoadFromFile($FileName) { $this-&gt;String = file_get_contents($Filename); $Values = explode("|", $this-&gt;String); $this-&gt;HostName = $Values[0]; $this-&gt;UserName = $Values[1]; $this-&gt;Password = $Values[2]; $this-&gt;Database = $Values[3]; } } </code></pre> <p>Calling code:</p> <pre><code>$ConnectionString = new ConnectionString(); $FileName = "db.conf"; $ConnectionString-&gt;LoadFromFile($FileName); print('&lt;p&gt;Connection Info: ' . $Connection-&gt;String . '&lt;/p&gt;'); </code></pre> <p>I'm getting ann error on the <code>file_get_contents($Filename)</code> line stating: <em>Filename cannot be empty</em>. If I hard-code the filename in place of $Filename, then I simply get all empty strings for the fields.</p> <p>What simple concept am I missing?</p>
php
[2]
848,093
848,094
how to get over security in asp.net
<p>If you have a code, log in information of which is encrypted, how to decrypt using asp.net ?</p> <p>Cryptography class?</p> <p>Any other?</p>
asp.net
[9]
2,593,492
2,593,493
How to replace decorView in Android?
<p>As it knows, we can get Android top-hierarhy <code>Views</code> via <code>Activity.getWindow().getDecorView()</code> and <code>Activity.findViewById(android.R.id.content)</code>.</p> <p>Is it possible to replace the standard set of custom Views?</p>
android
[4]
2,039,347
2,039,348
Need Help about how to use Google Maps API
<p>Some one had about document , curriculum about Google Maps API could share me because i prepare do de project about Google Maps API for my last exam . I know i can find guide about google maps api on developer.android.com but i dont understand </p> <p>Some one had document , curriculum about Google Maps API could share me please </p>
android
[4]
5,641,289
5,641,290
jquery error undefined function
<p>I created this fiddle from code found on Stack, but it is firing an error. Can you help please.</p> <p>My Fiddle: <a href="http://jsfiddle.net/422steve/DVNGc/" rel="nofollow">http://jsfiddle.net/422steve/DVNGc/</a></p> <p>Original anser : <a href="http://stackoverflow.com/a/13000179/501173">http://stackoverflow.com/a/13000179/501173</a></p> <p>Error I am getting is: TypeError: $allExtended.slideUp() is not a function</p> <p>js:</p> <pre><code>$('.holder').on('click','a',function(e){ e.preventDefault(); var $allExtended = $(this).closest('.wrapperdoo').find('.extended'), $extended = $allExtended.eq( $(this).index() ), doIt= ($extended.is(':visible')) ? $extended.slideUp() : ($allExtended.slideUp()) ($extended.slideDown()); }); </code></pre>
jquery
[5]
3,657,453
3,657,454
reference to call ambiguous in java
<pre><code>class A { public void printFirst(int... va) throws IOException{ System.out.print("A"); } public static void main(String args[]) { try { new B().printFirst(2); } catch (Exception ex) { } } } class B extends A { //@Override public void printFirst(float... va) throws IOException{ System.out.print("B"); } } </code></pre> <p>Why, it is showing <strong>reference to call ambiguous</strong> ??</p>
java
[1]
1,551,796
1,551,797
Android Mobile Calls
<p>Whether It is possible to set User busy when call comes from particular number in Android mobiles 2.1 version</p>
android
[4]