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 |
---|---|---|---|---|---|
5,550,225 | 5,550,226 | c++ basic problem | <p>hi everybody out there
i have a problem in file handling i,m writing a code for file handling my code igs folowing </p>
<pre><code>ofstream SaveFile("/home/core-site2.xml")
//SaveFile<<"<?xml version="1.0"?>" ;
SaveFile <<endl ;
SaveFile<<"<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>" ;
</code></pre>
<p>now when i compile this file i got the folowing error
error: expected ‘;’ before ‘text’
what shouuld i do to remove the error?
how to write these line properly?</p>
| c++ | [6] |
163,703 | 163,704 | How to fix android.os.DeadObjectException android X | <p>When android unbind a service I created (service.MyService), I see the
following DeadObjectException.</p>
<p>Can you please tell me how what does this mean and can I fix this exception?</p>
<pre><code>W/ActivityManager( 583): Exception when unbinding service
com.mycompany/.service.MyService
W/ActivityManager( 583): android.os.DeadObjectException
W/ActivityManager( 583): at
android.os.BinderProxy.transact(Native Method)
W/ActivityManager( 583): at
android.app.ApplicationThreadProxy.scheduleUnbindService(ApplicationThreadNative.java:516)
W/ActivityManager( 583): at
com.android.server.am.ActivityManagerService.removeConnectionLocked(ActivityManagerService.java:9609)
W/ActivityManager( 583): at
com.android.server.am.ActivityManagerService.killServicesLocked(ActivityManagerService.java:8515)
...
</code></pre>
<p>Thank you.</p>
| android | [4] |
3,158,216 | 3,158,217 | Can I have a common Queue to queue up the requests received through function call? | <p>I will be happy, if you can give me some suggestions to solve my problem.</p>
<p>I have to make a function call from one program to another program (separate package). Now my question is, can i have a common Queue in the called program in which all the calling requests will be queued up ???? is it possible to maintain a queue??</p>
<p>Example.</p>
<pre><code>package1:
public class Callingprogram
{
public static void main(String args[])
{
CalledProgram cp=new Calledprogram();
cp.function(hashset);
}
}
package2:
public class Calledprogram
{
public void function(Hasheset hs)
{
here i am going to make use of the hashset sent by them
}
}
</code></pre>
<p>now here by i repeat my question :can i make any queue in Calledprogram such that it keeps track of all the calls made by Callingprogram and serves one by one...if so can i have a sample code such that i can proceed further....</p>
<p>Thank you..</p>
| java | [1] |
2,306,755 | 2,306,756 | I left Python learning because of Python 2 vs 3. Please Help | <p>I wanted To learn how to program for the first time.
Because i`m mainly practice on IT and Security, I choose to start with Python.</p>
<p>But, As is started to learn Python 3, I came to realize that Non of the modules I wanted to use were ported to Python 3, and even Django (one of the main reasons I wanted to learn python) and IronPython does not support python 3.</p>
<p>From my view, <strong>Python is not recommended for newbies</strong> because 1) Python 2 is about to be "<strong>out of future support</strong>" (the 2.7 is the last one). and 2) <strong>the Python 3 is not supported by the all important modules and frameworks</strong>...
So - someone who wants to learn python from scratch and not wasting time on a version that is about to be out of support (2), as no any good options (nor 2 or 3 version)...</p>
<p><strong>Please correct me if I`m wrong (and before I move to C# :) ).</strong></p>
| python | [7] |
4,033,984 | 4,033,985 | Best Place to Filter Inputs? | <p>I am wondering where the best place to filter user submitted input is. In regards to filter, I am talking about <a href="http://php.net/manual/en/function.filter-var.php" rel="nofollow">filter_var</a> and <a href="http://www.php.net/manual/en/function.filter-input.php" rel="nofollow">filter_input</a>.</p>
<p>I've come up with three scenarios:<br/></p>
<ol>
<li>Filter data from POST/GET, and pass filter data to function which takes it as-is.</li>
<li>Take raw data from POST/GET, and pass as-is to function where the function filters it.</li>
<li>Filter data from POST/GET, and filter is a second time in the function.</li>
</ol>
<p>Each of these methods has its advantages and disadvantages. I was looking for some insight into which may be best or standard practice.</p>
<p>Method 1 passes sanitized data to the function, and thus functions can be smaller not having to sanitize everything coming in. The downfall is if any other place your function is called and the data isn't sanitized, this can lead to problems. This simply requires good coding practice to remember to sanitize everything before passing to a function.</p>
<p>Method 2 you will never have to worry about your function dealing with unsanitized data, but the functions will be bigger.</p>
<p>Method 3 is the safest, but is wasteful. More code is written, and data may be sanitized multiple times as it passes through possibly various functions, wasting CPU resources and time.</p>
| php | [2] |
2,124,529 | 2,124,530 | Which one is better in terms of readability? | <p>If you have to check 3 conditions, and in an cases return the same value, like in this example:</p>
<pre><code> if (designatorType != AttributeDesignator.ENVIRONMENT_TARGET)
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
if (! attributeId.toString().equals("processor-load"))
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
if (! attributeType.toString().equals(IntegerAttribute.identifier))
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
</code></pre>
<p>Wouldn't it be better to rewrite it like this</p>
<pre><code> if (designatorType != AttributeDesignator.ENVIRONMENT_TARGET) ||
(! attributeId.toString().equals("processor-load")) ||
(! attributeType.toString().equals(IntegerAttribute.identifier)) ||
return new EvaluationResult(BagAttribute.
createEmptyBag(attributeType));
</code></pre>
<p>This is probably highly subjective but still I hope someone can give a valid answer :-).</p>
| java | [1] |
5,821,074 | 5,821,075 | how to be easier to analyse the json | <p>i want to analyse the json just like:</p>
<p>[{"id":"ssq","name":"双色球","term":"2010092","date":"2010-08-12 19:15","numbers":{"normal":"3,13,19,27,28,30","special":"2"},"jackpot":"30000000"},{"id":"3d","name":"3D","term":"2010216","date":"2010-08-12 19:55","numbers":{"normal":"6,8,8"},"jackpot":"-"},{"id":"qlc","name":"七乐彩","term":"2010093","date":"2010-08-11 20:45","numbers":{"normal":"08,09,10,11,16,21,27","special":"26"},"jackpot":"0"},{"id":"dfljy","name":"东方6+1","term":"2010093","date":"2010-08-14 18:30","numbers":{"normal":"4,1,3,9,7,2","special":"羊"},"jackpot":"12866531"},{"id":"swxw","name":"15选5","term":"2010217","date":"2010-08-12 18:45","numbers":{"normal":"1,3,5,13,15"},"jackpot":"5693612"},{"id":"ssl","name":"时时乐","term":"20100811-23","date":"2010-08-12 10:27","numbers":{"normal":"6,7,1"},"jackpot":"-"},{"id":"klsf","name":"快乐十分","term":"201021649","date":"2010-08-11 22:00","numbers":{"normal":"5,11,12,14,20"},"jackpot":"-"},{"id":"klsc","name":"快乐双彩","term":"2010215","date":"2010-08-10 21:25","numbers":{"normal":"12,23,10,15,7,3","special":"11"} ,"jackpot":"198059"}]</p>
<p>i want to gain all of them,but the data is so many,so whether i need to create 8 kinds of class to store the data,so to be easier to use.thanks!</p>
| android | [4] |
43,126 | 43,127 | select all options in select listbox by default -- javascript | <p>I have a form which has a select list associated with the field <code>players</code>.</p>
<p>To populate the listbox, user clicks on a button on the form to display a popup and from that popup select players' names and then click another button on the popup which closes the popup and displays the selected values in the listbox.</p>
<p>By default, i put <code>selected="true"</code> in the select tag so that when user saves the form, the values in the listbox are saved. </p>
<pre><code><select size=5 id="sub_player_ids" name="sub[player_ids][]" multiple selected="true">
</code></pre>
<p>The above code selects all options in the selectbox and those options are highlighted in blue.</p>
<p>However it can happen that user deselects an option in the player's select box by error.</p>
<p>I would like all options in the select box to be selected by default - whether they are highlighted or not </p>
<p>Is there is a way to select all options in the select box by default when saving the form?</p>
<p>Thanks a lot for any suggestion provided.</p>
<p>Cheers</p>
| javascript | [3] |
4,362,686 | 4,362,687 | Get multiple character positions in array? | <p>I want to get position of dots and commas in an array.</p>
<p>w.wer,ads,</p>
<p>should give something like:</p>
<pre><code>[0] > 1
[1] > 5
[2] > 9
</code></pre>
<p>How can this be done with javascript?</p>
| javascript | [3] |
553,097 | 553,098 | How does the Search Predicate of Findall work in a generic List | <p>I am able to work with the findAll and it's predicate...but I am wondering about the mechanics that makes it work.</p>
<pre><code> List<BradCollection> b = myList.FindAll(SearchForMe);
List<BradCollection> SearchForMe(string str)
{
if (str.Contains("brad"))
return true;
else
return false;
}
</code></pre>
<p>where is the "str" argument in the SearchForMe obtained?</p>
| c# | [0] |
389 | 390 | insatll php-fpm patch for php5.2.x | <p>I have php 5.2.17 and i download relevent php-fpmm file "php-5.2.17-fpm-0.5.14.diff.gz "
form php-fpm.rg But I don't know how to install this patch
i use slackware 13.1 x64</p>
| php | [2] |
4,332,656 | 4,332,657 | recursive template types | <p>I want to make following code snippet to work</p>
<pre><code>typedef boost::function<result_type ()> functor_type;
typedef boost::variant<int, functor_type> result_type;
</code></pre>
<p>two types depend on each other, how to break the circular dependencies?</p>
<hr>
<p>The Motivation</p>
<p>Basicly, I want to implement tail call in c++, like this</p>
<pre><code>template<typename ResultT>
struct TailCall
{
typedef ResultT result_type;
typedef boost::function<ret_type ()> continuation_type;
typedef boost::variant<result_type, continuation_type> ret_type;
TailCall(const continuation_type& init) : next(init) {}
result_type operator()()
{
while (true) {
ret_type r = next();
result_type *result = boost::get<result_type>(&r);
if (result)
return *result;
else
next = boost::get<continuation_type>(r);
}
}
private:
continuation_type next;
};
TailCall<int>::ret_type fibonacci_impl(int term, int val, int prev)
{
if (term == 0) return prev;
if (term == 1) return val;
return boost::bind(fibonacci_impl, term-1, val+prev, val);
}
int fibonacci(int index)
{
TailCall<int> fib(boost::bind(fibonacci_impl, index, 1, 0));
return fib();
}
</code></pre>
| c++ | [6] |
4,755,400 | 4,755,401 | How can I make some lines of code to run only one time | <p>Two classes in the same assembly: <code>Class A</code> and <code>Static</code> <code>Class B</code></p>
<p>In a method of <code>ClassA</code>, I am calling a method in <code>ClassB</code>,... but I want that to be called only one time and not every single time that I am caling that method of <code>ClassA</code> ...
currently I am setting a global property -Ran - to see if that method has been ran before or not...well it works but I feel that this is not the best design. I was wondering if there are better ways to do the same?</p>
<p>Thanks.</p>
<pre><code>ClassA.MyMethod(...)
{
....
//....
if (ClassB.Ran != 1)
ClassB.Foo();
....
//...
}
</code></pre>
| c# | [0] |
1,131,094 | 1,131,095 | pdf download from mysql database | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1204630/create-a-pdf-file-with-php">Create a PDF file with PHP</a> </p>
</blockquote>
<p>i need help..i want a php code to download information stored in the mysql database and save it in a pdf file..
so far, below is the code i have but it's not printing anything..
please help me to modify it or send me another better code.
thanks..</p>
<pre><code><?php
$host = 'localhost';
$user = 'root';
$pass = 'hello';
$db = 'version';
$table = 'childinfo';
$file = 'export';
$csv_output;
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$gotten =mysql_query("select sex,childnumber from child_nfo");
$row =mysql_fetch_assoc($gotten);
$bytes = $row[imgdata];
header("Content-type: application/pdf");
header('Content-disposition: attachment; filename="thing.pdf"');
print $bytes;
?>
</code></pre>
| php | [2] |
4,178,182 | 4,178,183 | sampling files from a folder | <p>I have a folder containing 100000 files, and need to get 1000 files from this folder through random sampling. Are there any sample functions that I can use to sample from folder? In addition, how to copy the sampled files to another folder?</p>
| java | [1] |
2,112,214 | 2,112,215 | Launching application on iPhone for non-developer | <p>Say I have created an application, and I want my friend to have it. (I am not going to submit it to the App Store; I just want my friend to run it on her iPhone). </p>
<p>I am not going to give the code, but is there any way I could create something like an <code>.exe</code> file, where she could launch it easily ?</p>
<p>Note, I used the word <code>exe</code>, to mean that I am looking for a easy way for a non-developer to launch the application on his/her iPhone.</p>
| iphone | [8] |
4,084,829 | 4,084,830 | Is jQuery runs only client side controll and gives error when we add runat=server | <p>I am working on a Portfolio project in which I am displaying Images in a Div "Book" . For giveng it an effect am using a jQuery that set the Div's size to a fixed size(500*700). Everything was going fine.</p>
<p>Now I need to controll the size of the division at runtime(new requirement). as soon as i add runat="server" to div jQuery starts to raise an error "Book is null or not an object" at bold position.</p>
<pre><code>Book.appendChild(B_LI);
B_RI = document.createElement("img"); **Book.appendChild(B_RI);**
B_MI = document.createElement("img"); Book.appendChild(B_MI);
</code></pre>
<p>I am not much familier with jQuery. Is jQuery runs only client side controll and gives error when we add runat=server.</p>
<p>Thanks</p>
<p>Suren</p>
| jquery | [5] |
3,734,981 | 3,734,982 | How to check a clicked button's second class? | <p>If I have two button, one with an <code>apple</code> class and the other with an <code>apple</code> and and <code>orange</code> class:</p>
<pre><code><button class="apple"/>
<button class="apple orange"/>
</code></pre>
<p>In my button click event for an <code>apple</code> button, how can I tell if the clicked button also has an <code>orange</code> class?</p>
<pre><code>$("button.apple").click(function(event)
{
var hasOrange = // ???
}
</code></pre>
| jquery | [5] |
4,950,762 | 4,950,763 | Finding the second highest number in array | <p>I'm having difficulty to understand the logic behind the method to find the second highest number in array. The method used is to find the highest in the array but less than the previous highest (which has already been found). The thing that I still can't figure it out is why <code>|| highest_score == second_highest</code> is necessary. For example I input three numbers: 98, 56, 3. Without it, both highest and second highest would be 98. Please explain.</p>
<pre><code>int second highest = score[0];
if (score[i] > second_highest && score[i] < highest_score || highest_score == second_highest)
second_highest = score[i];
</code></pre>
| java | [1] |
2,030,682 | 2,030,683 | If you use a database to store $_SESSION with session_set_save_handler should you encrypt? | <p>If you use a database to store $_SESSION with session_set_save_handler should yoou encrypt? If you should encrypt any recommendations on what to use to encrypt?</p>
| php | [2] |
1,655,004 | 1,655,005 | How do I access call log for android? | <p>I would like to recieve call log e.g numbers of call make by this person, number of minutes called, etc.</p>
<p>How do I archieve this in android?</p>
| android | [4] |
1,971,159 | 1,971,160 | find unique items in a set of arrays and remove non-uniques from arrays found | <p>Givven an object with <strong>Key</strong> as an Array (of position) and <strong>Value</strong> as an Array as well:</p>
<pre><code>// Example Object
0,2 : [6, 8, 9]
0,3 : [1, 6, 8]
0,4 : [6, 8]
0,5 : [6, 8]
0,6 : [4, 5, 8, 9]
0,7 : [5, 8]
0,8 : [4, 5, 7, 9]
</code></pre>
<p>(it was created like this:</p>
<pre><code>x = {};
x[[0,2]] = [6, 8, 9];
x[[0,3]] = [1, 6, 8];
...
</code></pre>
<p>Now, I want to narrow down my object to this, by checking if any number in an Array <strong>appears only inside this array</strong>, and not in others value's arrays, then eliminating all the other numbers inside the specific array which holds the unique number.<br/>(Rule: no duplicated inside a given array, so no need to check that):</p>
<pre><code>// Result Object
0,2 : [6, 8, 9]
0,3 : [1]
0,4 : [6, 8]
0,5 : [6, 8]
0,6 : [4, 5, 8, 9] // now 4 becomes also a "loner"
0,7 : [5, 8]
0,8 : [7]
</code></pre>
<p>so here in Key [0,3] the Value's array was narrowed down to just [1] because 1 is a unique number not showing up in the other array.</p>
<p>I'm having trouble thinking of an efficient pattern for this...</p>
| javascript | [3] |
76,362 | 76,363 | Configuring Android app settings via its website. Any pointers? | <p>I need some guidance/tutorial links/code logic to know how can we use web to configure an android app installed on a non-rooted android phone.</p>
<p>Eg. Disable some functionality of the app by logging on to the app's website and disabling the setting. What trigger does the website send to the app and how does this get changed/stored on the app side. How does a web server initiate an action(http request) to the app?</p>
<p>I am more concerned about the android part of the code that the web.</p>
<p>Any pointers please ?</p>
| android | [4] |
5,577,479 | 5,577,480 | Variable in load function SimpleImage class | <p>I have problem with SimpleImage class. </p>
<p>In case I have in load filename.extension (like 51533b35b6096.jpg) it works. </p>
<pre><code>$image = new SimpleImage();
$image->load('51533b35b6096.jpg');
$image->resize(900,700);
$image->save("./images/b_" . $img_name);
</code></pre>
<p>If I add variable in load it gives me error "failed to open stream: No such file or directory"</p>
<pre><code>$image = new SimpleImage();
$img_path = "51533b35b6096.jpg";
$image->load('$img_path');
$image->resize(900,700);
$image->save("./images/b_" . $img_name);
</code></pre>
<p>How can I solve that? Thanks in advance</p>
| php | [2] |
3,108,943 | 3,108,944 | Start and stop div scrolling between two other divs | <p>Someone else recently helped me out with the start of this question but I'm after a little more help. I currently have this working - </p>
<pre><code>var windw = this;
$.fn.followTo = function ( elem ) {
var $this = this,
$window = $(windw),
$bumper = $(elem),
bumperPos = $bumper.offset().top,
thisHeight = $this.outerHeight(),
setPosition = function(){
if ($window.scrollTop() > (bumperPos - thisHeight)) {
$this.css({
position: 'absolute',
top: (bumperPos - thisHeight)
});
} else {
$this.css({
position: 'fixed',
top: 0
});
}
};
$window.resize(function()
{
bumperPos = pos.offset().top;
thisHeight = $this.outerHeight();
setPosition();
});
$window.scroll(setPosition);
setPosition();
};
$('#one').followTo('#two');
</code></pre>
<p>Example here - <a href="http://jsfiddle.net/Tgm6Y/1447/" rel="nofollow">jsFiddle</a></p>
<p>This stops a div from scrolling once it reaches the border of another div - works great. What I'm stuck trying to figure out now is how I can make the scrolling div START at a div, then scroll down and stop at another div as it does in this example. Anyone got any ideas? </p>
<p>Here's a terrible illustration of it - <a href="http://jsfiddle.net/Tgm6Y/1450/" rel="nofollow">jsFiddle</a>. The blue section SHOULD sit underneath the yellow section until you reach it. I just can't figure out how that's possible due to my limited brain function. </p>
<p>Thanks a lot for any help. </p>
| jquery | [5] |
3,006,483 | 3,006,484 | How to get similar records from database and show in popup using php | <p>I Have 3 html fields when entered the values and click on find similar records button we have to get the similar records which are present in database table.</p>
<p>The 3 html fields were there in 3 different tables in database. How can i achieve this using php.</p>
<p>HTML Code:
User Form
</p>
<pre><code> <body>
<div style="text-align: right;">
<input type="button" name="similarRecords" value="Find Similar Records" ononclick="similarRecords();" />
</div>
<table>
<tr>
<td>User Name:</td>
<td><input type="text" name="userName" /></td>
</tr>
<tr>
<td>Email Id:</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>X Id:</td>
<td><input type="text" name="xId" /></td>
</tr>
</table>
</body>
</html>
</code></pre>
<p>I have thought about zend lucene (as i am using zend framework) but is there any other approach to it.</p>
<p>Please suggest me best way to to do it.</p>
| php | [2] |
357,242 | 357,243 | How to Serialize unserializable object in .NET | <p>I have 3-rd party dll. From that I receive an object of some type (I know its interface, but not all the object). That object is not marked as serializable and I'm not related to that libruary development at all. </p>
<p>I want to serialize it to some storage and then receive it from storage with <strong>the same state later (public/private, references etc.)</strong>. I got here one option - make my own serialization mechanism that will act the same as .NET serializers with the only difference - it won't revise serialization attributes. </p>
<p>Is that the best way? </p>
<p>Thanks.</p>
| c# | [0] |
3,964,970 | 3,964,971 | Context menu by short click | <p>Sorry for stupid question, but what I should change/add in that code- to show context menu by short click on item in list view?</p>
<pre><code>public class MyActivity extends ListActivity implements AdapterView.OnItemClickListener {
static final String[] COUNTRIES = new String[]{
"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
"Angola", "Anguilla", "Antarctica"
};
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(this);
}
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenu.ContextMenuInfo menuInfo) {
Log.e("sdklfjsdkljfl", " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ");
menu.setHeaderTitle("HELLO");
}
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.e("kjhasjkdhkas", "sdkhjkhskaf");
this.openContextMenu(view);
}
}
</code></pre>
| android | [4] |
5,015,351 | 5,015,352 | How do i use labels that are in Form1 dsigner at the new class? | <p>For example in my new class i have this:</p>
<pre><code>if ((connectionStart[f] == i && connectionEnd[f] == j) || (connectionStart[f] == j && connectionEnd[f] == i)) // this checking dosent work good !
{
//button2.Enabled = false;
return;
}
else
{
/*label12.Text = connectionStart[f].ToString();
label11.Text = connectionEnd[f].ToString();
label9.Visible = true;
label10.Visible = true;
label11.Visible = true;
label12.Visible = true;*/
}
</code></pre>
<p>Marked them with /* and */ for now</p>
<p>But how can i use them also the button2 so it will take effect when running the program ?</p>
<p>I cant make the button or labels static in Form1 since they are in the designer and i dont want to use static.</p>
<p>And i dont want to create Form1 instance.</p>
<p>I also want to build for all the labels,buttons and other objects like that some function/s in the class so i can use them easy and so they will take effect when im running the program.</p>
<p>For now they are not exist in the new class that clear. </p>
<p>** Maybe to create a property in Form1 for all this objects so i can use them easy in the new Class ? **</p>
| c# | [0] |
683,859 | 683,860 | getting error in HTTPURLConnection while running program on linux server | <p>I am running a progrom which is successfully running on my local machine(Success 200 Ok) but when I upload this to my linux web server I am getting the 404 error code.</p>
<p>My Code Is:</p>
<pre><code>try{
String url = "http://sms.bazaardekho.com/ComposeSMS.aspx";
String charset = "UTF-8";
String username = "shaillu";
String priority="1";
String dnd="1";
String unicode="0";
String query = String.format("username=%s&priority=%s&dnd=%s&unicode=%s",
URLEncoder.encode(username, charset),
URLEncoder.encode(priority, charset),
URLEncoder.encode(dnd, charset),
URLEncoder.encode(unicode, charset));
URL oracle = new URL(url + "?" + query);
HttpURLConnection yc =(HttpURLConnection) oracle.openConnection();
yc.setRequestMethod("GET");
yc.setConnectTimeout(3000);
yc.setRequestProperty("Accept", "*/*");
yc.setRequestProperty("User-Agent", "PARSHWA WEB SOLUTIONS");
yc.setRequestProperty("Accept-Charset", charset);
out.println(yc.getRequestMethod());
out.println(yc.getResponseCode());
out.println(yc.getResponseMessage());
out.println("<br/>ErrorStream :"+yc.getErrorStream());
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
out.println(inputLine);
in.close();
}catch(Exception e){out.println("Exception:" + e);}
</code></pre>
<p>Output:</p>
<pre><code>GET 404 Not Found
ErrorStream :sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@33a719 Exception:java.io.FileNotFoundException: http://sms.bazaardekho.com/ComposeSMS.aspx?username=shaillu&priority=1&dnd=1&unicode=0
</code></pre>
<p>This program is successfully running on my local machine but when I am trying to run this on my online server to use for my website, then I am getting this error.
Please give me the cause of this error & how can I resolve this.</p>
<p>Thank You.</p>
| java | [1] |
5,670,782 | 5,670,783 | jQuery function not able to get values unless an alert is written | <p>I have </p>
<pre><code> $j("input[id^='tab_name_edit']").each(function(){
var divcnt = $j(this).attr('id');
var divcnt = divcnt.split(/[_]/);
nosoftabs = divcnt[divcnt.length-1];
var tabnm1 = $j(this).val();
addInputGroup(tabnm1);
automateDynamicFields(nosoftabs);
});
function automateDynamicFields(nosoftabs){
//alert('No the value of nosoftab is recieved and the function works perfectly.')
$j("input[id^='registration_label"+nosoftabs+"']").slice(0,-1).each(function(){
add_tier($j('#dynamic_registration_url'+nosoftabs),'dynamic_registration_label',dynamic_registration_url_hn,nosoftabs);
});
}
</code></pre>
<h2>What I have.</h2>
<p>A function calling another function and passing a value <code>nosoftabs</code>. This value is recieved and the <code>function automateDynamicFields</code> works perfectly when i write Alert in it.</p>
<p>I know this has to do something with DOM elements not being ready. Is there any way to check if a <code>variable</code> is loaded in jQuery. I know using <code>$('myDiv').load(....)</code> this may be fixed, but curious to know if it can be done while putting a check on the variable load and only when it loads, it should be passed to the next function. </p>
| jquery | [5] |
5,375,551 | 5,375,552 | How to set Id of dynamic created layout? | <p>I want to give ID to some views (textview ,imageview etc) in a layout that is programmetically created.
So what is the best way to set ID. </p>
| android | [4] |
409,647 | 409,648 | Return a new array with specified values? | <p>Is there a way to write the following function code</p>
<pre><code>int* returnFilledArray() {
int* arr = new int[2];
arr[0] = 1;
arr[1] = 2;
return arr;
}
</code></pre>
<p>somehow like that? (create and fill the array as one liner).</p>
<pre><code>int* returnFilledArray() {
return new int {1,2};
}
</code></pre>
<p>if have tried various combinations, but I allways get some syntax errors, so when if it's
possible I would be thankful for a detailed explanation.</p>
| c++ | [6] |
5,262,658 | 5,262,659 | return monodimensional-array from multidimensional | <p>I have a multidimensional array:</p>
<pre><code>$array=array( 0=>array('text'=>'text1','desc'=>'blablabla'),
1=>array('text'=>'text2','desc'=>'blablabla'),
2=>array('text'=>'blablabla','desc'=>'blablabla'));
</code></pre>
<p>Is there a function to return a monodimensional array based on the $text values?</p>
<p>Example:</p>
<pre><code>monoarray($array);
//returns: array(0=>'text1',1=>'text2',2=>'blablabla');
</code></pre>
<p>Maybe a built-in function?</p>
| php | [2] |
2,921,484 | 2,921,485 | Python: how to ensure method gets a list | <p>I have a method that takes a list of strings. Unfortunately, if the list is only one item long, Python treats this list as a string.</p>
<p>This post has a method for checking whether something is a string, and converting it to a list if it is:
<a href="http://stackoverflow.com/questions/10654377/python-how-to-define-a-function-that-gets-a-list-of-strings-or-a-string">Python: How to define a function that gets a list of strings OR a string</a></p>
<p>But this seems an incredibly redundant way of getting the item that I passed in as a list to in fact be a list. Is there a better way?</p>
| python | [7] |
981,408 | 981,409 | how to display the number 1 each time user accesses the page | <p>I have a problem when it comes to displaying the correct number in my heading. When a user submits a page and navigates to this current page, I want the heading below to appear:</p>
<p>CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 1 OF 3</p>
<p>As you can see it above it starts with the number 1 as the user is creating their first session. The problem I am getting is that it never displays number 1, it just keeps displaying this below:</p>
<p>CREATING QUESTIONS AND ANSWERS: SESSION (AAA) 3 OF 3</p>
<p>It keeps displaying the number 3 which is incorrect as if the user enters the current page for the first time then obviousl they don't start with session 3, they start with session 1, then 2 then 3.</p>
<p>So my question is how do I get "SESSION 1" to be displayed when the useer enters the page for the first time?</p>
<p>Below is the current code I have:</p>
<pre><code> if(isset($_POST['sessionNum'])){
//Declare my counter for the first time
$_SESSION['initial_count'] = $_POST['sessionNum'];
$_SESSION['sessionNum'] = $_POST['sessionNum'];
}
if (!isset($_SESSION['sessionCount'])) {
$_SESSION['sessionCount'] = 1;
}
else if ($_SESSION['sessionCount'] < $_SESSION['sessionNum']) {
++$_SESSION['sessionCount'];
}
$sessionMinus = $_SESSION['sessionCount'];
...
<h1>CREATING QUESTIONS AND ANSWERS: SESSION (<?php echo $_SESSION['id'] ?>) <?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_count'] ?></h1>
</code></pre>
| php | [2] |
3,788,142 | 3,788,143 | Unable to hide/show div | <p>I need to hide one div and show one div.
I am new to Jquery but I've tried several methods that i could find. It still doesn't work and i have no idea.
Anyone has any idea? Very much appreciated for your help.</p>
<pre><code><div id="div1" runat="server">
<asp:Button ID="btnCalculate" runat="server" Text="Calculate Claim" OnClientClick="cfrm();"/>
</div>
<div id="div2" runat="server" visible="false">
<script language="javascript" type="text/javascript">
function cfrm() {
var fee = $('[id$=lblTotalProcedureFee]').text();
if (fee > 500) {
if (confirm('You are making a claim exceeding $500. Are you sure to do this operation?')) {
$('#div1').hide('fast');
$('#div2').show();
}
}
}
</script>
</code></pre>
| jquery | [5] |
5,569,480 | 5,569,481 | how to have multiple headers for different users of wishlist members (three different) | <p>I’ve a created wordpress membership site using wishlist member plugin. But I want to have different header.php based on different logins.</p>
<p>Eg: Users are: Print, Web and Free</p>
<pre><code>When Free user logs in – I want header1.php to load and stay till he logs out
When Print user logs in – I want header2.php to load and stay till he logs out
When Web user logs in – I want header3.php to load and stay till he logs out
</code></pre>
<p>If nobody has logged in the default header.php stays.</p>
<p>Please assist on how to do this.</p>
<p>Regards, Raghav.</p>
| php | [2] |
5,505,718 | 5,505,719 | How to convert a result of one object to string object | <p>I am new to java. There is a method which return a value of type xxx.</p>
<pre><code> public Cost getTotalCost() {
return getCost();
}
</code></pre>
<p>I want to convert the getCost() to type string. How do I do it?</p>
| java | [1] |
916,974 | 916,975 | Attaching events to two items in JQuery | <p>I would like to create a click event that will work when two different items are clicked.
Is there a way to do this?</p>
<p>For example, normally what I'd do is this:</p>
<pre><code><a id="link1" onclick="doSomething()">link1</a>
<a id="link2" onclick="doSomething()">link2</a>
</code></pre>
<p>But what I would like to know is whether there is any event overloading of sorts, perhaps like:</p>
<pre><code><script>
$("#link1", "#link2").click(function () {
alert('doSomething');
});
</script>
</code></pre>
<p>Thanks</p>
| jquery | [5] |
2,534,524 | 2,534,525 | image url Concatenate string | <p>i want to achievet the following Url</p>
<pre><code>ImageUrl='~/products_pictures/(imageId)_middle.jpg
</code></pre>
<p>im using gridview and datalist</p>
<p>im trying the follwoing combination but it not working</p>
<pre><code> <asp:Image ID="Image1" ImageUrl='~/products_pictures/<%#Eval("Id")%>_middle.jpg' runat="server" /></td>
<asp:Image ID="Image1" ImageUrl=<%"~/products_pictures/"%><%#Eval("Id")%><%"_middle.jpg"%> runat="server" />
</code></pre>
| asp.net | [9] |
4,813,531 | 4,813,532 | Does unbind('click') remove onclick? | <p>I'm running the following:</p>
<pre><code>$("#myelement").unbind('click');
</code></pre>
<p>When I view <code>$("#myelement")[0].onclick</code> in the VS.NET 2010 Watch window, I see <code>"{...}".</code></p>
<p>Should <code>unbind('click')</code> remove <code>onclick</code> events?</p>
| jquery | [5] |
5,518,264 | 5,518,265 | Mastermind game | <p>I'm a beginner in java programming. Now I'm doing a game called mastermind.</p>
<p>It has many conditions and I'm using numbers instead of colours.</p>
<p>I have no idea of how to solve this problem: I'm using if else statement to do my game but if the solution is 4444 and user input is 4444, the output answer is wrong.</p>
<p>In this game the first input is computer generated, but i have to test the program, so i set the number by myself, and the second input is the player input.</p>
<p>Here is the code i've done:</p>
<pre><code>import javax.swing.JOptionPane;
public class asd {
public static void main (String args[]){
int i,j;
int b=0 ,w=0;
String input[] = new String[4];
input[0] = JOptionPane.showInputDialog("input a digit");
input[1] = JOptionPane.showInputDialog("input a digit");
input[2] = JOptionPane.showInputDialog("input a digit");
input[3] = JOptionPane.showInputDialog("input a digit");
String Uinput[] = new String[4];
Uinput[0] = JOptionPane.showInputDialog("input a digit");
Uinput[1] = JOptionPane.showInputDialog("input a digit");
Uinput[2] = JOptionPane.showInputDialog("input a digit");
Uinput[3] = JOptionPane.showInputDialog("input a digit");
for(i=0;i<4;i++){
for(j=0;j<4;j++){
if(i<4){
if(input[i].equals(Uinput[j])){
if(i==j){
b++;
i++;
j=0;
}else{
w++;
}
}
}
}
}
System.out.println("black = "+b+"\nwhite = "+w);
}
}
</code></pre>
| java | [1] |
2,954,101 | 2,954,102 | How to format a double Value upto 2 decimal places in iPhone | <p>I am extracting double data from sqlite3 database. But I want to display it only upto two decimal places. So how to truncate it.</p>
| iphone | [8] |
5,977,161 | 5,977,162 | Customize context menu? | <p>I wonder if it's possible and and how to customize a context menu in Android? I have set a title to the menu, but I get a black background and the corners are angular compared to a similar menu that I get when I press the screen on my device. That menu has a blue background color and the corners are round and it also has a thin border.</p>
<p>Is this something that I also can do with a context menu?</p>
| android | [4] |
4,139,454 | 4,139,455 | jQuery: form and ajaxcall | <p>I would like to make an ajax call on submit.</p>
<pre><code><form id="editMail" action="" method="post">
<input name="user_email" type="text" value="mail" maxlength="50" id="user_email" style="width:200px;">
<input name="submit" type="submit" id="submit_editMail" value="Ändra">
</form>
$('#editMail').submit(function() {
$.ajax({
type: "POST",
url: "misc/email/activate.php",
data: { action: 'edit', user_email: new_usermail },
success: function(r){
if(typeof(r.error) != 'undefined') {
if(r.error != ''){
alert(r.error);
}
}else{
alert('OK');
}
});
});
</code></pre>
<p>But still nothing is happening, it doesnt do the ajax call but only refersh the page it's on. I tried adding onClick="return false;" to the submit button, but then nothing at all happens</p>
| jquery | [5] |
5,777,974 | 5,777,975 | iPhone, is it possible to remove the back button and make a view slide up? | <p>I have a view which I'm reusing (its a date range selection screen) it elsewhere in my app, its the only view and there isn't any other views to navigate too. So theres no back button.</p>
<p>I'm trying to reuse the screen to select a date range in another part of my app. I call it from a done button on the previous view. However, I'd rather it appeared like a dialog. Also my title is too big and if I have a back button it doesn't fit.</p>
<p>So can i remove the back button, is my main question?</p>
<p>Also can i make the view slide up from the bottom of the screen ?</p>
| iphone | [8] |
2,763,183 | 2,763,184 | I'm new to python, and trying to program a sales tax button for a calculator | <p>I just started programming in python not long ago, and I'm having trouble figuring out the rounding issue when it comes to tax and money. I can't seem to get decimals to always round up to the nearest hundredths place. for instance, in our state, sales takes is 9.5%, so a purchase of 5 dollars would make tax $.48, but in reality its $.475. I've tried math.ceil, but it seems like that only works to the nearest integer. Is there a simple way to enable a round up on any thousands digit? (ex .471 would round to .48)</p>
<p>Thanks</p>
| python | [7] |
1,179,593 | 1,179,594 | Possible to set transparency to XML gradient file? | <p>Is it possible to set transparency in gradient which is set in the XML file?</p>
| android | [4] |
570,248 | 570,249 | Threadpool in c++ using Boost Library | <p>I would like to write a multithreaded merge sort using threadpool and hence downloaded the boost library. I am newbie to c++ and has difficulty in understanding how to run the example programs given with the source. here is the source from where i downlaoded.. <a href="http://threadpool.sourceforge.net/" rel="nofollow">http://threadpool.sourceforge.net/</a> .... It is there in the Download section...Any help is appreciated.</p>
| c++ | [6] |
115,568 | 115,569 | jQuery function sometimes doesn't run | <p>I have the following function, basically used to set an iframe height to the height of it's content:</p>
<pre><code>$("#MSOPageViewerWebPart_WebPartWPQ1").load(function()
{
var Height = document.getElementById('MSOPageViewerWebPart_WebPartWPQ1').contentWindow.document.body.scrollHeight;
document.getElementById('MSOPageViewerWebPart_WebPartWPQ1').height = Height;
});
</code></pre>
<p>The vast majority of the time this will run as expected, but on the odd occasion it will take numerous reloads of the page before it works. Of course trying to debug it is fruitless as it always seems to hit the function and work.</p>
<p>Anyone any idea why it might not work every time?</p>
| jquery | [5] |
2,797,179 | 2,797,180 | Can we make a listview behave like expandablelistview | <p>Can we make an <code>ListView</code> behave like an <code>ExpandableListView</code>? I have an header with a button, with <code>ListView</code> below it. On the click of the Header Button can i <code>expand/collapse?</code></p>
<p><img src="http://i.stack.imgur.com/YYj4o.png" alt="enter image description here"></p>
| android | [4] |
4,704,069 | 4,704,070 | Javascript prototypal inheritance - descendants override each other | <p>I'm creating two objects (Inherits), both inherit from Base.
The second object's property assignment overrides the value in the first object.</p>
<p>Any thoughts? How to make a proper inheritance so that Base class will contain common members for its inheritance descendants, but the descendants could assign values of their own without interfering each other.</p>
<pre><code>var testParams1 = { title: "john" };
var testParams2 = { title: "mike" };
Function.prototype.inheritsFrom = function (baseClass)
{
this.prototype = new baseClass;
this.prototype.constructor = this;
this.prototype.base = baseClass.prototype;
return this;
};
function Base() {
this.viewModel = {};
this.viewModel.title = (function ()
{
var savedVal = "";
return function (newVal)
{
if (typeof (newVal) === "undefined")
{
return savedVal;
}
savedVal = newVal;
};
})();
}
function Inherits(params) {
this.viewModel.title(params.title);
}
Inherits.inheritsFrom(Base);
///// preparing code:
var testObj1 = new Inherits(testParams1);
var testObj2 = new Inherits(testParams2);
///// testing code:
equals(testObj1.viewModel.title(), testParams1.title, "first instance ok"); // returns "john"
equals(testObj2.viewModel.title(), testParams2.title, "second instance ok"); // also returns "john"
</code></pre>
| javascript | [3] |
2,765,375 | 2,765,376 | how to submit a from with validation in PHP? | <p>I want to submit this form through PHP. with validation for required field and validation for phone number and email field also</p>
<pre><code><form action="" method="" id="get-protected">
<div class="row requiredRow">
<label for="txt_FirstName">
First Name</label>
<input id="txt_FirstName" type="text" class="required" title="First Name. This is a required field" />
</div>
<div class="row">
<label for="txt_LastName">
Last Name</label>
<input id="txt_LastName" type="text" title="First Name. This is a required field" />
</div>
<div class="row">
<label for="txt_Phone">
Phone</label>
<input id="txt_Phone" type="text" title="First Name. This is a required field" />
</div>
<div class="row requiredRow">
<label for="txt_Email">
Email</label>
<input id="txt_Email" type="text" class="required" title="Email. This is a required field" />
</div>
<div class="row">
<input type="submit" value="" class="button" />
</div>
</form>
</code></pre>
| php | [2] |
329,486 | 329,487 | confused with BroadcastReceiver | <p>i have the following pgm which responds with a Toast with an incoming msg and also speaks out the received msg, however there seems to be no speech synthesis in background but i still can see the Toast though, so should i start a service from the onReceive method (don't know if that's possible) here and then in the startService method , write the speak method??</p>
<p>here's one of my pgms:</p>
<p><strong>Receiver</strong></p>
<pre><code>package com.example.TextSpeaker;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;
public class Receiver extends BroadcastReceiver{
public static String str;
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Log.d("Receiver","Message received successfully");
SmsMessage[] msgs = null;
if(bundle!=null)
{
// retrive the sms received
Object[] pdus = (Object[])bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for(int i=0;i<msgs.length;i++)
{
str="";
msgs[i]=SmsMessage.createFromPdu((byte[]) pdus[i]);
str+="Message From "+msgs[i].getOriginatingAddress()+". ";
str+="The message is "+msgs[i].getMessageBody().toString();
//TextSpeaker.mtts.speak(Receiver.str, TextToSpeech.QUEUE_FLUSH,null);
//str="";
}
Toast.makeText(context,str,Toast.LENGTH_LONG).show();
TextSpeaker.mtts.speak(Receiver.str, TextToSpeech.QUEUE_FLUSH,null);
}
}
</code></pre>
<p>}</p>
| android | [4] |
970,944 | 970,945 | When to pull default values from a file? | <p>Not a specific coding question so much as program structure in general.</p>
<p>I'm one of those poorly self taught hobby programmers and I've got no idea what the best route is here. I want to create an object with 4 variables (name, objID, a, and b). For example:</p>
<pre><code>class myObj:
def __init__(self, objName, objID):
self.name = objName
self.objID = objID
self.a = 0
self.b = 0
</code></pre>
<p>My question/problem is I want the initial values for a and b to be pulled from a .txt file, based on the value of objID. I actually want more than just 2 variables, and I'll be creating hundreds of these objects with a dozen different types.</p>
<p>I don't think I want to read the file from this class, as I believe it will reopen the file every time an object is created, and I don't really like pulling it into a list/array/dictionary and passing it to the class because the myObj class will only be called from an object above it, also with dozens of instances.</p>
<p>To clarify - I plan to create 100 'topObj' objects, each with 5-10 'myObj' objects, with each 'myObj' having starting values (that will change later), pulled from a text file, and I don't know when and where to read the data from the text file without reading it 500-1000 times.</p>
<p>Hopefully this makes some semblance of sense.</p>
<p>Thanks,<br>
db_</p>
| python | [7] |
164,926 | 164,927 | Printing a list of objects | <p>I am a Python newbie. I have this small problem. I want to print a list of objects but all it prints is some weird internal representation of object. I have even defined <code>__str__</code> method but still I am getting this weird output. What am I missing here?</p>
<pre><code>class person(object):
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return self.name + "(" + str(self.age) + ")"
def partition(coll, pred):
left = []
right = []
for c in coll:
if pred(c):
left.append(c)
else:
right.append(c)
return left, right
people = [
person("Cheryl", 20),
person("Shemoor", 14 ),
person("Kimbala", 25),
person("Sakharam", 8)
]
young_fellas, old_fellas = partition(people, lambda p : p.age < 18)
print(young_fellas)
print(old_fellas)
</code></pre>
<p>Please note that I know I can use either a <code>for</code> loop or a <code>map</code> function here. I am looking for something shorter and more idiomatic. Thanks.</p>
<p><strong>EDIT:</strong></p>
<p>One more question: Is the above code of mine Pythonic?</p>
| python | [7] |
4,056,212 | 4,056,213 | Exporting dll functions to unmanaged programs | <p>How can I export my c# dll functions to be able to use them from unmanaged programs.</p>
<ul>
<li>For example : Dll in c# and the application in Delphi/c++ .</li>
</ul>
<p>I don't have the source of the exe because is not Open S.
Can't use COM.</p>
| c# | [0] |
2,245,405 | 2,245,406 | Remove duplicate in a string without using arrays | <pre><code> String input = "AAAB";
String output = "";
for (int index = 0; index < input.length(); index++) {
if (input.charAt(index % input.length()) != input
.charAt((index + 1) % input.length())) {
output += input.charAt(index);
}
}
System.out.println(output);
</code></pre>
<p>But it doesn't work if my input is "ABABAB" or just "AAAA". Any ideas?</p>
| java | [1] |
618,375 | 618,376 | list fixed no of files from directory in java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/354703/is-there-a-workaround-for-javas-poor-performance-on-walking-huge-directories">Is there a workaround for Java's poor performance on walking huge directories?</a> </p>
</blockquote>
<p>I created a utility which lists all the files within some directory by using <strong>File.listFiles()</strong> function, but the problem occurred when i copied huge amount of files (around 100K) under that directory. </p>
<p>I was looking for some solution take actually takes some fixed no of files (say X) from that directory and processes and then deletes those files and takes next X number of files.
Can any one please suggest me any solution. </p>
<p>Regards</p>
| java | [1] |
20,280 | 20,281 | How to get image path from images stored on sd card | <p>is it possible to get the path of all the images that are stored on the sd card of my android phone? also is it possible to check for other images stored on sd card or in the internal memory? I am currently doing this:</p>
<pre><code>Cursor cur = this.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null,null);
startManagingCursor(cur);
cur.moveToFirst();
while (cur.moveToNext()) {
String str = cur.getString(cur.getColumnIndex(MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME));
Log.e("#########",str);
}
</code></pre>
<p>this seems as if returns the directories names,
also I have seen this code:</p>
<pre><code>File images = Environment.getDataDirectory();
File[] imagelist = images.listFiles(new FilenameFilter(){
public boolean accept(File dir, String name)
{
return ((name.endsWith(".jpg"))||(name.endsWith(".png")));
}
});
String []mFiles = new String[imagelist.length];
for(int i= 0 ; i< imagelist.length; i++)
{
mFiles[i] = imagelist[i].getAbsolutePath();
}
Uri[] mUrls = new Uri[mFiles.length];
for(int i=0; i < mFiles.length; i++)
{
mUrls[i] = Uri.parse(mFiles[i]);
Log.e("###############","MURIS: "+mUrls[i].getEncodedPath());
}
</code></pre>
<p>but this is throwing a nullpointer exception .</p>
<p>regards maxsap</p>
| android | [4] |
2,868,860 | 2,868,861 | Draw circle inside a label | <p>I am trying to draw a circle using Windows Form at runtime inside a label control. I am trying to display green or red circle and display the text('L1' or 'L2') on top of it. Could you please help. </p>
| c# | [0] |
5,142,776 | 5,142,777 | Is learncpp.com good for beginners? | <p>In my search for a good, freely available resource that will teach me C++ I stumbled on <a href="http://www.learncpp.com/" rel="nofollow">http://www.learncpp.com/</a>.</p>
<p>My question is for intermediate to experienced C++ programmers...</p>
<p><strong>Does this site seem to be a good resource for a beginner to learn C++ from?</strong></p>
<p>I've gone through the first few section of the site, and I feel like I am starting to grasp the language, but being a beginner in C++ I really could be learning things all wrong and have no idea. </p>
<p><strong>EDIT:</strong> After doing some research on this topic, and reading the answers and comments here, it seems like if I do the tutorial, read Accelerated C++, and then read Effective STL... I'll be on the right track. Of course, I'll be writing programs to solve project Euler programs and such. <strong>Do any of you have a better idea for a beginner with intentions to become competent in the language?</strong></p>
| c++ | [6] |
282,144 | 282,145 | using volatile keyword in java4 and java5 | <p>what is the difference in using <code>volatile keyword</code> in java4 and java5 onwards?</p>
<p>and related to that, </p>
<blockquote>
<p>Read/write operations on non-atomic variables(long/double) are atomic when they are
declared as volatile.</p>
</blockquote>
<p>Is this also true for java4 <strong>or</strong> it is valid from java5 onwards???</p>
| java | [1] |
627,558 | 627,559 | JavaScript Internals 101: arrays are just a special type of objects | <p>Internally, JavaScript has only objects (and primitive types). Objects are <strong>unordered</strong> collection of <code>key:value</code> pairs, where <code>key</code> is string and <code>value</code> can be any JavaScript type.</p>
<p>Arrays, though on the outside look like normal arrays of any other language, are actually a special case of objects, with natively supported language syntax.</p>
<p>Each array is an object where the key is a number and value can be any type. The keys are managed by JavaScript itself so that we can manipulate the array as an <strong>ordered</strong> collection of values. This is the reason we can use arrays in a <code>for-in</code> loop too. Additionally, JavaScript provides standard array operations (length, indexOf, splice, slice, join) as methods that take use the numbered keys to do their thing.</p>
<pre><code>>>> typeof []
"object"
>>> Object.prototype.toString.call([])
"[object Array]"
</code></pre>
<p>Is my understanding correct, or am I missing something?</p>
| javascript | [3] |
3,212,086 | 3,212,087 | How to view all JavaScript functions called in real time? | <p>I want to figure out how a website reloads it's content using AJAX. Therefore i would like to see what JS functions are called in real time because I can't figure out what function is responsible for reloading the page dynamically. How to see all executed functions JS in real time in FF, Chrome, Opera or IE?</p>
| javascript | [3] |
2,584,435 | 2,584,436 | Android 4.x and Dropbox - does not authenticate | <p>I've implemented a Dropbox interface in my Android app exactly as shown in the example
on the dropbox dev guide - <a href="https://www.dropbox.com/developers/start/setup#android" rel="nofollow">https://www.dropbox.com/developers/start/setup#android</a></p>
<p>It works perfectly on my Android 2.3.5 device, and works fine on my 4.x Emulator. However, in testing on real devices, it fails on 4.x devices with a "Not properly authenticated" error.
Two separate devices running 4.x have failed in the same way. </p>
<p>I realize this is a bit of a stretch to ask a question with out all the tech details, but the plain truth is I don't have them. The two users I was able to convince to help test on their real devices are a) remote and b) completely non-technical, so I have no Logcat data or stacktrace or anything else that might help. I was simply hoping someone else has run into
this and might have an answer. Failing that, anyone have a 4.x device they would be willing to run an app on and provide some logcat data?</p>
| android | [4] |
5,964,768 | 5,964,769 | Applying style to li generated in loop of function | <p>@nrabinowitz</p>
<p>I am now wondering how to get the map icon when clicked to apply a style to the LI that is created in the previous section. Is that possible? I attempted below in the code but does not work. </p>
<pre><code>function(I) {
// within the scope of this function,
// "thismarker" will work as expected
var listid = I + 1;
$("<li id="+I+"/>")
.html('<span class="leadId">' + listid + '</span>' + '<div class="leadDataWrapper"><div class="leadName">' + data[I][3] + ' ' + data[I][4] + '</div><div class="leadDate">' + data[I][2] + '</div></div><div class="leadType"><img src="/images/map-' + data[I][1].toLowerCase() + '.png"></div>')
.click(function(){
infowindow.close();
infowindow.setContent(contentString[I]);
map.setCenter(markers[I].position);
infowindow.open(map, markers[I]);
})
.appendTo("#leadsList ul");
google.maps.event.addListener(marker, "click", function(e){
infowindow.close();
infowindow.setContent(contentString[I]);
infowindow.open(map, markers[I]);
$("#leadsList li #"+I).css({"background-color":"#666666"});
});
})(I);
</code></pre>
| jquery | [5] |
3,832,547 | 3,832,548 | Adding UIViewController subclass with IBOutlet | <p>I have seen this example on Apple's website before, but for some reason, I cannot find it and am brainfarting. I created a TestViewController.h and .m file that subclass from UIViewController and have a .xib. In the TestAppDelegate.h, I have:</p>
<pre><code>@interface TestAppDelegate : NSObject <UIApplicationDelegate> {
TestViewController *rootController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TestViewController *rootController;
</code></pre>
<p>in TestAppDelegate.m, I have:</p>
<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self.window addSubview:rootController.view];
[self.window makeKeyAndVisible];
return YES;
}
</code></pre>
<p>Then in my MainWindow.xib, I drag a ViewController, change the class to TestViewController, control drag the outlet from TestAppDelegate to TestViewController. It builds fine, but when I run it I get:</p>
<pre><code>*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TestViewController 0x4d06570> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key label.'
</code></pre>
<p>I cannot remember what I'm missing in these steps. Any help would be appreciated. Thanks.</p>
| iphone | [8] |
2,324,876 | 2,324,877 | Safe ways of using os.system | <p>I have a program which retrieves information from a feed (say, a download link), and then downloads it. I also wish to provide for the user to use her own download handler. In general, I would like to allow the user to provide an instruction with several placeholders (such as <code>{link}</code>, <code>{directory}</code> and the like), and execute it.</p>
<p>The relevant bit of what I have now is</p>
<pre><code>instruction = value.format(link = link, filename = filename,
directory = directory, fullpath = fullpath,
title = title)
os.system(instruction)
</code></pre>
<p>This is probably all sorts of wrong, as nothing forbids <code>value</code> from simply erasing all user data, or some such. What is the right way to do this?</p>
| python | [7] |
5,695,239 | 5,695,240 | What do I have to do with the variable count in order to pass this tutorial about JavaScript function scopes? | <p>The <a href="http://nathansjslessons.appspot.com/lesson?id=1055&lang=en" rel="nofollow">tutorial</a> says:</p>
<blockquote>
<p>Define a function named callFunc that takes one argument, a function
f. It should return an array containing the values f(0), f(0), f(1),
f(1). You can only call f twice.</p>
</blockquote>
<p>This is what the tutorial gives:</p>
<pre><code>var count = 0;
var f = function (x) {
count += 1;
return x + 2;
};
var callFunc = function (f) {
};
</code></pre>
<p>I have no idea how to use <code>count</code> to pass this tutorial.
Any suggestions?</p>
| javascript | [3] |
2,358,423 | 2,358,424 | JavaScript math trouble | <p>well i was trying to hack storm8 scripting but it didnt work and it was annoying triyng to get the elements, that the gist of what was going on here but people didnt like the question...</p>
| javascript | [3] |
1,731,078 | 1,731,079 | C# -- How to handle duplicate multicastdelegate? | <p>Since we register the callback function <strong>PrintOne</strong> twice, the following code will print the message "PrintOne" twice. Here are questions,</p>
<p>Question 1> Why by default the operator+=(i.e. Combine) doesn't check duplicate method handler?</p>
<p>Question 2> How to avoid this duplicated call in method RegisterCall? I try to find some method in MulticastDelegate/Delegate that can tell me there is already one in the calling list. But I didn't find it.
<a href="http://msdn.microsoft.com/en-us/library/system.multicastdelegate.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.multicastdelegate.aspx</a></p>
<p>Thank you</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace app3
{
class Car
{
public delegate void PrintMethod(string msg);
public string Name { get; set; }
private PrintMethod printMethods;
public Car() { }
public Car(string name) { Name = name; }
public void PrintCar()
{
if (printMethods != null)
{
printMethods(this.ToString());
}
else
{
Console.WriteLine("No Method will be called");
}
}
public override string ToString()
{
return string.Format("Car Name is {0}: ", Name);
}
public static void PrintOne(string msg)
{
Console.WriteLine("PrintOne");
}
public static void PrintTwo(string msg)
{
Console.WriteLine("PrintTwo");
}
public void RegisterCall(PrintMethod methodToCall)
{
printMethods += methodToCall;
}
}
class Program
{
static void Main(string[] args)
{
Car mycar = new Car { Name = "BMW" };
mycar.RegisterCall(new Car.PrintMethod(Car.PrintOne)); // **will print for the first time**
mycar.RegisterCall(new Car.PrintMethod(Car.PrintOne)); // **will print for the second time**
mycar.PrintCar();
Console.ReadLine();
}
}
}
</code></pre>
| c# | [0] |
3,494,554 | 3,494,555 | JQUERY if not hover | <p>Mouseenter of DIV A sets DIV B to show(). What I want is on mouseleave of DIV A if they are <strong>not</strong> hovering over DIV B, hide DIV B. But, on mouseleave of DIV A if they are hovering over DIV B keep showing DIV B.</p>
<pre><code>$('#DIVA').mouseenter(function() {
$('#DIVB').show();
}).mouseleave(function() {
//if DIVB not hovering
$('#DIVB').hide();
//end if
});
</code></pre>
| jquery | [5] |
369,985 | 369,986 | prevent parent page from loading inside jquery dialog box on button click | <p>I have a jquery dialog box that loads a php file (shopping_cart_temp.php) via ajax. The php file has 3 ajax buttons, remove, add 1, or minus 1. The href for all 3 buttons is #. The problem is, when I click on any of the 3 ajax buttons, the parent page loads inside the jquery dialog box instead of completing the ajax button action. After doing some research I found that it could be because event.preventDefault or onclick=return false; are not present or not working. I can see this question or similar questions has been asked many times, but each solution I tried didn't work for me. Can you help me solve this please?</p>
<pre><code> $info_box_contents[$cur_row][] = array('align' => 'center',
'params' => 'class="productListing-data" valign="middle"',
'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id']) .
'<a class="cart-remove" style="visibility:hidden;" href="#" rel="' . $products[$i]['id'] . '">'
. tep_image(DIR_WS_ICONS . 'cancel.png', TABLE_HEADING_REMOVE) . '</a>' .
'<span style="display:none;" id="pn-' . $products[$i]['id'] . '">' .
'<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . $products[$i]['name'] . '</a></span>') ;
</code></pre>
| jquery | [5] |
2,382,034 | 2,382,035 | Is it right to have a setter to set different type than the property type? | <p>e.g.</p>
<pre><code> [XmlAttribute("Type")]
public string DataTypeString
{
get
{
return _dataType.ToString();
}
set
{
_dataType = Type.GetType(value);
}
}
private Type _dataType;
public Type DataType
{
get { return _dataType; }
set { _dataType = value; }
}
</code></pre>
<p>In the above code, first property type is string, however the setter sets, the _dataType which is of System.Type</p>
| c# | [0] |
1,034,575 | 1,034,576 | Edit Mozilla configuration file in Python | <p>Settings for the Mozilla Firefox browser my be changed by entering <code>about:config</code> in the address bar, which will open a configuration file. I would like to be able to edit, delete and add parameters to this file in Python. How can I do this?</p>
| python | [7] |
4,301,591 | 4,301,592 | A question related to UITextfield | <ol>
<li>I have code that dynamically load 10 different textfields in viewdidload method</li>
<li>now if i click on any UITextfield and then autorotate device then my cursor should directly
come to that UITextfield when device rotates from portrait to landscape mode</li>
<li>second case is that if i click on any UITextfield and then i click on return and then if i rotate my device from portrait to landscape mode then also it works as 1 st case</li>
</ol>
<p>How to do this thing by code<br>
any guidance helps me a lot<br>
I'm stuck here</p>
| iphone | [8] |
3,389,164 | 3,389,165 | delete db entry using js | <p>i have three file...
1st index.tpl.php
code of this is</p>
<pre><code><td>
<input type="button" name="checkbox" value="delete" onclick="selectAccess('<?php echo __('are you sure you want to delete data')?>','<?php echo $sGroups['id_user']; ?>')">
</td>
</code></pre>
<p>2nd is common.js</p>
<pre><code>function selectAccess(message,AccessId){
var answer = confirm(message)
alert(AccessId);
if (answer)
{
$.ajax({
url: SITE_URL + '/users/delete',
type: 'POST',
data: {
'ID':AccessId
},
success: function(data){
alert(data);
}
});
}
}
</code></pre>
<p>here its not working..... plese advice me where is mistake
thnks...</p>
| php | [2] |
2,006,357 | 2,006,358 | run a servo motor | <p>I'm having trouble running a servo motor using java. I know the servo works because I can test it using the program that came with it. The circuit board I'm trying to use is motor bee. The instructions tell me how to do it in C++, but I'm not good at converting it to java.</p>
| java | [1] |
2,561,652 | 2,561,653 | UserCollection? Cant locate dll | <p>Ive added the using Microsoft.SharePoint.Client;</p>
<p>But still getting errors, is it some dll i need to download?</p>
<p>This is the error:</p>
<blockquote>
<p>The type or namespace name 'SharePoint' does not exist in the
namespace 'Microsoft' (are you missing an assembly reference?)</p>
</blockquote>
| c# | [0] |
2,810,574 | 2,810,575 | Simple Javascript loop that repeats each second | <p>I'm writing a code to move a character in a browser game. I managed to get the pixels it must move per second both horizontally and vertically.</p>
<p>pxsecx is the number of pixels it must move horizontally per second
pxsecy is the same but vertically</p>
<p>Basically it should += them to the current horizontal and vertical position.</p>
<p>I need the loop to keep repeating itself every second until the element position meets the new position (newx). </p>
<p>This is as far as I have gone:</p>
<pre><code><body onmousedown="showCoords(event)">
<script type="text/javascript">
function showCoords(evt){
oldx = parseInt(document.getElementById("character").style.left);
oldy = parseInt(document.getElementById("character").style.top);
width = parseInt(document.getElementById("character").style.width);
height = parseInt(document.getElementById("character").style.height);
newx = evt.pageX - width/2;
newy = evt.pageY - height/2;
disx = newx - oldx;
disy = newy - oldy;
diag = parseInt(Math.sqrt(disx*disx + disy*disy));
speed = 50;
secs = diag/speed;
pxsecx = disx/secs;
pxsecy = disy/secs;
while(document.getElementById("character").style.left<newx)
{
document.getElementById("character").style.left += pxsecx;
document.getElementById("character").style.top += pxsecy;
}
}
</script>
</code></pre>
<p>Everything works until the while where I have no idea how to do make it work every second. I'm testing it here: <a href="http://chusmix.com/game/movechar.php" rel="nofollow">http://chusmix.com/game/movechar.php</a></p>
<p>How do I make it repeat that once a second so it works?</p>
<p>thanks</p>
| javascript | [3] |
2,836,030 | 2,836,031 | Early binding in final methods | <p>I have read in multiple places that final methods are early bound but none offers a satisfactory reason. I doubt how can it be so coz even in a final method called on parent class reference, compiler cannot say whether parent's non final or child's final method is called.<br>
Please advice. </p>
<pre><code>class Parent {
void meth() {
System.out.println("parent");
}
}
class Child extends Parent {
@Override
final void meth() {
// TODO Auto-generated method stub
System.out.println("child");
}
public static void main(String[] args) {
Parent parent = new Parent();
Parent child = new Child();
child.meth();
parent.meth();
}
}
</code></pre>
<p>In the above code method meth() called on child(a Parent reference) is a final method but then the JVM should need to use a method look up table at run time as in its the child or parent method being called.</p>
| java | [1] |
360,322 | 360,323 | how to set android default title bar at Bottom with image on it? | <p>how to set android default title bar at Bottom with image on it ?</p>
| android | [4] |
426,562 | 426,563 | Adding int to string | <p>Im triying to make a list which should look like this
Pages = ["Page 1", "Page 2" ... "Page 48"]</p>
<p>and im using this, Is there anything wrong with the following lines?</p>
<pre><code>String[] Pages = {};
int i = 0;
for (; i < 47; i++) {
String p = Integer.toString(i+1);
Pages[i] = ("Page " + p);
}
</code></pre>
<p>it keeps giving me a arrayIndexOutOfBoundsException</p>
| java | [1] |
355,430 | 355,431 | add event once in jquery | <p><br/>How can I have something like this :</p>
<pre><code><input class="myClass" id="a" type="checkbox" other="x"/>
<input class="myClass" id="b" type="checkbox" other="x"/>
<input class="myClass" id="c" type="checkbox" other="x"/>
<input class="myClass" id="d" type="checkbox" other="y"/>
<input class="myClass" id="e" type="checkbox" other="z"/>
</code></pre>
<p>I can retrieve the element a to e, add a click event and I want to add an event on the element define in the attribut <code>other</code> (x, y and z).<br/>
How can I do it?<br/>
I try :</p>
<pre><code>$(".myClass").each( function() {
$("#" + $(this).attr("other")).click( function() {
...
});
});
</code></pre>
<p>But three elements have <code>other="x"</code> so the event is add three time on x and I want just one.</p>
| jquery | [5] |
2,918,870 | 2,918,871 | Handling Shutdown Event | <p>Hi I have an Standalone application in which when an user logs in a abc.lck file gets created when the application is closed it gets deleted.I have used <strong>addshutdownhook()</strong> to delete the file when power supply is interrupted that is switching off the power supply when my application is running.My problem is the file is not getting deleted when I <strong>manually shutdown the system i.e by start-->shutdown</strong> and I should prompt the user with a message to save the changes using cofirm dailog box like in MS Word.Can some one help me
Thanking u
Chaithu </p>
| java | [1] |
4,126,770 | 4,126,771 | Defining >> operator | <p>I can not implement >> operator </p>
<pre><code>ostream&operator>>(Mode&refMode,ostream&os)
</code></pre>
<p>to perform chaining operations as </p>
<pre><code>refMode.iMode>>(refMode.jMode>>os)
</code></pre>
<p>Would you please provide me an implementation of it ?</p>
| c++ | [6] |
4,510,774 | 4,510,775 | Is there a shorter way to write "x = not y" when y is a boolean without importing a module? | <p>Just wondering if there is a smarter, shorter way to write this in python.</p>
<pre><code>y = False
x = not y
</code></pre>
<p>In javascript I would:</p>
<pre><code>y = false,
x = !y
</code></pre>
<p>Thanks!</p>
| python | [7] |
3,891,919 | 3,891,920 | How to check if a user is idle on a website using php | <p>How can I check if a user is idle for 10 minutes or more using php?</p>
<p>Is this possible?</p>
| php | [2] |
4,370,451 | 4,370,452 | invoking javascript for a input text which is part of dynamically added row in a table | <p>I need to have a datetimepicker to popup onclick of the date input fields, the date pickers are defined in a javascript function like this:</p>
<pre><code> function loadcalendar(){
jQuery(function() {
$('#ar_startdate').datetimepicker({
dateFormat: 'yy-mm-dd',
showSecond: true,
timeFormat: 'hh:mm:ss'
});
$('#ar_enddate').datetimepicker({
dateFormat: 'yy-mm-dd',
showSecond: true,
timeFormat: 'hh:mm:ss'
});
});
}
</code></pre>
<p>now I am calling load calendar when I populate the input fields into table row dynamically just after they are appended as rows to a table
Something like this:</p>
<pre><code>// when a image in table_newrole is clicked the input fields are appended as a row in table_rolecart, below is the js code
$(document).ready(function() {
$("#table_newrole img.move-row").live("click", function() {
$("#table_rolecart tbody").append('<tr><td>Start Date: <input type="text" value="" id="ar_startdate"></td><td>End Date: <input type="text" value="" id="ar_enddate </td></tr>');
loadcalendar();
</code></pre>
<p>With the above setup the datepickers get displayed only in first iem as right all input text fields share the same id, so how do I create an id from an index and associate each with the datepicker after that row is appended .
Regards,
Priyank</p>
| jquery | [5] |
3,452,013 | 3,452,014 | anyway to tell if a user has app installed using facebook? | <p>Is there anyway to know if a user has a app installed dy using Facebook?
I was thinking there may be a way because it asks for permissions from the user, so I'm sure its something that registers.
I want to be able to tell a user if any friends on Facebooka particular app installed that uses Facebook. If so tell them who. </p>
| android | [4] |
5,074,917 | 5,074,918 | jQuery delay not working | <pre><code>$('.transparent').removeClass('transparent').delay(2000).addClass('not_transparent').delay(4000)
</code></pre>
<p>I have a div that is semi transparent and then want to switch it to not transparent. But the jQuery .delay(); method doesn't seem to work here. I've tried .fadeIn(); instead and that works with a delay but it doesn't work the changing classes.</p>
| jquery | [5] |
1,921,955 | 1,921,956 | How to access child element out of children()? | <p>I'd like to get the # of immediate children an element has, and then get the class of a child at a particular index. Something like:</p>
<pre><code>var index = 25;
var children = $("#myListElement").children();
if (index < children.length) {
if (children[index].hasClass("testClass")) {
alert("hi!");
}
}
</code></pre>
<p>I think the syntax for .children() is ok, but how do I get the indexed element out of them in jquery style?</p>
<p>Thanks</p>
| jquery | [5] |
5,870,239 | 5,870,240 | ASP.NET Configuration tool provider error | <p>I want to setup login roles for my application.
When I go to the ASP.NET Configuration Tool and Click on the Provider Tab,
I select: Select a single provider for all site management data</p>
<p>I get this: AspNetSqlProvider
When I click on the test hyperlink, I get this message:</p>
<p>Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.</p>
<p>1) I created a ASPNETDB.MDF file in the APP_Data Folder
2) Ran the aspnet_regsql.exe tool that created the database ASPNETDB in my SQL Server
3) Edited the maching.config file for</p>
<pre><code><connectionStrings>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DIRECTORY|\App_Data\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
</code></pre>
<p>In DIRECTORY, I replaced DIRECTORY with the actual path: C:\Documents and Settings\Owner\My Documents\Visual Studio 2010\WebSites\myProject</p>
<p>Don't know what else I am missing to get the ASP.NET Configuration Tool to work</p>
<p>Thanks in advance for any help!</p>
| asp.net | [9] |
3,740,615 | 3,740,616 | How to recieve data from the server? | <p>I am trying to fetchg data from server like MP3 files, video files, etc. in my application. The application should show the list of video files received from the server. </p>
<p>How can I do this?</p>
| android | [4] |
4,767,649 | 4,767,650 | Naming the member variable beginning with m_ conforms to javabean style? | <p>Wondering if m_ naming convention conforms to Javabean property style?</p>
| java | [1] |
5,574,416 | 5,574,417 | How to reference object properties in another module | <p>I am relatively new to Python having used C# for many years and I'm hoping someone can help me with this question. I have a module called actuators.py that contains a number of classes for defining properties and methods for the servos I use in a robot project. In another module called robot.py, I instantiate my actuators like this:</p>
<pre><code>import actuators as Actuators
myActuators = Actuators.AllActuators()
</code></pre>
<p>This allows me to access the properties of my servos as long as I am in the robot.py module. For example, I can write:</p>
<pre><code>print myActuators.HeadTilt.MinPosition
</code></pre>
<p>to get the minimum value allowed for the servo that tilts the robot's head. So far so good.</p>
<p>Now I want to access these same values in a separate thread that is defined by a different module called tilt_head.py. I assume I need to import a reference to the robot.py module, but doing this ends up re-executing all the code in robot.py whereas all I really want is a static reference to the myActuators object. And I can't use</p>
<pre><code>from robot.py import myActuators
</code></pre>
<p>because myActuators is not a module.</p>
<p>In C#, I would do this using a declaration like this:</p>
<pre><code>public static Actuators myActuators;
</code></pre>
<p>which then allows me to reference myActuators in any other file within my project. Is there a way to do something similar in Python? If you need my actual code, I will be happy to post it.</p>
<p>Thanks!</p>
| python | [7] |
4,316,348 | 4,316,349 | Android-Prev Next button MediaController | <p>I want to show prev next button on my video but I don't know how to
This is my code:</p>
<pre><code> public static void play() {
mediaController.setAnchorView(mVideoView);
Uri video = Uri.parse(path_uri);
mVideoView.setMediaController(mediaController);
mVideoView.setVideoURI(video);
mVideoView.start();
mVideoView.requestFocus();
mDialog.dismiss();
Sipdroid.setIPTVflag(IPTV_PLAYER_STARTED)
</code></pre>
<p>Can anyone provide code to enable these buttons? </p>
| android | [4] |
3,242,945 | 3,242,946 | JavaScript synchronise multiple function calls | <p>I have a document, which has two <code>javascript</code> functions <code>A();</code> and <code>B();</code>.The functions get called in no particual order, I want to do something upon the last call.</p>
<p>I can accomplish the task by using local variables, but before doing so I'd like to confirm if there's more elegant/robust way for doing that - I might have more than two such fucntions, which makes local vars solution a complete mess.</p>
<p>Update 1 - More details</p>
<p>I've a few SilverLight plugins on a page, each has </p>
<pre><code><param name="onLoad" value="pluginLoaded" />
</code></pre>
<p>I can't go any further than "pluginLoaded" no paramters no nothing.</p>
<p>The plugins get loaded in an absolute random order, upon the overall compeltion I want to call another function. </p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.