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 |
---|---|---|---|---|---|
3,624,039 | 3,624,040 |
Play Animation with specefic Time [iPhone Animation]
|
<p>iam trying play animation with xcode,in specefic Time for example after 3 minutes play an animation .. i don't know how coding with NSTimer !</p>
<p>here is my animation codes :</p>
<pre><code> NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.gif"], nil];
UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 0.25;
myAnimatedView.animationRepeatCount = 0;
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView]; [myAnimatedView release];
</code></pre>
|
iphone
|
[8]
|
5,214,317 | 5,214,318 |
How to wireup an event that adds numeric html input values for a slots game.
|
<p>I'm trying to make a slot machine and im new to programming, so this will probably be a easy fix for people. </p>
<p>When i try this </p>
<pre><code>var money = document.getElementsByName('money')[0].value;
var bet = document.getElementsByName('bet$')[0].value;
var winnings = Number(bet) + Number(money);
$('#money').val(winnings);
</code></pre>
<p>it only lets me bet the value of the input which is 10</p>
<p>I want to have the current bet to be added to the current money and then i want the sum to be displayed in the money input box.</p>
<p>heres my html </p>
<pre><code><div id="betbox">
<button id="bet">Bet</button>
<input type="number" id="bet$" name="bet$" value="10" />
</div>
<div id="moneybox">
<input type="text" id="money" name="money" value="100" />
</div>
</code></pre>
|
jquery
|
[5]
|
506,531 | 506,532 |
Android applying border around SurfaceView
|
<p>I have one <code>SurfaceView</code> for which I want to display a border of <code>20dp</code> size which will flow around the <code>SurfaceView</code>. I need 'SurfaceView' in <code>16:9</code> aspect ratio, so i kept the size of the <code>SurfaceView</code> to <code>161x286</code> which is in <code>16:9</code> ratio. </p>
<p>To display border around the surface view i have following implementation in XML. </p>
<pre><code><RelativeLayout
android:id="@+id/my_surface_view_holder"
android:layout_height="161dp"
android:layout_width="286dp"
android:padding="20dp"
android:focusable="true"
android:clickable="true"
android:background="#fff"
>
<SurfaceView
android:id="@+id/video_surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
</code></pre>
<p>Above code displays the border around the <code>SurfaceView</code> properly but it breaks the 16:9 aspect ration of the video as i have given padding of <code>20dp</code> for displaying border.</p>
<p>If i adjust aspect ration according to the border size then border is not evenly set, on top/bottom it is different and on left/right it is different. </p>
<p>So How can i display the border around SurfaceView by keeping it's aspect ration maintained to size 161x286.</p>
<p>Thanks.</p>
|
android
|
[4]
|
4,843,631 | 4,843,632 |
Trying to convert a char array to integer array in Java with this code
|
<p>I'm trying to convert an array of characters into integers, so I can get the ascii code, but the code I have doesn't seem to be working.</p>
<pre><code>import javax.swing.*;
import java.text.*;
import java.util.*;
import java.lang.*;
public class Encrypt {
public static void main(String[] args) {
String phrase = JOptionPane.showInputDialog(null, "Enter phrase to be messed with ");
char[] charArray = phrase.toCharArray();
for (int count = 0; count < charArray.length; count++) {
int digit = ((int)charArray[count]);
System.out.println(digit[count]);
}
}
</code></pre>
|
java
|
[1]
|
3,787,782 | 3,787,783 |
how can i search sub string from original string
|
<pre><code>String ORIGINAL = "This is my demo string";
String search = "demo";
</code></pre>
<p>I want to get the result as true or false if "demo" is exits into ORIGINAL then result is true otherwise return false </p>
|
android
|
[4]
|
4,007,505 | 4,007,506 |
How to point elements childrens with JavaScript
|
<p>I have little problem with element childrens.</p>
<p>Heres some code to explain my question:</p>
<pre><code>function check(element){
// I want to get custom attribute from element children.
// Children elements are always radio buttons
var temp = element. ?? .attr('temp');
return temp;
}
// element variable is the whole div here
<div id = "test">
<table>
<tr>
<td> <input type="radio" temp="somethinghere"/></td>
</tr>
</table>
</div>
</code></pre>
<p>Hope someone has ideas or even better.. solution.</p>
|
javascript
|
[3]
|
2,264,575 | 2,264,576 |
How to store $_POST data in an array and access it with foreach and save into mysql
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3489387/php-post-print-variable-name-along-with-value">PHP $_POST print variable name along with value</a> </p>
</blockquote>
<p>I am just wondering how to store $_POST variables in an array.</p>
<p>I have several $_POST variables, as follows:</p>
<pre><code>$_POST['cCode'];
$_POST['sSubject'];
$_POST['lect'];
$_POST['rRoom'];
$_POST['dDay'];
$_POST['sTime'];
$_POST['eTime'];
</code></pre>
<p>How can I access them all at the same time using a <code>foreach()</code>?</p>
<p>I know how to access one, like this:</p>
<pre><code> $data = $_POST['cCode'];
foreach($data as $code){
echo $code;
}
</code></pre>
<p>Then I want to save it into mysql..</p>
<p>Here is my database: </p>
<pre><code>DROP TABLE IF EXISTS `ocs_database`.`schedule`;
CREATE TABLE `ocs_database`.`schedule` (
`schedID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`courseCode` varchar(30) NOT NULL,
`subjectName` varchar(45) NOT NULL,
`roomName` varchar(45) NOT NULL,
`lecturerName` varchar(45) NOT NULL,
`day` varchar(45) NOT NULL,
`startTime` varchar(45) NOT NULL,
`endTime` varchar(45) NOT NULL,
PRIMARY KEY (`schedID`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=latin1;
</code></pre>
|
php
|
[2]
|
1,479,791 | 1,479,792 |
itext variable issue
|
<p>I am trying to show a variable value from class 'dbproperties' in the pdf document. Following code illustrates it,</p>
<pre><code>dbproperties db = new dbproperties();
Chunk text1 = new Chunk(db.index_number);
Paragraph p = new Paragraph();
p.add(text1);
document.close();
</code></pre>
<p>but getting an error </p>
<blockquote>
<p>non-static variable cannot be referenced from a static content" for "Chunk text1 = new Chunk(db.index_number);</p>
</blockquote>
<p>Can anyone help me with this please??</p>
|
java
|
[1]
|
3,608,438 | 3,608,439 |
Onclick button timeout javascript
|
<p>Can someone help me get started with a button timeout feature. All I want is a button (when clicked) it becomes inactive for 2 seconds. After which it is active again.</p>
|
javascript
|
[3]
|
1,521,250 | 1,521,251 |
how to use jQuery to handle specific types of html controls
|
<p>Creating a click event for an input is easy</p>
<pre><code>$('input').click(function () {
alert('adsf');
});
</code></pre>
<p>But how can I be selective so that the previous code only works on type checkbox or of type button, rather than using the generic 'input' selector?</p>
|
jquery
|
[5]
|
3,738,506 | 3,738,507 |
how to start development of android applications?
|
<p>Since I have a requirement to develop a application.</p>
<p>The application must do the following
The application must be able to send SMS.
It should be able to save messages as drafts SMS.
It should also save messages as templates.
No limits should be there for saving templates and drafts.
It should show contacts when send action is clicked.</p>
<p>Please help from where should I start. I have experience only .net Mobile application.</p>
|
android
|
[4]
|
2,345,283 | 2,345,284 |
Why I can't get value printed?
|
<p>I wrote the following program:</p>
<pre><code>import java.util.Scanner ;
public class Triangle
{
public static void main ( String [] args )
{
Scanner scan = new Scanner ( System.in ) ; // new object named "scan"
// Next lines scan ribs values into a,b,c parameters
System.out.println ( "Please enter first rib value : " ) ;
int a = scan.nextInt () ;
System.out.println ( "Please enter second rib value : " ) ;
int b = scan.nextInt () ;
System.out.println ( "Please enter third rib value : " ) ;
int c = scan.nextInt () ;
if ( ! ( ( a >= 1 ) && ( b>=1 ) && ( c>=1 ) ) )
System.out.println ( "One or more of the ribs value is negative !!\nPlease enter a positive value ONLY ! " ) ;
else if ( ! ( (a <= b+c) && ( b <= a+c ) && ( c <= a+b ) ) )
System.out.println ( "Error !\n\nOne rib can not be bigger than the two others ! " ) ;
else
{
float s = (a+b+c) / 2 ;
double area = Math.sqrt( s * ( s-a ) * ( s-b ) * ( s-c ) ) ;
float perimeter = s*2 ;
System.out.println ( "Perimeter of the triangle is: "+perimeter+"\n\nArea of the triangle is: "+area) ;
}// end of else
}//end of method main
} //end of class Triangle
</code></pre>
<p>The problem is that I get on screen <em>area</em> value 0.0 for every legal values of the triangle's ribs.</p>
<p>Why is that ? I did everything seems to be Ok .. isn't it ?!</p>
<p>thnx</p>
|
java
|
[1]
|
331,504 | 331,505 |
How to getimagesize() after file_get_contents()?
|
<p>Unless I am mistaken, doing it the obvious way would download the file twice.</p>
<pre><code>$image = file_get_contents($location);
$checkImage = getimagesize($location);
</code></pre>
<p>I was wondering how I could do it without downloading twice. Placing <code>$image</code> inside <code>get_image_size()</code> doesn't work so I am not sure what to do. I found my tmp folder but when I ran the page to test I didn't see anything show up there so I'm not sure where to go with this. if I need to specify the actual location of <code>$image</code> (I think that is what I need to do) I am not sure how to find that.</p>
|
php
|
[2]
|
3,283,941 | 3,283,942 |
cannot find symbol error in super constructor call
|
<p>Compilation fails at line 8. It says the "s" in "super" is wrong.</p>
<pre><code>public class BasePlusCommissionEmployee extends CommissionEmployee {
private double baseSalary;
//constructor
public BasePlusCommissionEmployee( String first, String last, String ssn, int mth,
int day, int yr, double sales, double rate, double salary )
{
super( first, last, ssn, mth, day, yr, sales, rate );
setBaseSalary( salary );
}
</code></pre>
<p>Error message:
<img src="http://i.stack.imgur.com/G4T8Z.png" alt="Error message"></p>
|
java
|
[1]
|
1,579,882 | 1,579,883 |
What is the simplest way to change the behavior of a method during runtime?
|
<p>I have class called <code>Enemy</code>, and I want to have multiple types of enemies. Each <code>Enemy</code> will have different movement behavior, for example one might move straight at the player, one might maintain a certain distance, etc. What I would like to know is, what is the simplest way to have multiple different behaviors, preferably in one class?</p>
<p>My current idea is to use a <code>switch</code>, and include all the behavior in one method</p>
<pre><code>public class Enemy
{
public int health;
public int damage;
// etc etc
public void Move(string type)
{
switch(type)
{
case "charge":
chargeMove();
break;
case "maintain":
maintainMove();
break;
}
}
private void chargeMove()
{
//stuff
}
private void maintainMove()
{
//stuff
}
//all the behaviors
}
</code></pre>
<p>What I would like to know, is it better to keep everything to one function like this, or to create a new class for each enemy type that inherits from <code>Enemy</code>? I would prefer to keep it to one class, so that all the enemies can be nicely stored into a <code>IList</code>, without me having to do any casting to use any of the specific functions.</p>
<p>Any advice would be appreciated.</p>
<p>EDIT: Thanks for all the responses, I think that I will use the interface method proposed by Alastair.</p>
|
c#
|
[0]
|
6,031,692 | 6,031,693 |
Access Facebook page data using Android
|
<p>Is there any way to access a Facebook non-user page (ex: Musician, Product, etc) through an API through Android? I saw that there is a Facebook Android SDK but I haven't been able to figure out if this can be done.</p>
|
android
|
[4]
|
2,671,830 | 2,671,831 |
How to get data back from BroadcastReciever to Activity?
|
<p>I wrote sms application for which I wrote BroadcastReceiver.I want to get data from BroadcastReceiver into my activity ,so how do I get it.Please help me ,Please.</p>
<p>My Broadcast Reciever code is below:</p>
<pre><code>public class SmsReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
str += msgs[i].getOriginatingAddress();
}
//---display the new SMS message---
Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
}
}
}
</code></pre>
<p>I want to get back "str" value into another activity.</p>
|
android
|
[4]
|
5,641,181 | 5,641,182 |
Add new contact on Android no activity to handle intent error
|
<p>I am trying to add new contact to android and receive this ActivityNotFoundException: No Activity to handle intent. I am pretty sure that I need to use intent filter to resolve this problem but have no idea how.</p>
<pre><code>Intent addContactIntent = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
addContactIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
addContactIntent.putExtra(ContactsContract.Intents.Insert.NAME, "My Name");
addContactIntent.putExtra(ContactsContract.Intents.Insert.PHONE, "123456789");
startActivity(addContactIntent);
</code></pre>
<p>Here is my manifest file:</p>
<pre><code><activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/com.example.android.beam"></data>
</intent-filter>
<intent-filter>
<action android:name="com.android.contacts.action.SHOW_OR_CREATE_CONTACT" />
<data android:scheme="mailto" />
<data android:scheme="tel" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</code></pre>
|
android
|
[4]
|
1,415,291 | 1,415,292 |
Featured ad php site
|
<p>Can i program my ad site to open with the location geographically with ads showing that are in that area?</p>
|
php
|
[2]
|
4,863,365 | 4,863,366 |
How to start an application using Python
|
<p>I want to use a Python script to start an application, and then click File to Open a file. How should accomplish this? For example, I want to write a script which starts an automation tool/program that I have.</p>
<p>Is there another scripting language that is better suited for this?</p>
<p>You are appreciated!</p>
|
python
|
[7]
|
1,768,362 | 1,768,363 |
Javascript Book for free Download
|
<p>i'm lookin for a good javascript pdf book. which i can download freely.</p>
|
javascript
|
[3]
|
556,793 | 556,794 |
C++ function that do base 10 significant + exponent calculation from double
|
<p>I need to represent numbers using the following structure. The purpose of this structure is not to lose the precision.</p>
<pre><code>struct PreciseNumber
{
long significand;
int exponent;
}
</code></pre>
<p>Using this structure actual double value can be represented as <code>value = significand * 10e^exponent</code>. </p>
<p>Now I need to write utility function which can covert double into PreciseNumber. </p>
<p>Can you please let me know how to extract the exponent and significand from the double?</p>
|
c++
|
[6]
|
3,694,790 | 3,694,791 |
can copy constructor be a conversion operator?
|
<p>Consider the following code.</p>
<pre><code>#include <iostream>
using namespace std;
class Test
{
private:
int x,y;
public:
Test () {
cout <<" Inside Constructor "<<endl;
x=100;
}
explicit Test (const Test & t)
{
cout <<"Inside Copy Constructor "<<endl;
x = t.x;
}
void display()
{
cout <<" X is "<<x<<endl;
}
};
int main (int argc, char ** argv){
Test t;
t.display();
cout <<"--- Using Copy constructor "<<endl;
Test t2(t);
t2.display ();
Test t3=t2;
t3.display ();
}
</code></pre>
<p>Test (const Test & t) -> is a copy constructor</p>
<p><strong>Question:</strong></p>
<p>Is the same used as a "Conversion Operator" ?
Test t3 = t2 [ Here copy Constructor is treated as a conversion operator]</p>
<p>I am not sure if my understanding is correct?. Kindly correct me if i am wrong? </p>
|
c++
|
[6]
|
600,766 | 600,767 |
PHP Website Development
|
<p>My next project is developing a dynamic website in PHP. I have the idea and database schema figured out. I want to avoid writing redundant code, hence looking for a way to implement "User" registration,user home page etc directly(may be some framework or scripts directly).
Using that i will add up my own functionality . </p>
<p>PS:As this is going to be my first big php project, please do suggest me some IDE's to use.</p>
|
php
|
[2]
|
3,849,403 | 3,849,404 |
Discards qualifiers error
|
<p>For my compsci class, I am implementing a Stack template class, but have run into an odd error:</p>
<blockquote>
<p>Stack.h: In member function β<code>const T Stack<T>::top() const</code> [with T = int]β:</p>
<p>Stack.cpp:10: error: passing β<code>const Stack<int></code>β as β<code>this</code>β argument of β<code>void Stack<T>::checkElements()</code> [with T = int]β discards qualifiers</p>
</blockquote>
<p><code>Stack<T>::top()</code> looks like this:</p>
<pre><code>const T top() const {
checkElements();
return (const T)(first_->data);
}
</code></pre>
<p><code>Stack<T>::checkElements()</code> looks like this:</p>
<pre><code>void checkElements() {
if (first_==NULL || size_==0)
throw range_error("There are no elements in the stack.");
}
</code></pre>
<p>The stack uses linked nodes for storage, so <code>first_</code> is a pointer to the first node.</p>
<p>Why am I getting this error?</p>
|
c++
|
[6]
|
4,789,762 | 4,789,763 |
Working with module libraries on Android
|
<p>I need to create a generic application that will work with different languages (not localized per device settings) and different drawables.
The development is done using intelliJ.</p>
<p>My question is whether it is possible to create the "generic" app in a specific module, have a library modules and drawable module for the different languages/drawables.
Then, I'll use different compilations (with ANT) to build the different apps (for example, english with dark style images or spanish with white style images).</p>
<p>Thanks.</p>
|
android
|
[4]
|
1,481,123 | 1,481,124 |
OnActionResult method is not called in Android
|
<p>I want to choose images from the Gallery. Please check the following code.</p>
<pre><code>public class Camera extends Activity {
private static final int SELECT_PICTURE = 1;
private String selectedImagePath;
WebView localview;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
}
public void ChoosePhoto(WebView webview)
{
localview=webview;
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE)
{
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
try {
FileInputStream fileis=new FileInputStream(selectedImagePath);
BufferedInputStream bufferedstream=new BufferedInputStream(fileis);
byte[] bMapArray= new byte[bufferedstream.available()];
bufferedstream.read(bMapArray);
localview.loadUrl("javascript:ReceivePhoto(\""+bMapArray+"\")");
if (fileis != null)
{
fileis.close();
}
if (bufferedstream != null)
{
bufferedstream.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public String getPath(Uri uri) {
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
}
</code></pre>
<p>And included the activity in Manifest file. But after choosing the image, <strong>OnActivityResult is not called.</strong></p>
<p>Can anyone please help me???</p>
|
android
|
[4]
|
722,546 | 722,547 |
How do deploy IPhone app
|
<p>I need to create an IPhone app as an alternative interface to our commercial application. Our application is sold to Hospitals and installed at their location. How do I distribute this IPhone app to the doctors that practice at the individual hospitals? </p>
|
iphone
|
[8]
|
3,406,005 | 3,406,006 |
Which way is better, setInterval() or window.setInterval()?
|
<p>Ok so there is a couple things to this question.</p>
<p>First of all, i'm asking this for setTimeout() and for setInterval()</p>
<p>I have seen a couple different ways to call them and i'm wondering which way is the best for this circumstance..</p>
<p>I'm making a js/canvas game and I'm just looking over my draw interval (where it loops the draw method)</p>
<p>Anyways, here are the different ways I have seen... </p>
<p><strong>Part A:</strong></p>
<ol>
<li><p>Using window.</p>
<pre><code>drawInterval = window.setInterval(draw, 60);
</code></pre></li>
<li><p>Not using window.</p>
<pre><code>drawInterval = setInterval(draw, 60);
</code></pre></li>
</ol>
<p><strong>Part B:</strong> </p>
<ol>
<li><p>Not using quotes and brackets around the function name</p>
<pre><code>drawInterval = setInterval(draw, 60);
</code></pre></li>
<li><p>Using quotes and brackets around the function name</p>
<pre><code>drawInterval = setInterval("draw()", 60);
</code></pre></li>
</ol>
<p>So for <strong>Part A:</strong> should i use window. or not?
And what about window.clearInterval() vs clearInterval by itself?</p>
<p>And for <strong>Part B:</strong> should I use quotes and brackets or not? I was told before that it was a bad idea to use quotes and brackets for this situation.</p>
|
javascript
|
[3]
|
4,830,558 | 4,830,559 |
how to get the user id from this array and print that
|
<p>i have code to get the my friend list from facebook </p>
<p>the code is................</p>
<pre><code>function getFriends() {
//if the person has not pressed login button
if(!loggedIn) {
loginFacebook();
}
document.getElementById("status").innerHTML = "Now loading your friends' id...";
//if the person is loggedIn
if(loggedIn) {
document.getElementById("friendBtn").disabled = "disabled";
FB.api("/me/friends",function(response){
friends = response["data"];
totalToBeLoaded = friends.length;
// addNewRow("Name","id");
loadid(friends.length);
});
}
}
</code></pre>
<p>the response["data"] function returns the data in the form of array as </p>
<pre><code>{
"data": [
{
"name": "name 1",
"id": "123456781"
},
{
"name": "name 2",
"id": "123456782"
},
{
"name": "name 3",
"id": "123456783"
},
{
"name": "name 4",
"id": "123456784"
},
{
"name": "name 5",
"id": "123456785"
},
{
"name": "name 6",
"id": "123456786"
}
]
}
</code></pre>
<p>now i need to get that name and id of the user from that response["data"] and print that .. how to do that?</p>
|
javascript
|
[3]
|
5,596,544 | 5,596,545 |
Is it possible to programmatically detect the caret position within a <input type=text> element?
|
<p>Assuming a regular <code><input type=text></code> text-box with data in it. </p>
<p>Is it possible to detect (via JavaScript) the position of the text-coursor inside that text-box? </p>
<p>I am able to detect an ARROW LEFT or ARROW RIGHT keydown event - but how to detect the cursor location? </p>
<p><em><strong>Why I need this:</em></strong> </p>
<p>I have a dynamic text-box here: <a href="http://vidasp.net/tinydemos/dynamic-textbox.html" rel="nofollow">http://vidasp.net/tinydemos/dynamic-textbox.html</a><br>
It works great, however there are two scenarios that I would like to fix: </p>
<ol>
<li>when the cursor is at the beginning of the text-box and the user presses BACKSPACE </li>
<li>when the cursor is at the end of the text-box and the user presses DELETE </li>
</ol>
<p>(In both cases, the text-box must contain data for the effect to be observable.)</p>
|
javascript
|
[3]
|
613,174 | 613,175 |
How to make a list of numbers to calculate the arithmetic mean of the remainder?
|
<p>I have a project about java which wants me from to writing a console program that reads in a list of number scores on one line, separated by spaces, discards the highest and lowest numbers, then calculates the arithmetic mean of the remainder.</p>
<p>I have problems about how to make a array-list of number to calculate he arithmetic mean.</p>
<p>These are the codes : </p>
<p>Actually these codes are working in Java Applet and Java Application but I can take the numbers with scanner method but I couldn't find a solving way to make a list for the numbers.</p>
<pre><code>public static void main(String[] args) {
/*
* For data input.
*/
Scanner kb = new Scanner(System.in);
/*
* Declare an array to store the judge's scores.
*/
double[] scores = new double[8];
/*
* Declare variables for lowest and highest scores.
*/
double lowestScore = Integer.MAX_VALUE;
double highestScore = Integer.MIN_VALUE;
/*
* Read 7 judge's scores.
*/
for (int i = 0; i < 7; i++) {
System.out.println(String.format("Judge Score #%d: ", i + 1));
scores[i] = kb.nextDouble();
/*
* Compare the current score with the lowest and the highest scores.
*/
if (scores[i] < lowestScore) {
lowestScore = scores[i];
}
if (scores[i] > highestScore) {
highestScore = scores[i];
}
}
/*
* Sum the scores, except the lowest and the highest scores.
*/
double total = 0.00;
for (int i = 0; i < 7; i++) {
if (scores[i] != lowestScore && scores[i] != highestScore) {
total = total + scores[i];
}
}
/*
* Display the output.
*/
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("Total points received: " + df.format(total));
System.out.println("Arithmetic Mean : " + df.format(total / 7));
}
</code></pre>
<p>Does anyone has another ideas about my question ?</p>
|
java
|
[1]
|
1,423,565 | 1,423,566 |
getting variable
|
<p>I have kind of stupid question:</p>
<p>Is there any way to use instance variable from one class in another class?
I guess inheritance could be the way to do it, but I don't know how:(</p>
<p>for example:</p>
<pre><code>class A():
def __init__(self):
self.var1 = 12
self.var2 = C()
def start(self):
self.var1=11
B()
class B():
def doSomething(self):
varXX = " here I would like to have objet self.var2 from A()"
class C():
def makeUI(self):
something
</code></pre>
<p>thx for help</p>
|
python
|
[7]
|
1,779,248 | 1,779,249 |
Direct download & install into iphone/ipad in C#
|
<p>I want to create a download and install ipa file automatically function in to iphone/ipad in C# ?But i have no idea how to do it.I only use a command way to download the file but it wont install into my iphone/ipad automatically?Is that possible do in C#?</p>
<p>It wrong code just an ideal for it:</p>
<pre><code> protected void Page_Load(object sender, EventArgs e)
{
string filePath = string.Empty;
string appType = string.Empty;
//ios
filePath = "appFile/Apps.ipa";
appType = "application/octet-stream";
Response.ClearContent();
Response.ContentType = MimeType(Path.GetExtension(fName),appType);
Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}",System.IO.Path.GetFileName(fName)));
Response.AddHeader("Content-Length", sz.ToString("F0"));
Response.TransmitFile(fName);
Response.End();
}
public static string MimeType(string Extension,string appMineType)
{
string mime = appMineType;
if (string.IsNullOrEmpty(Extension))
return mime;
string ext = Extension.ToLower();
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (rk != null && rk.GetValue("Content Type") != null)
mime = rk.GetValue("Content Type").ToString();
return mime;
}
</code></pre>
|
c#
|
[0]
|
5,673,222 | 5,673,223 |
android how to draw cicles ,rectangles on canvas?
|
<p>In my app i am able to draw something on canvas within on touch event.</p>
<p>But problem is, at a time single item can be draw within touch event. means if i will put lineto() and moveto() then it ll draw lines.
if addCircle() ll given then circle drawn.and also for Rect and oval.</p>
<p>But i want to give different buttons for that. By default line will be drawn. If i press Circle then circle will drawn, if Rect button press then Rectangle will draw on canvas by using same touch event.</p>
<p>So i want to know what i ll write under on touch events so that it will work for every button click?
Give me a way.
Thank you</p>
|
android
|
[4]
|
1,516,389 | 1,516,390 |
Java application running slower and slower
|
<p>my Java code is running slower and slower when it is processing a large text file. I can observe that the output of my program is slowing because the increase of the output file is becoming slower. </p>
<p>I am afraid there is a memory leak somewhere. However, when I watch the memory usage through Windows Task Manager's Performance tag, I can see that the memory consumption stays quite stable, only minimal increase. Maybe Windows Task Manager doesn't show the memory leak?</p>
<p>the main logic is like this: read each line of text from the file, process it and store the result of the processing into a map </p>
<pre><code>Map<String, Integer> resultsPerLine = new HashMap<String, Integer>();
</code></pre>
<p>and then store a line number with resultsPerLine into another static map </p>
<pre><code>static Map<Integer, Map<String, Integer>> extractedResultMap
</code></pre>
<p>That's the main code.</p>
|
java
|
[1]
|
5,449,240 | 5,449,241 |
Do I need an Mac to post an app to the app store?
|
<p>Do I need to a Mac computer to post an app to the app store? Can I post an app using my PC?</p>
|
iphone
|
[8]
|
193,175 | 193,176 |
Looking for a tool can run javascript in my computer
|
<p>Sometimes I have to test some javascript code, that I use <a href="http://jsbin.com" rel="nofollow">jsbin.com</a>, but it's not always convenient.</p>
<p>I hope there is a GUI tool can let me run javascript in my computer. I paste some javascript code into it and click 'RUN', that it will show me result.</p>
<p>Is there such a tool?</p>
<hr>
<p><strong>UPDATE</strong></p>
<p>If I use browser, I need to create a html file first, that's not convenient. I think what I want is a offline version of jsbin.com.</p>
|
javascript
|
[3]
|
4,992,817 | 4,992,818 |
jquery - how to select for this, get a count, and get the current position within the selected group
|
<p>I have a set of img boxes that are marked up like this</p>
<p>I want to get a count and have this:</p>
<pre><code><div data-location-id="6" class="img-box-set">my img</div>
</code></pre>
<p>I have:</p>
<pre><code>var location_id = $(this).data('location-id');
// fixed per comment #1 below
var count_of=$('.img-box-set[data-location-id='+location_id+']').length;
alert("here is count_of" + count_of);
</code></pre>
<p>but the length always returns 0. Am I doing something wrong with selector or with length property?</p>
<p>Also, assuming I have 4, how would I determine which position I'm in (either 0-based or 1-based)?</p>
<p>thx</p>
<p><strong>edit #1</strong>
So I'd think this works but it isn't (per @jack ) and index docs. (update - this does work; had syntax error)</p>
<pre><code>var index_box=$('.img-box-set[data-location-id='+location_id+']').index(this);
alert("here is the index" + index_box);
</code></pre>
|
jquery
|
[5]
|
2,092,945 | 2,092,946 |
jquery get selected option in SELECT
|
<p>Is there any difference between </p>
<pre><code>$("#myselectname option:selected").val()
</code></pre>
<p>and</p>
<pre><code>$("#myselectname").val()
</code></pre>
<p>, where myselectname is identifier for a SELECT. I can see both return the same.</p>
|
jquery
|
[5]
|
1,603,589 | 1,603,590 |
Labelled break statement...where next
|
<p>I'm just doing the Sierra-Bates SCJP study guide and am wondering about the following question:</p>
<pre><code>public class Wind {
public static void main(String[] args) {
foreach:
for(int j=0; j<5; j++) {
for(int k=0; k< 3; k++) {
System.out.print(" " + j);
if(j==3 && k==1) break foreach; //1
if(j==0 || j==2) break;
}
}
}
}
</code></pre>
<p>When the value of k is equal to 1 and break foreach is executed (at line 1), where exactly does iteration go after this, to my mind does this now exit the whole loop. Where is the next point of iteration ? How is there any further iterations if the outside loop is exited ?
The answer given in the study book for this is 0111233. The way I see it, only 01 gets printed before the entire loop is exited. No ?</p>
|
java
|
[1]
|
466,034 | 466,035 |
Is it bad practice to nest 2 try catch statements in C#?
|
<p>Is the following code bad practice?</p>
<pre><code> try //Try Overall Operation
{
try //Try section 1 of operation
{
}
catch(exception ex)
{
//handle exception code
//throw the exception
}
catch (exception ex)
{
// send soap exception back to SOAP client.
}
</code></pre>
<p>I know from a program review point of view, other developers seeing 2 tries nested directly like that might wonder why, but is it totally taboo, or is it accepted practice now days?</p>
<p>Thanks Guys, I agree with you all about the refactoring, going to create a seperate method for the sub functionality, the method was getting really long. I am very impressed to all of you who picked this up...</p>
|
c#
|
[0]
|
3,434,653 | 3,434,654 |
aspx missingfieldexception error
|
<p>i have just updated my company website and looked okay, few seconds later i encounter this error:</p>
<pre><code>System.MissingFieldException: Field not found: xxx.include.NaviBar.ASPnetMenu1.
</code></pre>
<p>need help, urgent!</p>
<p>thanks in advance!</p>
|
asp.net
|
[9]
|
1,644,689 | 1,644,690 |
Image replacement with throbber inside webview - Android
|
<p>What is the best way of replacing an image with a throbber image inside webview? onclick is responses slow inside webview... </p>
|
android
|
[4]
|
2,048,508 | 2,048,509 |
getApplicationContext() not working for asynchronous event
|
<p>I want to toast text entered into a texbox using an asynchronous event eg. press button. It compiles without error but nothing happens when the button is pressed. From what I have been able to gather on the forum, my context is wrong. Can someone help me? Below is the code:</p>
<pre><code>mSendButton = (Button)findViewById(R.id.button_send);
mSendButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
TextView view = (TextView)findViewById(R.id.edit_text_out);
String message = view.getText().toString();
if (message == "bla") {
Toast.makeText(getApplicationContext(), "Bla was entered", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getApplicationContext(), "Bye ", Toast.LENGTH_SHORT).show();
}
}
});
</code></pre>
|
android
|
[4]
|
138,672 | 138,673 |
Why can't I add a new row in my table using javascript?
|
<pre><code>function add(tableID) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
cell2.innerHTML = rowCount;
var cell2 = row.insertCell(1);
var element1 = document.createElement("input");
element1.type = "text";
cell2.appendChild(element1);
}
</code></pre>
<p><a href="http://jsfiddle.net/89Q7T/" rel="nofollow">jsFiddle: add a row</a></p>
<p>What is wrong with my code? It doesn't seem to work.</p>
<p>Any help will be greatly appreciated.</p>
|
javascript
|
[3]
|
4,271,887 | 4,271,888 |
C# modifing a string array in a foreach loop and changing the same array
|
<p>Maybe I asked this is a bad way so let me try to explain.</p>
<p>I have a <strong>public static string[]</strong></p>
<pre><code>public static string[] MyInfo {get;set;}
</code></pre>
<p>I set this via</p>
<pre><code>MyInfo = File.ReadAllLines(@"C:\myfile.txt");
</code></pre>
<p>What I want to do is a foreach on each of those lines and modify it based on x number of rules. One the line has been modified change that exisiting line in MyInFo</p>
<p>so</p>
<pre><code>foreach(string myI in MyInfo)
{
string modifiedLine = formatLineHere(myI);
//return this to MyInfo somehow.
}
</code></pre>
|
c#
|
[0]
|
2,575,071 | 2,575,072 |
sequentially delayed fading in with jquery
|
<p>I have some array data returned from an ajax call consisting of an image link, some title text and a link. I am adding each element of this array to a div on the page by using the jQuery append method and the fading it in. Because it's executing so fast all the elements fade in at the same time. I'd like each one to fade in sequentially. So, when the element is added to the main div, fade in and then pause the .each statement for about 100 milliseconds before adding the next element. However I'm not sure how to do this. Any ideas? Here's my code.</p>
<pre><code>jQuery.each(data.themes, function (index){
theme_html = "<div class=\"themePreviewWrap\" id=\"theme_" + index + "\" style=\"display:none;\"><div class=\"themePreview\"><img src=\"" + data.themes[index]['custom_color_screenshot'] + "\" /></div><div class=\"themePreviewButtom\"><div class=\"title\"><b>" + data.themes[index]['title'] + "</b></div><div class=\"link\">" + data.themes[index]['actions'] + "</div></div></div></div>";
jQuery('#themeholder').append(theme_html);
jQuery("#theme_" + index).fadeIn(500);
});
</code></pre>
|
jquery
|
[5]
|
3,494,493 | 3,494,494 |
marquee text in android
|
<p>How can I use marquee text in an android application?</p>
|
android
|
[4]
|
5,890,230 | 5,890,231 |
jQuery select elements with incrementing ID's
|
<p>I would like to select list items based on their incrementing ID's but I am having a bit of trouble. Thoughts? </p>
<pre><code>$(document).ready(function () {
var listCount = 1;
$('#listitem-' + listCount + ' a').hover(function() {
$('#anotheritem-' + listCount).show();
return false;
});
listCount++;
});
</code></pre>
<p>HTML:</p>
<pre><code><ul id="cap">
<li id="listitem-1"><a href="#">content 1</a></li>
<li id="listitem-2"><a href="#">content 2</a></li>
<li id="listitem-3"><a href="#">content 3</a></li>
<li id="listitem-4"><a href="#">content 4</a></li>
</ul>
<div style="display:none;" id="anotheritem-1">hello 1</div>
<div style="display:none;" id="anotheritem-3">hello 3</div>
<div style="display:none;" id="anotheritem-3">hello 3</div>
<div style="display:none;" id="anotheritem-4">hello 4</div>
</code></pre>
<p>UPDATED Question. I'm trying to achieve the following revision of the answer:</p>
<pre><code>$('.listitem_to_hover').hover(function () {
var senderID = sender.id.replace('listitem-', '');
$('#anotheritem-' + senderID).show();
}, function () {
var senderID = sender.id.replace('listitem-', '');
$('#anotheritem-' + senderID).hide();
});
</code></pre>
|
jquery
|
[5]
|
2,429,219 | 2,429,220 |
document.activeElement.id is not working
|
<p>I am developing an application for device. and i want to know the current focused anchor.</p>
<p>for this i used <strong>document.activeElement.id</strong>. It is working fine on webkit but not working on older browser.
So i used </p>
<pre><code> $(":a").focus(function () {
id = this.id;
});
</code></pre>
<p>It is also not working. I go through meny website and i found that .focus method wil work for only <strong>input</strong> tag.</p>
<p>So please give me IDea for this problem . If it will be purely javascript it will be better .</p>
<p>Any help will be appricated</p>
|
javascript
|
[3]
|
4,125,755 | 4,125,756 |
c# sending email message threading
|
<p>I am using the following in c# .NET to send out emails when a user fills out an online form.
I was wondering if threading is necessary for what I have.</p>
<pre><code>MailAddress From = new MailAddress("xyz@qinc.com");
MailAddress To = new MailAddress(toemail);
MailMessage alert = new MailMessage(From, To);
alert.Subject = "Registration for " + name;
alert.Body = bodyText;
alert.IsBodyHtml = true;
NetworkCredential creds = new NetworkCredential("bot@qinc.com", "Xfdfdfd");
SmtpClient client = new SmtpClient("smtp.gmail.com");
client.EnableSsl = true;
client.Credentials = creds;
client.Send(alert);
</code></pre>
<p>Thanks in advance</p>
|
c#
|
[0]
|
4,072,309 | 4,072,310 |
Android: How to add listener to hardware menu button?
|
<p>I'm currently trying to add a click listener to the menu hardware button. Currently I'm just putting my onclick logic into the onCreatePanelMenu-method and return false. But that just feels wrong.</p>
<p>Is there a more clean way?</p>
<p>The code currently looks like that:</p>
<pre><code>@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
Toast.makeText(this, "HALLO!", Toast.LENGTH_SHORT).show();
return false;
}
</code></pre>
|
android
|
[4]
|
3,777,320 | 3,777,321 |
Error - "Use of Unassigned out parameter envelope"
|
<p>I am getting an error in below function as "Use of Unassigned out parameter envelope"</p>
<pre><code> public override bool Parse(string input, out Envelope envelope)
{
XmlDocument doc = new XmlDocument();
//Load XML from the file into XmlDocument object
doc.LoadXml(input);
XmlNode root = doc.DocumentElement;
XmlNode MsgEnvroot = doc.DocumentElement.SelectSingleNode("MsgEnvelope");
XmlNode MsgBodyroot = doc.DocumentElement.SelectSingleNode("MsgBody");
XmlNodeList nodeList = root.SelectNodes("MsgEnvelope");
foreach (XmlNode node in nodeList)
{
envelope.Priority = node["Priority"].InnerText;
envelope.RecipientPIMA = node["RecipientPimaAddress"].InnerText;
envelope.SenderPIMA = node["SenderPimaAddress"].InnerText;
envelope.EnvelopeDateTime = node["GMT"].InnerText;
}
envelope.MsgEnvString = MsgEnvroot.InnerText;
envelope.MsgBodyString = MsgBodyroot.InnerText;
return true;
}
</code></pre>
|
c#
|
[0]
|
628,671 | 628,672 |
alias keyword (like typedef) in C#?
|
<p>I have 2 libs that have different case on different platforms :(. It seems like everything else is the same (method names, param order, etc). How can i create an alias so my current spelling for platform a will work when i compile for platform b (I would really hate to make a wrapper for case difference)</p>
|
c#
|
[0]
|
3,294,311 | 3,294,312 |
UITableView and UIDatePicker are not autorotating?
|
<pre><code> UITableview
|
Row(1)...........................Row(0)
| |
| |
UIDatepicker UITabelview
</code></pre>
<p>Now I set autoresizingMask for UITabelview then UITabelview resize as iphone moves from portrait to landscape mode.</p>
<p>But when I click on row1 or row0 and then I move iphone from portrait to landscape mode, UITabelview or UIDatepicker doesn't resize even though I'm using autoresizingmask property.</p>
<p>What can I do? </p>
|
iphone
|
[8]
|
4,843,564 | 4,843,565 |
iPhone: performSelector with BOOL parameter?
|
<p>Is there any way to send BOOL in selector ?</p>
<pre><code>[self performSelector:@selector(doSomething:) withObject:YES afterDelay:1.5];
</code></pre>
<p>Or I should use NSInvocation ? Could somebody write a sample please ?</p>
|
iphone
|
[8]
|
3,954,671 | 3,954,672 |
Why I can not use a variable for the :eq filter to append data to an unordered list?
|
<p>Why I can not use a variable counter for the :eq filter to append data to an unordered list?</p>
<p>For example, the code is not working. It not being updated into the div of unordered list.</p>
<pre><code> $('#list li:eq("+ counter +")').append('<li>' + variable + '<li>');
</code></pre>
|
jquery
|
[5]
|
4,351,152 | 4,351,153 |
what is the correct syntax to use when testing if a posted form value contains text equal to XX php
|
<p>I'm trying to write an if statement to test if a posted form value is equal to xx</p>
<pre><code> $field = $_POST['myfield'];
if($field == 'Hello world') {
/ /do something
}
</code></pre>
<p>Is this correct..?</p>
<p>Thanks</p>
|
php
|
[2]
|
4,006,003 | 4,006,004 |
Screen Capture Making Video
|
<p>Can anyone know how to make video recording by capture the screen on iphone? I have an animation and other audio that is working simultaneously with same time and I want to record it as a video so that I can post this video to</p>
|
iphone
|
[8]
|
1,571,371 | 1,571,372 |
Tools to map threads to their memory usage?
|
<p>Having some performance issues in a Weblogic 11g production system. </p>
<p>As part of the debugging effort, Iβm interested in finding a way to map threads to their memory usage, then seeing the stack to determine what part of the application is consuming so much. </p>
<p>Anyone know of a tool or method to do what I want to do?</p>
<p>I'm not interested in JProbe memory profiling as it requires too much overhead (taking snapshots of everything). Also, I've read about Heapwalker in NetBeans that seems promising.</p>
|
java
|
[1]
|
5,874,441 | 5,874,442 |
ASP.NET Form Authenticaion
|
<p>I have created ASP.NET project and connect it to database. After I just added Login and Register control. Something like:</p>
<pre><code> <asp:Login ID="Login1" runat="server"
DestinationPageUrl="~/Users/UserAccount.aspx">
</asp:Login>
</code></pre>
<p>Actually it works! It does registration and login operation. But HOW? Where is a code, where is SQL statement? I don't see anything related to that. Could you please explain me how it works? and how do I modify say registration control if I need extra information.</p>
<p>Thanks!</p>
|
asp.net
|
[9]
|
2,686,472 | 2,686,473 |
Variable referenced instead of copied
|
<p>When I run the code below it removes <code>deleted_partner</code> from <code>B</code>. But as it removes it from <code>B</code> it also removes it from <code>A</code>. So that when I try to remove it from <code>A</code> the program crashes. What is the problem?</p>
<pre><code>for deleted_partner in self.list_of_trading_partners:
B = A[:]
print("t", deleted_partner)
print(B[self.ID].list_of_trading_partners)
B[self.ID].list_of_trading_partners.remove(deleted_partner)
Round_neo_classic(B)
Round_costs(B)
if B[self.ID].final_good > reference_value:
print("d", deleted_partner)
print(A[self.ID].list_of_trading_partners)
A[self.ID].list_of_trading_partners.remove(deleted_partner)
</code></pre>
<p>Output:</p>
<pre><code>('t', 1)
[1, 2, 3, 4]
('d', 1)
[2, 3, 4]
</code></pre>
|
python
|
[7]
|
2,452,499 | 2,452,500 |
Python string .format(*variable)
|
<p>I'm reading a book to read and it covers this below example.</p>
<pre><code>somelist = list(SPAM)
parts = somelist[0], somelist[-1], somelist[1:3]
'first={0}, last={1}, middle={2}'.format(*parts)
</code></pre>
<p>Everything seems clear apart from the star being used at the end of the last line. The book fails to explain the usage of this and I hate to progress on without full understanding things.</p>
<p>Many thanks for your help.</p>
|
python
|
[7]
|
5,456,431 | 5,456,432 |
C++ Abstract Base Class Problem
|
<p>So I have run into a problem with my ABC design in C++. I'm going to use a simplified example from what I actually have. Please ignore any syntax errors until I get to where my issue is.</p>
<p>So I have an ABC:</p>
<pre><code>class ABC
{
public:
virtual void DoSomething() = 0;
};
</code></pre>
<p>Then I have a derived class:</p>
<pre><code>class Derived: public ABC
{
public:
void DoSomething() { // something }
};
</code></pre>
<p>In my main logic function I have something along the lines of:</p>
<pre><code>ABC* obj = new Derived;
obj->DoSomething();
</code></pre>
<p>Now at this point my code works beautifully, I have multiple classes functioning correctly based on if I change the type (manually for now) from one derived class to another using the abstract base class as the type for the derived objects.</p>
<p>Now my issue...</p>
<p>If I want to change my derived class to add in functionality that is not supported by the ABC then my compiler is not recognizing them whatsoever. For example if I leave ABC the way it is and change Derived to:</p>
<pre><code>class Derived: public ABC
{
public:
void DoSomething() { // something }
void DoSomethingElse() { // something else, not defined in ABC}
};
</code></pre>
<p>Then back to my main logic function:</p>
<pre><code>ABC* obj = new Derived;
obj->DoSomething();
// Compiler does not recognize this, due to not being in the "ABC" class
obj->DoSomethingElse();
</code></pre>
<p>My compiler keeps giving me errors that "DoSomethingElse()" is not a member of the ABC. Is what I am trying to do possible? It feels like I am overlooking something simple but I've hit this road block in my architecture of this piece of software. Any help is greatly appreciated.</p>
|
c++
|
[6]
|
6,029,291 | 6,029,292 |
jQuery monitor entire page?
|
<p>I have some code which adds a tooltip to all links. Now, the page keep changing with AJAX - how can I track these changes and add tooltips to links which are added to the document by AJAX?</p>
<p>I thought this might work:</p>
<pre><code>$(document).live('change', function(){
//code...
});
</code></pre>
<p>But I'm guessing there's a smarter/more efficient method to work this out. Any ideas? </p>
<p>Note: I can only use jQuery 1.3.2</p>
|
jquery
|
[5]
|
1,676,636 | 1,676,637 |
What is the class of Map<MyClassType1,Object>
|
<p>I have to pass to a constructor the class of <code>Map<ClassType1,Object></code>. if i pass <code>Map.class</code> only, I have an error. So I would like to know what's the class of <code>Map<MyClassType1,Object></code> ?</p>
<pre><code>public class GetSessionRequest extends SpiceRequest<Map<ClassType1, Object>> {
private Client mClient;
public GetSessionRequest(Class<Map<ClassType1, Object>> clazz) {
super(clazz);
}
public GetSessionRequest(Client client) {
super(/*What should I pass here. I can't pass Map.class*/);
mClient = client;
}
@Override
public Map<ClassType1, Object> loadDataFromNetwork() throws Exception {
Map<ClassType1, Object> map = mClient.getSession();
return map;
}
}
</code></pre>
|
java
|
[1]
|
1,603,581 | 1,603,582 |
Screen auto rotates when unlocking
|
<p>Hi I am trying to save some values in my activity but I'm having a problem when I save it with onSaveInstanceState and restore with onRestoreInstanceState, I am saving an int years and it saves the first time the screen changes orientation, the spinner repopulates and sets it at the last value , but not when I switch back the orientation again.</p>
<p>My orientation is set to landscape in my manifest, and I have the two save and restore method overridden but it doesn't seem to work, do I need to do something in onPause aswell?</p>
<p>here is my code:</p>
<pre><code> int years;//global variable
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Spinner spinnerYears = (Spinner) findViewById(R.id.spinYears);//Spinner
final ArrayAdapter <Integer> adapter = new ArrayAdapter <Integer>(this,android.R.layout.simple_spinner_item );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
for(int i=0;i<=100;i++)
{
adapter.add(i);
}
spinnerYears.setAdapter(adapter);
years = spinnerYears.getSelectedItemPosition();
}//onCreate
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putInt("MyInt", years);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
Spinner spinnerYears = (Spinner) findViewById(R.id.spinYears);//Spinner
final ArrayAdapter <Integer> adapter = new ArrayAdapter <Integer> (this, android.R.layout.simple_spinner_item );
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
for(int i=0;i<=100;i++)
{
adapter.add(i);
}
spinnerYears.setAdapter(adapter);
TextView tvYears = (TextView) findViewById(R.id.tvYears);//spinner Tv
tvYears.setVisibility(TextView.GONE);
int myInt = savedInstanceState.getInt("MyInt");
spinnerYears.setSelection(myInt);//
Toast.makeText(getBaseContext(), "Restored int"+myInt, Toast.LENGTH_LONG).show();
}
</code></pre>
|
android
|
[4]
|
5,988,984 | 5,988,985 |
translate php website without extrernalizing resources
|
<p>I have a php site that mixes html and php.
ex: </p>
<pre><code><html>
hello <?=$username?>
</code></pre>
<p>I need infact to keep texts are they are. I do not want a classical solution such as that consits of creating reosurce strings and replace them such as: </p>
<pre><code><html>
<?=echo $helloString?> <?=$username?>
</code></pre>
<p>Infact a kind of "autoscript" that will replace all text resources at run time. So I keep the existing site and just add some script at begin.</p>
<pre><code><? include("translation_module.php?")?>
<html>
hello <?=$username?>
</code></pre>
<p>and this translation_module.php will replace "hello" to "bonjour".</p>
<p>Any clue to achieve that ?</p>
<p><strong>I don't care about grammer, currencies, plurial problems.</strong></p>
<ul>
<li>I guess it should work like google translate: it should execute itself, and translate then output texts and finally printout the result (of course I have no idea how it does it, how it handles $GET, $POST, $SESSION variables...)</li>
</ul>
<p>Thanks</p>
|
php
|
[2]
|
4,445,099 | 4,445,100 |
javascript new Date function not working
|
<p>My problem is as follows:<br/>
I want to display nepalese standard time in my website,so i set default timezone of my<br/> website to 'Asia/kathmandu' using command: <b>php_value date.timezone 'Asia/kathmandu'</b> in htaccess file.<br/>
<p>when i display time using any php functions like <b>strf() or date() </b>,it shows the nepalese standard time,<br/>
But when i use javascript function <b>new Date(<code><?php echo time()*1000; ?></code>)</b>,it displays<br/> the time of my personal pc i am using to view my website.<br/>
How can i display correct time using javascript date functions? Can anybody help me out?</p>
|
javascript
|
[3]
|
2,447,440 | 2,447,441 |
for loop of array
|
<p>i want to make check of array by using for loop
the check is if selected value display it also display its index</p>
|
php
|
[2]
|
2,973,437 | 2,973,438 |
Is there anyway to know that application launches firsttime?
|
<p>Is there anyway to know that when an application is launched for the firsttime? I dont want to use sharedpref because when the user cleardata manually it clears all the data.</p>
|
android
|
[4]
|
5,761,042 | 5,761,043 |
simple jquery image change onclick failing
|
<p>I have a simple jQuery image switch that is failing.</p>
<pre><code>$('.heart_img').click(function()
{
var heart_type = $(this).attr('src');
//alert( heart_type );
if ( heart_type == 'images/unheart.png')
{
//alert('uheart');
$(this).attr('src','images/heart.png');
}
else if ( heart_type == 'images/heart.png');
{
$(this).attr('src','images/unheart.png');
}
});
</code></pre>
<p>The alerts fire correctly when not commented out so and the images are in the correct place so I am not sure what the problem is.</p>
|
jquery
|
[5]
|
616,962 | 616,963 |
How to use Reflection to extend a class in runtime with php
|
<p>How can I use Reflection to extend a class in runtime?<br>
I need A class is extended from B class.</p>
<pre><code>class A{
function methodA()
{
echo 'This is method A';
}
}
class B{
function methodB()
{
echo 'This is method B';
}
}
</code></pre>
|
php
|
[2]
|
5,984,706 | 5,984,707 |
class attribute with css in jquery
|
<p>I need jquery function do this: </p>
<p>First:</p>
<pre><code><a class="MyClass1 Myclass2 {padding-top:10px;height:20px;}"></a>
</code></pre>
<p>After calling function:</p>
<pre><code><a class="MyClass1 Myclass2" style="padding-top:10px;height:20px;"><a/>
</code></pre>
<p>Function must work with all elements</p>
<p><strong>Edit</strong></p>
<p>For example: i'm using on the asp.net mvc. Every Module contains different theme properties. This code is Module <code>partial view</code> section.</p>
<pre><code><div class="<%=Model.Theme.HeaderClass%>">...content goes here
</div>
<div class="<%=Model.Theme.BodyClass%>">...content goes here</div>
<div class="<%=Model.Theme.PagerClass%>">
<a class="<%=Model.Theme.PagerItemClass%>"> </a>
</div>
</code></pre>
|
jquery
|
[5]
|
3,946,293 | 3,946,294 |
Help with jQuery show/hide on keyup
|
<p>Basically I have a text box and when I type characters into the box it hides rows in my table that don't contain the text. How can I reform the following code so that it re-evaluates the function so that it starts showing the rows again when I press backspace?</p>
<p>This is as far as I got:</p>
<pre><code>$("#txtFilter").keyup(function () {
var text = $("#txtFilter").val();
if () {
$(".tableStripe .tdName:not(:contains(" + text + "))").closest("tr").show();
}
else {
$(".tableStripe .tdName:not(:contains(" + text + "))").closest("tr").hide();
}
});
</code></pre>
|
jquery
|
[5]
|
3,620,707 | 3,620,708 |
Android Application that give timing advance and AOA
|
<p>I would like to know if there is any application on Android that gives the timing advance and maybe the angle of arrival.</p>
<p>If not, maybe a way of doing it would be very helpful.</p>
|
android
|
[4]
|
594,932 | 594,933 |
how is a matrix associated with a canvas in android?
|
<p>i was just going through the documentation given on developer.android.com and when i was going through the canvas class if i found this method named scale, so i searched for its documentation and found the following:</p>
<p>public void scale (float sx, float sy)
Since: API Level 1</p>
<p>Preconcat the current matrix with the specified scale.
Parameters
sx The amount to scale in X
sy The amount to scale in Y </p>
<p>what matrix are they talking about over here? How is the matrix associated with canvas and how does it matter if i scale my canvas or not?</p>
|
android
|
[4]
|
3,650,208 | 3,650,209 |
determing the height in pixels of a gridview on an asp.net page at runtime?
|
<p>Anyone know if it possible at run-time to know how many pixels high an asp.net gridview is?</p>
<p>I have a gridview on the left of my page. On the right side, I populate with random images that vary in height and I would like to (as close as possible) match the total height of the gridview with the sum total heights of the pictures on the right. (The code keeps checking for pictures until it find ones with the right height).</p>
<p>I can approximate the height by knowing the number of rows (gridview.rows.count * an average row height), but since row heights can vary depending on if they are long lines wrapping, I'd prefer to try and get a better height estimate...</p>
<p>Thx!</p>
|
asp.net
|
[9]
|
314,923 | 314,924 |
Python: Make a if statement to do something when a certain error is raised?
|
<p>I am making a connect4 game on python, and when a column is full, this error is raised when a player puts a piece in the full column. How do I make a if statement to say that if this error is raised, print("Make a valid move?")</p>
<pre><code>class ConnectFourGameOverError(Exception):
'''Raised whenever an attempt is made to make a move after the game is
already over'''
pass
</code></pre>
|
python
|
[7]
|
3,672,284 | 3,672,285 |
How can I declare a pointer with filled information in C++?
|
<pre><code>
extern "C" {
typedef struct Pair_s {
char *first;
char *second;
} Pair;
typedef struct PairOfPairs_s {
Pair *first;
Pair *second;
} PairOfPairs;
}
Pair pairs[] = {
{"foo", "bar"}, //this is fine
{"bar", "baz"}
};
PairOfPairs pops[] = {
{{"foo", "bar"}, {"bar", "baz"}}, //How can i create an equivalent of this NEATLY
{&pairs[0], &pairs[1]} //this is not considered neat (imagine trying to read a list of 30 of these)
};
</code></pre>
<p>How can I achieve the above style declaration semantics?</p>
|
c++
|
[6]
|
5,788,644 | 5,788,645 |
Parsing JSON array in android
|
<p>I want to parse this json array in android. How can I do this?</p>
<pre><code> {
"posts": [{
"post": {
"indexid": "13",
"network_id": "dma",
"network_pwd": "dma",
"network_name": "dma",
"network_contact": "dma",
"network_address": "chicago",
"network_city": "chicago",
"network_state": "Illinois",
"network_zip": "21211",
"network_email": "info@madincare.com",
"network_mobile": " ",
"network_phone": "5717575",
"network_fax": "000-000-0000",
"network_form": "dbr2",
"cor_display": "0",
"cor_name": "",
"network_image": "no_pic",
"network_country": "United States",
"business_id": "1",
"status": "1",
"level": "1",
"users": "0",
"locations": "0",
"multi_registers": "0",
"cc_breakup": "0",
"version": "DBRPOSv2",
"nwt_type": "F"
}
}]
}
</code></pre>
|
android
|
[4]
|
3,279,542 | 3,279,543 |
How can I change the css class of each th tag from βTβ to βSTβ? And how can I assign 1 more function(PI) to the button of the last table of iframe(A)
|
<p>I have an iframe with the following HTML which is empty when I load a page. </p>
<pre><code><iframe id="A"></iframe>
</code></pre>
<p>I am loading the iframe(A) with the following code using JavaScript:</p>
<pre><code>document.getElementById(A).src = 'https://adms.lifemark.ca/Apps/app_quickadd_frame.jsp?appid=102946&oppid='+Current;
</code></pre>
<p>After loading the iframe(A) it creates 10 iframe within iframe(A).Each new iframe has 1 table and many th tag.
How can I change the css class of each th tag from βTβ to βSTβ ? And how can I assign one more function(PI) to the following button within the last table of iframe(A) using Jquery?</p>
<pre><code><table>
<tbody>
<tr>
<td class="Submit">
<input type="Button" value="Submit" onclick="sb()" style="width:200px">
</td>
</tr>
</tbody>
</table>
</code></pre>
|
jquery
|
[5]
|
3,420,721 | 3,420,722 |
jquery - day month year validation
|
<p>I'm having separate select boxes for day, month, year validation.
12 ...
JanFeb ...
20092010 ... </p>
<p>If I use jquery validation plug-in, it displays separate error messages for each fields if it not selected.</p>
<p>But I want to treat all the three as a single field, and display error message.
if day is selected and month and year are not selected. then the error message would be please select a month.
if day and month are selected then it should be please select the year etc.</p>
|
jquery
|
[5]
|
561,202 | 561,203 |
How to set the autoresize property to change according to orientation in iPhone?
|
<p>I have an application created with a root class to be UIViewController class. I have placed one button on its view with frame size fixed in the view and have also set:</p>
<pre><code> -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
</code></pre>
<p>Now when i rotate the button remains in the same place except it is turned up.
If i set the autoresizing will the UIButton appears in the proper position.
If so how to set the autoresizing??</p>
|
iphone
|
[8]
|
2,099,364 | 2,099,365 |
Class or interface expected error (java)
|
<p>When i try to compile this: </p>
<pre><code> public static int compareCardhl (Card c1, Card c2)
}
if (c1.suit > c2.suit) return 1 ;
if (c1.suit < c2.suit) return -1 ;
if (c1.rank > c2.rank) return 1 ;
if (c1.rank < c2.rank) return -1 ;
return 0;
}
</code></pre>
<p>i get a lot of class or intereface expected errors. They all point at the <code>if's</code>. i also get a <code>; expected</code> error at the end of <code>Card c2)</code>. </p>
<p>whats going wrong here? </p>
|
java
|
[1]
|
204,022 | 204,023 |
Code for Auto starting a java application on windows startup
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/979451/auto-startup-for-java-desktop-application">Auto startup for java desktop application?</a> </p>
</blockquote>
<p>I have a Java desktop application using netbeans 6.5.1. I was wondering if anybody can help me in suggesting code for autosatrting the Jar file on windows start up.</p>
<p>Thanks in advance
Bhavi</p>
|
java
|
[1]
|
2,981,280 | 2,981,281 |
How to display custom dialog in android
|
<p>I need to display custom dialog from other method i.e, not in onCreate.
Is it possible? If so please let me know.</p>
|
android
|
[4]
|
5,820,653 | 5,820,654 |
Sending Email - Error
|
<p>I am trying to send email using the following piece of code in Winforms app.
Username and Password are correct and real- but have masked in the code.</p>
<p>I don't know wheather my local machine has the capacity to send emails or not?</p>
<p>But please advise me , What do I need to look at my machine Configuration(in IIS)?</p>
<p>ERROR: "No connection could be made because the target machine actively refused it 209.85.143.109:587"</p>
<pre><code>//All Variable Declarations
String senderAddress = string.Empty;
String receiveraddress = string.Empty;
String emailSubject = string.Empty;
String emailMessageText = string.Empty;
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient("smtp.gmail.com",587);
private void btnEmail_Click(object sender, EventArgs e)
{
try
{
//Get the Values of Controls
senderAddress = txtSenderEmail.Text;
receiveraddress = txtReceiverEmail.Text;
emailSubject = txtSubject.Text;
emailMessageText = txtMessageBody.Text;
//Pass the Values
mail.From = new MailAddress(senderAddress, "xxxxxxxxxx", System.Text.Encoding.UTF8);
mail.To.Add(receiveraddress);
mail.Subject = emailSubject;
mail.Body = emailMessageText;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("xxxxxxx@gmail.com", "xxxxxx");
client.EnableSsl = true;
client.Send(mail);
System.Windows.Forms.MessageBox.Show("Email Sent Successfully");
}
catch (Exception mailException)
{
System.Windows.Forms.MessageBox.Show("Message Not Sent ,Error: " + mailException.Message);
throw;
}
finally
{
}
}
</code></pre>
<p>I have done a telnet for both the ports and the error comes is : Could not open connection to the host. </p>
<p>Please look at the following pic, it should give you more clarity,</p>
<p><img src="http://i.stack.imgur.com/egcno.gif" alt="enter image description here"></p>
|
c#
|
[0]
|
727,227 | 727,228 |
How to terminate the script in Javascript
|
<p>I neeed a code that will exit the js script much like PHP 'exit' or 'die'.
(I know its not the best programming practice but I need it).</p>
|
javascript
|
[3]
|
19,144 | 19,145 |
Why use MultiByteToWideCharArray to convert std::string to std::wstring?
|
<p>I want to convert a std::string to std::wstring. There are two approaches which i have come across.</p>
<ol>
<li><p>Given a string str we cant convert into wide string using the following code
wstring widestring = std::wstring(str.begin(),str.end());</p></li>
<li><p>The other approach is to use MultiByteToWideCharArray().</p></li>
</ol>
<p>What i wanted to understand was what is the drawback of using the first approach and how does the second approach solves thing problem</p>
|
c++
|
[6]
|
563,096 | 563,097 |
Jquery Age calculation on date
|
<p>Am I missing something in following jQuery code.</p>
<pre><code>var dob = $('#date').val();
if(dob != ''){
var today = new Date();
var dayDiff = Math.ceil(today - dob) / (1000 * 60 * 60 * 24 * 365);
var age = parseInt(dayDiff);
$('#age').html(age+' years old');
}
</code></pre>
<p>And I am getting pre fetched value of #date from MySQL db.</p>
<pre><code><input type="text" value="1988-04-07" id="#date" name="dob" /><p id="age"></p>
</code></pre>
<p>It's returning Nan, not correct value.</p>
|
jquery
|
[5]
|
3,413,310 | 3,413,311 |
Java, rounding a double to two decimal places
|
<p>I'm trying to round a double to the nearest two decimal places however, it is just rounding to the nearest full number.</p>
<p>For example, 19634.0 instead of 19634.95. </p>
<p>This is the current code I use for the rounding</p>
<pre><code>double area = Math.round(Math.PI*Radius()*Radius()*100)/100;
</code></pre>
<p>I can't see where i am going wrong.</p>
<p>Many thanks for any help.</p>
|
java
|
[1]
|
3,724,335 | 3,724,336 |
Textbox control in asp.net
|
<p>i have a problem whith my small project asp.net.</p>
<p>I have a variable : </p>
<pre><code>String pr_name;
</code></pre>
<p>and a textbox control.</p>
<p>I get data form textbox and set to variable:</p>
<pre><code>String pr_name = Textbox1.Text;
</code></pre>
<p>but i received value : </p>
<pre><code>System.Web.UI.WebControls.TextBox
or null.
</code></pre>
<p>WHY ?</p>
|
asp.net
|
[9]
|
514,029 | 514,030 |
iPhone Loading Screen Effect
|
<p>I'm interested to making a "fade effect" like Foursquare app. I want the main view to fade in.</p>
<p>How can I do this?</p>
<hr>
<p>Sincerely I don't know what should I use. If anyone have the Foursquare's app on his iPhone, please open and see what I mean.</p>
|
iphone
|
[8]
|
5,319,027 | 5,319,028 |
Can I create a function with the same name as the class?
|
<p>I want to create a function with the same name as its class using C#.</p>
<p>Sample Snippet:</p>
<pre><code>public class MyCustomer
{
public MyCustomer()
{
}
public void MyCustomer()
{
}
}
</code></pre>
<p>If I try to compile it visual studio is throwing an error.</p>
|
c#
|
[0]
|
3,302,518 | 3,302,519 |
C# Static Classes & Scope
|
<p>I am just wondering why can't I define a static class as protected, private etc?</p>
<pre><code>protected static class Class1 {}
</code></pre>
<p>The compiler gives the following error message:</p>
<blockquote>
<p>Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal</p>
</blockquote>
|
c#
|
[0]
|
5,305,461 | 5,305,462 |
roaming detection in android
|
<p>I'm trying to detect when the roaming activation occurs. So far I've used the following piece of code, but because I haven't been able to test it I am unaware of it's correctness</p>
<pre><code>TelephonyManager telephonyManager = TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener cellLocationListener = new PhoneStateListener() {
public void onCellLocationChanged(CellLocation location) {
if(telephonyManager.isNetworkRoaming()
{
Toast.makeText(getApplicationContext(),"in roaming",Toast.LENGTH_LONG).show();
}
}
};
telephonyManager.listen(cellLocationListener, PhoneStateListener.LISTEN_CELL_LOCATION);
</code></pre>
<p>I've written this , thinking that in order for roaming to activate first the signal cell must change. Please let me know whether my deduction is correct or not, and if not how could I accomplish this.</p>
|
android
|
[4]
|
452,830 | 452,831 |
Reading Html Code and finding <div> text. C#
|
<p>i am useing this code to read html pages :</p>
<pre><code> WebClient client = new WebClient();
String htmlCode = client.DownloadString(@"C:\checkemails\check.html");
// Replace all html breaks for line seperators.
htmlCode = htmlCode.Replace("<br>", "\r\n");
MessageBox.Show(htmlCode);
</code></pre>
<p>the html page is on C:\ but lets say i am loading yahoo.com.. or what ever page.</p>
<p>i need to find a div named who got the id of </p>
<pre><code><div id ="say">
</code></pre>
<p>how can i do so?</p>
|
c#
|
[0]
|
3,561,422 | 3,561,423 |
how to reload the selected tab jquery
|
<p>how to reload the selected tab actually i having problem in reloading part.
when i add my data i'll successfully saved in datatable but in id field in database it shows proper id but when i add the detail its not shows id in datatable.</p>
<p>(before refresh the summary tab)
here is example it shows something like this in datatable
id patient husband age ...........so on...
xyz abc 23....... so on...</p>
<p>(after refreshing manually)
but when i refresh my page it show successfully..like this in datatable:
id patient husband age ...........so on...
13 xyz abc 23 ....... so on...</p>
<p>but exactly i want when i add my detail it will automatically refresh the selected tab.</p>
<p>here is my code as below:</p>
<pre><code><button type="button" a href="javascript:void(0);" onclick="fnClickAddRow();">Add Summary</button>
function fnClickAddRow(event) {
$('#table_scroll').dataTable().fnAddData( [
"",$('#patientt').val(),$('#husband').val(),$('#age').val(),$('#opu_no').val(),$('#date').val(),$('#proc').val(),$('#no_of_eggs').val(),$('#fert').val(),$('#et_date').val(),$('#et_day').val(),$('#et').val(),$('#fz').val(),$('#bioch_preg').val(),$('#clin_preg').val(),$('#fh').val(),$('#comment').val()
]);
var datastring = $(Form_summary).serialize();
$.ajax({
type: "POST",
url: "summaryajax.php",
data: datastring,
success: function(response){
alert(response);
}
});
</code></pre>
|
jquery
|
[5]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.