Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,285,995
1,285,996
Manipulating hover state
<p>Is there anyway to manipulate :hover state through HTML DOM like:</p> <pre><code>javascript:void("document.body.backgroundColor=red"); </code></pre> <p>In the above code or through html DOM can hover state be defined but not through css. I want to make the background color red on only hover state so how can i solve this when the above code is placed in the URL?</p>
javascript
[3]
5,678,947
5,678,948
dictionary library in C++
<p>I have to use write a program in which the dictionary should be used to check whether one string is a valid word in it. Is there any dictionary library I could use? If not, how could I construct a dictionary for query?</p> <p>Thanks!</p>
c++
[6]
3,354,669
3,354,670
Dynamically Change Css Styles in C# (Sharp) Without Asp
<p>Hi all hopefully this is a quick one.<br> I'm working on a c# web browser that, amongst other things, changes css styles of web pages like google and facebook. for example it will make the background on facebook and google red instead of white. i've had success but its not at all consistent and i have no idea why.<br></p> <pre><code>HtmlDocument doc = Browser1.Document; HtmlElement textElem = doc.CreateElement("DIV"); textElem.InnerHtml = "&lt;STYLE&gt;body{background-color:red!important}&lt;/STYLE&gt;"; doc.Body.AppendChild(textElem); </code></pre> <p>that code works on www.google.com but not www.rationality.tk however..</p> <pre><code>HtmlElement head = Browser1.Document.GetElementsByTagName("body")[0]; head.SetAttribute("bgcolor", "red"); </code></pre> <p>That code works on <a href="http://rationality.tk" rel="nofollow">www.rationality.tk</a> but not <a href="http://google.com" rel="nofollow">www.google.com</a> and both codes do not work on www.facebook.com which i cannot get anything to work on.</p> <p>I'm probably doing something wrong and I just moved on to c# after giving up on c++ and I have found it a lot easier but still getting the hang of it. thank you in advance.</p> <p>EDIT: PROBLEM SOLVED <br></p> <pre>HtmlElement head = Browser1.Document.GetElementsByTagName("body")[0]; head.Style = "background-color:red";</pre> <p>this works on facebook, google and rationality.tk</p>
c#
[0]
151,682
151,683
Exporting and Importing Metabase Nodes Using WMI using C#
<p>Has anyone done the following using C#</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms525669(v=vs.90).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms525669(v=vs.90).aspx</a></p> <p>I am trying to import the IIS configuration setting to create a new website using C#.</p> <p>Many Thanks Ela</p>
c#
[0]
995,763
995,764
java Enum or Class with few constants. which one is advantageous?
<p>i have set of constants. Enum will be the best option to define set of constants.even we can define all constants in a java class. what are the advantages and disadvantages over both? i mean which one is more advantageous? Please help me.</p> <p>Thanks!</p>
java
[1]
5,243,662
5,243,663
why does the subclass have to invoke the no args constructor in the super class?
<p>On the piece of code below, I understand super(t) in the subclass is explicitly invoking a no-args constructor in its superclass (class B). What I seem to be having problems understanding is why does the subclass have to invoke the no-args constructor in the superclass? I can't seem to work out the purpose of this?</p> <pre><code>public class Test { public static void main(String[] args) { B b = new B(5); } } class A extends B { public A(int t) { super(t); System.out.println("A's constructor is invoked"); } } class B { public B(int k) { System.out.println("B's constructor is invoked"); } } </code></pre>
java
[1]
3,241,629
3,241,630
animation block not working
<p>im trying to update a uilabel sequentially via animation and as far as i can tell the label never animates it just goes from its default text to [tweets objectAtIndex:2]</p> <pre><code>- (void) statusesReceived:(NSArray *)statuses forRequest:(NSString *) connectionIdentifier { for ( NSDictionary *dict in statuses ) { [tweets addObject:[dict objectForKey:@"text" ]]; } tweetsLabel.text = [tweets objectAtIndex:0]; [tweetsLabel setFont: [UIFont fontWithName:@"Verdana-BoldItalic" size:42]]; [UIView animateWithDuration:5.5 animations:^{tweetsLabel.transform =CGAffineTransformIdentity;} completion:^(BOOL finished){ tweetsLabel.text = [tweets objectAtIndex:1]; [UIView animateWithDuration:5.5 animations:^{tweetsLabel.transform =CGAffineTransformIdentity;} completion:^(BOOL finished){ tweetsLabel.text = [tweets objectAtIndex:2]; }];}]; [self.tableView reloadData]; } </code></pre>
iphone
[8]
5,008,120
5,008,121
Update value of a nested dictionary of varying depth
<p>I'm looking for a way to update dict dictionary1 with the contents of dict update wihout overwriting levelA</p> <pre><code>dictionary1={'level1':{'level2':{'levelA':0,'levelB':1}}} update={'level1':{'level2':{'levelB':10}}} dictionary1.update(update) print dictionary1 {'level1': {'level2': {'levelB': 10}}} </code></pre> <p>I know that update deletes the values in level2 because it's updating the lowest key level1.</p> <p>How could I tackle this, given that dictionary1 and update can have any length?</p>
python
[7]
71,558
71,559
Strange behavior of 'return' statement in JavaScript
<p>I am quite new to JavaScript and just started some more serious development in JavaScript. I had a lot of fun implementing the Module pattern. One thing that really drove me crazy was the behavior of the 'return' statement. It is a big difference if you write </p> <pre><code>Test = ( function() { var message = "Hello World!"; return { // Does not work printTest: function() { window.alert(message); } }; }()); </code></pre> <p>or</p> <pre><code>Test = ( function() { var message = "Hello World!"; return { // Works well printTest: function() { window.alert(message); } }; }()); </code></pre> <p>Note the curly brace after the 'return' statement.</p> <p>Is that a typical stupid rookie error and is well documented somewhere?</p> <p>Firebug was not able to give a hint. IE9 and Chrome did report some obscure syntax error at a later location in the code: the opening brace after the '<code>function</code>' statement in "<code>printTest: function()</code>".</p> <p>Any comments on this? Are there more such pitfalls in JavaScript?</p>
javascript
[3]
4,004,699
4,004,700
MessageBox equivalent in Android?
<p>What would it be? (It would have an "[OK]" button on it too.)</p> <p>Thanks for any help.</p>
android
[4]
5,060,761
5,060,762
OnCreate Calls After OnPause in Android
<p>I am developing an app in which i have create three activities </p> <ul> <li>Main_Activity</li> <li>Second_Activity</li> <li>CustomView_Activity</li> </ul> <p>Here is the process in which these Activties called:</p> <ul> <li>MainActivity calls Second_Activtiy and in OnCreate of Second_Activtiy I have created object of CustomView_Activity.</li> <li>In Main_Activity I have a button on a LinearLayout which onClick calls Second_Activity in Second_activity OnCreate i have to keep my Screen On and and declare other things like buttons layouts etc.</li> <li>In CustomView_Activity i have creates canvas and onCanvas i have draw a Rectangle.</li> <li><p>Now when my Second_Activity calls after Main_Activity and calling OnPause on pressing Power button my activity calls </p> <pre><code>OnPause -&gt; OnStop -&gt; OnCreate -&gt; OnResume -&gt; OnRestart -&gt; OnDestroy </code></pre> <p>and when I press the power button to on the screen <code>OnResume -&gt; onCreate -&gt; OnRestart</code> calls.</p></li> </ul> <p>Due to calling of OnCreate again and again my activity not performing tasks correctly.</p> <p>Please anyone who can help??</p>
android
[4]
2,999,389
2,999,390
How to place the checkbox in tableview cells?
<p>hai,I want to place the checkbox in every row of tableview.Please provide any example code for place the checkbox in tableview cells</p>
iphone
[8]
296,707
296,708
Access web page from a different project
<p>NET ..</p> <p>In my solution I have two projects and I need a access a webpage of a second project from my 1st project .. Used</p> <pre><code>protected void registerButton_Click(object sender, EventArgs e) { Response.Redirect("./PersonalDetails/Details.aspx"); } </code></pre> <p>where PersonalDetails is my second project...but no sucess</p> <p>Please help Urgent Thanks </p>
asp.net
[9]
2,703,719
2,703,720
how to change a line in a txt-document with C#
<p>I'm having a problem here. I have a .txt-file where one line contains "message", this is the line I wanna change. But I can't get this code to work, anyone that can help me? I have this code here that is working for only replacing a string, but I don't know how to do it so it changes the whole line.</p> <pre><code>public void t() { string filename = @"F:\test\test.txt"; StringBuilder result = new StringBuilder(); if (System.IO.File.Exists(filename)) { using (StreamReader streamReader = new StreamReader(filename)) { String line; while ((line = streamReader.ReadLine()) != null) { string newLine = String.Concat(line, Environment.NewLine); newLine = newLine.Replace("message", "HEJHEJ "); result.Append(newLine); } } } using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite)) { StreamWriter streamWriter = new StreamWriter(fileStream); streamWriter.Write(result); streamWriter.Close(); fileStream.Close(); } } </code></pre> <p>This code is changeing "" to "HEJHEJ", but I want to whole line in the txt-document to change to "HEJHEJ", not just only the "message" part</p>
c#
[0]
1,313,926
1,313,927
Javascript and module pattern
<p>i think i did not understand javascript module pattern.</p> <p>I just create this module:</p> <pre><code>var mycompany = {}; mycompany.mymodule = (function() { var my = {}; var count = 0; my.init = function(value) { _setCount(value); } // private functions var _setCount = function(newValue) { count = newValue; } var _getCount = function() { return count; } my.incrementCount = function() { _setCount(_getCount() + 1); } my.degreeseCount = function() { _setCount(_getCount() - 1); } my.status = function() { return count; } return my; })(); var a = mycompany.mymodule; var b = mycompany.mymodule; console.debug(a, 'A at beginning'); console.debug(a, 'B at beginning'); a.init(5); b.init(2); console.log('A: ' + a.status()); // return 2 (wtf!) console.log('B: ' + b.status()); // return 2` </code></pre> <p>Where is the mistake? I thought that my code would have returned to me not 2 value, but 5.</p> <p>What's the reason? </p>
javascript
[3]
4,809,566
4,809,567
php: how to know what file has contains a php function that is called
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2222142/how-to-find-out-where-a-function-is-defined">How to find out where a function is defined?</a> </p> </blockquote> <p>in a client's website I have a php code:</p> <pre><code>return userHasActivePurchase($iId); </code></pre> <p>The website is full of icludes, requires. I have made a full text search on "userHasActivePurchase" to find out what php file does contain this function without success.</p> <p>My question is : <strong>I have a function name and I would like to know what php files contains that function.</strong></p> <p>I tried with:</p> <pre><code>print_r(userHasActivePurchase); </code></pre> <p>without success.</p> <p>Please help !</p>
php
[2]
3,402,917
3,402,918
Appending data into an array when condition is met?
<p>I'm trying to keep a timer for users in my IRC. When a user types a message I'm trying to insert the username &amp; time of the message. This is to stop spammers.</p> <pre><code>if(userList.Contains(username)) { //check the time of message //if last message is 3 seconds ago or greater, continue } else { //Add username &amp; time into the array keeping all other values too } </code></pre> <p>The problem is I don't know how to append data into the array. I don't know how to copy the other existing array data into the new array with the new values. Can this be done?</p> <p>Since array.Contains() doesn't work for two-dimensional arrays, what can I do to record the username and time? Should I insert data in two arrays?</p> <p>Thank you for the help.</p>
c#
[0]
1,947,323
1,947,324
Use a drawable with layer-list as if it was a normal image
<p>I am using an Intent to share an image, like elsewhere is explained on stackoverflow. Here is the code I stole from this site (thanks) :)</p> <pre><code>private void share(String nameApp, String imagePath) { List&lt;Intent&gt; targetedShareIntents = new ArrayList&lt;Intent&gt;(); Intent share = new Intent(android.content.Intent.ACTION_SEND); share.setType("image/jpeg"); List&lt;ResolveInfo&gt; resInfo = getPackageManager().queryIntentActivities(share, 0); if (!resInfo.isEmpty()){ for (ResolveInfo info : resInfo) { Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND); targetedShare.setType("image/jpeg"); // put here your mime type if (info.activityInfo.packageName.toLowerCase().contains(nameApp) || info.activityInfo.name.toLowerCase().contains(nameApp)) { targetedShare.putExtra(Intent.EXTRA_TEXT, "My body of post/email"); targetedShare.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)) ); targetedShare.setPackage(info.activityInfo.packageName); targetedShareIntents.add(targetedShare); } } Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), getResources().getString(R.string.share_select)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); startActivity(chooserIntent); } } </code></pre> <p>My problem is that I don't have any jpg to share, but I create the images, with drawables and layer-lists like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:drawable="@drawable/background01" /&gt; &lt;item android:drawable="@drawable/img02" /&gt; &lt;item android:drawable="@drawable/img07" /&gt; &lt;/layer-list&gt; </code></pre> <p>I don't understand if and how I can use these drawables as they were full images and use them inside the share() function. Can some one please explain me?</p> <p>Thank you in advance.</p>
android
[4]
5,777,752
5,777,753
Hightlight <tr> if data changed on database
<p><br> I`m trying to figure how I can highlight row in table when the data of this row is changed on my database.<br> So i have a timer that every few second ask if there is change in database but its only count my rows in the database, my question is how to highlight the row that user change some data there, I can know the <strong>id he changed</strong> ( I know because the user will submit some form and then i have a timer that looking for changes in my database, the timer will give me the id that changed recently) , for now I am only highlight the row onclick with this code : <br> </p> <pre><code> $(document).ready(function() { $("tbody tr").click(function () { $(this).effect("highlight", {}, 30000); }); }); </code></pre> <p>There is some way with jquery to detect specific value in the table ( like the id of this row - I will echo it in the table too ) and then every few second if i get from my script if the specific row id is changed to do something like :<br></p> <pre><code>$("tbody tr tr-child value==something").click(function () { $(this).effect("highlight", {}, 30000); </code></pre> <p>it is possible? Thanks.</p>
jquery
[5]
1,070,183
1,070,184
Iteration count in python?
<p>Let's say I have a list of tuples l, and I do something like this:</p> <pre><code>for (a,b) in l: do something with a,b, and the index of (a,b) in l </code></pre> <p>Is there an easy way to get the index of (a,b)? I can use the index method of list, but what if (a,b) is not unique? I can also iterate on the indexes in the first place, but its cumbersome. Is there something simpler?</p>
python
[7]
3,047,190
3,047,191
Filter apply concept with high performance and in fast way in android
<p>i am new to android and having a requirement to apply filter effect to the bitmap image.so,before i start with some basic effect like sepia to the bitmap image but the processing of image while applying is taking too much time(waiting time is more).for filter effect i had followed some link:</p> <p><a href="http://xjaphx.wordpress.com/2011/06/21/image-processing-photography-sepia-toning-effect/" rel="nofollow">link 1 for filter effect</a></p> <p><a href="http://xjaphx.wordpress.com/2011/06/21/image-processing-grayscale-image-on-the-fly/" rel="nofollow">for the grayscale effect</a></p> <p><a href="http://xjaphx.wordpress.com/2011/06/20/image-processing-highlight-image-on-the-fly/" rel="nofollow">for highlight effect</a></p> <p>as u go to link will find many more effect but all the effect taking much time in order to process the image,so on failing to achieve the fast performance again give a try for new concept of filter apply in bitmap image and on search in google play found one app <strong>Instagram</strong> which is also applying effect on image only but performance is good and fast in nature.so can anyone tell me what concept they are using in order to achieve the performance.Thanks for any reply. </p>
android
[4]
3,563,218
3,563,219
Get month of a given date
<p>Get month of a given date which is stored in a PHP time variable in 'Y-m-d' format</p>
php
[2]
3,117,211
3,117,212
Procedural--enough?
<p><em>I posted a similar question on the PHP section of stackoverflow and was told that this might be a better forum in which to submit my question.</em></p> <p>Without any programming experience whatsoever, I started studying PHP beginning in the second quarter of this year with the goal of slowly building my dream website starting later this summer.</p> <p>Just as I was wrapping my head around PHP and beginning--I felt-- to truly understand the different concepts and how the code works (this is why I prefaced my post with my non-experience--I've really had to bang and cram it all in my head), I come across Object Oriented PHP.</p> <p>I've taken the approach of of mastering (trying, as much as possible, at least) as many of the concepts and ideas before diving in to try and create my own scripts; much like learning how to dribble, throw a baseball or football well, before playing a single game. (of course I've played around with and done some code -drills).</p> <p>My question to the experts is this: Should or must I learn and delve deep into Object-Oriented-PHP, thus delaying my "start-to-code" date? Or will procedural PHP Programming suffice if one would like to build good E-commerce, forum/comment-type (like PHP Help) or basic social networking websites?</p> <p>How far will procedural programming take me? A site with 1,000; tens-of-thousands; hundred thousand visitors?</p> <p>Thanks in advance for your expert insights.</p>
php
[2]
1,711,963
1,711,964
cv-qualifiers and implicit type conversion
<p>In the code,</p> <pre><code>const int x = 3; int y = 0; y += x; </code></pre> <p>Is there any need to remove the const from x before doing the addition or is this maybe done implicitly in the addition operator definition?</p>
c++
[6]
362,875
362,876
Only one jQuery click event for div with same class name
<p>There are two <code>div</code> sections with the same class and also has same <code>ul</code> and <code>li</code> and <code>a</code>. </p> <p>I have two jQuery click events in my code. When I click Google both of the jQuery click events fire. But I do not want both to do so, only one. How do I achieve this?</p> <p>For example, if Google gets clicked I want only that jQuery click event to do something, not the other one. These are the DOM element I am working with:</p> <pre><code>&lt;div class = "abc"&gt; &lt;ul&gt; &lt;li class="year_"&gt;&lt;a href="www.google.com"&gt;google&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class ="abc"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="www.yahoo.com&gt;yahoo&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>The <code>href</code> might change so I cannot base my selector on that. The code that I have follows.</p> <pre><code>$( 'div.abc ul li[class^="year_"] a' ).click( function(){ //do something }); $( 'div.abc ul li a' ).click( function(){ //do something }); </code></pre>
jquery
[5]
5,292,002
5,292,003
What happen when the selector didn't find in JQuery?
<p>E.g:</p> <p>I pass one <code>selector</code> as <code>parameter</code> to a function.</p> <pre><code>// selector is an object function(selector){ selector.trigger('eventHere'); } </code></pre> <p>Obviously,the <code>event</code> will never fireed if the <code>selector</code> which passed in didn't have this <code>event</code>,but should I do some condition checking before trigger the event? I mean:</p> <pre><code>// selector is an object if(selector === 'matched'){ // then fire the event } else{ // do nothing } </code></pre> <p>or just leave it...?</p> <p>Thank you very much!!</p>
jquery
[5]
4,256,281
4,256,282
How to change group title in BaseExpandableListAdapter
<p>I created a sample about expandableList, and the structure is as below, </p> <ul> <li>MainGroup 1 (Expandable) text <ul> <li>SubGroup 1 (Expandable) <ul> <li>Child View</li> </ul></li> </ul></li> </ul> <p>The requirement is when I was clicking childView, that 'text' filed will change to childView text, do you know how to handle this?</p>
android
[4]
4,981,889
4,981,890
automatically start up a service when the application is closed
<p>i have created an application which will start a service to check a particular remote file for update..</p> <p>the service part is done but now the user needs to manually start up the service</p> <p>is there a way which i can make the service start up automatically once the application is not in view (either the user clicks the home button/clicks back or open another application)</p> <p><strong>++++++++++ANSWER++++++++++</strong></p> <p>anyway figured out how to do it already</p> <pre><code> @Override protected void onPause() { startService(new Intent(this, fileService.class)); super.onPause(); } @Override protected void onResume() { stopService(new Intent(this, fileService.class)); super.onResume(); } </code></pre> <p>i used this to start the service when the application is paused and stop when its resume</p>
android
[4]
5,412,823
5,412,824
warning:array elements are more than 100
<p>I have a piece of code declaring an array.</p> <pre><code>#define MAX_ELEMENT 150 Struct_arr arr_elem[MAX_ELEMENT]; </code></pre> <p>Here <code>Struct_arr</code> is a structure. On compilation i am getting the warning for this later line as:</p> <pre>warning:array elements are more than 100</pre> <p>could someone please help me about this?</p> <p>regards, vivG</p>
c++
[6]
3,685,648
3,685,649
How to improve Performance of asp.net web page
<p>Can any one give me links of good performance in asp.net pages.</p>
asp.net
[9]
1,980,199
1,980,200
How do I get this variable to be global?
<p>The problem here is that I do not know where to define the variable <code>wage</code>, before its use in the if-else block to make it a field variable, so it can be recognized and used by Eclipse.</p> <p>The code just below will give me the error at the last line of code: <code>wage</code> cannot be resolved to a variable. But when I place it in another line of code just under the Scanner console line (4 lines down from the top), it comes up with errors at all lines of code with the variable <code>wage</code> beneath it and says "duplicate local variable" So I do not know where to place it to make it a field variable. Any ideas anyone?</p> <pre><code>import java.util.Scanner; public class Java3 { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("*** Basic Wage Calculator ***"); System.out.printf("%n"); System.out.println("Enter start time in 24:00 format"); String startTime = console.nextLine(); String[] tokens = startTime.split(":"); double starttimeHours = Double.parseDouble(tokens[0]); double startMinutes = Double.parseDouble(tokens[1]); if (starttimeHours &gt;= 6 &amp;&amp; starttimeHours &lt;= 8 || starttimeHours &gt;= 9 &amp;&amp; starttimeHours &lt;= 19) { double wage = 1.6; } else if (starttimeHours &gt;= 9 &amp;&amp; starttimeHours &gt;= 10 &amp;&amp; startMinutes &gt;= 01) { double wage = 43; } else { double wage = 987; } System.out.println(wage); } } </code></pre>
java
[1]
3,308,476
3,308,477
How to check if a string is numeric?
<p>I have a gpa program, and it works with the equalsIgnoreCase method which compares two strings, the letter a to the user input which check if they put "a" or not., but now I want to add an exception with an error message that executes when a number is the input. I want the program to realize that the integer input is not the same as string and give an error message. which methods can I use to compare a type string variable to input of type int, and throw exception</p>
java
[1]
1,556,378
1,556,379
Draw a user's attention back to a tab
<p>I'm working on a PDF generation process that might take a few minutes. I'd like to flash the window and maybe change the title as well when the process finishes so it draws the user's attention back to the window when the process is complete.</p> <p>Is this simple to do? I've seen code snipplets to change the title, so I supposed I'm looking more for a solution on how to flash the window/tab's color.</p>
javascript
[3]
1,846,664
1,846,665
Fixing Python file association
<p>I'm learning python on x64 windows 7 machine. But after installing and uninstalling python 2.7 and 3.2 a few times too many (i just found out 3.x doesn't support some of the 3rd party libraries like PIL), i have lost .py file association(when i double click my python scripts, windows asks me to choose a program to open it with instead of making python interpret it). How can i fix the issue?</p>
python
[7]
4,329,998
4,329,999
Python get class name
<p>So i have this problem, i want to get the name of a python class in this way:</p> <pre><code>class TestClass(): myName = (get class name here automatically) saveDirectory = os.path.join(saveDir, myName) # so i can save it in unique location def __init__(self): pass # do something </code></pre> <p>However, it seems that <code>__class__.__name__</code> doesn't actually exist as of yet at the time when <code>myName</code> is created. So i have been forced to put that into the <code>__init__()</code> function, like this:</p> <pre><code>class TestClass(): def __init__(self): self.myName = self.__class__.__name__ saveDirectory = os.path.join(saveDir, self.myName) # so i can save it in unique location pass # do something </code></pre> <p>But this has a big problem, because I cannot get the name of the class until I instantiate the class, I instend to create a few gigabytes of data for each instance of the class to be saved in the saveDirectory, so it can be re-used later. So I don't actually want to do go ahead with my current solution.</p> <p>Is there anyway to get the class name as I have intended? Or am I just dreaming?</p> <p>EDIT:</p> <p>Thanks guys for your great suggestions. I am going to spend a little bit of time taking a look at Metaclasses. Otherwise, I will probably create a dictionary globally, and have references to these instantiated classes instead.</p>
python
[7]
2,352,412
2,352,413
Receive udp data from the system udp server on android?
<p>hi I am new to android.I need to know how to receive the udp data in android emulator.Data's are coming from the PC (UDP SERVER is running on the pc).I am using Eclipse IDE.Can anyone guide me to solve this ?</p>
android
[4]
3,948,309
3,948,310
Cannot open attached file with '#' sign in the filename. Firebug prompts 'NetworkError: 401 Unauthorized'
<p>Cannot open attached file with '#' sign in the filename. Firebug prompts 'NetworkError: 401 Unauthorized'</p>
asp.net
[9]
1,480,940
1,480,941
How to center an shape created through canvas?
<p>I am using android java to create an application that uses the accelerometer, i have created a shape that does kinda move with the accelerometer but it stays in the top left hand corner and moves there, can anyone help me with how can i move it to the center of the screen and set bounds</p>
android
[4]
862,166
862,167
How to capture key events inside a service?
<p>I want to be able to capture key events inside a service I am writing. I can do this inside an activity without problems, but all my attemps to get this working in a service have failed. The key I wanted to capture (globally) is the BACK button, but if this is not possible any (hardware) button a HTC Desire offers would be OK.</p>
android
[4]
4,585,427
4,585,428
php & operator construct
<p>I got this piece of code which I'm analysing and it have this condition</p> <pre><code>if(($hint&amp;self::HINT_WRITE &amp;&amp; $hint&amp;self::HINT_NOWRITE) || ($hint&amp;self::HINT_READ &amp;&amp; $hint&amp;self::HINT_NOREAD)) { some code .. } </code></pre> <p>Any Idea what '&amp;' in '$variable&amp;self::CONSTANT' means?</p>
php
[2]
3,409,468
3,409,469
Passing command line arguments in C#
<p>I'm trying to pass command line arguments to C# application, but I have problem passing something like this:</p> <p>"C:\Documents and Settings\All Users\Start Menu\Programs\App name"</p> <p>even if I add " " to the argument?</p> <p>Any help??</p> <p>Here is the code:</p> <pre><code> public ObjectModel(String[] args) { if (args.Length == 0) return; //no command line arg. //System.Windows.Forms.MessageBox.Show(args.Length.ToString()); //System.Windows.Forms.MessageBox.Show(args[0]); //System.Windows.Forms.MessageBox.Show(args[1]); //System.Windows.Forms.MessageBox.Show(args[2]); //System.Windows.Forms.MessageBox.Show(args[3]); if (args.Length == 3) { try { RemoveInstalledFolder(args[0]); RemoveUserAccount(args[1]); RemoveShortCutFolder(args[2]); RemoveRegistryEntry(); } catch (Exception e) { } } } </code></pre> <p>And here is what I'm passing:</p> <p>C:\WINDOWS\Uninstaller.exe "C:\Program Files\Application name\" "username" "C:\Documents and Settings\All Users\Start Menu\Programs\application name"</p> <p>The problem is:</p> <p>I can get the first and the second args correct, but the last one it gets like this: C:\Documents</p>
c#
[0]
5,213,659
5,213,660
Showing activity indicator in android
<p>I am new to android.I need to show an activity indicator while synchronizing.On clicking a button,i am redirecting to a new activity.In this new activity i am synchronizing.I need to show an activity indicator on button click till it is synchronized.</p>
android
[4]
138,102
138,103
Visual Studio Compiler Configuration Options
<p>I have recently inherited an old c++ project built in visual studio 2003 that consists of a lot of code that looks like this:</p> <pre><code>for(int i=7;i&lt;40;i++) title[i-7]=temp_title[i]; for(i=33;i&lt;80;i++) title[i] = ' '; </code></pre> <p>However, since I do not have VS2003, I installed 2008 and now I am running into a lot of compilation errors due to i being an undeclared identifier since its out of scope. I am a complete novice to visual studio, how do I configure my project so it uses whatever compatible c++ compiler for 2003 so I can build the project and see what the heck its supposed to do.</p> <p>@Kirill V. Lyadvinsky</p> <p>Yes, I do plan to fix the code, however, I'd like to have a base version that I can use to test against in case I mess something up since the person who wrote this is now retired (thankfully)</p>
c++
[6]
730,467
730,468
Live calculation doesn't work
<p>I'm doing some live calculations while user typing.</p> <p>It's weird, it works in jsfiddle but not in localhost.</p> <pre><code>window.onload = function() { var base = 10; var numberField = document.getElementById('numberField'); numberField.onkeyup = numberField.onpaste = function() { if(this.value.length == 0) { document.getElementById('result').innerHTML = ''; return; } var number = parseInt(this.value); if(isNaN(number)) return; document.getElementById('result').innerHTML = number * base; }; numberField.onkeyup(); //could just as easily have been onpaste(); }; </code></pre>
javascript
[3]
3,353,202
3,353,203
No space left on device - android
<p>while run time am getting the following errors... I clean my project then after that too am getting the same error</p> <pre><code>[2011-04-10 05:33:31 - PersonalTask] ------------------------------ [2011-04-10 05:33:31 - PersonalTask] Android Launch! [2011-04-10 05:33:31 - PersonalTask] adb is running normally. [2011-04-10 05:33:31 - PersonalTask] Performing com.acarin.project.personal.task.LoginPage activity launch [2011-04-10 05:33:31 - PersonalTask] Automatic Target Mode: launching new emulator with compatible AVD 'MA_AVD_2.3.1' [2011-04-10 05:33:31 - PersonalTask] Launching a new emulator with Virtual Device 'MA_AVD_2.3.1' [2011-04-10 05:33:34 - Emulator] NAND: could not write file D:\Bama_BackUp\andr\android-sdk-windows/platforms\android-9\images\/system.img, No space left on device </code></pre> <p>Any one can help me pls thank you fri</p>
android
[4]
5,316,074
5,316,075
Java Observer Update function
<p>I have a class that implements observer, and of course it needs to have the update function:</p> <pre><code>public void update(Observable obs, Object obj); </code></pre> <p>Can someone please explain what do the two parameters stand for? Observable is my observable of course, but, how can I access my observable fields through this Observable obs object? And what is Object obj?</p>
java
[1]
1,865,258
1,865,259
Cannot Add Dynamically Generated Textbox's Text To A List (C#)
<pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Mod { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int c = 0; private void button1_Click(object sender, EventArgs e) { TextBox txtRun = new TextBox(); txtRun.Name = "txtDynamic" + c++; txtRun.Location = new System.Drawing.Point(20, 18 + (20 * c)); txtRun.Size = new System.Drawing.Size(200,15); this.Controls.Add(txtRun); } private void button2_Click(object sender, EventArgs e) { List&lt;string&gt;tilelocation = List&lt;string&gt;(); tilelocation.Add(); //What goes in this method's arguments? } } } </code></pre> <p>Here is my code. Button1 creates a theoretically infinite # of textboxes, but I wish to add the text in these dynamically generated textboxes to a list. How can this be done?<br> [EDIT] And how can I display them all in a messagebox, each on separate lines?</p>
c#
[0]
2,005,709
2,005,710
Can the Repository Pattern work well with Asp.net webforms?
<p>I've been using MVC for the last year and unfortunately I am stuck adding features to an existing web forms site. The site makes heavy use of inline SQL and it is kind of all over the place. Using an ORM is not going to happen either and wouldn't address the problem of keeping queries all in one place.</p> <p>Can the Repository Pattern and Service layers also work well with classic asp.net web forms?</p>
asp.net
[9]
3,337,190
3,337,191
php function parameters
<p>How to write a php function in order to pass parameters like this</p> <p>student('name=Nick&amp;roll=1234');</p>
php
[2]
3,866,474
3,866,475
jquery and grabbing td title to tack on new td?
<p>I am trying to get the titles from my td:</p> <pre><code> function titleObject(table) { var titleArray=[]; $('tr',table).each(function(i){ var data={}; $('td',this).each(function(j){ data[j]=$(this).attr('title'); }) titleArray.push(data); }); return titleArray; } </code></pre> <p>I am not sure this will work. The next thing is I want to tack the title on to a td:</p> <pre><code> function objectToTable(objectArray,table){ var body=$('tbody',table); var color = colorStyleObject(table); var title = titleObject(table); body.children().remove(); if(options.zebra){ for(var i=0;i&lt;objectArray.length;i++){ (i%2)?(tr=$('&lt;tr class="'+options.zebraClass+'"&gt;&lt;/tr&gt;')):(tr=$('&lt;tr&gt;&lt;/tr&gt;')); for(var j in objectArray[i]){ tr.append($('&lt;td class="ui-widget-content"&gt;&lt;/td&gt;').html(objectArray[i][j])); } body.append(tr); } } else { for(var i=0;i&lt;objectArray.length;i++){ tr=$('&lt;tr&gt;&lt;/tr&gt;'); for(var j in objectArray[i]){ tr.append($('&lt;td class="ui-widget-content"&gt;&lt;/td&gt;').attr(title[i][j]).css('background-color',color[i][j]).html(objectArray[i][j])); } //$('.ui-widget-content').css('background-color','green'); body.append(tr); } } } </code></pre> <p>This does not seem to be working. The page just churns forever. Am I getting the title correctly? Am I not tacking it on to the new td line correctly?</p>
jquery
[5]
1,268,306
1,268,307
How to draw a ring using canvas in android?
<p>Can anybody suggest me how to draw a ring using canvas methods. I may draw to circles using <code>canvas.drawCircle()</code> but how should I feel a space between them?</p>
android
[4]
5,830,356
5,830,357
How increase the performance of asp.net application?
<p>Hi I want to increase the performance of asp.net application when multiple user access my application about 5000 users.</p> <p>Can we do this </p>
asp.net
[9]
3,741,718
3,741,719
strange behavior in PHP function: timezone_name_from_abbr
<p>echo timezone_name_from_abbr("", 3600*7, 0); //ok<br/> echo timezone_name_from_abbr("", 3600*8, 0); //NOT ok! return nothing!<br/> echo timezone_name_from_abbr("", 3600*9, 0); //ok<br/></p>
php
[2]
3,479,470
3,479,471
service needs to vibrate the phone
<p>The following code is supposed to toast values from a service. But, it's not toasting the values</p> <pre><code>public class service extends Service { int sleepTime = 10; private Handler handler = new Handler(); String add= "north harmon ave"; (new Timer()).schedule(new TimerTask() { public void run() { handler.post(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "address"+add, Toast.LENGTH_LONG).show(); } }); } }, sleepTime); } </code></pre>
android
[4]
1,970,516
1,970,517
Setting Toolbar Items
<p>I try to set toolbar items in the navigationcontrollers top view. Seems to work in the subviews... but why not in the top view...any ideas? I get the add button... but not my custom button.</p> <pre><code>- (void)configureToolbarItems { UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewTaskButtonPressed)]; //Green button greenButton=[app makeGreenButton:self]; UIBarButtonItem *greenBarButton = [[UIBarButtonItem alloc] initWithCustomView:greenButton]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; // Set our toolbar items [self setToolbarItems:[NSArray arrayWithObjects: addButtonItem,flexibleSpace, greenBarButton, nil] animated:YES]; } </code></pre> <p>This is the makeButton procedure... works fine in other views:</p> <pre><code>-(UIButton*)makeGreenButton:(UIViewController*)caller { UIButton *greenButton; //load the image for yellow button UIImage *greenButtonImage = [UIImage imageNamed:@"greenButton.png"]; //create the button and assign the image greenButton = [UIButton buttonWithType:UIButtonTypeCustom]; [greenButton setImage:greenButtonImage forState:UIControlStateNormal]; greenButton.showsTouchWhenHighlighted=TRUE; //set the frame of the button to the size of the image (see note below) greenButton.frame = CGRectMake(0, 0, greenButtonImage.size.width*2, greenButtonImage.size.height*2); //Add target [greenButton addTarget:caller action:@selector(greenButtonReleased:) forControlEvents:UIControlEventTouchUpInside]; return greenButton; } </code></pre>
iphone
[8]
5,029,564
5,029,565
Does anyone know of a replacement method for setFixed() that returns a number?
<p>Working with the method setFixed() returns a string in most browsers, but sometimes I need to set a number to a fixed set of decimal places and I need it to stay a number.</p> <p>Plus I would like to be able to access it from the number object in javascript as part of the prototype object.</p> <p>And it should ALWAYS return a number as a result instead of a string.</p> <p>Anyone know of a good article or method to use?</p> <p>I would also like a way to control whether it rounds up, down, or uses standard rounding.</p>
javascript
[3]
2,242,722
2,242,723
Java - Returning strings
<p>I wish to return a string from a method object that is called by another method in another class. My problem is: when I attempt to assign the returned value to a String in the other class, it cannot find the method object within the class object.</p> <pre><code>Guessing Game = new Guessing(); </code></pre> <p>This makes the object using the class Guessing.Java</p> <pre><code>else if (buttonObj == guess){ double g = yourGuess.getNumber(); if ((g &gt; 0)&amp;&amp;(g &lt; 11)){ Game.StartGame(g); label3.setVisible(false); yourGuess.setEnabled(false); label1.setText(Game.StartGame()); }else{ label3.setVisible(true); yourGuess.requestFocus(true); } } </code></pre> <p>When I try retrieving the String from the StartGame method within the Guessing.Java class, it says it cannot find the class.</p> <pre><code>public String StartGame(double guess){ int round = 1; int guesses = 3; String correct = "correct"; if (guesses &gt; 0){ if (guess == ans){ correct = "correct"; }else if ((guess == ans - 1)||(guess == ans + 1)){ correct = "hot"; guesses--; }else if ((guess == ans - 2)||(guess == ans - 2)){ correct = "warm"; guesses--; }else{ correct = "cold"; guesses--; } }else{ correct = "round"; } return correct; } </code></pre> <p>I have tried several different things and looked it up multiple times but nothing works, can anyone help?</p>
java
[1]
1,448,810
1,448,811
jQuery - Show id, based on selected items class?
<p>I have a layout roughly as follows:</p> <pre><code>&lt;div id="foo"&gt; &lt;!-- a bunch of content --&gt; &lt;/div&gt; &lt;div id="thumbnails"&gt; &lt;div class="thumb-content1"&gt;&lt;/div&gt; &lt;div class="thumb-content2"&gt;&lt;/div&gt; &lt;div class="thumb-content3"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id="content-1"&gt; &lt;!-- some text and pictures, including large-pic1 --&gt; &lt;/div&gt; &lt;div id="content-2"&gt; &lt;!-- some text and pictures, including large-pic2 --&gt; &lt;/div&gt; &lt;div id="content-3"&gt; &lt;!-- some text and pictures, including large-pic3 --&gt; &lt;/div&gt; etc .... </code></pre> <p>On page load I want to show 'foo' and 'thumbnails' and hide the three content divs.</p> <p>As the user clicks each thumbnail, I want to hide foo, and replace it with the matching 'content-x'.</p> <p>I can get my head round jQuery show, hide and replace (although, bonus points if you want to include that in your example!). But how would I extract and construct the appropriate content id, from the thumbnail class, then pass it to the show hide code?</p>
jquery
[5]
5,459,078
5,459,079
Custom event in javascript
<p>I know that there is a lot of questions like mine, but I don't think it's a duplicate.</p> <p>I want to create my own custom event, for exemple onresize or onshake.</p> <p>And I would like to make a library, then the user of my library would just write that :</p> <pre><code>&lt;script src="theLib.js" &gt;&lt;/script&gt; &lt;script&gt; window.addEventListener("shake",myFunc,false); &lt;/script&gt; </code></pre> <p>I saw a lot of tutoriels and questions on stackoverflow but either they are using jQuery(I want the most simple exemple to make a custom event) or the user must not just write <code>window.addEventListener</code>.</p> <p>Can you please explain me the most basic way to add a custom event?</p>
javascript
[3]
4,197,861
4,197,862
php tools to detect bottle neck
<p>I'm developing a web-application with PHP and some libraries. The problem is that i need to generate some excel files, and this procedure takes a lot of time. Can you help me with some tools to identify where my application spends a lot of time,. Can you recommend a php tool which will help me to detect the bottle necks?</p> <p>ps: the lib that I use for generating the excel files is <a href="http://www.codeplex.com/PHPExcel" rel="nofollow">PHPExcel</a>. </p>
php
[2]
1,318,822
1,318,823
Output loop one at a time rather than all at once?
<p>I'm running PHP SOAP and the loop runs with 10 iterations. The issue I am having is that it will not output until the loop is complete, whereby displaying every output at once.<br> How can I have it output one at a time as it processes through the loop rather than all in one go after it completes the entire 10 loops?</p> <pre><code>&lt;?php $loops = 0; // set loops to 0 // connection credentials and settings $location = 'https://theconsole.com/'; $wsdl = $location.'?wsdl'; $username = 'user'; $password = 'pass'; // include the console and client classes include "class_console.php"; include "class_client.php"; // create a client resource / connection $client = new Client($location, $wsdl, $username, $password); while ($loops &lt; 10) { $dostuff; $echo "It has done: " .$stuff; // display output ob_end_flush(); ob_flush(); flush(); ob_start(); // added as per comments below - still not working } ?&gt; </code></pre> <p>Thanks!</p>
php
[2]
1,425,751
1,425,752
Why should my local variables be final to be accessible from anonymous class?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1299837/cannot-refer-to-a-non-final-variable-inside-an-inner-class-defined-in-a-different">Cannot refer to a non-final variable inside an inner class defined in a different method</a> </p> </blockquote> <p>What is the reason behind the rule of having local variables declared as final in order to access them from anonymous class? </p>
java
[1]
95,806
95,807
How to find a index from a two dimensional array
<p>What I'm trying to do is print the largest number within a two dimensional array and it's index location. I'm able to find the largest number, but I can't seem to figure out how to print it's index location. Anyway, here's what I have so far:</p> <pre><code>public static void main(String[] args) { int[][] arr = {{4, 44, 5, 7, 63, 1}, {7, 88, 31, 95, 9, 6}, {88, 99, 6, 5, 77, 4}}; double max = arr[0][0]; for (int i = 0; i &lt; arr.length; i++) { for (int j = 0; j &lt; arr.length; j++) { if (arr[i][j] &gt; max) { max = arr[i][j]; } } } System.out.println(max); System.out.println(i + j); //No idea what I should be doing here, just trying out everything I can think of </code></pre>
java
[1]
27,754
27,755
How/when is PhoneApp instantiated in android
<p>I've read in a few places that PhoneApp (com.android.phone.PhoneApp.java), is a "persistent process" which is "started early in the boot sequence." Can anybody explain exactly how and when this happens? Thanks.</p>
android
[4]
5,824,069
5,824,070
view based application
<p>hii...</p> <p>I am making a view based application in which I have tabbar controller but this application has no of pages. And I am adding these pages as subview due to which stack get increase each. I want to put navigation bar controller too in this application to decrease the memory allocation.</p> <p>Can it possible to have tabbar and navigation bar controller both in view based application.</p> <p>If anyone know how to implement it. Then please help me.</p> <p>Thanks in advance. </p>
iphone
[8]
4,287,281
4,287,282
changing the color of the text in an c# application when i change the computer
<p>I have created an application in c # visual studio, I set the text color to blue. When I opened the application in another computer the text color was changed to black</p> <p>any ideas please. thanks. </p>
c#
[0]
5,467,633
5,467,634
Getting images to change in a for loop in javascript
<p>So far I created an array with 11 images, initialized the counter, created a function, created a for loop but here is where I get lost. I looked at examples and tutorial on the internet and I can see the code is seeming simple but I'm not getting something basic here. I don't actually understand how to call the index for the images. Any suggestions. Here is the code.</p> <pre><code> &lt;script type="text/javascript"&gt; var hammer=new Array("jackhammer0.gif", "jackhammer1.gif", "jackhammer2.gif", "jackhammer3.gif", "jackhammer4.gif", "jackhammer5.gif", "jackhammer6.gif", "jackhammer7.gif", "jackhammer8.gif", "jackhammer9.gif", "jackhammer10.gif") var curHammer=0; var numImg = 11; function getHammer() { for (i = 0; i &lt; hammer.length; i++) { if (curHammer &lt; hammer.length - 1) { curHammer = curHammer +1; hammer[i] = new Image(); hammer[i].src="poses/jackhammer" +(i+1) + ".gif"; var nextHammer = curHammer + 1; nextHammer=0; { } } } } setTimeout("getHammer()", 5000); &lt;/script&gt; &lt;/head&gt; &lt;body onload = "getHammer()";&gt; &lt;img id="jack" name="jack" src = "poses/jackhammer0.gif" width= "100" height ="113" alt = "Man and Jackhammer" /&gt;&lt;br/&gt; &lt;button id="jack" name="jack" onclick="getHammer()"&gt;Press button&lt;/button&gt; </code></pre>
javascript
[3]
2,818,108
2,818,109
How to execute commands in Command Prompt using c#
<p>I want to execute these steps in CMD using c#</p> <p>1 - CD C:\MySQL\MySQL Server 5.0\bin</p> <p>2 - mysqldump -uroot -ppassword sample> d:\Test\222.sql</p> <p>On manually doing this, i will get file named "222.sql"</p> <p>I am using the below code to do it, but missing something.. Nothing Happens</p> <pre><code>public void CreateScript_AAR() { string commandLine = @"CD C:\MySQL\MySQL Server 5.0\bin\mysqldump -uroot -ppassword sample&gt; d:\Test\222.sql"""; System.Diagnostics.ProcessStartInfo PSI = new System.Diagnostics.ProcessStartInfo("cmd.exe"); PSI.RedirectStandardInput = true; PSI.RedirectStandardOutput = true; PSI.RedirectStandardError = true; PSI.UseShellExecute = false; System.Diagnostics.Process p = System.Diagnostics.Process.Start(PSI); System.IO.StreamWriter SW = p.StandardInput; System.IO.StreamReader SR = p.StandardOutput; SW.WriteLine(commandLine); SW.Close(); } </code></pre>
c#
[0]
3,914,529
3,914,530
PHP trigonometry TAN
<p>I try to figure out an angle of a triangle.</p> <p>If one side of the triangle is 100 and the other side is 100.</p> <p>How do I get that to be 45 degrees.</p> <p>If I run tan<sup>-1</sup>(100/100) on my calculator i get 45. How do I do this in PHP?</p>
php
[2]
4,925,913
4,925,914
How can I create an editable combobox?
<p>I need to populate the combo box Items from a database query (this part is no problem). Then if the user does not find an option, they can enter their own text and store in Db with index.. Add new item to store in Db with index value and display the value from db with index and value. </p> <p>using jquery or javascript...</p> <p>Help plz..</p>
jquery
[5]
1,187,475
1,187,476
javascript: sort an array a certain way with integers and characters
<p>I am trying to sort an array in a specific way and I'm trying to do it efficiently, preferably with the .sort() function. Here is as example of the kind of array I need to work with:</p> <pre><code>["10", "11", "12", "13", "2", "3", "4", "5", "6", "7", "8", "9", "2a", "2s", "3a"] </code></pre> <p>Here is what i am looking for after the sort:</p> <pre><code>["13", "12", "11", "10", "9", "8", "7", "6", "5", "4", "3", "3a", "2s", "2", "2a"] </code></pre> <p>rules:</p> <p>sort integer values in descending order. integers that have an "a" appended have a lesser value. integers appended with an "s" have a greater value. Therefore, 2a would be inbetween 2 and 1, and 2s would be inbetween 3 and 2. 3a would be greater than 2s. </p> <p>please help!</p>
javascript
[3]
98,559
98,560
How to pass the html name of button group to a javascript function
<p>Say I have a function similar to this: </p> <pre><code> function getGroupValue(group) { for (var i=0; i &lt; group.length; i++) { if (group[i].checked) { return group[i].value; } } } </code></pre> <p>that i can call with something like <code>getGroupValue(document.forms[0].myGroup)</code> </p> <p>How do I convert this to just passing in the name of a html radio button group like <code>getGroupValue('myGroupName')</code> ?</p>
javascript
[3]
825,034
825,035
how to check if textarea field exist on form with jquery or javascript?
<pre><code>$("textarea").cleditor({ width: "800px", height: "300px" })[0].focus(); </code></pre> <p>but when i do not have textarea felad i get</p> <pre><code>Error: $("textarea").cleditor({width: "800px", height: "300px"})[0] is undefined </code></pre> <p>how can i check if textarea field exist. </p> <p>I try ($("textarea").val()) but not working correctly. I also try value() but also not working. How can i check if exist or not?</p>
jquery
[5]
88,545
88,546
Simple Python concatenation question
<p>If I type the following into IDLE, it gives me the result of 'wordwordword':</p> <pre><code>print("word" * 3) </code></pre> <p>If I go through the following steps in IDLE, it gives me the same result:</p> <pre><code>sentence = input() #I type "word" number = int(input()) #I type it to int because input() saves as a string, I type "3" print(sentence * number) </code></pre> <p>But then, if I try to use the exact same three lines above in a Notepad document to create it as a script, I only get the result of 'word' instead of 'wordwordword'</p> <p>Any thoughts?</p>
python
[7]
3,804,292
3,804,293
Div Appear After 5 Seconds Jquery
<p>I'm having problems getting a div to appear using jquery after 5 seconds.</p> <p>right now I was using</p> $(document).ready(function() { $("#message").delay(delay).fadeIn(5000); }); <p>But it's not working (#message being the name of the div serounding the content I'd like to show)</p> <p>If anyone could help me get it working that would be great.</p> <p>Thanks </p>
jquery
[5]
997,328
997,329
python: how to get the class of a calling method through inspection?
<p>For my exception class I'd like to find out whether the function which instantiated the exception object is a method and if so, show the class name.</p> <p>So in the <strong>init</strong> method of my exception class I get the name of the calling function:</p> <pre><code>frame, module, line, function, context, index = inspect.stack()[1] </code></pre> <p>But is there any way the get the class name (if any) of the calling function?</p>
python
[7]
337,280
337,281
What's the bad magic number error?
<p>What's the "Bad magic number" ImportError in python, and how do I fix it?</p> <p>The only thing I can find online suggests this is caused by compiling a .py -> .pyc file and then trying to use it with the wrong version of python. In my case, however, the file seems to import fine some times but not others, and I'm not sure why.</p> <p>The information python's providing in the traceback isn't particularly helpful (which is why I was asking here...), but here it is in case it helps:</p> <pre><code>Traceback (most recent call last): File "run.py", line 7, in &lt;module&gt; from Normalization import Normalizer </code></pre>
python
[7]
188,898
188,899
Android: app licensing, copy protection
<p>I have an apk file, that is non-free</p> <p>My questions is the following:</p> <p>1, If Copy Protection is set to "true" on the market, the users can copy my apk file from the device or not? (rooted/non rooted) <a href="http://www.jayceooi.com/2010/10/19/how-to-copy-backup-android-apk-file/" rel="nofollow">copy apk from device</a></p> <p>2, If they can: what is the best way to make a REAL copy protection? </p> <p>Thanks, Leslie</p>
android
[4]
439,045
439,046
In which folder should I insert a tool in python?
<p>I downloaded numdifftools, and I don't know where to save in python path to make it work. Can anyone give me an advice?</p>
python
[7]
628,837
628,838
how to work with multiple database
<p>I am working on one company internal web software and in this I have given forum option for internal employee.Now I have to add second company to forum so that second company employee can also give some comment in forum.I have two database one for my company internal and second is second company database.</p> <p>Please Help me how can I Implement this???</p>
php
[2]
4,975,924
4,975,925
Enable a disabled button and click it with Javascript
<p>I have a disabled button I want to click with Javascript. The following function works in Chrome but not in Firefox.<br> The problem with Firefox: Firefox javascript is too slow.<br> The button is still disabled if the code wants to click it. How to click the button when it is enabled?</p> <pre><code>function enable_and_click() { document.getElementById('button1').disabled=false; document.getElementById('button1').click(); } </code></pre>
javascript
[3]
2,599,187
2,599,188
MapView - Trace and draw route on the way he travels?
<p>I'm trying to draw a route in a mapView from the current location (got from GPS) to the way he travels.</p> <p>I am able to fetch the location of the user as he moves in a particular direction, but I was not able to draw the path.</p> <p>What is the best way to draw the route path as he moves from place to place continuously?</p> <p>I want the method to be good (in terms of performance).</p>
android
[4]
1,738,604
1,738,605
Adding setUTCDate() to replace "computers" time
<p>Well, I followed this tutorial <a href="http://tutorialzine.com/2011/12/countdown-jquery/" rel="nofollow">http://tutorialzine.com/2011/12/countdown-jquery/</a> (I have no idea how to do ANYTHING in JavaScript, I've done everything I know so far, and gotten a little budge..) But I wanted to just be able to set a date and have it count down to that date, but even so, it would just base it off my computers time, how can I make it so its standard for everyone, [He mentioned setUTCDate() But Have no idea how to implement it. (new to this whole thing)</p> <p><a href="http://justin.derp.us/assets/js/script.js" rel="nofollow">http://justin.derp.us/assets/js/script.js</a> (I can only post two links, so the site is in the javascript post;))</p>
javascript
[3]
3,289,284
3,289,285
how to get the server to process the php file instead of the browser?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://serverfault.com/questions/286882/apache-is-not-interpreting-php-files">Apache is not interpreting .PHP files</a> </p> </blockquote> <p>All the tutorials which i found gave me all the information about php and how to go about it.But php code which i type is getting parsed by the browser and not the server.</p> <p>I have installed apache2 on a ubuntu11.04 system.</p> <p>Please guide me on how to run the php script on the server(on request from a client)</p> <ul> <li>Php beginner</li> </ul>
php
[2]
2,504,877
2,504,878
Meaning in this Line
<p>Im creating an Itemized Map Overlay for my map used in an app im creating. In a tutorial that I am following it uses the following lines:</p> <pre><code>public class CustomItemizedOverlay extends ItemizedOverlay&lt;OverlayItem&gt; { ... private ArrayList&lt;OverlayItem&gt; mapOverlays = new ArrayList&lt;OverlayItem&gt;(); ... } </code></pre> <p>My question is this; what does the brackets part actually mean? It that passed as a parameter to the ItemizedOverlay class? Does the &lt;> brackets actually mean 'instanceof'? Im just looking for a-bit of clarity and understanding of the code Im trying to use so I can manipulate it better later.</p> <p>Cheers </p>
android
[4]
5,847,246
5,847,247
Get absolute path of current script
<p>I have searched high and low and get a lot of different solutions and varialbles containing info to get the absolute path. But they seem to work under some conditions and not under others. Is there one silver bullet way to get the absolute path to the current executing script in php? For me the script will be running from the command line but it should just as well function if run within apache etc.</p> <p>Clarification: The initial executed script (I only had one here so therefore I missed stating that)</p>
php
[2]
5,880,767
5,880,768
How to let the Android OS know my App has stuff to do when it is background?
<p>I am designing an android app that needs to play a sound every minute while in its active state.</p> <p>I have the logic that plays the sound every minute in the active state using a runnable and handler. The app works fine if you press the start or stop buttons. </p> <p>If you run the app and hit stop it kills the app. If you run the app hit home the sounds continue to play and when you relaunch the timer will be up to date. This is expected.</p> <p>The problem i am having is that if you hit home and then launch another app, there is a high chance my app gets killed and the sounds will no longer play (and consequently GUI will is reset when you relaunch)</p> <p>My question is, <strong>What approach should i use so that my app will continue to play the sounds until i tell it to stop, even if its not in the foreground?</strong> The sounds can be thought of as a reminder to the user.</p> <p>I have tried using the google machine to help me out but am having no luck.</p>
android
[4]
5,768,724
5,768,725
Generating a random number in java based on user inputs for max and min
<p>I having a little trouble trying to genertae a radom set of numbers with what the user defines as max and min, I am new to programming and feel a little lost with my code</p> <pre><code>int upperRange; int lowerRange; Random random = new Random(int)(Math.random()*(upperRange - (lowerRange-1)))+lowerRange; Scanner keyboard = new Scanner(System.in); { System.out.println("Enter upper limit number "); upperRange = keyboard.nextInt(); System.out.println("Enter lower limit number"); lowerRange = keyboard.nextInt(); </code></pre> <p>Any help would be appreciated </p>
java
[1]
793,637
793,638
For loop not behaving as expected without nested do-while
<p>I wrote the following code to shuffle a deck of cards:</p> <pre><code>int i,j; for(int x=1;x&lt;53;x++) { i=rand()%4; j=rand()%13; if(deck[i][j]=0) deck[i][j]=x; else x--; } </code></pre> <p>That didn't produce any result, whereas the following code produced results:</p> <pre><code>int i,j; for(int x=1;x&lt;53;x++) { do { i=rand()%4; j=rand()%13; } while(deck[i][j]!=0); deck[i][j]=x } </code></pre> <p>What difference causes this? </p>
c++
[6]
2,636,410
2,636,411
TypeError HTMLSpanElement has no method 'html'
<p>I get the error</p> <pre><code>Uncaught TypeError: Object #&lt;HTMLSpanElement&gt; has no method 'html' </code></pre> <p>When I am running this method</p> <pre><code>$("input[name=advancedSettings]").change(function() { $('span[id^="sFile"]').each(function() { this.html('Hey'); }); }); </code></pre> <p>And span should of course have a method called text and html, and I have tested with both</p>
jquery
[5]
873,639
873,640
web based timer
<p>Is there anyway to create a variable speed timer in the browser that will give the exact same results for all operating systems and browsers? If I want 140 beats per minute for every user regardless of their computer speed.</p> <p>I've been using javascript setTimeout() and setInterval() but I think they are dependant on the speed of the computer and the amount of code in the program. How do I incorporate the system clock into a browser? Or any other ideas?</p>
javascript
[3]
4,969,455
4,969,456
Save State in my Android application
<p>I am developing an android application in which,the first activity is that for Login. After successful authentication, user can see an activity with 4 Tabs. My problem is that when user taps on the home button,the application should terminate and when the user again starts my application, he should be able to see the Login screen again and after successful Login, user should be able to see the tab on which he was working before application terminated(i.e., save state for all the tabs). Please help me out in this. Thanks in advance.</p>
android
[4]
6,001,770
6,001,771
DateTime constructor throws error when the values are OK
<p>This line:</p> <pre><code>new DateTime(2000, 11, 31, 10, 0, 0) </code></pre> <p>throws error: Year, Month, and Day parameters describe an un-representable DateTime.</p> <p>Why is this happening?</p>
c#
[0]
4,473,550
4,473,551
Is it possible to programmatically uninstall a package in Android
<p>Can a package uninstall itself? Can a package uninstall another package if they share the same userId and signature?</p>
android
[4]
1,740,892
1,740,893
php problem in the encoding way
<p>I am going to encrypt that with ioncube when giving to a client side and i will simply include to call the licensing system But the problem is when i simply include the code </p> <pre><code>include "lic.php" </code></pre> <p>the user can directly remove the line to get the script worked So can some one help me in coding a script inside the lic.php which will make the script to prevent from running if the code i.e, is removed from the file Note that i will include the line in all the php files in my script Also do you face any issues with ioncube while running?? Great Thanks! </p>
php
[2]
5,601,099
5,601,100
What exactly is happening in the piece of code with the newInstance() method being used statically?
<p>I understand mostly everything in this code, except when newIstance() is being used. Could anyone please explain. Much appreciated.</p> <pre><code>public class DateDialogFragment extends DialogFragment { public static String TAG = "DateDialogFragment"; static Context sContext; static Calendar sDate; static DateDialogFragmentListener sListener; public static DateDialogFragment newInstance(Context context, int titleResource, Calendar date){ DateDialogFragment dialog = new DateDialogFragment(); sContext = context; sDate = date; Bundle args = new Bundle(); args.putInt("title", titleResource); dialog.setArguments(args); return dialog; } } </code></pre> <p>I made an edit, I guess its working differently when its static. I assume thats why I am confused. How is the method changed when its static? I don't really see why not do it in the constructor?</p>
android
[4]
2,560,423
2,560,424
Why Does My Generic Method Require a Cast?
<p>I have a service layer method that I want to expose that should return an instance of an object that extends CMSContent (e.g. Delivery Time, Price). However, in method <strong>getCMSContent</strong>, the compiler is insisting that I do a cast to <strong>T</strong>. Is this cast below acceptable, or am I defeating the purpose of generics?</p> <p>I compile with "-Xlint:unchecked" and receive no warnings, and it functions as I expect.</p> <pre><code> public &lt;T extends CMSContent&gt; T getCMSContent(String cmsKey, Class&lt;T&gt; clazz) { T cmsInstance = (T) CMSObjectCache.getCachedCMSObject(cmsKey, clazz); return cmsInstance; } </code></pre> <p>This is the entire method of getCachedCMSObject</p> <pre><code>public static &lt;T&gt; T getCachedCMSObject(String objectKey, Class&lt;T&gt; cls) { init(); CMSObject cmsObject = cmsObjectCache.get(objectKey); if (cmsObject != null) { return cmsObject.getCMSObject(cls); } return null; } </code></pre>
java
[1]
3,862,918
3,862,919
How do I pass a variable from Google maps geocoder to another function?
<p>How could I get the value from test2 variable passed on to another function? I've been trying with global variables and by chaining functions, as suggested in another thread I found, but couldn't get those to work. </p> <pre><code>function codeAddress(addresstocode) { var test2 = ['123','321']; geocoder.geocode( { 'address': addresstocode}, function(results, status) { if(status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); coded_lat = results[0].geometry.location.Ka; coded_long = results[0].geometry.location.La; //coded_location = [{"latitude" : coded_lat, "longitude" : coded_long}]; //test2 = returnAddress(coded_location); test2 = [coded_lat,coded_long]; //coded_lat = coded_location[0].latitude; //coded_long = coded_location[0].longitude; //returnAddress(coded_location); } }); console.log('test2: '+test2); return test2; } </code></pre>
javascript
[3]
6,003,955
6,003,956
How to have different header.php based on the user logged in?
<p>I’ve a created wordpress membership site using wishlist member plugin. But I want to have different <code>header.php</code> based on different logins.</p> <p>Eg: Users are: Print, Web and Free</p> <ol> <li>When Free user logs in – I want <code>header1.php</code> to load and stay till he logs out </li> <li>When Print user logs in – I want <code>header2.php</code> to load and stay till he logs out </li> <li>When Web user logs in – I want <code>header3.php</code> to load and stay till he logs out</li> </ol> <p>If nobody has logged in the default <code>header.php</code> stays.</p> <p>Please assist on how to do this.</p> <p>Regards, Raghav.</p>
php
[2]
2,507,939
2,507,940
Android Development - Best Advice Please :-)
<p>Firstly, please excuse my complete lack of knowledge of Android Development.</p> <p>I know a bit of PHP, JavaScript, HTML, CSS, MySQL etc...but I am completely new to Android Development.</p> <p>As the world is moving mobile, I would like to start learning Android Dev. Few questions I have, I hope someone can answer in layman's terms. :-/</p> <ol> <li><p>What languages does Android support, what is best to start learning? Where are things moving in Android land? Is it purely C+ or Java etc or a mixture of things?</p></li> <li><p>How do apps communicate with servers? For example if I have dating app, and I have a database on members sitting in a MySQL table. Is there any problems with speed/connection/network etc, or is something else recommended?</p></li> <li><p>As I know a bit of PHP and JS. Is there anything remotely similar to these to develop in? </p></li> <li><p>What is the best way to learn? Just do it, physical course, online course, books etc?</p></li> <li><p>How good are you, and how did you learn?</p></li> </ol> <p>Again, please excuse my complete "noobness", hopefully someone can point me in the right direction!</p> <p>Thanks guys</p>
android
[4]