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
780,051
780,052
defining hash in tr1 for a template class
<p>I have the class Gateway. I need to store object of this class in a hash table (using tr1::unordered_set). I've used both the unorderd_set and the class Gateway in another context and they work fine, yet I can't figure how to put a gateway in a unordered set because I can't define its <code>hash</code> function in tr1's namespace.</p> <p>I've tried: (and many other variants)</p> <pre><code>namespace std { namespace tr1 { template&lt;&gt; &lt;typename T&gt; inline size_t hash&lt;(typename Gateway&lt;T&gt;)&gt;::operator()(Gateway&lt;T&gt; gT) const { return gT.getCore()-&gt;hash(); //!DOESN't WORK } } </code></pre> <p>The compiler says the this (<code>typename Gateway&lt;T&gt;</code>) is wrong. If i take the <code>()</code> off, it assumes the <code>&gt;&gt;</code> in the end of <code>hash&lt;typename Gateway&lt;T&gt;&gt;()</code> is the output stream.</p> <p>While in the past i've done this</p> <pre><code>namespace std { namespace tr1 { template&lt;&gt; inline size_t hash&lt;Board&gt;::operator()(Board b) const { return b.hash(); //!WORKS FINE } } } </code></pre> <p>Can anyone shed some light on the problem?</p> <p><strong>Update</strong></p> <p>Thanks for the answer yet there is still a problem The compiler says invalid use of incomplete type <code>struct std::tr1::hash&lt;&gt;</code></p> <p>This sort of error happens when we use the class without its complete definition, yet the class is fully defined before the declaration. I've already used this without templates in a very similar fashion without a problem.</p>
c++
[6]
162,317
162,318
jquery creating or inserting html objects/elements
<p>i'm all new to all this so i have this problem. i have to make a box in my blog and i didn't get any clue how to do it by only using jquery. on this site www.trojka.rs on right side you'll see box with header "sociometar". i need to make something like that.. so i only need guidance how to do it or where could i find anything that could help me. Thanx</p>
jquery
[5]
4,673,870
4,673,871
using ref to view error
<p>I working now on firm that using ref in every function.<br> The reason, is to catch errors.<br> There example :</p> <pre><code>//return true if the read is success //otherwise writing to the error ,the problem bool ReadFile(ref string error) </code></pre> <p><strong>Question:</strong><br> How do you catching errors?<br> Using ref,exceptions or other way?</p>
c#
[0]
1,860,642
1,860,643
using fibonacci sequence to print out words
<p>I am writing a program where it prints out how the frequency of a word as long as the frequency is in the fibonacci sequence (1,2,3,5,8,etc). I have figured out how to print all the words that appear once, however I am having trouble figuring out how to iterate so it prints out the words that have a higher freqeuncy.</p> <pre><code>import string import itertools def fib(): a,b = 0, 1 while 1: yield b a, b = b, a + b while True: filename = raw_input('Enter a file name: ') if filename == 'exit': break try: file = open(filename, 'r') text = file.read() file.close() except: print('file does not exist') else: for word in string.punctuation: text=text.replace(word, "") word_list = text.lower().split(None) word_freq = {} for word in word_list: if len(word) &gt; 1: word_freq[word] = word_freq.get(word, 0) + 1 frequencies = sorted(word_freq.items(), key=lambda item: item[1]) a = fib() order = sorted(word_freq.values()) n = 1 a = next(a) for words in frequencies: try: if a == words.index(n): print(words) except: print('nope') # HELP: how would I iterate here?? print('Bye') </code></pre>
python
[7]
432,024
432,025
Limited icon in gridview in android
<p>How can I design gridview in android which shows us the icon which are limited on first time and then by clicking particular button we get remaining icons on the screen?</p> <p>For example</p> <p>I have total 30 to 40 icon to display,on the first screen i want to show half of the total icons and another icon by clicking some particular action like clicking button.</p> <p>Is it possible to design for this view?if possible then plz send me some hint.</p> <p>Thnx.</p>
android
[4]
5,438,748
5,438,749
Page Peel effect broken for new version of jquery
<p>I am trying to use this javascript for a page peel effect without using flash but it was written for jquery 1.3.2 and the site I am using this for uses a newer version that is doesn't function properly on. It displays the image behind the page peel until you hover over it then it hides it. Here is a fiddle showing what I'm talking about. How do I fix this without using so that I don't have to use 1.3.2 jquery?</p> <p>The developers don't appear to support this plugin anymore so I am coming here for help.</p> <p><a href="http://jsfiddle.net/bGbgS/1/" rel="nofollow">http://jsfiddle.net/bGbgS/1/</a></p> <pre><code>&lt;div id="pagepeel" class="xteam-pagepeel"&gt; &lt;span class="peel"&gt; &lt;map name="peelmap"&gt; &lt;area shape="poly" coords="0,0,614,0,614,614,0,0" title="Go!" href="#" class="peel-hotzone" /&gt; &lt;/map&gt; &lt;img src="https://denmat-media.s3.amazonaws.com/website_code/page-peel/page_turn.png" alt="" class="peel" /&gt; &lt;span class="back corner"&gt;&lt;p&gt;Hello World&lt;/p&gt;&lt;/span&gt; &lt;span class="back link"&gt; &lt;img src="http://0.s3.envato.com/files/250075/trans.gif" alt="" class="map" usemap="#peelmap" /&gt; &lt;span class="peel-content"&gt; &lt;!-- Your HTML Content Goes here --&gt; &lt;/span&gt; &lt;/span&gt; &lt;/span&gt; &lt;/div&gt; </code></pre> <p>(posting this code because stackoverflow won't let me publish this post without code after the fiddel)</p>
jquery
[5]
4,746,963
4,746,964
Calculate time difference in c# windows phone 7
<p>I am trying to <strong>calculate the time difference between 2 time</strong> and put the result into a text block.</p> <p>For example,</p> <p>Start time: 9:45 AM</p> <p>End start: 5:15 PM</p> <p>How can i <strong>calulate the time difference</strong> between it?</p> <p>DateTime dt1 = DateTime.ParseExact(DateTime.Now.ToShortTimeString(), "hh:mm tt", new DateTimeFormatInfo());</p> <pre><code> DateTime dt2 = DateTime.ParseExact(timePicker1.ValueString, "hh:mm tt", new DateTimeFormatInfo()); </code></pre> <p>TimeSpan ts1 = dt2.Subtract(dt1);</p>
c#
[0]
5,273,765
5,273,766
Access tomcat server resources
<p>I write a mobile app with tomcat simulated server. When I enter address It can access the server resources. It is no problem in android simulator. I can access server resources use my app. when I install the application to my phone, it has the error:</p> <pre><code>12-28 13:36:36.474: E/PhonePolicy(27800): Could not preload class for phone policy: com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback </code></pre> <p>I use my phone browser can access my tomcat server. I can not find <code>“com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback”</code> in api. But I can find it in resource sound code.</p> <p>What is this problem? How to solve it? thanks very much!</p>
android
[4]
4,649,338
4,649,339
where is the '__path__' comes from
<p>i can't find who defined the <code>'__path__'</code>,why <code>'__path__'</code> can be use.</p> <pre><code>import os import sys import warnings import ConfigParser # ConfigParser is not a virtualenv module, so we can use it to find the stdlib dirname = os.path.dirname distutils_path = os.path.join(os.path.dirname(ConfigParser.__file__), 'distutils') if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)): warnings.warn( "The virtualenv distutils package at %s appears to be in the same location as the system distutils?") else: __path__.insert(0, distutils_path)#who defined me.??? exec open(os.path.join(distutils_path, '__init__.py')).read() </code></pre>
python
[7]
5,087,752
5,087,753
How to close the form in ASP.NET with a LinkButton?
<pre><code>&lt;asp:LinkButton ID2="lnbClose" SkinID="LinkButton" runat="server" meta:resourcekey="lnbClose" onclick="javascript: window.close() </code></pre> <p>How to close the form in ASP.Net with a LinkButton?</p> <p>I am in Web Application.</p>
asp.net
[9]
1,524,050
1,524,051
Can I show custom Confirm dialog before some operation
<p>I am using <code>ASP.NET/C#</code>.In one of my page I have a requirement where before <code>inserting data</code> into <code>database</code> I need to check if the <code>ApplicationNo</code> is unqiue.If it is not unique I need to show a <code>confirm dialog</code> which will inform the user that the <code>ApplicationNo</code> is not unique.Can I use custom <code>confirm dialog</code> for this purpose. Thanks.</p>
jquery
[5]
5,959,817
5,959,818
Static class member declaration error
<p>I am trying to find dynamically and statically instantiated objects number. I am getting errors that variable myheap is not declared.</p> <pre><code>#include&lt;iostream.h&gt; #include&lt;stdlib.h&gt; class A { public: static int x; //To count number of total objects. incremented in constructor static int myheap; //To count number of heap objects. Incremented in overloaded new void* operator new(size_t t) { A *p; p=(A*)malloc(t); myheap++; return p; } void operator delete(void *p) { free(p); myheap--; } A() { x++; } ~A() { x--; } }; int A::x=0; int A::myheap=0; int main() { A *g,*h,*i; A a,c,b,d,e;//Static allocations 5 g= new A();//Dynamic allocations 3 h= new A(); i= new A(); cout&lt;&lt;"Total"&lt;&lt;A::x&lt;&lt;'\n'; cout&lt;&lt;"Dynamic"; cout&lt;&lt;'\n'&lt;&lt;"HEAP"&lt;&lt;A::myheap; delete g; cout&lt;&lt;'\n'&lt;&lt;"After delete g"&lt;&lt;A::x; cout&lt;&lt;'\n'&lt;&lt;"HEAP"&lt;&lt;A::myheap; delete h; cout&lt;&lt;'\n'&lt;&lt;"After delete h"&lt;&lt;A::x; cout&lt;&lt;'\n'&lt;&lt;"HEAP"&lt;&lt;A::myheap; delete i; cout&lt;&lt;'\n'&lt;&lt;"After delete i"&lt;&lt;A::x; cout&lt;&lt;'\n'&lt;&lt;"HEAP"&lt;&lt;A::myheap; } </code></pre>
c++
[6]
5,073,504
5,073,505
jQuery prev() and next()
<p>I am using jQuery. I have HTML code which looks like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;123&lt;/li&gt; &lt;li id="hello"&gt;456&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;789&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want, with jQuery, to get the li element after #hello (the 789 element). I tried with <code>$('#hello').next()</code>, it does not work.</p> <p>How do I do?</p>
jquery
[5]
4,886,031
4,886,032
Make background yellow for correct answer in listivew
<p>A user selects an answer from a series of options in a listview. After submitting (right or wrong) I intend to highlight the correct answer in the list view.</p> <p>I thought I had it figured:</p> <pre><code> // get the position from the array we fed into the list view that has the correct answer int correct = curquestion.GetIndexOfCorrectAnswer(); // set that item's background to yellow lView.getChildAt(correct).setBackgroundColor(Color.YELLOW); </code></pre> <p>I've discovered though through watching this run, and reading other people's posts herem that getChildAt doesn't provide a reliable result- sometimes it appears to pick a random child to set yellow. Any suggestions on other approaches?</p>
android
[4]
5,883,849
5,883,850
Android: Supporting Multiple Screens
<p>Have a question...Android divides the range of actual screen sizes and densities into: A set of four generalized sizes: small, normal, large, and xlarge. A set of four generalized densities: ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high)</p> <p>1) What have the higher priority ?</p> <p>Lats say I have hdpi device with large screen size...And I have 2 folders in my project: 'layout-large' and 'layout-hdpi'...Which folder will use my device ?</p> <p>2) I have hdpi device and 2 folders in my project...default 'layout' folder and 'layou-mdpi' Why hdpi use layou-mdpi ?</p> <p>3) How to name folder correctly ? layout-mdpi-normal or layout-normal-mdpi...</p> <p>Thanks...</p>
android
[4]
3,390,520
3,390,521
Cannot use Controls.Add in WPF application
<p>When I write Controls.Add() to dynamically create a control in a window, it says that Controls is not defined or present in window class. In other words "Controls" is not being recognized as a class or command and hence the code is not working. Any suggestions will be appreciated.</p> <p>I want to dynamically create a window and add a textbox to it.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; public partial class Window2 : Window { public Window2() { InitializeComponent(); } private void button2_Click(object sender, RoutedEventArgs e) { Window f1 = new Window(); f1.Show(); TextBox tb = new TextBox(); tb.Width = 150; tb.Height = 60; tb.Name = "TextBoxID"; tb.Text = "This is textbox first data"; Controls.Add(f1); } } </code></pre>
c#
[0]
1,696,017
1,696,018
How to combine php code as hyperlink
<p>I am trying to combine a code used to pull name of a store for my site with a word, and it is seperating the store name and word and not forming a hyperlink. </p> <p>For example it will read..............<strong>6pm</strong> deals, but only hyperlink the store name, here is code that pulls the store name........</p> <pre><code>&lt;div class="store-name"&gt; &lt;?php echo get_the_term_list($post-&gt;ID, APP_TAX_STORE, ' ', ', ', ''); ?&gt; &lt;/div&gt; </code></pre> <p>I want it to say <strong>6pm deals</strong> and hyperlink entire term.</p>
php
[2]
379,292
379,293
Create modal form dialog in function
<p>My app works with many modal form dialogs, i want to create modal form dialog by call a function, but i get error when i click OK button on dialog "i.apply is not a function". My code below</p> <p>html: </p> <pre><code>&lt;div id="dlg_srch_acnt"&gt; &lt;table cellpadding="0" cellspacing="0" border="0" class="display" id="dtl_acnt_srch" style=" padding-bottom:0px;"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Account name&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>Script</p> <pre><code>function init_dlg(id, autoOpen, height, width, modal, fn_button1) { id.dialog({ autoOpen:autoOpen, height:height, width:width, modal:modal, buttons:{ 'OK':fn_button1, }, close:fn_close }); } function fn_ok() { $('#parnt_acnt').val(acnt_name); $('#dlg_srch_acnt').('close'); } init_dlg($('#dlg_srch_acnt'), false, '440', '480', true, 'fn_ok()'); </code></pre>
jquery
[5]
4,307,218
4,307,219
AnsyncTask to open web page
<p>i am trying to use the Asynctask method to fetch data from a web server.</p> <p>I have the following code.</p> <pre><code>package com.example.myfirstapp; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import android.app.Activity; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.view.View; import android.widget.TextView; public class FetchData extends Activity { private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fetch_data); textView = (TextView) findViewById(R.id.TextView1); Intent intent = getIntent(); String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); } private class DownloadWebPageTask extends AsyncTask&lt;String, Void, String&gt; { @Override protected String doInBackground(String... urls) { String response = ""; for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); BufferedReader buffer = new BufferedReader(new InputStreamReader(content)); String s = ""; while ((s = buffer.readLine()) != null) { response += s; } } catch (Exception e) { e.printStackTrace(); } } return response; } @Override protected void onPostExecute(String result) { textView.setText(result); } } public void readWebpage(View view) { DownloadWebPageTask task = new DownloadWebPageTask(); task.execute(new String[] {message}); } } </code></pre> <p>My problem is this FetchData Activity in turn has to receive a data from MainActivity. I have used intent to do so. Now, the intent I am using here, has the data from the MainActivity. This message contains the URL of the web server. I just need to use the message to obtain the results from web page. I want to pass this message to the task.execute method so that it can return me the web page. How should I do it.?</p>
android
[4]
3,784,900
3,784,901
ASP.Net circular reference situation
<p>I have the following code and everytime i try to compile, I get the error "/Website/InsightLogo.ascx has a circular reference!" I am assigned to fix up somebody els' code, so please excuse any odd mistakes</p> <pre><code>&lt;%@ Control Language="vb" AutoEventWireup="false" CodeBehind="InsightLogo.ascx.vb" Inherits="eDox.InsightLogo" %&gt; &lt;%@ Register Src="InsightLogo.ascx" TagName="InsightLogo" TagPrefix="uc1" %&gt; &amp;nbsp;&lt;img src="Images/InsightLogo.bmp" alt="Company Logo"/&gt; </code></pre>
asp.net
[9]
3,691,507
3,691,508
reference the "self" type in a static method - C#
<p>I am trying to create a static method that would return an instance of the class, something like:</p> <pre><code>class A { public static A getInstance() { return new A(); } } </code></pre> <p>The problem I am having is that if I have a subclass B derived from A, I would like B.getInstance() to return an instance of B, and not A. In PHP world, you could use a keyword "self" to reference to your own type, so your getInstance() would look like:</p> <pre><code>public static function getInstance() { return new self(); } </code></pre> <p>What's the best way to go about this?</p>
c#
[0]
1,581,434
1,581,435
compare to collection objects
<p>How to compare to ArrayList objects in my project i want to check like this</p> <pre><code>ArrayList al=new ArrayList(); al.add(".net"); al.add("java"); ArrayList list=new ArrayList(); list.add(".net"); list.add("java"); list.add("iphone") </code></pre> <p>now i want to compare al and list and i want the output is iphone please help me</p>
java
[1]
245,281
245,282
How to pass socket, inputstream, outputstream objects between activities
<p>How to pass socket, inputstream, outputstream objects between activities</p>
android
[4]
435
436
how to remove underline for anchor link in jquery
<p>i have anchor tag in jquery as </p> <pre><code>success: function(result) { $('#MyGrid tbody').append('&lt;tr&gt;&lt;td&gt;&lt;a STYLE="text-decoration:none" href="#"&gt;&lt;font color=black&gt;&lt;strong&gt;' + result.name+ '&lt;/font&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'); </code></pre> <p>to remove the underline i have added style property ,but it is not removing the underline.How can i remove the underline for anchor tag?</p> <p>thanks, michaled</p>
jquery
[5]
24,800
24,801
Issue to open browser on specified site with specified input on click button
<p>if user click on it i want to open the browser on <a href="http://www.dtcsearch.com/" rel="nofollow">http://www.dtcsearch.com/</a> and on this site in bar search i want to auto-insert the value of string S of my program. at example: if s="ciao" and the user click on button i want to open <a href="http://www.dtcsearch.com/" rel="nofollow">http://www.dtcsearch.com/</a> with written in search ciao</p>
android
[4]
5,021,039
5,021,040
Convert String array to ArrayList
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2607289/converting-array-to-list-in-java">Converting array to list in Java</a> </p> </blockquote> <p>I want to convert <code>String</code> array to <code>ArrayList</code>. For example String array is like: </p> <pre><code>String words={"ace","boom","crew","dog","eon"}; </code></pre> <p>How to convert this String array to ArrayList?</p>
java
[1]
5,097,793
5,097,794
If I have a thread instance with variable name myThread, how can I find out if it is in the state RUNNABLE?
<p>I looked at this api but didn't find the information I was looking for:</p> <p><a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html#RUNNABLE" rel="nofollow">http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html#RUNNABLE</a></p>
java
[1]
5,958,591
5,958,592
how danger is this with php backend for simple portfolio site?
<p>Hello friends i am creating simple portfolio site, where admin username and password are neither salted or used md5 but plain text. 'login.php' page is 'unguessable.php' page. Is this ok for simple site ? </p> <pre><code>if(isset($_POST['btnCreateAccount'])) { $Error-&gt;blank($_POST['username'], 'Username'); $Error-&gt;blank($_POST['password'], 'Password'); $Error-&gt;blank($_POST['level'], 'Level'); $Error-&gt;email($_POST['email']); if($Error-&gt;ok()) { $u = new User(); $u-&gt;username = $_POST['username']; $u-&gt;email = $_POST['email']; $u-&gt;level = $_POST['level']; $u-&gt;setPassword($_POST['password']); $u-&gt;insert(); redirect('users.php'); } else { $username = $_POST['username']; $email = $_POST['email']; $level = $_POST['level']; } } else { $username = ''; $email = ''; $level = 'user'; } </code></pre>
php
[2]
3,564,941
3,564,942
jQuery 1.7.1 - fadeout delay issues
<p>I have this very simple jQuery script, which gives me error that delay is not a function.</p> <p>What am I doing wrong? Thing is that everything works, except that delay is causing error :S</p> <p>I made sure I'm loading only jquery library once, which is also latest version 1.7.1</p> <pre><code>function statusInquiry(orderItemID) { var loadUrl = "bl_updaInfo.php"; $.post( loadUrl, {"orderItemID": orderItemID, "type": "statusInquiry"}, function(responseText){ $("#reportArea" + orderItemID).fadeIn("slow").html(responseText); }, "html" ); updateLogList(orderItemID); $("#reportArea" + orderItemID).delay(10000).fadeOut("slow"); } </code></pre> <p>ERROR I'm getting: - <code>[19:44:10.792] $("#reportArea" + orderItemID).delay is not a function</code></p> <p>responseText is exactly this:</p> <pre><code>&lt;table class="tablerainbow-noborder" cellpadding="0" cellspacing="0"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td style="color: #888786;" width="70%"&gt;Client requests status for this search.&lt;/td&gt; &lt;td style="color: #888786;"&gt;Posted 2012-03-12 12:34:22 by Client&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
jquery
[5]
1,603,480
1,603,481
Jquery Menu Request
<p>I want a jquery menu like this link </p> <p>the menu in link is in Flash format</p> <p><a href="http://www.atid1.com/default/" rel="nofollow">Flash Menu</a></p> <p>when i hover on parent menu with mouse all sub menus will open</p> <hr> <p>I think now this is the correct answer</p> <pre><code>&lt;div class="hoverMenuItem" id="item1"&gt; Menu Item&lt;/div&gt; &lt;div class="hoverMenuItem" id="item2"&gt; Menu Item&lt;/div&gt; &lt;div class="hoverMenu" style="display: none; position: absolute;"&gt; &lt;!--menu laid out--&gt; &lt;/div&gt; &lt;div class="hoverMenu" style="display: none; position: absolute;"&gt; &lt;!--menu laid out--&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $('.hoverMenuItem').mouseover(function () { //var id = $(this).attr("id"); //var itemNum = id.substring(4); //$('#menu' + itemNum).slideDown(250); $('.hoverMenu').slideDown(250); }); $('.hoverMenuItem').mouseout(function () { //var id = $(this).attr("id"); //var itemNum = id.substring(4); //$('#menu' + itemNum).slideUp(250); $('.hoverMenu').slideUp(250); }); }); &lt;/script&gt; </code></pre> <p>but there is a problem</p> <p>in this way how can we Determine childs for each parent ?</p>
jquery
[5]
4,054,308
4,054,309
jQuery function to change background color not working
<pre><code>function ajaxFunction2(){ var chooser2 = $('#chooser2').val(); $('#floatcontainertop').css("background",$('#chooser2').val()); } </code></pre> <p>Could someone please tell me how to fix my above code so that it works. I have absolutely no knowledge of jquery and I do not know how to call a variable within a function that I have already predefined. Thanks for the help! </p> <p>Chooser2 represents a color, i.e. red, blue, yellow, black.</p>
jquery
[5]
3,556,840
3,556,841
In Android Password having four individual fields is not showing previous field as dot when moving to next field using requestfocus() in textwatcher
<p>In android i have a requirement of Password with four single number fields and i have used four edittext views. If we enter 4 numbers it has automaically fill the four fields. I have done this by using addTextChangedListener. But my password fileds are not replaced by dots except the problem. I think because of using requestfocus() to next field previous field is not converting dot. Please help me.</p> <pre><code> passInput1.addTextChangedListener(new CustomTextWatcher(passInput1, passInput2)); passInput2.addTextChangedListener(new CustomTextWatcher(passInput2, passInput3)); passInput3.addTextChangedListener(new CustomTextWatcher(passInput3, passInput4)); </code></pre> <p>and My CustomWatcher is shown below.</p> <pre><code>public class CustomTextWatcher implements TextWatcher { private EditText currentEditTextFiledId; private EditText nextEditTextFiledId; public CustomTextWatcher(EditText currentEditTextFiledId, EditText nextEditTextFiledId) { this.currentEditTextFiledId = currentEditTextFiledId; this.nextEditTextFiledId = nextEditTextFiledId; } public void beforeTextChanged(CharSequence s, int start, int count, int after) { currentEditTextFiledId.setTransformationMethod(PasswordTransformationMethod.getInstance()); } public void onTextChanged(CharSequence s, int start, int before, int count) { Integer textlength1 = currentEditTextFiledId.getText().length(); if (textlength1 &gt;= 1) { nextEditTextFiledId.requestFocus(); } } public void afterTextChanged(Editable s) { } } </code></pre>
android
[4]
3,996,450
3,996,451
Convert blob to string
<p>I am working on a project where I have to store a large amount of data into database. For example 1200 - 2000 lines of code in a single column. When I read the information back from database I want to customize those codes. For example one of the line of codes has syntax error I want to show that line in red. at the moment when I read as the information is in blob its treated as chunk. So can't do what I want to do. Any idea how to change them to string so I can customize any lines of code I want. And I am working on PHP. </p>
php
[2]
4,571,058
4,571,059
Reading variables from a configuration file
<p>I'm trying to determine the best way to read in a configuration file. This "Parameters.cfg" file is just to define values and is of this form:</p> <pre><code>origin_uniform_distribution 0 origin_defined 1 angles_gaussian 0 angles_uniform_distribution 0 angles_defined 0 startx 0 starty 0 gap 500 nevents 1000 origin_uniform_distribution_x_min -5 origin_uniform_distribution_x_max 5 origin_uniform_distribution_y_min -5 origin_uniform_distribution_y_max 5 origin_defined_x 0 origin_defined_y 0 angles_gaussian_center 0 angles_gaussian_sigma 5 angles_uniform_distribution_x_min -5 angles_uniform_distribution_x_max 5 angles_uniform_distribution_y_min -5 angles_uniform_distribution_y_max 5 angles_defined_x 10 angles_defined_y 10 </code></pre> <p>The names are there for the user to know which variables they are defining. I would like to have my program read in only the actual numbers and skip over the strings. I know I can do this in a way where I define a whole lot of strings in my program, and then just leave them sitting there defined but obviously unused. Is there a way to read in the numbers easily while skipping over the strings?</p>
c++
[6]
5,368,021
5,368,022
How to name my variable class dynamicly in python
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/686715/python-why-cant-i-modify-the-current-scope-within-a-function-using-locals">Python: Why can&#39;t I modify the current scope within a function using locals()?</a><br> <a href="http://stackoverflow.com/questions/285061/how-do-you-programmatically-set-an-attribute-in-python">How do you programmatically set an attribute in Python?</a> </p> </blockquote> <p>i know nammed dynamicly an varial in python with:</p> <pre><code>var = "my_var" locals()[var] = "coucou" print my_var &gt;&gt;coucou </code></pre> <p>But i don't know how to make it on a variable class. When i try:</p> <pre><code>class Controller(object): def __init__(self): var = 'ma_variable_dynamique' locals()[var] = 'toto' print ma_variable_dynamique </code></pre> <p>The exeception "NameError: global name 'ma_variable_dynamique' is not defined" is raised.</p> <p>Example in php:</p> <pre><code>class Users extends Controller{ public $models = array(‘User’); function login(){ $this-&gt;User-&gt;validate(); } //Call in contructor function loadModel(){ foreach($this-&gt;models as $m){ $_class = $m.’Model’;s $this-&gt;{$m} = new $_class(); } } } </code></pre> <p>Thx</p>
python
[7]
3,442,845
3,442,846
Internal property and subclassing
<p>I think it is by design and there is nothing can be done about it, but I found it interesting.</p> <p>I needed to create a concreate class based on third-party abstract base class. As always, I told Visual Studio to implement abstract base class, which it did, but the code didn't compile complaining about missing getter. However, event after adding getter manualy, the code still didn't compile. It turned out that this getter is internal. Funny thing about internal property is that it's not shown in metadata (View Definition). Vendor will make it protected in the next release, but at the time being, unless I'm missing some other way, there is nothing I can do about it, right?</p> <p>-Stan</p>
c#
[0]
454,157
454,158
Can't run Python .py files from terminal on Mac
<p>I just downloaded Python 3.2 to Mac OS 10.6 environment. I'm new to programming and am trying to run my first stand-alone .py file, but I keep getting an error message saying "no such directory or file." The name of the file is "script1.py" and I saved it to /Users/billp/Documents. When I open the Terminal to run the file I type:</p> <pre><code>python script1.py </code></pre> <p>I've also tried adding this line to the beginning of the script:</p> <pre><code>#!/usr/local/bin/python </code></pre> <p>As well as this one:</p> <pre><code>#!/usr/bin/env python </code></pre> <p>Yet, I keep getting the same error message. Any help would be greatly appreciated.</p>
python
[7]
1,310,096
1,310,097
Alternative to "echo" withe less code/characters?
<p>As per the title, is there a quicker way to display something in PHP without using echo, so for example is you are using GET[1] taking code from a parsed parameter "1" and displaying it to the screen. </p>
php
[2]
5,540,983
5,540,984
Two Validation Groups in a single button without client click event
<p>In a multigrid i have validating two controls like date and amount.it is validating correctly when i press the tabevent.when i press the save button it is not validating.iam using two validations gruops and two validation summary.Then in save button i have also tried onclientclick() function with javascript it s working fine but if i give the correct value in date and amount records not saving how to over come this.</p> <h2>Date</h2> <p> ' runat="server" CausesValidation="true" ValidationGroup="group" Width="80px" AutoPostBack="true" OnTextChanged="txtDate_TextChanged"> * </p> <h2>Amount</h2> <p> ' CausesValidation="true" ValidationGroup="req" runat="server" AutoPostBack="true"> </p> <h2>validations summary:</h2> <p> </p> <h2>button save:</h2> <p>" OnClick="ButtonSave_Click" TabIndex="6" /> how to validate this in the button save also two popup box should be shown.....................</p>
asp.net
[9]
558,633
558,634
How to detect electric current using iphone?
<p>I am implementing an iPhone application in which I want to detect if the user holds the iPhone near an electric wire.</p> <p>I don't know is it possible or not. I have tried to findout but have had no success.</p> <p>Any advice is appreciated.</p> <p>Thanks in advance.</p>
iphone
[8]
4,966,668
4,966,669
Change phone mode to vibrate using checkbox
<p>In my application i want to use a functionality which can make the vibrate mode of phone disable or unable. I want to do it through checkbox, i.e. if i click the checkbox, it changes its mode into vibrate visa versa. Any thoughts ?? </p>
android
[4]
2,080,301
2,080,302
Weird: Variables keep unsetting themselves
<p>For some reason, I cannot access <code>$phone_number</code> within the if block - outside of it works just fine. Please help: code below. Thank you!</p> <pre><code>protected function _parse_message($message, $phone_number){ require_once('coupon-classes.php'); //If there is the need for a coupon, let's make a coupon! if(preg_match('/{!cpn}/', $message)){ $coupon = new pre_coupon; $new_coupon = $coupon-&gt;create(); $coupon-&gt;save($new_coupon, $phone_number); $message = preg_replace('/{!cpn}/', $new_coupon, $message); //unset($coupon); } return $message; } function parse($message, $phone_number=''){ return $this-&gt;_parse_message($message, $phone_number); } </code></pre> <p>I used <code>update_option('api_sms', get_defined_vars());</code> to trace this (I'm working in Wordpress)</p> <p>Inside the if statement, after $message= $preg_replace.. this is what I get:</p> <pre><code> Array ( [message] =&gt; Here is a coupon FF5CB5 [phone_number] =&gt; [coupon] =&gt; pre_coupon Object ( [client_id:private] =&gt; 1 ) [new_coupon] =&gt; FF5CB5 ) </code></pre>
php
[2]
1,184,269
1,184,270
How to replace this html using jquery?
<p>I have this html.</p> <pre><code>&lt;div&gt; &lt;input type="password" id="user_password" name="user_password" class="password"&gt; &lt;div class="passwordstrength s_1" style="display: block;"&gt;bad&lt;/div&gt; &lt;input type="password" id="user_password_confirm" name="user_password_confirm" class="password" style="display: inline-block;"&gt; &lt;/div&gt; </code></pre> <p>i want to reset and replace it back to</p> <pre><code>&lt;div&gt; &lt;input type="password" id="user_password" name="user_password" class="password"&gt; &lt;div class="passwordstrength" style="display: none;"&gt;&lt;/div&gt; &lt;input type="password" id="user_password_confirm" name="user_password_confirm" class="password" style="display: none;"&gt; &lt;/div&gt; </code></pre> <p>how do i do this using jQuery?</p>
jquery
[5]
1,717,873
1,717,874
Visual representation of nodes in Python
<p>I have data that I want to represent visually. The actual data is a tree made up of nodes. Each node has a bunch of data associated with it, but as far as this question goes, I just want a way to represent a tree visually using Python. Any ideas?</p> <p>The different solutions that popped in my head were to use a GUI library like WxPython or PyQT, or maybe even a PDF generator like ReportLab. I'm hoping there's a library out there that deals closer with data so that I don't have to think out the plotting locations of all the nodes.</p>
python
[7]
570,036
570,037
Modify code to check for duplicate entries in select box
<p>I have the below, it dynamically adds a new value option into a selectbox. The problem i have is that it does not check for duplicate entries before adding new options into the select box. Is there a way i can make a change to my code so it will alert the user that a duplicate entry is found and to stop adding the same option value?</p> <pre><code>function refadd() { var val = document.getElementById('docsref').value if (val != "") { var select = document.getElementById('docsref_list'); var option = document.createElement('option'); option.text = value select.add(option,select.option) select.selectedIndex = select.options.length - 1; } } </code></pre>
javascript
[3]
1,514,393
1,514,394
plus one in function python
<p>so say i had this</p> <pre><code>global a a = 1 def newre(): global a a += 1 b = str(a) print b op = urlopen('http://website/'+b+'.html') ops = op.read() </code></pre> <p>it wont work because maybe its in a function i guess but how you make it so that each time the class is run then b in op would be 1 higher then before?</p>
python
[7]
2,070,528
2,070,529
UIActivityIndicator issue when downloading from URL
<p>I'm trying to download the picture from URL and use a activity indicator animating to present the fact that the file is downloading. However, it is not working as my indicator isn't animating when I call this download function, can somebody tell me why? </p> <pre><code>-(void)download{ [indicator startAnimating]; NSString *downloadPath=@"http://www.xyz.com/path/pic.jpg; NSData *downloadData=[NSData dataWithContentsOfURL:[ NSURL URLWithString:downloadPath]]; if(downloadData){ //do something [indicator stopAnimating]; } else{ //do something [indicator stopAnimating]; } } </code></pre>
iphone
[8]
3,091,080
3,091,081
game programming for iphone
<p>i want to know how many engine are available for game programming on iphone using sdk 2.2 for both 2d and 3d??</p> <p>which one is best?? widely used?? </p> <p>how should i start??</p> <p>books and tutorials online??</p> <p>i am a beginner as iphone developer</p>
iphone
[8]
5,756,363
5,756,364
Java atomic classes in compound operations
<p>Will the following code cause race condition issue if several threads invoke the "incrementCount" method?</p> <pre><code>public class sample { private AtomicInteger counter = new AtomicInteger(0); public int getCurrentCount { int current = counter.getAndIncrement(); if (counter.compareAndSet(8, 0)) current = 0; return current; } } </code></pre> <p>If it causes race condition, what are the possible solution other than using synchronized keyword?</p>
java
[1]
5,350,010
5,350,011
android 4.0 and above,Canvas.clipRect() ,memory leaks
<p>is there any one has been met ? can someone give me a hit how to deal it? thanks a lot.</p> <p>in my game, I used a large number of funtions of Canvas.clipRect(),I found that,in android 4.0 and above,after the game runed for 10 mins,its process killed by activityManager.and I gived up using Canvas.clipRect() ,it runed properly for a long time.</p>
android
[4]
2,238,720
2,238,721
ASP.NET Mailing: Usage of SMTPClient.EnableSsl
<p>Iam trying to send a mail using ASP.NET. When the <code>SMTPClinet.EnableSsl</code> is set to <em>true</em>, mail is receivable. However, if it is set to <em>false</em>, an error is thrown. </p> <p>Can anyone help me in understanding its need.</p>
asp.net
[9]
358,598
358,599
string extensions for "today", "yesterday", "8 seconds ago", etc. in C#
<p>Has anyone ever heard of, or have access to some c# string extension snippet(s) or library that turns stuff like "yesterday", "today", "tomorrow" into DateTimes or "8 seconds ago", "10 minutes from now" into TimeSpans?</p> <p>If not, any thoughts on what that might look like in C#?</p> <p>Thanks</p>
c#
[0]
3,227,901
3,227,902
Pointer-to-member selection
<p>I have seen the following binary operator listed on a book <a href="http://www.apibook.com" rel="nofollow">pp 191</a>,</p> <pre><code>Point-to-member selection x-&gt;*y </code></pre> <p>I understand <code>x-&gt;y</code> but not <code>x-&gt;*y</code>. Is this a typo or something else?</p>
c++
[6]
3,564,585
3,564,586
How to find the exact center of a String?
<p>How to find the exact pixel center of a String? I need this for drawing onto a canvas.</p>
android
[4]
3,214,020
3,214,021
Why am I able to manipulate UI elements from a background thread?
<pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mTextView = (TextView) findViewById(R.id.text); new Thread(new Runnable() { @Override public void run() { mTextView.setText("Hello"); } }).start(); </code></pre> <p>But if I add delay for thread it doesnt work.So I can manipulate UI elements from not UI thread. Can anybody clarify this situation for me? }</p>
android
[4]
3,561,894
3,561,895
Validate unknown number of textfields using JavaScript
<p>I have defined text fields as follows:</p> <pre><code>&lt;form name="form1" method="post" action="save_banners.php" onsubmit="return check_form();"&gt; &lt;input type=text name=banner[]&gt; &lt;input type=text name=banner[]&gt; &lt;input type=text name=banner[]&gt; &lt;input type=text name=banner[]&gt; &lt;input type=submit value="submit"&gt; &lt;script&gt; function check_form(){ alert (document.form1.banner[0].value); } &lt;/script&gt; </code></pre> <p>How to access these fields in JavaScript? I am using the above JavaScript code, but it's not working.</p> <p>Regards,</p>
javascript
[3]
5,750,298
5,750,299
Asp.Net End date greater than start date
<p>Work on Asp.Net vs 08. Below is my code</p> <pre><code>&lt;asp:TextBox ID="txtSTART_DATE" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;cc1:PopupControlExtender ID="txtSTART_DATE_PopupControlExtender" runat="server" CommitProperty="value" CommitScript="e.value += '';" PopupControlID="pnlSTART_DATE" Position="Bottom" TargetControlID="txtSTART_DATE"&gt; &lt;/cc1:PopupControlExtender&gt; &lt;asp:TextBox ID="txtEND_DATE" runat="server" ontextchanged="txtEND_DATE_TextChanged"&gt;&lt;/asp:TextBox&gt; &lt;cc1:PopupControlExtender ID="txtEND_DATE_PopupControlExtender" runat="server" CommitProperty="value" CommitScript="e.value += '';" PopupControlID="pnlEND_DATE" Position="Bottom" TargetControlID="txtEND_DATE"&gt; &lt;/cc1:PopupControlExtender&gt; </code></pre> <p>C# syntax is </p> <pre><code>protected void dtpSTART_DATE_SelectionChanged(object sender, EventArgs e) { AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(this.Page).Commit(dtpSTART_DATE.SelectedDate.ToString("dd MMM yyyy"));//Set the value } protected void dtpEND_DATE_SelectionChanged(object sender, EventArgs e) { AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(this.Page).Commit(dtpEND_DATE.SelectedDate.ToString("dd MMM yyyy"));//Set the value } </code></pre> <p>want to compare start date with the end date.Verify that end date greater than start date and today date.How to check the value? </p>
asp.net
[9]
652,051
652,052
jQuery load() doesnt work on IE?
<p>This is my code</p> <pre><code>function grabLatestWho() { jQuery("#items").load(window.location.href +" #items"); } </code></pre> <p>Seems not to be working on IE :(</p> <h3>update</h3> <p>The function is pretty selft explainatory. It loads the div#items from that ajax page into the div#items on the current page which works fine on other browsers.</p> <p>It is null on IE.</p>
jquery
[5]
923,546
923,547
modify ProgressDialog Message size and Message color
<p>i have a ProgressDialog:</p> <pre><code>pBar = new ProgressDialog(context); ((TextView) pBar.findViewById(android.R.id.message)).setText("dfdf"); pBar.setTitle(title); pBar.setMessage(msg); pBar.setProgressStyle(style); pBar.setProgress(100); </code></pre> <p>but i want to modify the message text size and color,can you give me some advice</p>
android
[4]
1,371,707
1,371,708
Android Add-on site edit repository.xml
<p>I have an Android Sdk Add-on that I want to publish on a site and make it possible to download via Android SDK and AVD Manager. Anyone who knows if there is a tool to generate the repository.xml file or do I have to edit it myself? </p> <p>BR</p>
android
[4]
4,810,314
4,810,315
How can I check if an element is in map keys in C++?
<p>I am wonder if there is a way I can check if an element is included in map keys. For example:</p> <pre><code>#include&lt;iostream&gt; #include&lt;map&gt; using namespace std; int main() { map&lt;char, int&gt; mymap; mymap['a'] = 1; mymap['b'] = 2; mymap['z'] = 26; // I want to check if 'b' is one of the keys in map mymap. return 0; } </code></pre> <p>Elements 'a', 'b' and 'z' are the keys of map mymap. I want a command that will return <code>true</code> if element is in keys of a map and <code>false</code> if the elements is not in keys of a map. I looked around, but could find a quick build-in method that does this. Did I miss anything? Is there a such a method?</p> <p>Here is a long way that gets me my desired outcome:</p> <pre><code>#include&lt;iostream&gt; #include&lt;map&gt; using namespace std; bool check_key(map&lt;char, int&gt; mymap, char key_val); int main() { map&lt;char, int&gt; mymap; mymap['a'] = 1; mymap['b'] = 2; mymap['z'] = 26; char key_val = 'h'; cout&lt;&lt;mymap.find('z')-&gt;first&lt;&lt;endl; cout&lt;&lt;"checking "&lt;&lt; check_key(mymap, 'h')&lt;&lt;endl; cout&lt;&lt;"checking "&lt;&lt; check_key(mymap, 'b')&lt;&lt;endl; return 0; } bool check_key(map&lt;char, int&gt; mymap, char key_val){ for (map&lt;char, int&gt;::const_iterator it = mymap.begin(); it != mymap.end(); ++it ){ if (key_val == it-&gt;first){ return true; } } return false; } </code></pre> <p>Thank You in Advance</p>
c++
[6]
3,093,348
3,093,349
Fade edge with custom ListItems
<p><strong>EDIT: Solved</strong> I am developing on a Samsung Galaxy Tab 10.1, which has some version of TouchWiz. I tried my application on a device running stock android 3.x and it faded the items correctly. </p> <p><strong>Original Post:</strong> I am wondering why my <code>ListView</code> is not fading the top or bottom of my list. I have a feeling that because I have made a custom <code>ListItem</code>, that it ignores any fading that the <code>ListView</code> is trying to do.</p> <p>I have tried:</p> <ul> <li>manually setting fading edge to <code>vertical</code> for moth the <code>ListItem</code> and the <code>ListView</code></li> <li>setting the fading edge length to some value to see if it was defaulting to 0 for some reason.</li> </ul> <p>Is there something I need to implement in my <code>ListItem</code> to allow it to fade properly? Here is a picture of my <code>ListItem</code>. It has a 9-patch background image, a few <code>TextView</code>s, and a <code>ProgressBar</code>. Some of the <code>TextView</code>s have a custom font applied to them in code.</p> <p><img src="http://i.stack.imgur.com/iDf4X.png" alt="My custom ListItem"></p>
android
[4]
913,669
913,670
What does super's clone do?
<p>I am reading about <code>clone</code> from <code>Effective Java</code><br> It says that in <code>clone</code> the first method to be called must be <code>super.clone()</code><br> In this case, I guess that eventually we would end up calling the <code>clone</code> of <code>java.lang.Object</code> going up the hierarchy chain.<br> But I thought that object's clone doesn't do anything.<br> Looking in code I see:<br> <code>protected native Object clone() throws CloneNotSupportedException;</code> and no implementation.<br> But from the paragraph it seems that if a class has only primitive fields calling<br> <code>(ClassX) super.clone()</code> is sufficient for creating a clone.<br> But how? <code>super.clone</code> is of <code>Object</code>. </p>
java
[1]
4,904,818
4,904,819
php scripts as root user
<p>Before anyone decides to tell me running php scripts as root is bad please read the next line carefully:</p> <p>THIS IS A LAN ACCESS ONLY NO PUBLIC ACCESS.</p> <p>now that said I'm trying to setup some php scripts to manage the lan dhcp server and a few other tasks and I have su php installed but not sure how to configure it to run the php files as root.</p> <p>if anyone has done this before please guide me in allowing the scripts to run as root</p>
php
[2]
3,426,704
3,426,705
I feel stuck in the center of Python, How to get past beginner
<p>I really apologize if this doesn't follow the S.O rules but I need a little help, I personally still classify myself as a beginner in python, Yet I've wrote a very small and VERY SURE impractical program for my boss to use. </p> <p>I know I'm still a beginner because simple things still perplex me but every book I read for beginners honestly just rehashes what I do already know but every 'more advanced' book doesn't really allow me to learn, they depend on example files and I never really understand why they built 'said' function or 'said' class. So onto my question...</p> <p>Is there any recommendations on a book or ANYTHING that pushes me out of this stage, I've used head first and normally they are really good but my issue there is they have me back tracking just to move forward again, It worked in HTML but its confusing in Python, basically I think I need to build a program while following along, Again I like HeadFirst's style but I need something that isn't going to make me have to remember one thing just to forget it...</p> <p>for record, I've checked into some O'Reilly books</p>
python
[7]
5,040,166
5,040,167
Nested associative array as object
<p>I'm trying to access a nested associative array as object</p> <pre><code>function multiArrayToObject(array $array){ if(!is_string(key($array))){ throw new Exception('Invalid associative array'); } $root = new ArrayObject($array,ArrayObject::ARRAY_AS_PROPS); foreach($array as $value){ if(is_array($value)){ multiArrayToObject($value); } else{ return $root; } } return $root; } $array = array('user' =&gt; array('data'=&gt;array('name'=&gt;'bob'))); $data = multiArrayToObject($array); var_dump($data-&gt;user-&gt;data); </code></pre> <p>but it doesn't work.</p> <p>Could you help me, please ?</p> <p>Thanks in advance.</p>
php
[2]
5,110,967
5,110,968
Java parameter passing question
<p>I have kind of a general java question I'm looking for an answer to. Lets say I have an object with a property height and I have a method that uses height to make some calculation. Is it better to pass the property height to the method or is it any different to pass the full object and use a getter to retrieve the value of height. I hope this makes sense.</p> <p>e.g.</p> <pre><code>public getHeightInMeters(Object object) { return object.getHeight()*x; } </code></pre> <p>is the same, worse, better than?</p> <pre><code>public getHeightInMeters(Height height) { return height*x; } </code></pre>
java
[1]
4,293,613
4,293,614
How to append some object arrays in C#?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1547252/how-do-i-concatenate-two-arrays-in-c">How do I concatenate two arrays in C#?</a> </p> </blockquote> <p>How do I append some object arrays into one big object array?</p> <p>For example, I have 3 elements of type: <code>object[]</code> and want to make one of it. How to do this?</p>
c#
[0]
5,902,001
5,902,002
Why am I receiving these syntax errors in Python 3.1.2?
<p>I have been receiving errors when trying to save and run this Python 3.1 script, and I'm not sure why. I'm new to python, and I've been trying some of the Project Euler problems (this is problem 2). I recieve a "invalid syntac" error on "evenfibsum(v)", and on the colon after "<strong>__<em>main</em>__</strong>". I'm not sure why this is as I wrote a script for the first Project Euler problem in this same fashion, and it worked fine. I understand that I could write a script without defining a function, but I'm still interested in why this is not working.</p> <pre><code>def evenfibsum(v): a = 1 b = 2 r = 0 while b &lt; v: if b%2 == 0: r = r + b a, b = b, a+b else: a,b = b, a+b print("The sum of the Fibonacci sequence is: ", r) def main(): print("This program is designed to find the sum of all even") print("numbers from the specificed Fibonacci sequence.") v = int(input("What is the highest number you would like to evaluate in the sequence? ") evenfibsum(v) if __name__ == '__main__': main() </code></pre>
python
[7]
3,294,955
3,294,956
Limit number of input tags in jQuery
<p>I've been searching for a jQuery auto-suggest tags (similar to the stackoverflow tags input) plugin which restricts the number of input tags (ie. does not allow to create more than 5 tags for example?). If someone knows such plugin, or is <a href="http://levycarneiro.com/projects/tag-it/js/tag-it.js" rel="nofollow">kind enough to modify this code</a> to Limit the number of tags, I'll be really thankful.</p>
jquery
[5]
3,522,795
3,522,796
Set scroll position
<p>I'm trying to set the scroll position on a page so the scroller is scrolled all the way to the top.</p> <p>I think I need something like this but it's not working: </p> <pre><code>(function () { alert('hello'); document.body.scrollTop = 0; } ()); </code></pre> <p>Any ideas?</p>
javascript
[3]
5,549,407
5,549,408
Uploading iphone application
<p>I am trying to create archive of my iphone project. The archive is created but it has no version and identifier information.version is Unspecified and identifier is blank.</p> <p>In my target summary page everything(version and identifier)are fine. I am using Xcode 4.3</p>
iphone
[8]
5,530,698
5,530,699
File not found found exception - but I know it's there
<p>I keep getting a "File not found exception", but I know it's there! <code>File file = new File("C:\\A-small-practice.in");</code> is able to find the file fine, but when I try to use <code>FileInputStream</code> it returns an exception.</p> <pre><code>import java.io.*; public class Solution { public static void main(String[] args) { File file = new File("C:\\A-small-practice.in"); System.out.println(file.getAbsolutePath()); //prints C:\A-small-practice.in FileInputStream fstream = new FileInputStream(file); } } </code></pre>
java
[1]
1,096,112
1,096,113
How to submit form on webpage in PYTHON?
<p>I want to tick checkboxes, select radio buttons, write in text boxes and finally click on submit button to submit the form on a page. Programming in PYTHON only. How do i achieve this?</p>
python
[7]
2,815,955
2,815,956
JQuery data() call
<p>Could anyone explain the difference between this:</p> <p>Update 1- reverting phrases</p> <pre><code>container.data("state", { test: 1 }); // works </code></pre> <p>and this:</p> <pre><code> container.data["state"] = { test: 1 }; // doesn't work </code></pre> <p>I found that the first construction works, while the last one doesn't. The call populates container with the initial data, i.e. "state" is blank when it's called.</p>
jquery
[5]
1,296,978
1,296,979
How fix the position the asp.net diagnostics trace on a page
<p>I use the <a href="http://www.codeproject.com/Articles/82290/Step-by-Step-Guide-to-Trace-the-ASP-NET-Applicatio" rel="nofollow">diagnostics trace</a> on one of my asp.net pages. It works somewhat, but the trace data is drawn all over my page: This makes it impossible to use the page any more, nor to properly read the trace.</p> <p>I use a master page. However i guess it has something to do with the css styles, but how to do without changing the customers styles, and on all pages, with probably different styles?</p>
asp.net
[9]
2,332,882
2,332,883
accessing php variables across files
<p>I have a php file with array as a global variable.I wish that the array should be accessed in other php file for further processing.But the thing is the global array variable is undergoing manipulation by a certain function in the first file.I want the updated value for the array variable in second file for further processing.Any help in this regard will be highly appreciated.</p>
php
[2]
1,314,962
1,314,963
how does an android app read data from the database/server?
<p>I am trying to make a simple android app. All I want the app to do is connect to my server/database and run a query. whatever the returned string from the DB is should be displayed on the screen. </p> <p>I have not found any examples of an app that show this. the <a href="http://developer.android.com/guide/index.html" rel="nofollow">dev guide</a> doesn't have anything like that. </p> <p>How does this work?</p> <ul> <li>Does the android app connect to the actual database and run queries?</li> <li>Does the android app require a restful API on the server?</li> </ul>
android
[4]
673,335
673,336
taking the value contained in the brackets using php
<p>for example the string is my name is xyz(25) i want to get 25 in a variable through php..</p>
php
[2]
4,578,111
4,578,112
Resources about the Javascript object model?
<p>I am looking for a good resource (comprehensive yet terse) that explains the Javascript object model: prototype, constructor, Function, Object, etc.</p> <p>Surprisingly there aren't many resources out there that discuss this issue. The best I found, so far, is this: <a href="http://www.mollypages.org/misc/js.mp" rel="nofollow">http://www.mollypages.org/misc/js.mp</a></p> <p>Anyone familiar with other (hopefully better) explanations?</p>
javascript
[3]
3,359,033
3,359,034
prevent window.opener.location.href form reloading parent
<p>I am opening a window on a page and when the user finishes filling out the form there is some logic that says </p> <pre><code>window.opener.location.href = window.opener.location.href; </code></pre> <p>This reloads the parent url. Is there anyway the parent document can prevent child windows from refreshing it?</p>
javascript
[3]
199,639
199,640
How to add Base class in Master Page for Multilingual Site
<p>I have got site for multilingual. I have added Resources file for it. But I have problem in Master Page.</p> <p>I have added Base class which have <code>InitializeCulture()</code> method. This Class inherit from content page. So all content page text have been changed according to language selection. But problem in master page Because when I inherit base class from master page error showing that Master Page does contain defination for Intializeculture.</p> <p>Base Class Method is:</p> <pre><code>protected override void InitializeCulture() { if (Session["myapplication.language"] != null) { string selectedLanguage = Session["myapplication.language"] as string; Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(selectedLanguage); Thread.CurrentThread.CurrentUICulture = new CultureInfo(selectedLanguage); } } </code></pre> <p>I also added this method in <code>Page_Init</code> event of Master Page. But no result found.</p>
asp.net
[9]
4,672,202
4,672,203
How to get a reference to the current window?
<p>Need a ref to the window in which a view is inside (no matter how deep inside). Usually there is only one window in an iPhone app. How would I access that the most easy way? Is there something cooler than getting the app delegate to access the window?</p>
iphone
[8]
3,042,175
3,042,176
Calling PHP functions from different domains
<p>Is it possible to call a PHP function found in a file on another website with a different domain? </p> <p>For example, I know that to call a PHP function from another file in the same domain (say function aaa() found in aaa.php) I just have to simply do this (with a few simplifying assumptions):</p> <pre><code>include_once('aaa.php'); aaa(); </code></pre> <p>I have tried doing something similar, such as:</p> <pre><code>include_once('http://othersite/aaa.php'); aaa(); </code></pre> <p>I cannot get this to work (the page seems to load fine, with no error messages, but the function does not execute). I have tried require(), which gives me a blank screen. I have had no success with fopen either.</p> <p>If it is possible to do this, how can I do it?</p>
php
[2]
4,035,320
4,035,321
Not getting the correct result back from inet_aton/struct.unpack
<p>Using python 2.6.5 on Windows XP, it seems I'm getting the wrong result when using the following code:</p> <pre><code>import struct import socket struct.unpack('L', socket.inet_aton('192.168.1.1'))[0] </code></pre> <p>This returns 16885952 while to my knowledge it should return 3232235777. Am I doing something wrong here? How do I fix this?</p>
python
[7]
3,367,154
3,367,155
What is the difference between crc32 and crc32b?
<p>Apparently the PHP function <a href="http://www.php.net/manual/en/function.hash.php" rel="nofollow"><code>hash()</code></a> can be called with the algorithms <code>crc32</code> and <code>crc32b</code>? What is the difference between them?</p>
php
[2]
1,526,605
1,526,606
mail server for windows 8 compatible with php mail
<p>Using php 5.3 and trying to use the mail command. I have windows 8 and want to get a pop3/smtp mail server setup so i can actually test the php mail functionality. I'm using apache web server and IIS for my version of windows 8 doesn't come with a smtp server. </p> <p>Any idea of what i should use to get this setup. </p>
php
[2]
5,874,544
5,874,545
Overflow one ul element into the next
<p>I have a number of <code>ul</code> elements on a page. I want to artifically limit the number of <code>li</code> elements it can contain. When that limit is reached, I want it to overflow to the next <code>ul</code> on the page (until it too reaches a limit and overflows to the next). And so on.</p> <pre><code>&lt;ul&gt; &lt;li&gt;1&lt;/li&gt; &lt;li&gt;2&lt;/li&gt; &lt;li&gt;3&lt;/li&gt; &lt;li&gt;4&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>In the above example, I'd limit it to 4 list items, and then overflow to the next <code>&lt;ul&gt;</code>:</p> <pre><code>&lt;ul&gt; &lt;li&gt;5&lt;/li&gt; &lt;li&gt;6&lt;/li&gt; &lt;li&gt;7&lt;/li&gt; &lt;li&gt;8&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I'd like to do this using jquery. Thank you. </p>
jquery
[5]
3,877,242
3,877,243
How can I get a string from the contents of a photograph on android?
<p>I am making an application for android as a final project in a class. The application determines if the equation is written a line, circle, ellipse, parabola or hyperbola. Now I can do it if I typed in the equation. Now what you are asking me is to take a photograph of the equation and make all the calculations automatically. Could you help? I know it's possible but have not found a single reference to indicate how. Really please that I only need to complete.</p>
android
[4]
5,376,646
5,376,647
how to find all first indexes in the string?
<p>I am use this source: </p> <pre><code>String fulltext = "I would like to create a book reader have create, create "; String subtext = "create"; int i = fulltext.indexOf(subtext); </code></pre> <p>but I find only the first index, how to find all first indexes in the string ? (in this case three index)</p>
java
[1]
3,936,855
3,936,856
CharAt gives "Cannot find symbol" error
<p>I recently start studying JAVA, and I find this code:</p> <pre><code>public class Dublicate{ public static void main(String[] args){ int r=0; for(int i=0;i&lt;(args[0]).length();i++){ char ch=args[0].CharAt(i); r=r*10+ch-'0'; } System.out.println(r); } } </code></pre> <p>I don't really confident that this code will work properly, I don't confident in <code>args[0]</code>, but this code don't what to compile:</p> <pre><code>Dublicate.java:6: cannot find symbol symbol : method CharAt(int) location: class java.lang.String char ch=a.CharAt(i); ^ 1 error </code></pre> <p><strong>How I can solve this problem?</strong></p> <p>P.S. Also if I write:</p> <pre><code>int i=4; String a = "argsas"; char ch=a.CharAt(i); </code></pre> <p>I also get Error:</p> <pre><code>Dublicate.java:5: cannot find symbol symbol : method CharAt(int) location: class java.lang.String char ch=a.CharAt(i); ^ 1 error </code></pre> <p><strong>Update:</strong> Yeah, lovercase works thank you all!!!</p>
java
[1]
2,697,345
2,697,346
does this error affect my code.?
<p>i m getting error in firebug console</p> <pre><code>uncaught exception: [Exception... "'Invalid save data.' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: chrome://firebug/content/spy.js :: callPageHandler :: line 744" data: no] </code></pre> <p>When i put this code</p> <pre><code>value = key+'^_^'+value; </code></pre> <p>But when i modify this code and put</p> <pre><code>value = key </code></pre> <p>the error removes.</p> <p>so does this error affect my code?</p>
javascript
[3]
2,980,607
2,980,608
Open quote is expected for attribute "android:showAsAction" associated with an element type "item"
<p>this error is shown when binding menu xml file </p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:id="@id/menu_settings" android:orderInCategory="100" **at here show this error**android:showAsAction=["ifRoom" | "never" | "withText" | "always" | "collapseActionView"] android:title="@string/menu_settings"/&gt; </code></pre> <p></p>
android
[4]
1,444,039
1,444,040
Android XML. What is the purpose of the star in the ID string?
<p>In some sources I see such declarations</p> <pre><code>&lt;item android:id="@+id/menu_display_groups" android:icon="@*android:drawable/ic_menu_allfriends" android:title="@string/menu_displayGroup" /&gt; </code></pre> <p>Notice the *</p> <pre><code>@*android: </code></pre> <p>It seems to give access to internal resources. But would like to know for sure.</p> <p>Also curious, if it is safe to build application with such declarations using Android 2.2 SDK, and run it on 1.5.</p>
android
[4]
4,813,682
4,813,683
Can I convert an Android 1.6 project to 2.0?
<p>I have an Android 1.6 project. Can I directly convert it to 2.0?</p>
android
[4]
1,865,135
1,865,136
UIGestureRecognizer firing twice?
<p>I've set up a UITapGestureRecognizer on viewDidLoad of my view controller but somehow it fires the selector method twice for a single tap.</p> <pre><code>UITapGestureRecognizer *g = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openInMapsApp:)] autorelease]; [self.mapView addGestureRecognizer:g]; </code></pre> <p>My method:</p> <pre><code>-(void)openInMapsApp:(UIGestureRecognizer*)g { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:@"This will open this location in the Maps application. Continue?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil]; [alertView show]; [alertView release]; } </code></pre>
iphone
[8]
2,446,904
2,446,905
what we do for this error Syntax error on token "(", Expression expected after this token in java
<pre><code>Test bo = new Test(); bo.BubbleSort([10]); } public void BubbleSort( int [ ] num ) </code></pre>
java
[1]
4,120,890
4,120,891
How to update UI and wait till update is done
<p>Using android sdk 2.3. How can I synchronously update the UI from a service. I just need to update a text view in an Activity but it has to be synchronous, so my worker thread needs to stop for a bit. On iOS there is performSelectorOnMainThread waitUnitDone</p> <p>I can't find a waitUntil done on Android using runOnUIThread etc</p> <p>Thanks</p>
android
[4]
5,208,326
5,208,327
Drag and Drop links into a form input box using jQuery
<p>I have an input box that I would like to drag and drop links into using jQuery. My goal would be to click the link drag/drop it into the input box and have it populate the image tag if its a link to an image or the href tag if its a link to a file.</p> <p>Is this possible? Can anyone think of any examples for something like this? The more answers the better so please post what worked for you.</p> <p>Thanks in advance!</p> <p>Here is some more information for people who are interested: The drag and drop feature relies on browsers supporting File.API. </p> <p>More information:</p> <p><a href="http://www.thebuzzmedia.com/html5-drag-and-drop-and-file-api-tutorial/" rel="nofollow">http://www.thebuzzmedia.com/html5-drag-and-drop-and-file-api-tutorial/</a></p> <p><a href="http://www.w3.org/TR/FileAPI/" rel="nofollow">http://www.w3.org/TR/FileAPI/</a> </p> <p>Let me know if this was helpful and or if I can add more information. Thanks all!</p>
jquery
[5]
3,899,817
3,899,818
How can I to centered my location with mylocationoverlay?
<p>I can take my location with myLocationOverlay easily, and I want to set as a center of my location, I tried map controller:</p> <pre><code>MapController mc = myMap.getController(); mc.animateTo(); mc.setCenter(myLocOverlay.getMyLocation()); </code></pre> <p>these code didnt work so I changed</p> <pre><code>p = new GeoPoint((int) (myLocOverlay.getMyLocation().getLatitudeE6()), (int) (myLocOverlay.getMyLocation().getLongitudeE6())); mc.setCenter(p); </code></pre> <p>But there is no good news. I took null pointer exception then I assigned new location before myLocationOverlay() but its not working.. Thanks for advance.. </p>
android
[4]