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 |
---|---|---|---|---|---|
343,418 | 343,419 | Restrict EditText accept only Urls in Android | <p>hi <br>
I am writing an application in which I need to Restrict EditText accept only Urls in Android. How can this be done in Android?</p>
<p>Thanks in Advance,</p>
| android | [4] |
1,219,109 | 1,219,110 | Android SDK Plugin on IBM RAD 7.5 | <p>Does anybody know where I can find and then how to install the <strong>Android SDK Plugin</strong> with IBM RAD 7.5? I tried to use the update site without success. Any help will be very appreciated.
Thanks</p>
| android | [4] |
3,599,754 | 3,599,755 | Launch Event Only Once Every 60 Seconds (JavaScript) | <p>I have a video that is 60 seconds long. I am working on adding some JavaScript to send data from my video player to Google Analytics. What I am looking to do is to launch an event no more than once every 60 seconds for a range of time.</p>
<p>So for example, a user watches 21 to 40 seconds into a video, I want only one event launched (rather then 19 times for the 19 seconds of time). Then the user watches 41 to 60 seconds into the video, I want only one event launched. I actually have figured this part out already.</p>
<p><strong>The problem is when it comes to time.</strong> So if a user watches the 21 to 40 seconds it launches an event. They watch the rest of the video and mentally process it and decide "hey I want to watch the video again". If they watch the video again, that one event at 21 to 40 seconds won't launch again unless they refresh the page.</p>
<p>How can I edit my script so an event is launched only once every 60 seconds for a specific range?</p>
<pre><code><script type="text/javascript">
function Follow( minimum, maximum )
{
this.min = minimum;
this.max = maximum;
this.done = false;
}
var following = [
new Follow( 1, 20 ),
new Follow( 21, 40 ),
new Follow( 41, 60 )
];
player().Time(
function(event)
{
var gone = Number(event.secondspassed);
for ( var t = 0; t < following.length; ++t )
{
var Follow = following[t];
if ( gone >= Follow.min && gone < Follow.max )
{
if ( ! Follow.done )
{
var range = Follow.min + " Seconds Watched ";
_gaq.push(['_trackEvent', range, 'Play', 'Title']);
Follow.done = true;
}
break;
}
}
}
);
</script>
</code></pre>
| javascript | [3] |
5,399,984 | 5,399,985 | Will Development on my Android Phone Cause Problems? | <p>I would like to start looking at development for Android applications (nothing huge, just for learning). Before I begin, I would like to find out whether or not development on the Android phone I use daily would be corrupted or changed in some way if I used it as a development device.</p>
<p>I probably won't put anything on the Market, but I would just like to test out how everything "works" with Android development.</p>
<p>Any help that will guide me is great.</p>
<p>Thanks.</p>
| android | [4] |
1,698,210 | 1,698,211 | SC Java Programmer 6 exam | <p>there is program from exam. Could anyone explain how "-434" is the answer:</p>
<pre><code>class A {}
class B extends A {}
public class ComingThru {
static String s = "-";
public static void main (String[] args) {
A[] aa = new A[2];
B[] ba = new B[2];
sifter(aa);
sifter(ba);
sifter(7);
System.out.print(s);
}
static void sifter(A[]... a2) { s += "1";}
static void sifter(B[]... b1) { s += "2";}
static void sifter(B[] b1) { s += "3";}
static void sifter(Object o) { s += "4";}
}
</code></pre>
<p>Thank you!</p>
| java | [1] |
1,688,036 | 1,688,037 | How can I make an iPhone UITextField required? | <p>How can I make a UITextField required? In other words, if the entry is empty, then refocus them on the required field.</p>
| iphone | [8] |
4,149,075 | 4,149,076 | C++ Member variables confusion | <p>I'm learning C++ (coming from Java) and this is bugging the hell out of me, say I have...</p>
<pre><code>class Foo {
public:
Bar &x; // <- This is a ref, Bar is not instantiated (this is just a placeholder)
Bar *y; // <- This is a pointer, Bar is not instantiated (this is just another placeholder)
Bar z; // <- What is this???
};
class Bar {
public:
Bar(int bunchOfCrap, int thatNeedsToBeHere, double toMakeABar);
};
</code></pre>
<p>In this example Bar has one constructor that needs a bunch of fields specified in order to create a "Bar." Neither x, nor y creates a Bar, I understand that x creates a reference that can be pointed to a Bar and that y creates a pointer that can also represent a Bar.</p>
<p>What I don't understand is what exactly z is. </p>
<ul>
<li><p>Is it a Bar? And if so, how can it be given Bar's only constructor?</p></li>
<li><p>Is it a Bar sized chunk of memory belonging to instances of Foo that can be initialized into a Bar?</p></li>
<li><p>Or is it something else?</p></li>
</ul>
<p>Thanks!</p>
| c++ | [6] |
1,862,671 | 1,862,672 | How to minimize my jQuery script | <p>I'm working on simples actions from jQuery Library.</p>
<p><code></p>
<pre><code>$('#hasAccount').click(function() {
$('.authForm').slideDown(500, function() {
if ($('.shippingAddress').is(':visible')) {
$('.shippingAddress').slideUp(250);
}
});
});
$('#hasNotAccount').click(function() {
$('.shippingAddress').slideDown(500, function() {
if ($('.authForm').is(':visible')) {
$('.authForm').slideUp(250);
}
});
});
</code></pre>
<p></code></p>
<p>Here is the code working : <a href="http://jsfiddle.net/6tZQ2/2/" rel="nofollow">http://jsfiddle.net/6tZQ2/2/</a></p>
<p>It's very simple, but I'm wondering if there are any solutiosn to minimalize this script as 1 action ?</p>
<p>Thanks :-)</p>
| jquery | [5] |
2,073,878 | 2,073,879 | How to get table cell value from QTableWidget in pyside? | <p><code>form_shift</code> is form name</p>
<p><code>tblSession</code> is <code>QTableWidget</code> object</p>
<pre><code>shift_id=form_shift.tblSession.item(1,0).text()
</code></pre>
<p>Error:</p>
<pre><code>AttributeError: 'NoneType' object has no attribute 'text'
</code></pre>
| python | [7] |
939,543 | 939,544 | how to call the javascript function on table row click | <p>I have a javascript function..</p>
<pre><code><script type="text/javascript">
var RowClick = function() {
$("#mytable").click(
$("#showgrid").load('/Products/List/Items/'));
};
</script>
</code></pre>
<p>Can I call this function on onclick event on tr?
I am calling something like this?</p>
<pre><code><tr class="something" onclick="javascript:RowClick()');">
can i call like this? if I call its not loading the URL?
</code></pre>
<p>can anybody help me out?</p>
<p>thanks</p>
| jquery | [5] |
622,878 | 622,879 | What makes new Date() / 1000 a valid javascript? | <p>How come I can "divide" an object by a number? </p>
| javascript | [3] |
2,264,430 | 2,264,431 | how can i append in reverse? python | <p><code>.append</code>
Function adds elements to the list.
How can I add elements to the list? In reverse? So that index zero is new value, and the old values move up in index?
What append does</p>
<pre><code>[a,b,c,d,e]
</code></pre>
<p>what I would like.</p>
<pre><code>[e,d,c,b,a]
</code></pre>
<p>Thank you very much.</p>
| python | [7] |
3,116,064 | 3,116,065 | Restricting arguments to certain defined constants | <p>Consider the following code </p>
<pre><code>public class ColorScheme {
public static final int DARK_BLACK = 0,
WHITE = 1;
private int Scheme;
public ColorScheme() {
this.Scheme = DARK_BLACK;
}
public ColorScheme(int SchemeType) {
this.Scheme = SchemeType;
}
}
</code></pre>
<p>I want the argument to the constructor <code>ColorScheme(int SchemeType)</code> to be restricted to one of the <code>static final int</code> - <code>DARK_BLACK</code> or <code>WHITE</code> or other constant I may define.</p>
<p>For Ex: When someone instantiates the <code>ColorScheme</code> class, he can use </p>
<pre><code> ColorScheme CS = new ColorScheme(DARK_BLACK);
</code></pre>
<p>while </p>
<pre><code> ColorScheme CS = new ColorScheme(5); //or any other non-defined constant
</code></pre>
<p>should return an error.</p>
| java | [1] |
4,971,492 | 4,971,493 | TypeError: OneTalk() takes exactly 5 arguments (4 given) | <pre><code>import host
Noms = "Name"
def init():
host.registerHandler('ChatReceivedExtended', onTalk) # extended to distinguish between local chat and whispers
def deinit():
host.unregisterHandler('ChatReceivedExtended', onTalk)
def onTalk(bnet, user, message, isWhisper, payload):
if isWhisper and user.getName() == Noms:
bnet.queueChatCommand("/me " + message)
bnet.queueChatCommand("/f m " + message)
</code></pre>
<p>When I try to run the script it gives me <code>"TypeError: OneTalk() takes exactly 5 arguments (4 given)"</code>. But when I add username to line 11 it gives me <code>"TypeError: OneTalk() takes exactly 5 arguments (6 given)'</code>.</p>
<pre><code>def onTalk(bnet, user, message, isWhisper, payload):
def onTalk(bnet, user, message, isWhisper, payload, username):
</code></pre>
| python | [7] |
6,022,699 | 6,022,700 | javascript require/include | <p>I wrote a script like that:</p>
<pre><code>NS.load = function(src) {
var script = document.createElement("script").setAttribute("src", src);
document.getElementsByTagName("head")[0].appendChild(script);
}
</code></pre>
<p>It loads files but I can't reach functions and variables defiened in other files. </p>
<pre><code>//js/main.js
var qux = {name: "name"};
NS.load("js/foo.js");
//js/foo.js
alert(qux.name); //undefined variable
</code></pre>
<p>But if I define qux like this:</p>
<pre><code>window.qux = {name: "name"};
</code></pre>
<p>I can reach qux variable in other modules. As far as I know all globals are already a member of window object. So why I have to define variables like this. Could you offer another method?</p>
<p>Thanks.</p>
| javascript | [3] |
3,277,204 | 3,277,205 | Type inference of KeyValuePair constructor - already in .NET? | <p>I'm currently using...</p>
<pre><code>public static class KeyValuePairFactory {
public static KeyValuePair<TKey, TValue> Create<TKey, TValue>(
TKey key,
TValue value
) {
return new KeyValuePair<TKey, TValue>(key, value);
}
}
</code></pre>
<p>...so instead of...</p>
<pre><code>var pair = new KeyValuePair<MyVeryUnwieldyType1, MyVeryUnwieldyType2>(
new MyVeryUnwieldyType1(),
new MyVeryUnwieldyType2()
);
</code></pre>
<p>...I can avoid repeating types and simply:</p>
<pre><code>var pair = KeyValuePairFactory.Create(
new MyVeryUnwieldyType1(),
new MyVeryUnwieldyType2()
);
</code></pre>
<p>Am I reinventing the wheel and reimplementing something that is already available in .NET Framework?</p>
| c# | [0] |
717,397 | 717,398 | Implement an algorithm to shuffle an array of numbers | <p>I wrote codes for the following question but they don't work. I get random numbers but the shuffle method don't shuffle them. Would you please help me?</p>
<pre><code>for( each index i)
choose a random index j where j>=i.
swap the elements at index i and j.
</code></pre>
<p>My code is:</p>
<pre><code>public static void shuffle(int[] a){
for( int i = 0; i < a.length-1; i++){
int range = a.length;
int j = (int) (Math.random() * range);
swap(a, i, j);
}
}
public static void swap(int[] array, int i, int j){
if (i != j) {
int temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
</code></pre>
| java | [1] |
4,807,650 | 4,807,651 | Variables Variable (Creating variable with the name of another variable) | <p>i want to create a new variable with a variable name,
for example:</p>
<pre><code>function preloader(imglist) {
var imgs = imglist.split("|");
for (i in imgs) {
var img_{i} = new Image; //this is the line where i sucked in!
img_{i}.src = imgs[i]; //another line where i sucked in!
}
}
preloader("asd.jpg|qwe.jpg|dorama.png");
</code></pre>
<p>i try to use arrays but, hmm.. how can i say...</p>
<pre><code>var qwe = new Array();
qwe[1] = "asd"; //or not! whatever...
var qwe[1] = new Image; // it didnt work!
</code></pre>
<p>in php u can use like this:</p>
<pre><code>$var1 = "test";
$var2_{$var1} = "test last";
echo $var2_test; //or...
echo $var2_{$var1};
</code></pre>
| javascript | [3] |
4,061,656 | 4,061,657 | Android Tabs in Bottom of the Layout | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2395661/android-tabs-at-the-bottom">Android: Tabs at the BOTTOM</a> </p>
</blockquote>
<p>How to add tabs at the bottom of the screen in android.Please any one tell the answer</p>
| android | [4] |
4,255,625 | 4,255,626 | Hiding apps in Android | <p>Is there any way to write a logic to hide app launcher icon from the app list. The hidden apps can be launched from a app designed for the same.</p>
| android | [4] |
5,513,545 | 5,513,546 | Multiple Variable Variables in PHP | <p>I am fairly new to PHP and programming in general... I am attempting to use a foreach loop to set some options on a page I have created. It all works except for the last section, where I am attempting to assign variables dynamically, so I can use them outside the loop.</p>
<pre><code><?PHP
$array=array(foo, bar, baz);
foreach ($array as $option) {
// I have if statements to determine what $option_req
// and $option_status end up being, they work correctly.
$option_req="Hello";
$option_status="World";
$rh='Req_';
$sh='Status_';
$$rh.$$option=$option_req;
$$sh.$$option=$option_status;
}
echo "<br>R_Foo: ".$Req_foo;
echo "<br>S_Foo: ".$Status_foo;
echo "<br>R_Bar: ".$Req_bar;
echo "<br>S_Bar: ".$Status_bar;
echo "<br>R_Baz: ".$Req_baz;
echo "<br>S_Baz: ".$Status_baz;
?>
</code></pre>
<p>When the loop is finished, should this now give me six variables? </p>
<pre><code>$Req_foo
$Status_foo
$Req_bar
$Status_bar
$Req_baz
$Status_baz
</code></pre>
<p>I have played with this a bit, searches on Google seem fruitless today.</p>
| php | [2] |
3,813,592 | 3,813,593 | if (is_uploaded_file($_FILES[image][name])) is not working | <pre><code>if (is_uploaded_file($_FILES[image][name]))
{
$row_PID = $_REQUEST['PID'];
$sql = "SELECT * FROM tbl_image where PID='".$str_PID."'";
$row = mysql_query($sql, $conn);
while($getPID=mysql_fetch_array($row))
{
$PID = $getPID['PID'];
$sqldelete ="delete from tbl_image where PID ='".$PID."'";
tep_db_query($sqldelete,$conn);
}
while(list($key,$value) = each($_FILES[image][name]))
{
if(!empty($value))
{
$filename = $value; // filename stores the value
$add = "../upload/portfolio/$filename"; // upload directory path is set
copy($_FILES[image][tmp_name][$key], $add);
chmod("$add",0777);
}
$query="insert into tbl_image (ImageID,PID,ImagePath,DateCreated,LastUpdate) values ('','$str_PID','$filename',now(),now())";
tep_db_query($query, $conn);
}
}
</code></pre>
<p>I not access <code>if (is_uploaded_file($_FILES[image][name]))</code> this condition</p>
| php | [2] |
3,639,867 | 3,639,868 | Accessing to Request object will lead to ReadEntityBody to return 0 (in a HttpHandler class) | <p>I created a httpHandler that successfully implements IHttpHandler for handling file uploads. It works perfectly fine. You send the file with the form, the class receives it and will save it to hard disk. It reads chunks of file with ReadEntityBody function of HttpWorkerRequest class.</p>
<p>Here is the situation i'm faced with.If at any stage before trying to read the file with ReadEntityBody, I try to access Request object (even Request.InputStream.Length!) ReadEntityBody would return 0 means it won't read from file stream.</p>
<p>After further testing I found out the reason behind it. <strong>Accessing to <code>Context.Current.Request</code> object will trigger some sort of functionality that will cause asp.net to handle file uploads at that moment by it's own!</strong> I believe this is a bug.</p>
<p>for example exactly after this line of code, asp.net will upload the file completely, and so there will be no stream for ReadEntityBody to read from later.</p>
<pre><code>int FileSize = context.Request.InputStream.Length;
</code></pre>
<p>Can anybody tell how to stop this? </p>
| asp.net | [9] |
2,979,957 | 2,979,958 | C# format decimal to string | <p>I need to format the Decimal variables Latitude=9113267; Longitude=59300357;
to string format 9,113267 and 59,300357</p>
<p>Thx
john</p>
| c# | [0] |
1,801,268 | 1,801,269 | grab text in the middle to a variable | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2345670/php-domdocument-get-html-source-of-body">PHP DOMDocument - get html source of BODY</a> </p>
</blockquote>
<p>I have the following code as a variable and trying to grab everything in between the body tags (while keeping the p tags etc). Whats the best way of doing this?</p>
<ul>
<li>pregmatch</li>
<li><p>strpos / substr</p>
<pre><code><head>
<title></title>
</head>
<body>
<p>Services Calls2</p>
</body>
</code></pre></li>
</ul>
| php | [2] |
861,754 | 861,755 | Validate image type using javascript | <p>i have a form like this: </p>
<pre><code><form method=post src=upload enctype="multipart/form-data">
<input name="img1" id="img1" type="file">
<input type="submit" value="Upload">
</form >
</code></pre>
<p>Please how can I valid this form using javascript so that only jpg files are uploaded. thanks for reading.</p>
| javascript | [3] |
5,114,526 | 5,114,527 | storing input into variable | <p>Hi I am seeking some insight into storing text input into a variable. My task is to take five text inputs, store the numbers the user inputs, then do some fancy math with them to create a solution variable to display. However, within the SDK I am getting confused quickly on how to actually store these correctly. I can't find much tutorials on this online, seeking gurus to help!</p>
| iphone | [8] |
127,101 | 127,102 | How to overwrite a HashSet element in Java while iterating over it | <p>Is it possible to overwrite some HashSet element (not necessarily the one iterated) while iterating over it. I want to know of a way apart from removing, editing and then re-adding it?
The reason I am asking this is because using remove while iterating always gives the java.util.ConcurrentModificationException. I figured out that there is no method to overwrite a set element.</p>
<p>Any help will be appreciated.</p>
<p>Thanks,</p>
<p>Somnath </p>
| java | [1] |
4,541,961 | 4,541,962 | Can the call log be closed programatically-android | <p>My app makes multiple calls programatically but to do that it needs to override / hide/ close the call log that is displayed at the end of one call. Is this possible? Can it be made to work using PhoneStateListener() type of functionalities ?</p>
| android | [4] |
1,998,218 | 1,998,219 | iphone: can i convert UIImageView animation to svg/gif file? | <p>is there any way to convert UIImageView animation which is composed of array of images to any animated format (i.e into gif/svg) in iphone?</p>
| iphone | [8] |
211,641 | 211,642 | Do i have to have both Droid and HTC to test my android app? | <p>I have an android app for which i need to ensure that it has no design/interface issues on both Motorola Droid and HTC touch-screens.
Now my question is that do i have to have both devices available for testing? If not, then is there an alternate? </p>
| android | [4] |
3,281,416 | 3,281,417 | simple C++ inheritance | <p>With the following code I want accomplish two different values for intA, but I get:</p>
<p>clsA a=1? 1
clsB a=2? 1</p>
<pre><code>//Code
#include <iostream>
using namespace std;
class clsA {
static const int intA = 1;
public:
virtual int get_a() { return intA; }
};
class clsB: public clsA {
static const int intA = 2;
};
int main() {
clsA a; clsB b;
cout << "clsA intA = " << a.get_a() << endl;
cout << "clsB intA = " << b.get_a() << endl;
}
</code></pre>
<p>How can I get intA=1 for object a and intA=2 for object b?
Thanks for the reaction,
André</p>
| c++ | [6] |
2,701,176 | 2,701,177 | How to find the names of classes inside a python module? | <p>If I import a module:</p>
<pre><code>import foo
</code></pre>
<p>How can I find the names of the classes it contains? </p>
| python | [7] |
757,835 | 757,836 | how do i change android soft keyboard's default language? | <p>I have made android app. my client ask me that change default language at soft keyboard case by case. one case, keyboard should be English keyboard, another, Korean keyboard.</p>
<p>how can i do?</p>
<p>thx.</p>
| android | [4] |
2,617,314 | 2,617,315 | Create pdf through java.io | <p>I tried creating a pdf file out of another one(in my local drive) using java.io. The thing is a file with a .pdf extension got created but im unable to open the file, it says the file is already in use and most importantly the size of the file is too large and it keeps on increasing (origin file size : 5,777kB and the newly created one file size as of now is 38,567kB). Im not that much of skilled java programmer but still i would appreciate if anyone can give me an explanation ..</p>
<pre><code>String path = "D:\\priya_Docs\\Android pdfs\\Professional_Android_Application_Development.pdf";
File file = new File(path);
System.out.println("Located a file " + file.isFile());
String filesArray = file.getPath();
File getFile = file.getAbsoluteFile();
FileInputStream fis = new FileInputStream(getFile);
FileOutputStream fos = new FileOutputStream(
"D:\\priya_Docs\\Androiddoc.pdf");
for (int b = fis.read(); b != -1;) {
fos.write(b);
}
</code></pre>
| java | [1] |
1,951,133 | 1,951,134 | how to populate option menu(drop down box) on the selection of another option menu in python? | <p>I want to know about the python code of which i asked. the thing is:</p>
<p>two option menu
1-country
2-city</p>
<p>when we select the country ,should be populate all city to second option
menu which is related to that particular country which we select from country
option menu.</p>
<p>please give me reply very soon......</p>
| python | [7] |
1,164,587 | 1,164,588 | Counting successive occurrences of numbers satisfying certain conditions in python | <p>I have a specific data set that reads like </p>
<pre><code>array([ 2.1, 3. , 179.1, 1.9, 2.6, 425.8, 1.7, 3.1,
4. , 144. , 2.2, 2.3, 5.3, 135.5, 2. , 2.7,
.....])]
</code></pre>
<p>Here I want to count the successive occurrences of numbers below 6 and save them in specific counters. For example, in the first three numbers there are two numbers that are continuously below 6 before a bigger number appears. So counter2 would get an addition of 1. If three numbers occur continuously like that, then counter3 would be incremented by 1 (as in the 2nd row) and so on. Are there any functions to do it in python, if not how do I proceed? Thanks in advance. </p>
| python | [7] |
4,274,004 | 4,274,005 | Collection in Java | <p>Quick Question...
Can collections in Java hold more than one type? Or do they all have to be the same type?</p>
<p>thanks</p>
| java | [1] |
888,987 | 888,988 | Is it possible to have a custom boolean object that inherits from Boolean.prototype? | <p>Something in the lines of:</p>
<pre><code> var MyCustomBoolean = function(b){
if (b === 'FALSE'){
this.b = false;
}else if(b === 'TRUE'){
this.b = true;
}
this.valueOf = function(){
return this.b;
}
}
</code></pre>
<p>so that the following would produce a single alert with the text "in your face"</p>
<pre><code>if (new MyCustomBoolean('TRUE')){
alert("In your face!");
}
if (new MyCustomBoolean('FALSE')){
alert("not so much.");
}
</code></pre>
<p>Now i can work around this by explicitly calling the valueOf function or. by checking equivalence through "myBObj == true".</p>
<p>So is it possible to have a custom boolean object that inherits from Boolean.prototype such that i could write if blocks as described above?</p>
| javascript | [3] |
1,616,572 | 1,616,573 | How to use NetworkUtils class on Android | <p>I would like to use the android.net.NetworkUtils class, to obtain a list of dns servers. How do i use this class on android.</p>
| android | [4] |
2,051,292 | 2,051,293 | animation fade in and out | <p>Using this code I've only a fade in, I looking for about add also a fade out. I add another xml called "fadeout" but I can't integrate it in my code.</p>
<pre><code>ImageView imageView= (ImageView)findViewById(R.id.imageView);
Animation fadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);
imageView.startAnimation(fadeInAnimation );
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
imageView.startAnimation(fadeInAnimation);
</code></pre>
<p>xml</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="Your Duration(in milisecond)"
android:repeatCount="infinite"/>
</set>
</code></pre>
| android | [4] |
5,890,378 | 5,890,379 | question about jQuery ajax form plugin | <p>I am using <a href="http://malsup.com/jquery/form/#code-samples" rel="nofollow">jQuery Form Plugin</a></p>
<p>It is working fine as I have it now. </p>
<p>I want to add some functionality. After the form submits the plugin is returning back responseText (see above link). I am updating one div with this link. What If I want to update multiple div's...with different messages. Basically, I'm wondering if there is a way to get 'multiple' responseText(s). </p>
<p>A way around is to put all I want in one responseText and then somehow break it (using substring) and update multiple divs?</p>
<p>Also, How do we add some content to the div using jQuery?</p>
| jquery | [5] |
4,097,122 | 4,097,123 | How to iter over a dict created by defaultdict? | <p>I am iterating a dict created using the following.</p>
<pre><code> tree = defaultdict(partial(defaultdict, partial(defaultdict, list)))
for dt, hour, value in flat_list:
tree[dt][hour]=[]
tree[dt][hour].append(value)
</code></pre>
<p>My output looks like this:</p>
<pre><code> for k,v in tree.iteritems():
2012-08-07 defaultdict(<functools.partial object at 0x1e0a050>, {'17': ['30']})
2012-08-24 defaultdict(<functools.partial object at 0x1e0a050>, {'3': ['70']})
</code></pre>
<p>How do I get rid of this stuff? How do I iter like a regular dict?:</p>
<pre><code>defaultdict(<functools.partial object at 0x1e0a050>
</code></pre>
| python | [7] |
110,874 | 110,875 | jquery scrolling on the page | <p>I want create this effect:
- I have on website a few divs with position absolute(only first is visible) and on some event I want that window will scroll to the second div(than to the third,4th..)</p>
<p>What jquery method is best for it?Because only animate isn't cool I think maybe margin-left or some scroll</p>
<p>Thanks for help.(if you know some website where is this effect please write me it)</p>
| jquery | [5] |
4,471,320 | 4,471,321 | Do I use a regular expression on this file path? | <p>I have to strip a file path and get the parent folder.</p>
<p>Say my path is </p>
<pre><code>\\ServerA\FolderA\FolderB\File.jpg
</code></pre>
<p>I need to get</p>
<ol>
<li><p>File Name = File.jog</p></li>
<li><p>Folder it resides in = FolderB</p></li>
<li><p>And parent folder = FolderA</p></li>
</ol>
<p>I always have to go 2 levels up from where the file resides.</p>
<p>Is there an easier way or is a regular expression the way to go?</p>
| c# | [0] |
777,348 | 777,349 | Toggle marginTop on mouseleave div | <p>I have a toggle function that slides a div up and down.. But how can I make it toggle marginTop -200 on mouseleave?</p>
<p>Should I have a separate function for mouseleave?</p>
<pre><code>$(document).ready(function() {
$('.menu-item-40').toggle(
function() {
$('#slidenav').animate({
marginTop: '0'
}, 500);
}, function() {
$('#slidenav').animate({
marginTop: '-200px'
}, 500);
});
});
</code></pre>
| jquery | [5] |
4,069,525 | 4,069,526 | jQuery -change from class to custom attribute | <p>I an trying to change a plug in from being based on anchor classes to being based on a custom attribute.</p>
<p>so from: a.categoryname</p>
<p>to: a data-category="categoryname"</p>
<p>The plug in I am customising is:
<a href="http://www.designchemical.com/blog/index.php/jquery/create-an-automatic-content-filter-using-jquery-css-classes/" rel="nofollow">http://www.designchemical.com/blog/index.php/jquery/create-an-automatic-content-filter-using-jquery-css-classes/</a></p>
<p>I won't post all the code here as I am almost there but but am having a problem with this line:</p>
<pre><code>$("#demo-list li a."+getText).fadeIn();
</code></pre>
<p>instead of fading in #demo-list li a."getText), I want it to fade in #demo-list li a, whose attribute "category-name" is "getText"</p>
<p>Here is my horrendous attempt...</p>
<pre><code>$("#demo-list li a).attr("data-category").val(getText).fadeIn();
</code></pre>
<p>Needless to say it doesn't work... I know enough to know the syntax is not right but not enough to fix it...</p>
<p>Can anyone help me out here please?</p>
<p>thanks</p>
| jquery | [5] |
3,724,605 | 3,724,606 | Remove the quote in the number | <p>This is really simple but I don't know how and I really need a quick answer.</p>
<p>So here's my output.</p>
<blockquote>
<p>[[['Dannish','24'],['Enterprise','34']]]</p>
</blockquote>
<p>And I want it to become</p>
<blockquote>
<p>[[['Dannish',24],['Enterprise',34]]]</p>
</blockquote>
<p>Or just simply remove the quote from the numbers. And keep the numbers.</p>
<p>Thanks for any help.</p>
| php | [2] |
2,453,767 | 2,453,768 | global variable to be stored at run time and could be accessible from many files | <p>As per my requirement I need to have some mechanism in Java, where one login essential variable is created by class ABC.java, and then for my further requirement I want to use this login essential variable in class DEF.java. What is the best and optimum way to code such a scenario. </p>
<p>Regards</p>
| java | [1] |
544,602 | 544,603 | How can I programmically disable all menu item in my activity | <p>In android, I create my menu item like this?</p>
<pre><code>public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, "Menu1");
menu.add(0, 1, 0, "Menu2");
return true;
}
</code></pre>
<p>How can I set all the menu item disabled programmically (in another part of the code in my activity, not in onCreateOptionsMenu() method itself)? </p>
<p>Thank you.</p>
| android | [4] |
687,087 | 687,088 | which javascript IDE automatically parse include js file in HTML code? | <p>I'm using Aptana plugin for eclipse, but it doesn't parse included js file when I write js code in a HTML file.Is Aptana support this function? If not Could you please show me which javascript IDE automatically parse include js file in HTML code? Thanks for help. </p>
| javascript | [3] |
4,359,629 | 4,359,630 | Simple Java Issue | <p>This isn't working the way I expect it to. Sample input will include an asterisk that will resemble ether 0 or 1. The rest is comparing to see if the numbers match up. When I try to see if a character an asterisk it doesn't work the way I expect it to.</p>
<p>Samples: </p>
<p>org = *01</p>
<p>bit = 001 || 101 || 011</p>
<pre><code>public static void doesItWork(String org, String bit)
{
for(int i = 0; i <= org.length() - 1; i++)
{
System.out.println(org.substring(i, i + 1));
if(org.substring(i, i + 1) != "*" && org.substring(i, i + 1) != bit.substring(i, i + 1))
break;
if(i == org.length() - 1)
System.out.println(bit);
}
}
</code></pre>
<p>Thanks guys for your help.</p>
| java | [1] |
1,135,102 | 1,135,103 | Android:About the android pad's screen | <p>I have checked the offical site of android and found that the <strong>Android3.0</strong> supported <strong>1024*800 screen</strong>.But I'm not clear about whether its "1024*800" means the <code>whole screen including the status bar(I mean the bar including BACK keys and can be not hidden.) or the screen without the status bar???</code>
And if including the status bar,I wanna know what <strong>the exact pixels of the status bar??</strong>
Can anyone tell me about it?
<strong>Thanks in advance!!</strong></p>
| android | [4] |
4,467,878 | 4,467,879 | Reading in HEX number from file | <p>This has me pretty bothered as I should be able to do it but when I read in the hex number and assign it to an unsigned int when I print it out I get a different number. Any advice would be great. Thanks</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream myfile;
myfile.open("test.text");
unsigned int tester;
string test;
myfile >> hex >> tester;
cout << tester;
system("pause");
return 0;
}
</code></pre>
| c++ | [6] |
2,673,343 | 2,673,344 | Manipulating Multi Dimensional array and representation | <p>I want to find out which user is not part of other games available in database i get an array as following</p>
<pre><code>$arr2=Array
(
(0) => Array
(
(uid) => 1,
(game_id) => 22
),
(1) => Array
(
(uid) => 2,
(game_id) => 22
)
(2) => Array
(
(uid) => 1,
(game_id) => 23
)
(3) => Array
(
(uid) => 3,
(game_id) => 24
)
);
</code></pre>
<p>For example User 1 is in Game 22,23 BUT NOT IN 24 user 3 is in only game 24
I want to find out which user is not participating in other game, Issue is effeciency(speed of execution)
and how to represent in array so as i can use it to display.Is it god idea to have it like
userid=> notInGame,notInGame (CSV)?</p>
| php | [2] |
930,953 | 930,954 | python class property does not evaluated in the if condition | <p>I have a python class as follow</p>
<pre><code>class Application(models.Model):
name = models.CharField(help_text="Application's name",max_length=200)
current_status = models.IntegerField(null=True, blank=True)
class Meta:
ordering = ["name"]
@property
def status(self):
"""Returns the current ApplicationStatus object of this Application."""
try:
return ApplicationStatus.objects.get(id = self.current_status)
except ApplicationStatus.DoesNotExist as e:
print e
return None
</code></pre>
<p>In another class I check the property status as in the following statements</p>
<pre><code> app = Application()
if app.status is None:
#do some thing
else:
print app.status
</code></pre>
<p>Although I am sure that the status of the application is not None, the else print statement print None and when I try to access the status like app.status.id, the application throws an exception <code>NoneType has no property id</code>.</p>
<p>When I changed the condition to:</p>
<pre><code> app = Application()
st = app.status
if st is None:
#do some thing
else:
#do another thing
</code></pre>
<p>it works fine.</p>
<p>Can someone tell my why the python properties does not evaluated in the print statement?</p>
| python | [7] |
4,997,435 | 4,997,436 | Sqlite doubts in iphone sdk | <p>I am doing a bible application in iphone.i have completed the ui desing part and authentication etc,the bible content is in sql formate.I can read the sql from the database and display it in tableview,but my need is to display the verses and contents in page ,one after another,like the pdf reader in iphone.How to do this?
Thanks in advance.</p>
| iphone | [8] |
5,583,496 | 5,583,497 | calculate a pixel value | <p>If I have this code in C#:</p>
<pre><code>int index = 10;
float value = 20;
float* pixels = getPixelData();
pixels[index+1] = (byte)(value/256);
pixels[index+0] = (byte)(value & 0xFF);
</code></pre>
<p>Then, the question is how to calculate the 'value' if I have:</p>
<pre><code>int index = 10;
pixels[index+1] = X;
pixels[index+0] = Y;
float value = ?
</code></pre>
<p>Thanks in advance. </p>
| c# | [0] |
126,168 | 126,169 | Printing XML format error | <pre><code>"<?xml version=\"1.0\"?>"
+ "<methodResponse>"
+ "<fault>"
+ "<value>"
+ "<struct>"
+ "<member>"
+ "<name>faultCode</name>"
+ "<value>"
+ "<int>"
+ "-1"
+ "</int>"
+ "</value>"
+ "</member>"
+ "<member>"
+ "<name>faultString</name>"
+ "<value>"
+ "<string>"
+ "The element type value must be terminated by the matching end-tag </value>"
+ "</string>" + "</value>" + "</member>" + "</struct>"
+ "</value>" + "</fault>" + "</methodResponse>";
</code></pre>
<p>Here, When i try to add the text The element type value must be terminated by the matching end-tag , it is throwing nullpointer exception. How can i handle this. I hope the following part throwing the error. The problem is with "end-tag ". How can i handle this.</p>
<pre><code>+ "<string>"
+ "The element type value must be terminated by the matching end-tag </value>"
+ "</string>" +
</code></pre>
| java | [1] |
2,989,913 | 2,989,914 | How to dynamically add class fields at runtime in Java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/14442998/how-to-dynamically-add-properties-to-class">How to dynamically add properties to class</a> </p>
</blockquote>
<p>I would like to know is their any way to add fields to my entity class in Java, dynamically, or is their any alternative way of doing this? We are developing a framework and our existing products has this as a requirement.</p>
<p>Example:</p>
<pre><code>class Entity1 {
String name;
String age;
// Getters/setters;
}
</code></pre>
<p>Suppose I want to add another field to my <code>Entity1</code> class (eg: <code>designation</code>), is their any way to add it dynamically/at runtime, so that if my client asks me to add any other properties I can do it with less alteration of code?</p>
<p>Waiting for your reply. Any suggestions are welcome.</p>
| java | [1] |
2,551,928 | 2,551,929 | Change animation in runtime | <p>I want to achieve simple tasks - before dialog is dismissed, I want to set different close animation depending on my logic (getWindow().getAttributes().windowAnimations = ...). For examle, I have 2 buttons on dialog and i want to slide left if first is pressed, slide right if second is pressed. I have created style file with some animations for android:windowExitAnimation and android:windowEnterAnimation and they work if passed in custom dialog constructor. But I cant override windowAnimations within the code as constructor approach can no be used as I need different animations. How can it be done and why this code is not working?</p>
<pre><code> // close button
_button_close = (ImageButton)findViewById(R.id.buttonClose);
if (_button_close != null)
{
_button_close.setOnClickListener(
new Button.OnClickListener()
{
public void onClick(View v)
{
// set animation
getWindow().getAttributes().windowAnimations = R.style.DialogSlideOutLeft;
// close form
dismiss();
}
}
);
}
</code></pre>
| android | [4] |
4,858,586 | 4,858,587 | ltrim strips more than needed | <p>Is there a way to limit exactly what ltrim removes in PHP.</p>
<p>I had a the following outcome: </p>
<pre><code>$str = "axxMyString";
$newStr = ltrim($str, "ax");
// result MyString and it should have been xMyString
</code></pre>
| php | [2] |
3,725,778 | 3,725,779 | Pop up box with a timer | <p>After some specified inactivity time (IDLE Time say for 10 mins) the application should give a pop up box with a timer (should display like 60 59 58 ....1), that box should close within 60 secs with cancel option selected and that browser should close if user didint select any option .If the user selects cancel options within 60 secs also it should be closed</p>
<p>To appear a pop box i am using <code>setTimeout("pop()",600000);</code>
but how to include timer in that atleast that box should close within 60 sec if user doesnt select any option
Is there any solution is there
Plz help
Thanks in Advance,
Satya</p>
| javascript | [3] |
574,003 | 574,004 | plusOut code java | <p>I'm trying to write a code that will give this output:</p>
<pre><code>plusOut("12xy34", "xy") → "++xy++"
</code></pre>
<p>it returns a string where the characters in the original have been replaced by + except for where the 2nd string appears in the first string, but im having problems with my code. Here it is:</p>
<pre><code>public String plusOut(String str, String word) {
String newString = "";
for (int i=0; i<str.length()-1; i++) {
if (str.substring(i, word.length()).equals(word)) {
newString = newString + str.substring(i, word.length());
}
else {
newString = newString + "+";
}
}
return newString;
}
</code></pre>
| java | [1] |
3,434,957 | 3,434,958 | Error with __init__ 'module' object is not callable | <p>I was creating my module and when I tested it, I got an error.
The code was like this:</p>
<pre><code>class test:
def __init__(self,size,type):
self.type = type
self.size = size
</code></pre>
<p>And after I import the module, when I type:</p>
<pre><code>x=test(10,'A type')
</code></pre>
<p>It says:</p>
<pre><code>TypeError: 'module' object is not callable
</code></pre>
<p>Please help me.</p>
| python | [7] |
5,953,342 | 5,953,343 | How to search a word in a file and replace the entire line with a new line? | <p>I have a file (with extension.hgx) that has some data like this:</p>
<pre><code>length = 0.00000783
height = 48
RATIO = 2
X = 1.0
Y = 1.0
</code></pre>
<p>I would like to open the file and replace the two lines:</p>
<hr>
<pre><code>height = 48
RATIO = 2
</code></pre>
<hr>
<p>With:</p>
<hr>
<pre><code>height = 8
RATIO = 8
</code></pre>
<hr>
<p>I tried parsing the file and could search for the "height" and "RATIO". Unfortunately, I could not replace the line with new line and re-save the file. In my case the problem is that, that in the file the value of parameters e.g. height(=48) varies and sometimes has uneven spaces in between. I want to replace this complete line with--
height = 8</p>
<p>I have written the following code</p>
<pre><code>import fileinput
import sys
f = open('test.hgx','r')
line_num = 0
search_phrase = "height"
for line in f.readlines():
line_num += 1
if line.find(search_phrase) >= 0:
print line_num
newline='height = 8'
lnum=1
for line in fileinput.FileInput("test.hgx",inplace=1):
if lnum==line_num:
result = newline+"\n"
else:
result=line
lnum=lnum+1
sys.stdout.write(result)
print line
</code></pre>
<p>This does not help replace complete line and save the file again. returns empty file.Any help would be greatly appreciated.</p>
<p>Regards,
Ris</p>
| python | [7] |
667,273 | 667,274 | How to make single from multiple element? | <pre><code>l = [{'name': 'abc', 'marks': 50}, {'name': 'abc', 'marks': 50}]
</code></pre>
<p>I want to uniqify the dictionary result.</p>
<pre><code> result = [{'name': 'abc', 'marks': 50}]
</code></pre>
| python | [7] |
3,647,444 | 3,647,445 | Take url and parse out a part of it | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7760797/getting-domain-name-without-tld">Getting domain name without TLD</a> </p>
</blockquote>
<p>So I have a Web site I am trying to work on. In the URL there is info and I want to parse it out and use it to make a db call to mysql:</p>
<p><a href="http://www.relevant-info.org/home.html" rel="nofollow">http://www.relevant-info.org/home.html</a></p>
<p>I want to take the Url put it into a string. </p>
<p>Then I want to only get 'relevant-info' out of the url.</p>
<pre><code>$webaddress = $_SERVER["SERVER_NAME"];
$parts = parse_url($webaddress);
$url = substr($Parts, 4, -4);
</code></pre>
<p>^ i am using that and I got the ip address (it is a centos 5.8 lamp) on a VM i am testing this, so in short this seams to work good so far :) </p>
| php | [2] |
254,102 | 254,103 | Running EXE with parameters | <p>I need help in trying to execute an execuatable from my C3 application.<br>
Suppose the path is <code>cPath</code>, the EXE is <code>HHTCtrlp.exe</code> and the parameter that has to be passed is <code>cParams</code>.</p>
<p>How would I go about this?</p>
<p>The reason why the path is a variable is that there are 3 different EXE files to run and the path will change depending on which one will run, same with the parameter string.</p>
<p>Any help would be greatly appreciated.</p>
| c# | [0] |
1,178,525 | 1,178,526 | date validation | <p>can any one tell me the code to validate the date field in signup form(which shd also validate the leap year and no of days in each month</p>
| asp.net | [9] |
4,599,111 | 4,599,112 | Get self web content | <p>I have a php that makes some maintenance operations in my web and I need that the last operation it'll do is to save into a file the content of the screen. I mean, self content.
If the screen shows: "OP1 - OK ..." it has to save into a file this: "OP1 - OK ...".</p>
<p>Saving all the results of my operations into a variable will very hard for me. That's why I need to get the content of the self screen.</p>
<p>Is there any way to do this?</p>
| php | [2] |
5,931,994 | 5,931,995 | What are the top 3 productivity improving libraries for core java? | <p>Compared with other languages, Java sometimes is pretty "chatty" and some of the core libraries are considered cumbersome by a lot of programmers. Over the last years an tremendous zoo of small libraries has evolved, which try to "fix" a single aspect of these e.g. Joda Time, guava-libraries, lambdaj</p>
<p>What are the top three libraries that can improve productivity when working with core Java? </p>
| java | [1] |
1,792,522 | 1,792,523 | Is it safe to let the users provide the link for their image? | <p>I am playing with my little PHP project right now and I am struck with a question about how I should approach the image handling. As far as I know, it's either you host the image in your server or let the user provide the link. Given my application is on a shared hosting site, which one better? What are the risks?</p>
| php | [2] |
5,210,900 | 5,210,901 | C# implementation of PushbackInputStream | <p>I need a C# implementation of Java's PushbackInputStream. I have made my own very basic one, but I wondered if there was a well tested and decently performing version already available somewhere. As it happens I always push back the same bytes I read so really it just needs to be able to reposition backwards, buffering up to a number of bytes I specify. (like Java's BufferedInputStream with the mark and reset methods).</p>
<p><strong>Update:</strong> I should add that I can't simply reposition the stream as CanSeek may be false. (e.g. when the input steam is a <a href="http://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream.canseek.aspx" rel="nofollow">NetworkStream</a>)</p>
| c# | [0] |
4,991,565 | 4,991,566 | How to create server clock with php | <p>I want to create server clock with PHP, so that every 24 hours, the script to get from the db and do it's functions. I want this to be a server clock.Because the thing is, in my case there can be 0 people that had been in the site for 24 or more hours, but still i want each 24 hours the script to get from database some info and do it's job.</p>
| php | [2] |
2,335,468 | 2,335,469 | How many times is onDraw() called? | <p>I'm just starting to play around with the android SDK, and was trying to build a simple bubble wrap app, so I could understand how custom components work. I have my onMeasure(), onSizeChanged(), onDraw() methods which create the unpopped bubble bitmaps. I have a onTouchEvent() so I know which bubble number is being touched. After this I wanted to replace the unpopped bubble with a popped bubble image, and was wondering how I could go about doing that. If I understand it right, onDraw() is only called once initially right? </p>
<p>Thanks in advance!</p>
| android | [4] |
5,343,138 | 5,343,139 | How to Draw TextView on Canvas in android..? | <p>How to Draw TextView on Canvas in android..?</p>
<p>We have <code>Canvas.DrawBitmap()</code>, <code>Canvas.drawText()</code>. Do we have any Method in Canvas which takes TextView as a parameter or any other method to display TextView on Canvas?</p>
<p>Actually, I have a alphabet in TextView and I have to make drawing on that alphabet which is in canvas.</p>
<p>Please suggest anything....Thanks for your cooperation</p>
| android | [4] |
5,443,029 | 5,443,030 | Problem adding check box to dialog box | <p>Hi I’ve been having some difficulty adding a checkbox to a dialog window. The dialog contains instructions and I don’t want it to show every time. I want it to stop showing when the user checks the checkbox and clicks ok. A moment code I get a force close because of the on click listener for the check box but not sure how else to implement it.
Thanks in advance for any help. </p>
<p>Here's the code</p>
<pre><code> private void dialog(){
final SharedPreferences settings = this.getSharedPreferences("MyApp",0);
boolean stillrun=settings.getBoolean("stillrun",true);
if (stillrun) {
final Dialog dialog = new Dialog(Zoom.this);
dialog.setContentView(R.layout.info);
dialog.setTitle("Using the zoom function");
dialog.setCancelable(true);
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText(R.string.zoomtext);
Button button = (Button) dialog.findViewById(R.id.buttonClose);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dialog.cancel();
}
});
CheckBox checkbox = (CheckBox) findViewById(R.id.checkBox1);
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (((CheckBox) v).isChecked()) {
SharedPreferences.Editor e = settings.edit();
e.putBoolean("stillrun",false);
e.commit();
}
}
});
dialog.show();
}
</code></pre>
| android | [4] |
3,885,647 | 3,885,648 | Passing parameter in crystal report using C#.NET | <p>How to pass the parameter in Crystal report?</p>
| c# | [0] |
5,544,568 | 5,544,569 | Partially "open" SlidingDrawer | <p>I've searched the discussion list (not to mention the interwebs ad nauseum) and I can't seem to find an answer and/or example.</p>
<p>I need to be able to expose part of a ListView on the bottom portion of the screen, and then (like SlidingDrawer) have the rest of the list displayed if the user flings upwards. </p>
<p>SlidingDrawer has the behavior I want, but doesn't seem to have a way of controlling how much it's open or closed (perhaps I'm just missing it). </p>
<p>I've experimented with using Animations to open and close the list. This works (mostly) except then I have to deal with list scrolling issues as animating the view doesn't seem to reset it's scrollable area to it's visible area.</p>
<p>Does anyone have an example of something like described above? Or a pointer to bits and pieces to get me going the right direction again?</p>
<p>Thanks, in advance. </p>
| android | [4] |
2,100,527 | 2,100,528 | Choosing the type of Index Variables | <p>We use Integer type represent index variables most of the time. But in some situations, we're forced to choose </p>
<pre><code>std::vector<int> vec;
....
for(int i = 0; i < vec.size(); ++i)
....
</code></pre>
<p>This will cause the compiler to raise the warning that mixed use of signed/unsigned variables. if I make the index variable as <code>for( size_t i = 0; i < vec.size(); i++ )</code>, (or an <code>unsigned int</code> )it will sort out the issues.</p>
<p>When it come more specific to use windows types, most of the Windows APIs are dealing with DWORD (which typedef-ed as unsigned long).</p>
<p>So when I use similar iteration, will again cause the same warning. Now if I rewrite it as </p>
<pre><code>DWORD dwCount;
....
for(DWORD i = 0; i < dwCount; ++i)
....
</code></pre>
<p>I find this a bit weird. It might be the problem withe perceptions. </p>
<p>I agree that we are supposed to use the same type of index variable to avoid the range problems can happen with the index variables. For e.g if we're using </p>
<pre><code>_int64 i64Count; //
....
for(_int64 i = 0; i < i64Count; ++i)
....
</code></pre>
<p>But in the case of DWORD, or unsigned integers, are there any problems in rewriting it as </p>
<pre><code>for(int i = 0; (size_t)i < vec.size(); ++i)
</code></pre>
<p>How most of the people are working with similar issues?</p>
| c++ | [6] |
2,823,113 | 2,823,114 | Javascript - turning if statement into switch statement | <p>I'm trying to convert an if statement into a switch statement using javascript. This is the working if statement:</p>
<pre><code> if(!error1(num, a_id) && !error2(num, b_id) && !error3(num, c_id) && !error4(num, d_id)) {
a.innerHTML = num;
</code></pre>
<p>Any tips on how to put this into a switch statement would be great. Thanks</p>
| javascript | [3] |
4,693,993 | 4,693,994 | Calling keyevent from mouse | <p>I need to emulate a key press with click on a link. The keyboard shortcut <kbd>CTRL</kbd>+<kbd>+</kbd> must be called with a click on a link, or a similar function.</p>
| javascript | [3] |
1,171,916 | 1,171,917 | jQuery wait for all select options to load | <p>I have a select box object and an ajax function is called OnChange using the selected value as an input. I also want to call the the same function when the select box is first loaded. I use jQuery .load, but the ajax function is called before any of the options are loaded and the input to my ajax function is undefined. Does anyone know how to get jQuery to wait for all the options to load before calling the function?</p>
<p>Thanks.</p>
<p><strong>Edit - Adding Code</strong>
I have found that a <code>setTimeout()</code> works pretty well to delay the function. However, I get nervous using <code>setTimeout()</code> because if the page loads slower than usual, it won't work. I tried replacing the timeout with <code>$(document).ready</code> as you suggested, but the function was still called before an option was selected and the input was undefined. </p>
<p>Here's the code:</p>
<pre><code><script type="text/JavaScript">
setTimeout('AjaxFunction($("#SelectID option:selected").val()));', 400);
</script>
<select id="SelectID" name="SelectName" onchange="AjaxFunction(this.value);">
<option value='Inland Empire'>Inland Empire</option>
<option value='San Bernardino'>San Bernardino</option>
<option value='Riverside'>Riverside</option>
<option value='California'>California</option>
</select>
</code></pre>
| jquery | [5] |
2,068,143 | 2,068,144 | Storing property inside function, static? | <p>Hello fellow programmers, I have taken up learning JavaScript. This syntax is pure sorcery, can someone clarify: </p>
<pre><code>function CleanPet(){
alert("The pet is now clean!");
}
CleanPet.Description="Dirty Business";
</code></pre>
<p>The material I am reading explains that in JavaScript, functions are like any other object, but if I attach a property to a function, does this mean it is static, since I haven't actually declared it?</p>
<p>Thanks for help,
I.N.</p>
| javascript | [3] |
1,666,615 | 1,666,616 | if(listStr.size == 0){ versus if(listStr.isEmpty()){ | <pre><code>List<String> listStr = new ArrayList<String>();
if(listStr.size == 0){
}
</code></pre>
<p>versus</p>
<pre><code>if(listStr.isEmpty()){
}
</code></pre>
<p>In my view one of the benefits of using <code>listStr.isEmpty</code> is that it does'nt check the size of the list and then comapre it to zero, it just checks if the list is empty. Are there any other advantages as I often see <code>if(listStr.size == 0)</code> instead of <code>if(listStr.isEmpty())</code> in codebases. Maybe there is a reason its checked this way that I am not aware of ?</p>
| java | [1] |
254,364 | 254,365 | Working with Image and Bitmap in c#? | <p>I'm developing a project that includes a picture gallery managing by admin panel. I want to show thumbnail images to admin in the admin panel which is active and will be showing to end user.</p>
<p>Ok. I'm storing images into db in two parameters: ImageData(byte[]), ImageMimeType. So I want to store thumbnail versions of pictures at the when first time store images.
I have found some example code to resize and manipulate pictures in this adress <a href="http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing" rel="nofollow">link text</a> :</p>
<pre><code>private static Image cropImage(Image img, Rectangle cropArea)
{
Bitmap bmpImage = new Bitmap(img);
Bitmap bmpCrop = bmpImage.Clone(cropArea,
bmpImage.PixelFormat);
return (Image)(bmpCrop);
}
</code></pre>
<p>this function taking a image as a parameter. But I have ImageData(byte[]).</p>
<p>So, How do I convert my byte array to Image and Image to byte array?</p>
| c# | [0] |
212,539 | 212,540 | Can We use one UIViewController class for tab-bar's | <p>Can We use one UIViewController class for tab-bar application. Which has two tabs'' need to bind data in UIViewController with out effecting data in UIViewController when tab is changed. </p>
| iphone | [8] |
1,590,386 | 1,590,387 | Why does my JavaScript no longer clear the value of an input box when I comment out an alert on the previous line? | <p>I wrote a js and it look like</p>
<pre><code>$('#searchform').keydown( function( event ) {
if ( event.which == '13' ) {
submitForm();
return;
}else if ( event.which == '27' ){
alert("ESC keydown TO DO - Clear the contents from search box ");
$('#id_search').val('');
}
});
</code></pre>
<p>This will remove contents of that input box, <strong>but when i comment alert message</strong>, it will not. Could you please explain me why??</p>
| jquery | [5] |
4,518,075 | 4,518,076 | How do you convert from a List to a primitive array of a different type | <p>How do you convert from a List to an array of a different type (e.g. I would like to go from <code>List<Integer> to double[]</code>)</p>
| java | [1] |
4,490,096 | 4,490,097 | Is there any permission present in android to read a file from the internet | <p>i am asking this , because i have tried .... some codes and created my own for accessing a file , which is present in internet , i want to read that file but my code is not working so i am asking this question because in SD_CARD case we have to provide the permission to our android app , that you can access it .... by this reason every time my application is terminated & my code is :-</p>
<pre><code> try
{
url = new URL ("http://sites.google.com/site/androidersite/text.txt");
}
catch (MalformedURLException e)
{
Toast.makeText( this , "url String mein hi error aa raha hai .. oo" , Toast.LENGTH_LONG ).show();
}
HttpURLConnection urlConnection = null ;
try
{
urlConnection = (HttpURLConnection) url.openConnection();
}
catch (IOException e)
{
Toast.makeText( this , "HTTP url connection mein error" , Toast.LENGTH_SHORT ).show();
}
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected())
{
Toast.makeText( this , "connect hua" , Toast.LENGTH_SHORT ).show();
}
else
{
Toast.makeText( this , "nahi hua connect" , Toast.LENGTH_SHORT ).show();
}
try
{
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(url.openStream()));
String StringBuffer;
String stringText = "";
while ((StringBuffer = bufferReader.readLine()) != null)
{
stringText += StringBuffer;
}
bufferReader.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
</code></pre>
<p>& for permissions i have provided , it .</p>
<pre><code><uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</code></pre>
| android | [4] |
5,832,387 | 5,832,388 | Java JTable scrolling actions | <p>I am using a JTable in java for listing the values from database. </p>
<p>I need something like, I need to list few set of values in the JTable. And when we scroll down or scroll up using scroll pane of JTable, next set of values must be loaded from database. so that instead of loading all values, i can list few values and scrolling action will retrieve next range of values. </p>
<p>How can I do this?
Can any one suggest me an idea for this?</p>
| java | [1] |
1,990,726 | 1,990,727 | How to stop thread from BroadcastReceiver in onReceive() | <p>The main idea is how to stop running thread from onReceive(),for example if connection is lost stop thread which is making connections to internet?
I have a class that extends BroadcastReceiver and i want to have access on running thread in another class to stop it.</p>
| android | [4] |
2,106,792 | 2,106,793 | Sample code for insert and delete row iphone | <p>Is there any sample code provides apple for insert and delete rows in a UITableView iphone ?</p>
| iphone | [8] |
2,334,633 | 2,334,634 | how To Save Image In Sql DataBase From Android Using .net WebService? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/9357668/how-to-store-image-in-sqlite-database">how to store image in sqlite database</a> </p>
</blockquote>
<p><a href="http://i.stack.imgur.com/XxA5h.png" rel="nofollow">enter image description here</a>i want to tack signature in android application & Store in in Sql DataBase Using >net Web Service Can AnBudy Tell Me It Is Possible Or Not?</p>
<p>i tryed this Code But It Didn't Work</p>
<pre><code>hbitmap = Bitmap.createBitmap (mContent.getWidth(), mContent.getHeight(), Bitmap.Config.RGB_565);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hbitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
b=baos.toByteArray();
XpresionHome.by=b;
String image=Base64.encodeToString(by,Base64.DEFAULT);
</code></pre>
<p>It Sote In Database But The Result Of Converting Byte To String & String To Byte Is Diffrent</p>
| android | [4] |
5,203,868 | 5,203,869 | Get current ASP.NET Trust Level programmatically | <p>Is there an API to get the current ASP.NET Trust Level?</p>
| asp.net | [9] |
898,253 | 898,254 | smart pointers and when they destruct the object they point to | <p>I wish to use a smart pointer to an object that will be accessed by quite a few different objects. Therefore i don't want to destruct it until all the pointers are released to it. The smart pointer will point to an object that instantiates a couple objects, which instantiate a couple objects, and so on, so that you can access all the individual System objects through this one pointer. However, let's say that i create the smart pointer in main as <code>std::shared_ptr<System> object(new System);</code> and then let's say i have another object that all other entities derive from which has a static std::shared_ptr that i set equal to object above. The static declaration means that it's managed by the compiler and not on a per instance basis. So let's say that all the objects that derive from the base class use this static pointer to access the System object. WHEN is this smart pointer destructed if ever? I need this pointer to be destructed before the one in main, who's destruction should drop the reference count to 0, destroying the object pointed to by it. So my question is, when is a statically declared std::shared_ptr destructed in the scheme of things. Or even if a pointer were declared globally and used all over, when would this object be destructed?</p>
<p>the base class would look something like this:</p>
<pre><code>class Base
{
public:
static shared_ptr<System> m_System;
};
int main()
{
std::shared_ptr<System> system(new System);
Base::m_System = system;
/*
other stuff
*/
return 0;
}
</code></pre>
<p>also another thing that someone could help me with, i'm not very good with const-ness, and i would like for that static pointer to be a constant that cannot be changed by the derived classes. But then if it's const i can't initialize it like i did in main, right? so how would i go about declaring it so that it is const, but i can still set it equal to a pointer initially like this.</p>
| c++ | [6] |
1,462,759 | 1,462,760 | Java:Add an image to a JList item | <p>I have a JList and i am using DefaultListModel,everything is well and the items(strings)are added correctly, but i want to add an image in JList beside each string (e.g.to show the status of the users).Can anyone help me about that? Thanks in advance.Here is how i add the elements,can i add images too?</p>
<pre><code>private DefaultListModel modelO = (DefaultListModel) Teacher.made_list.getModel();
((DefaultListModel) Teacher.made_list.getModel()).addElement(studName);
</code></pre>
| java | [1] |
1,926,402 | 1,926,403 | gnu slist execute error: lost of file .../bits/allocator.h: No such file | <p>I'm using Ubuntu. g++ version 4.7.2.</p>
<p>Can anyone help me with the gnu-extension single list? I compiled the stuff here and got a core dump when executed.</p>
<p>I debuged it and saw the core dump happend in the first line, where it throwed an error that I cannot solve. May anyone please help me with that??</p>
<p>the error code:</p>
<pre><code>std::allocator<char>::allocator (this=0x7fffffffe4d0)
at /build/buildd/gcc-4.7-4.7.2/build/x86_64-linux-gnu/libstdc++-v3/include/bits/allocator.h:104
104 /build/buildd/gcc-4.7-4.7.2/build/x86_64-linux-gnu/libstdc++-v3/include/bits/allocator.h: No such file or directory.
</code></pre>
<p>This is my test code:</p>
<pre><code>#include <ext/slist>
#include <cstring>
#include <iostream>
int main(int argc, char * argv[])
{
__gnu_cxx::slist<char> li(&argv[1][0], &(argv[1][strlen(argv[1])]));
if(argc != 3)
return 1;
std::cout << "SList: ";
for(__gnu_cxx::slist<char>::iterator i = li.begin();
i != li.end();
++i)
std::cout << *i;
std::cout << std::endl;
li.remove(argv[2][0]);
for(__gnu_cxx::slist<char>::iterator i = li.begin();
i != li.end();
++i)
std::cout << *i;
std::cout << std::endl;
return 0;
}//main
</code></pre>
| c++ | [6] |
3,609,580 | 3,609,581 | Installing JAR on Andoird | <p>Every time I'm adding a resource by using <strong>Build Path > Configure Build Path > Add External JAR</strong> my Android application throws an exception and says <code>java.lang.NoClassDefFoundError ...</code></p>
<p>What am I doing wrong?</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.