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,146,836 | 3,146,837 | how much memory is required for metadata when using new int[10]? | <p>When array is created using 'new' and deleted using 'delete' operator, delete knows the size of array. As mentioned in other SO threads, this size information is stored in metadata.</p>
<p>My question: what exactly is stored in metadata and how much space is needed for that? Is it only the size which is stored in metadata? </p>
| c++ | [6] |
3,489,878 | 3,489,879 | Event adding problem in Android | <p>In my app I have to add an event. The event has a start date, end date, start time, end time and description. <strong>I do not know now how to add</strong> start date and end date to event.</p>
<p>I use the following code:</p>
<pre><code> Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", false);
intent.putExtra("rrule", "FREQ=DAILY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
startActivity(intent);
</code></pre>
<p>And when I run this code it asks me to add or cancel in the calendar. But my need is, that it should be added without user interaction. Please help me. </p>
| android | [4] |
4,001,531 | 4,001,532 | Using a Time Zone Conversion When Dynamically Generating Results | <p>If I understand correctly, the code below converts <code>$row["datesubmitted"]</code> from one timezone to another. </p>
<p>I would like to print the converted <code>$row["datesubmitted"]</code> dynamically in an HTML table. Is there a way that I can apply the conversion below for each row that is pulled from MySQL? I assume that I can't just plug $row["dt"] into the code since there is no field called "dt" in the MySQL that I am using.</p>
<p>Thanks in advance,</p>
<p>John</p>
<pre><code>$dt = new DateTime($row["datesubmitted"], $tzFrom);
$dt->setTimezone($tzTo);
</code></pre>
| php | [2] |
4,058,530 | 4,058,531 | How I can use a class name here in jQuery | <p>I want to use this for labels which contains <code>myClass</code></p>
<pre><code>if ($(field).val() != ""){
var fieldId = $(field).attr("id");
$("label[for='"+fieldId+"']").hide();
}
</code></pre>
<p>The above code is useful to put ID, but how I can use this for classes?</p>
| jquery | [5] |
2,455,816 | 2,455,817 | getActionBar returns null | <p>Calling <em>getActionBar</em> returns null. This has been frequently reported so I've made sure to include the solutions others have used: My minSdkVersion is 11, I DO have a titlebar, and I'm calling getActionBar after setContentView. Also, my activity is not a child activity. </p>
<pre><code>setContentView(R.layout.main);
// experiment with the ActionBar
ActionBar actionBar = getActionBar();
actionBar.hide();
</code></pre>
<p>Device is a Samsung Galaxy Tab 10.1 running Android 3.2</p>
<p>Thanks in advance for any ideas or suggestions!</p>
| android | [4] |
2,846,064 | 2,846,065 | Regex for splitting up strings (Java) | <p>I have a single string which looks like:</p>
<pre><code>6
0 1 1 0 0
1 1 1 1 0
0 0 0 1 0
4
1 1 0 1 0
0 0 0 1 0
1 1 0 1 0
0 1 1 0 0
</code></pre>
<p>and would like to split into two different strings such as:</p>
<pre><code>6
0 1 1 0 0
1 1 1 1 0
0 0 0 1 0
</code></pre>
<p>and the other string being:</p>
<pre><code>4
1 1 0 1 0
0 0 0 1 0
1 1 0 1 0
0 1 1 0 0
</code></pre>
<p>Would I do this using regex? Or is there a better way?
note: apart from the 6 and 4 the others numbers will always be 1 or 0.</p>
| java | [1] |
568,175 | 568,176 | map matching either at server or client | <p>I am creating an application in android. I need to perform map matching using the data I collected. Which way is better either to perform map matching at server by pushing the data I collected or at client itself having a copy of master data from server?</p>
| android | [4] |
4,476,916 | 4,476,917 | Why can we delete some built-in properties of global object? | <p>I'm reading es5 these days and find that [[configurable]] attribute in some built-in properties of global object is set to true which means we can delete these properties.</p>
<p>For example:</p>
<p>the join method of Array.prototype object have attributes </p>
<pre><code>{[[Writable]]:true, [[Enumerable]]: false, [[Configurable]]: true}
</code></pre>
<p>So we can easily delete the join method for Array like:</p>
<pre><code>delete Array.prototype.join;
alert([1,2,3].join);
</code></pre>
<p>The alert will display <code>undefined</code> in my chromium 17,firefox 9 ,ie 10,even ie6;</p>
<p>In Chrome 15 & safari 5.1.1 the [[configurable]] attribute is set to true and delete result is also true but the final result is still <code>function(){[native code]}</code>. Seems like this is a bug and chromium fix it.</p>
<p>I haven't notice that before. In my opinion, delete built-in functions in user's code is dangerous, and will bring out so many bugs when working with others.So why ECMAScript make this decision?</p>
| javascript | [3] |
2,750,094 | 2,750,095 | Adding android.hardware.usb.accessory.xml without root? | <p><br>
I'm trying to use Android's OpenAccessory on the Samsung Galaxy Note. When installing the app I get and error.<br>
Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY <br></p>
<p> After digging it looks like I need to add android.hardware.usb.accessory.xml to /system/etc/permissions/ </p>
<p>I tried:<br>
adb push android.hardware.usb.accessory.xml /system/etc/permissions/ <br>
but I got a "Read-only file system" so I tried to remount the partition rw:<br>
$ mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system<br>
but without root access I go the expected "Operation not permitted" error.<br></p>
<p> Is there any way to do this without root? or am I forced to root my phone to get this working?</p>
| android | [4] |
330,425 | 330,426 | How to compare in C# | <p>I have two strings.</p>
<pre><code> string a="50";
string b="60";
</code></pre>
<p>Now I want to comapre the value of string a and b with respect to their values, i.e. here b>a..
What is the best way to accomplish this ?</p>
| c# | [0] |
5,737,335 | 5,737,336 | Operators precedence | <p>Found some interesting code snippet today. Simplified, it looks like this:</p>
<pre><code>$var = null;
$var or $var = '123';
$var or $var = '312';
var_dump($var);
</code></pre>
<p>The thing is that, as i know, <a href="http://www.php.net/manual/en/language.operators.precedence.php" rel="nofollow">precedence of assignment is higher that <code>OR</code></a>, so, as i assume, <code>var_dump</code> should output <code>312</code> (first - assign, second - compare logically). But result is defferent, i getting <code>123</code> (first - check if <code>$var</code> converting to <code>true</code>, second - if not, assign value).
The questions is how does it work? Why behavior is the same for <code>or</code> and <code>||</code>?</p>
| php | [2] |
4,982,832 | 4,982,833 | str_replace back into variable | <p>I have a string:</p>
<pre><code>$ht="Sunday_ Oct. 31_ 2012"
</code></pre>
<p>I want to replace underscores with commas</p>
<p>I can do:</p>
<pre><code>echo "-------------------->>>".str_replace("_", ",", $ht);
</code></pre>
<p>and it works fine like that, but I don't want to echo it, I want it back in $ht.</p>
<p>Maybe something like</p>
<pre><code> $ht=str_replace("_",",",$ht)
</code></pre>
<p>which don't work.</p>
<p>Thanks in advance,</p>
<p>alan</p>
| php | [2] |
1,309,177 | 1,309,178 | Inject new SMS event on Android | <p>I’m working on an app for Android. Is it possible to inject an event, so the phone thinks It just revived a new SMS. So it gives you a notification and everything. Not just put the new sms in the inbox.</p>
<p>Still cant get this to work, im thinking something like: </p>
<pre><code>Intent a = new Intent("android.provider.Telephony.SMS_RECEIVED");
a.putExtra("tlf", "123");
startActivity(a);
</code></pre>
<p>And then some :) Any one? </p>
| android | [4] |
4,749,793 | 4,749,794 | Python: showing attributes assigned to a class object in the class code | <p>One of my classes does a lot of aggregate calculating on a collection of objects, then assigns an attribute and value appropriate to the specific object: I.e.</p>
<pre><code>class Team(object):
def __init__(self, name): # updated for typo in code, added self
self.name = name
class LeagueDetails(object):
def __init__(self): # added for clarity, corrected another typo
self.team_list = [Team('name'), ...]
self.calculate_league_standings() # added for clarity
def calculate_league_standings(self):
# calculate standings as a team_place_dict
for team in self.team_list:
team.place = team_place_dict[team.name] # a new team attribute
</code></pre>
<p>I know, as long as the <code>calculate_league_standings</code> has been run, every team has <code>team.place</code>. What I would like to be able to do is to scan the code for <code>class Team(object)</code> and read all the attributes, both created by class methods and also created by external methods which operate on class objects. I am getting a little sick of typing <code>for p in dir(team): print p</code> just to see what the attribute names are. I could define a bunch of blank <code>attributes</code> in the Team <code>__init__</code>. E.g.</p>
<pre><code>class Team(object):
def __init__(self, name): # updated for typo in code, added self
self.name = name
self.place = None # dummy attribute, but recognizable when the code is scanned
</code></pre>
<p>It seems redundant to have <code>calculate_league_standings</code> return <code>team._place</code> and then add</p>
<pre><code>@property
def place(self): return self._place
</code></pre>
<p>I know I could comment a list of attributes at the top <code>class Team</code>, which is the obvious solution, but I feel like there has to be a best practice here, something pythonic and elegant here. </p>
| python | [7] |
5,141,084 | 5,141,085 | JQuery - Why does this simple code not work in Explorer | <p>Why does this simple thing not work in Internet Explorer 9? (works in FireFox)</p>
<pre><code>var total = 0;
$("input[id=anzahl_feld]").each(function() {
var anzahl = parseInt($(this).val());
if(!isNaN(anzahl))
{
total += Anzahl;
}
});
alert(total);
</code></pre>
<p>Thanks!</p>
| jquery | [5] |
1,960,916 | 1,960,917 | Submitting a form with every field the same name | <p>Okay, so I learned that if I have a form like:</p>
<pre><code><form method="post" action="arrayplay2.php">
<input type="checkbox" value="1" name="todelete[]"/>
<input type="checkbox" value="2" name="todelete[]"/>
<input type="checkbox" value="3" name="todelete[]"/>
<input type="checkbox" value="4" name="todelete[]"/>
<input type="submit" value="delete" name="delete"/>
</form>
</code></pre>
<p>that the attribute name="todelete[]" initiates an array. How? And then how do I access this and the values in each one with the $_POST superglobal on my arrayplay2.php script?</p>
| php | [2] |
4,668,981 | 4,668,982 | How to use string value from one class to another class using Properties | <p>I have the class:</p>
<pre><code> public class pro {
private string url = string.Empty;
public string GetURL() { return url; }
public void SetURL(string value) { url = value; }
}
</code></pre>
<p>In this line I'm getting value:</p>
<pre><code> string url = li1.Value;
pro itm = new pro(); // I have create Proprtie so I'm calling that
itm.SetURL(url); // here I'm setting value
</code></pre>
<p>Then later:</p>
<pre><code> pro itm = new pro(); //properties object I have created
string url = itm.GetURL(); // I'm not getting value which I have set in first class.
</code></pre>
<p>I have create Properties also; what am I doing wrong?</p>
<p>Tell me how to get my String value of first class to second class using Properties. Tell me the code for that I am trying that but not able to do that.</p>
| c# | [0] |
4,077,134 | 4,077,135 | Null Reference Exception | <p>in c sharp
win-forms</p>
<p>i have added a combo box control to my form
and added items accordingly into the combo box
m trying to the item on select-index is assigned to a string which is passed as parameter to function declared in the following manner:</p>
<pre><code>private void cmbPayment_SelectedIndexChanged(object sender, EventArgs e)
{
string pm = cmbLocation.SelectedItem.ToString();
payment(pm);
}
</code></pre>
<p>THE FUNCTION:</p>
<pre><code>public void payment(string pym)
{
jd.PaymentMode = pym;
}
</code></pre>
<p><img src="http://img42.imageshack.us/img42/8691/adssd.png" alt="alt text"></p>
| c# | [0] |
2,580,157 | 2,580,158 | detect the end of asynchronous recursion | <pre><code>var checkduplicates = new Array();
drawOne(i);
//console.log(checkduplicates)
function drawOne(i)
{
//randomly select one photo
var picinfo = photos[Math.floor(Math.random()*photos.length)];
//check duplicates pic, if duplicates exist, get another one
while(checkduplicates.indexOf(picinfo)!=-1||picinfo.title.length>10)
{
picinfo = photos[Math.floor(Math.random()*photos.length)];
}
checkduplicates.push(picinfo);
var ctx = document.getElementsByClassName("canvas")[i].getContext('2d');
var img = new Image();
//get the pic URL
img.src = "http://farm" + picinfo.farm + ".static.flickr.com/"
+ picinfo.server + "/" + picinfo.id + "_" + picinfo.secret + "_m.jpg";
img.onload = function()
{
// Draw pieces
ctx.drawImage(img,0,0,132,150);
ctx.drawImage(frame,0,0,133,152);
if(picinfo.title=="")
$("#"+i).append("Untitled");
else
$("#"+i).append(picinfo.title);
i++;
if (i != canvaslength)
{
drawOne(i);
}
}
</code></pre>
<p>What I am doing here is that I am dynamically generate pictures to fill out 16 canvas and some people said that I am using asynchronous recursion which I dont even notice. I have tried to use loop instead of recursion but somehow ended it up getting exception that i dont know how to fix. So I stick to recursion. However, my problem is that how I can detect the end of the recursion like the commented line shows there is only one item in the array.</p>
<pre><code>//console.log(checkduplicates)
</code></pre>
<p>and the explanation I got is that as I understand, the commented console.log is executed before a bunch of recursion of drawOne function finished But what I wanted was that I wanted the full 16 images to be fully loaded and then select them so that I can do something with them. Therefore, the question is how I can detect the end of the recursion. Thank you. You are welcomed to ignore most of my codes and just look at the recursion part. </p>
| javascript | [3] |
2,989,201 | 2,989,202 | what this code do in c# | <pre><code>if (!condition)
return objecttoreturn;
{
//some other code here
}
</code></pre>
| c# | [0] |
151,656 | 151,657 | MPMoviePlayerController view is not adding to view controller | <p>i am writing code to play video file in ownservices.m class in a method like this.</p>
<p>-(void)playVediofile:(NSString *)vedioFileName {</p>
<pre><code>NSLog(@"playing vedio file ");
NSURL *movieUrl = [NSURL fileURLWithPath:
[[NSBundle mainBundle] pathForResource:vedioFileName ofType:@"mp4"]];
MPMoviePlayerController* myMovie=[[MPMoviePlayerController alloc]
initWithContentURL:movieUrl];
myMovie.scalingMode = MPMovieScalingModeNone;
myMovie.initialPlaybackTime = 2.0;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:myMovie];
[self.viewcontroller addSubview:myMovie.view];
[myMovie play];
</code></pre>
<p>}</p>
<p>i am calling this method from ownservicesviewcontroller.m class like this In a button click event.</p>
<pre><code>ownServices *obj = [[ownServices alloc]init];
[obj playVediofile:@"Movie"];
</code></pre>
<p>i am getting audio of the video clip,but it did n't display video.</p>
<p>but i am add MPMoviePlayerController view to viewcontroller.</p>
<p>i did n't get why it is not displaying. </p>
<p>why i am doing in seperate classes is because my requirement is like that,need to maintain all the methods in ownservices class and call them from ownservicesviewcontroller.m</p>
<p>can any one please help me.</p>
<p>Thank you.</p>
| iphone | [8] |
112,322 | 112,323 | ArrayDeque interface equivalent method with Queue interface | <p>I know that ArrayDeque offers both ends of processing (head and tail) but what i don't understand why the method offerlast() is equivalent to offer() method of Queue interface. Why not offerfirst()? Pleae advice. Thanks </p>
| java | [1] |
1,453,637 | 1,453,638 | Parsing StdClass Object from file | <p>I'm using the Superfeedr php client, and when it gets a ping, it json_encodes and then writes the ping to a file. The result is saved as a StdClass Object. I then tried to load the result via file_get_content but I can not access any of the data.</p>
<pre><code>$obj = file_get_contents('result.txt');
echo $obj->title;
</code></pre>
<p>the object is long but looks like:</p>
<blockquote>
<p>stdClass Object ( [status] =>
stdClass Object ( [title] => Blah
) [title] => Blah )</p>
</blockquote>
<p>I haven't used PHP in a long time so I'm rusty... but it seems like i'm loading the object as a string thus I can't treat it as a object. Am I right? If so, how do I approach this?</p>
| php | [2] |
312,141 | 312,142 | this parent children not working | <h2>Why doesn't this work?</h2>
<p>HTML</p>
<pre><code><div class="gallery">
<div class="viewport">
<div class="wrapper">
<img src="img/boat1.png" />
<img src="img/boat2.png" />
</div>
</div>
<a href="#" class="btn_prev">prev</a>
<a href="#" class="btn_next">next</a>
</div>
</code></pre>
<p>CSS</p>
<pre><code>.viewport {position: relative; height: 220px; width: 280px; overflow: hidden; }
.wrapper {position: absolute; height: 220px; width: 9999px;}
</code></pre>
<p>jQuery - this bit works fine</p>
<pre><code>$(".wrapper").stop().animate({left: '-312px'}, 500);
</code></pre>
<p>jQuery - but if i add parent.children it dies</p>
<pre><code>$(".btn_next").click(function(event){
event.preventDefault();
$(this).parent().children(".wrapper").stop().animate({left: '-312px'}, 500);
});
</code></pre>
| jquery | [5] |
405,443 | 405,444 | specific select in jquery | <p>I have a table with 14 table row and 3 column of data </p>
<p>i like to select the table, each row only the value of the #3 column</p>
<p>how do i count, i know the fisrt selector, the child... but how to not net </p>
<p>$('#tableofdata tr td).getmethethird </p>
| jquery | [5] |
4,611,969 | 4,611,970 | How to change this code? | <pre><code>#include <iostream>
#include <string.h> // for strlen
#include <stdlib.h> // for atoi
#include <sstream>
void expand_combinations(const char *remaining_string, std::ostringstream& i, int remain_depth)
{
if(remain_depth==0)
{
std::cout << i.str() << std::endl;
return;
}
for(int k=0; k < strlen(remaining_string); ++k)
{
std::ostringstream l;
l << i.str();
l << remaining_string[k];
expand_combinations(remaining_string+k+1, l, remain_depth - 1);
}
return;
}
int main(int argc, char **argv)
{
std::ostringstream i;
if(argc<3) return 1;
expand_combinations(argv[1], i, atoi(argv[2]));
return 0;
}
</code></pre>
<p>How can this code be changed so that it doesn't use ostringstream?</p>
| c++ | [6] |
3,952,286 | 3,952,287 | Hashcode of BigDecimal derivative | <p>I have a set of numbers with varying precision. I need to create a hashkey out of them.
This code shows that the numbers are equal (at the relevant precision). So, what is a hash function that returns equal value for equal numbers?</p>
<pre><code> int prec = 2;
double val=12.3456;
int digits = (int)Math.log(val);
MathContext mc = new MathContext(digits+prec);
BigDecimal bd = new BigDecimal(12.3020, mc);
System.out.println("Value A:"+bd.toString());
MathContext mcx = new MathContext(digits+prec-1);
BigDecimal bdx = new BigDecimal(12.3170, mcx);
System.out.println("Value A:"+bdx.toString());
System.out.println("Difference is:"+bdx.compareTo(bd));
System.out.println("HashCode A:"+bd.hashCode());
System.out.println("HashCode B:"+bdx.hashCode());
</code></pre>
<p>BTW, BigDecimal didn't work out of the box for me, because 12.34 @ 2 precision was 12 ... I need the precision to effect everything past the decimal point. (So, is there a more appropriate library class for this?)</p>
| java | [1] |
156,659 | 156,660 | How to have detect/implement parameter passing like domain.com/parameters without '?' or any carrier variable like name=aksd | <p>How to do that? Is it possible to do it without a framework? I'm using php.</p>
| php | [2] |
5,281,259 | 5,281,260 | How to Document via Graphic | <p>Ran across this on the web, and it seems like a nice way to document a project. Does anyone recognize if this is generated by a tool, and if so, what tool? </p>
<p><img src="http://i.stack.imgur.com/ZC21q.jpg" alt="enter image description here"></p>
| java | [1] |
1,290,059 | 1,290,060 | Any plugin of jQueryUI like jQuery EasyUI? | <p>i've found this 3rd party plugin of jQueryUI</p>
<p><a href="http://jquery-easyui.wikidot.com/" rel="nofollow">jQuery EasyUI</a></p>
<p>But i want to know is it another recommend?</p>
| jquery | [5] |
284,834 | 284,835 | How do I define a variable for use everywhere | <p>According to below code , after getting some value (newrev,newreview) and putting in the variable, I need to put them in the label ("some text"+newrev). But I have problem (newrev) does not exist in current context.</p>
<pre><code>Label1.Text = "Review Number:" + newReview + "(for preparing of Rev." + newrev+")";
protected void ddlProjectDocument_SelectedIndexChanged(object sender, EventArgs e)
{
_DataContext = new EDMSDataContext();
var x = ddlProjectDocument.SelectedValue;
var MaxRev = (from rev in _DataContext.tblTransmittalls
where rev.DocID.ToString() == ddlProjectDocument.SelectedValue
select rev.REV).Max();
if (MaxRev == null)
{
var newRev = 0;
}
else
{
var newRev = Convert.ToInt32(MaxRev) + 1;
}
var MaxReview = (from rev in _DataContext.tblFiles
where (rev.DocId.ToString()==ddlProjectDocument.SelectedValue)&&
(rev.Rev.ToString()==MaxRev)
select rev.Review).Max();
if (MaxReview == null)
{
var newReview = 1;
}
else
{
var newReview = Convert.ToInt32(MaxReview) + 1;
}
Label1.Text = "Review Number:" + newReview + "(for preparing of Rev." + newrev+")";
}
</code></pre>
| c# | [0] |
5,285,991 | 5,285,992 | How do I find out if window animations are enabled in settings | <p>I know, I can start the Settings-Activity with</p>
<pre><code>Intent intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS);
startActivityForResult(intent,1);
</code></pre>
<p>But how do I know if the animations are enabled in the first place?</p>
<p>I have an animation inside a custom view and only want to show it, if the animations are enabled in the settings. If they are disabled, I'd like to ask the user to enable them the first time he starts the application.</p>
| android | [4] |
2,144,200 | 2,144,201 | restore input field value on submit of form using php | <p>I am working on php form submit, and i have php validation for form.</p>
<p>The registration page name say "page1.php" and retrieving field values in other page say "page2.php". if validation throughs error. it will redirect to other page say "page3.php" on click of any link in "page3.php" it will redirect back to registraion page i.e "page1.php" but i am not able to store or retain values entered by user. can any one suggest or guide me how to over come this,</p>
<p>below is the code i used.</p>
<p>Page2.php</p>
<pre><code>$name = $_POST['txtname'];
$_SESSION['txtname'] = $name;
</code></pre>
<p>page1.php </p>
<pre><code><input type='text' name="txtname" id="txtname" value="<?php echo $_SESSION['txtname']; ?>"/>
</code></pre>
| php | [2] |
4,474,757 | 4,474,758 | php get variables as key with no value assigned | <p>If I enter the following into the browser:</p>
<pre><code> http://domain.com/script.php?1234
</code></pre>
<p>And script.php has the following script:</p>
<pre><code> $key=array_keys($_GET);
echo $key[0];
</code></pre>
<p>The output will be:</p>
<pre><code> 1234
</code></pre>
<p>(I'm trying to do away with the ugly ?r=1234 and if this works, it will be perfect.)</p>
<p>My question is, is this officially correct or it's poor programming?</p>
| php | [2] |
5,359,688 | 5,359,689 | Push user input to array | <p>Hi so yes this is a previous issue i have had, i have hit the books and whent back to basics adjusted a few things but im still having trouble getting the input value to push to the array can some one please help me get my head around this thanks</p>
<pre><code><!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var number=["1"]
function myFunction()
{
var x=document.getElementById("box");
number.push=document.getElementById("input").value;
x.innerHTML=number.join('<br/>');
}
</script>
<form>
<input id="input" type=text>
<input type=button onclick="myFunction()" value="Add Number"/>
</form>
<div id="box"; style="border:1px solid black;width:150px;height:150px;overflow:auto">
</div>
</body>
</html>
</code></pre>
| javascript | [3] |
1,607,753 | 1,607,754 | How to implement the SHARE function of a Android app? | <p>Sometimes we can see that after clicking some "share" button, a list of sharable ways displays. And that list seems generated dynamically and not hard-coded.</p>
<p>For example, I have SpringPad installed on my phone, and some apps' sharing function is able to share the content via SpringPad, but how could it know that I have SpringPad?</p>
<p>How to implement such a function? Thanks.</p>
| android | [4] |
2,494,070 | 2,494,071 | Java while loops - selecting a specific variable value from the many entered | <p>I am a little stuck with my coursework in JAVA. Could you help me?</p>
<p>let's say you want to write a program that repetitively asks the names of people and their age and stops when the string FINISH is entered, then prints out the name and the age of the youngest person of all the people entered. And if 2 or more people have the same age, jsut write the name of the last person of that age entered. How can you ask JAVA to select that person, without the use of arrays, but only while loops, if statements and for loops.</p>
<p>Here is the example, starting from the method.</p>
<pre><code>String name = "";
int age = 0;
while (!name.equals ("finish))
{
name = JOptionPane.showInputDialog ("Give name: ");
String ageText = JOptionPane.showInputDialog ("Give age: ");
int age = Integer.parseInt (ageText);
}
JOptionPane.showMessageDialog ("the yougest person is " + age + ". It's " + name + ".");
</code></pre>
<p>An example run of the program:</p>
<p>Give name: Lucy
Give age: 52</p>
<p>Give name: Paul
Give age: 29</p>
<p>Give name:John
Give age: 28</p>
<p>Give name: Mary
Give age: 31</p>
<p>Give name: finish</p>
<p>The youngest person is 28. It's John.</p>
<p>Please note how string "finish" is not printed out at the end.</p>
<p>I have been thinking trying to find a way of doing that for 8 hours. I beg you help please.</p>
<p>Kind regards,</p>
| java | [1] |
4,424,460 | 4,424,461 | PHP trying to include array of glob()'d directories and is not finding last one | <p>Hello I have the following method:</p>
<pre><code>private static function loadIncludes()
{
// prepare array of files from folders
$files = array(
glob(self::libPath()."/*.php"),
glob(self::controllersPath()."/*.php"),
glob(self::extensionsPath()."/*.php"),
);
// include files
foreach ($files as $set)
{
if (is_array($set)) foreach ($set as $file)
{
require_once($file);
}
}
}
</code></pre>
<p>If I print_r the $files array it contains all the files but for some reason its not doing a require_once() on the last array item (/home/<em>*</em>/app/extensions/Controller.php)
see output:</p>
<pre><code>Array
(
[0] => Array
(
[0] => /home/***/app/lib/CApp.php
[1] => /home/***/app/lib/CController.php
[2] => /home/***/app/lib/CDb.php
[3] => /home/***/app/lib/CView.php
)
[1] => Array
(
[0] => /home/***/app/controllers/SiteController.php
)
[2] => Array
(
[0] => /home/***/app/extensions/Controller.php
)
)
</code></pre>
| php | [2] |
5,073,556 | 5,073,557 | Alert Dialog outside of an App (not in an Activity) | <p>Is there a way to create some sort of popup window like an Alert Dialog, outside of an App? The context of this question is I have a need to display something to the user in the event of a Push Notification. Basically, a user receives some message, the App receives it even if it's not currently open, and a notification appears in the user's task bar. If the user opens the notification in their task bar, I want a popup to appear completely independent from the App.</p>
<p>The only solution I've found so far is calling an Activity with the Theme.Dialog setting create an Alert Dialog. The problem with this solution is that the Activity will be added to the Activity Stack if the App is already open. So I get inconsistent behavior, because if the App is closed, then the popup window will work as I want, and will display in whatever app the user is currently in. However, if the App is already open, but not currently in focus, then the focus will switch to my App, and then display the dialog.</p>
<p>Ideally, I would want the popup to display independently of the app, with a button to redirect the user to the app if they choose, or to simply close the notification and continue whatever they're doing.</p>
<p>Anyone have any ideas?</p>
| android | [4] |
5,569,442 | 5,569,443 | working with 'this' and jQuery | <p>I'm trying to use the 'this' keyword to work with jQuery. I'm trying to rotate an image when it's clicked by passing 'this' as a parameter in it's onclick function. How would I then reference the image using jQuery?</p>
| jquery | [5] |
991,161 | 991,162 | how to append an element as a first child in jquery | <p>lets say i have html something like this..</p>
<pre><code><ul id="leftNavigation">
<table id="leftNavTable"><tr><td>blablabla</td></tr><table>
<li>1</li>
<li>2</li>
</ul>
</code></pre>
<p>what i want to do is when i click on any li, then that table should get hide and another table should get appended in place of that table.lets say that table is</p>
<pre><code><table id="Selected"><tr><td>blablabla</td></tr><table>
</code></pre>
<p>how to do it in jQuery.</p>
<p>i tried in this way but its adding as a last child of ul.</p>
<pre><code>$('#leftNavigation').append('<table id="Selected"><tr><td>blablabla</td></tr><table>')
</code></pre>
<p>Thanks in advance!!!!</p>
| jquery | [5] |
2,739,010 | 2,739,011 | PHP "or" operator within conditional statement - newb question! | <p>Forgive me if this has been covered before, I searched to no avail.</p>
<p>I have a script that looks into a directory to find the files inside. There is a conditional line that only looks for files with a certain extension:</p>
<pre><code>if(strtolower(substr($file, -3)) == "mp4"){...
</code></pre>
<p>So that will only look for files with an 'mp4' extension.</p>
<p>I need to add some "or" operators to add two more extension types. I tried the following but it didn't work:</p>
<pre><code>if(strtolower(substr($file, -3)) == "mp4" || == "mov" || == "flv"){...
</code></pre>
<p>Now the line seems to be ignored and it gets every file in the directory.
If anyone could help me out, I'd be very grateful!
I know this is probably as basic as it gets, but my grasp of PHP is <strong>extremely</strong> limited (although I do see its beauty!!!)</p>
<p>Thanks in advance.</p>
| php | [2] |
126,868 | 126,869 | Assign RTF/HTML code to Excel cell | <p>I am Working on Microsoft C#.net(windows)</p>
<p>I have a requirement ,</p>
<p>I have an excel file containing formatted text in a cell (ex: text will be bold,italic,color) . I need to save the cell content in to the sql database.
Then i need to show the saved formatted text from database to a new excel file.</p>
<p>How to assign RTF code and HTML code to Excel cell.</p>
<p>Is there any option available. Please help</p>
<p>Thanks
Sandeep</p>
| c# | [0] |
414,386 | 414,387 | const values run-time evaluation | <p>The output of the following code:</p>
<pre><code>const int i= 1;
(int&)i= 2; // or: const_cast< int&>(i)= 2;
cout << i << endl;
</code></pre>
<p>is <strong>1</strong> (at least under VS2012)</p>
<p>My question:</p>
<ul>
<li>Is this behavior defined?</li>
<li>Would the compiler always use the defined value for constants?</li>
<li>Is it possible to construct an example where the compiler would use the value of the latest assignment?</li>
</ul>
| c++ | [6] |
1,537,405 | 1,537,406 | Copy Folder From Iphone Resourse directory to Application Directory | <p>i am new to Iphone programming.
I want to copy a folder(which contains subfolder hierearchy and files) from resourse folder to application folder. i have no idea about this.
Please suggest how can i do this task?</p>
<p>Thanks</p>
| iphone | [8] |
2,624,729 | 2,624,730 | jquery + autoresize re-bind on ajax loaded divs | <p>I use the following module to do auto-scaling on my textareas</p>
<p><a href="http://james.padolsey.com/javascript/jquery-plugin-autoresize/" rel="nofollow">http://james.padolsey.com/javascript/jquery-plugin-autoresize/</a></p>
<p>It works great till I load some new textareas via ajax. I'm use to just switching .click with .live('click', fn) and it works fine.. but not this time. </p>
<p>My js to init auto-resize looks like</p>
<pre><code>$('textarea.comment_entry').autoResize({
onResize : function() {
$(this).css({opacity:0.8});
},
animateCallback : function() {
$(this).css({opacity:1});
},
animateDuration : 300,
extraSpace : 10
});
</code></pre>
<p>I was using the infinite scroll plugin and this was the magic</p>
<pre><code>$('div#content').infinitescroll({
navSelector : "a#next:last",
nextSelector : "a#next:last",
itemSelector : "#content div.content_box",
donetext : ""
},function(posts){
$('textarea.comment_entry').autoResize({
onResize : function() {
$(this).css({opacity:0.8});
},
animateCallback : function() {
$(this).css({opacity:1});
},
animateDuration : 300,
extraSpace : 10
});
});
</code></pre>
| jquery | [5] |
4,758,994 | 4,758,995 | What is this controlled called? | <p>I wan't to use this controll in my app but cant find which it is.</p>
<p>Im looking for the "slide out options"-panel thing marked in red:</p>
<p><img src="http://i.stack.imgur.com/jfmB7.png" alt="enter image description here"></p>
| android | [4] |
4,953,966 | 4,953,967 | How can I convert number of seconds since 1970 to DateTime in c++? | <p>How can I convert number of seconds since 1970 to DateTime in c++?<br>
I am getting the time in the below format:</p>
<p>1296575549:573352</p>
<p>The left part of the colon is in seconds and the right part in micro seconds.<br>
Please help.</p>
<p>Thanks,<br>
Syd</p>
| c++ | [6] |
1,091,315 | 1,091,316 | Ntop Python API | <p>Can anyone point me towards tutorials for using the Python API in Ntop (other than that Luca Deris paper)?</p>
<p>In web interfaces there is <code>about > online documention > python engine</code> but I think this link has an error. Does anyone have access to that document to re-post online for me?</p>
| python | [7] |
5,586,826 | 5,586,827 | JQuery Map get index | <p>I am using the below code to get FILE OBJ > parse using jquery .map function.
The code is working as designed, but I need to get the INDEX for each object. </p>
<pre><code> $.map($('.multiupload').get(0).files, function (file) {
alert(this.length);
$('#fileList')
.append('<li><label>' + file.name + '</label><span><input name="tbDescription" type="text" id="' + file.name + '"></span>' + listitems + '<span class="btn btn-mini">remove</span></li>');
</code></pre>
<p>I need to get the file (index) value so I can add it to the html output.</p>
<p><strong>alert(this.length);</strong><br>
always return a 0 no matter how many files I have selected.</p>
<p>If the user selects 3 files I want the html output to be</p>
<ul>
<li>file 0 some html here</li>
<li>file 1 some html here </li>
<li>file 2 some html here</li>
</ul>
<p>Who do I get the File index value from $.map($('.multiupload').get(0).files, function (file) ?</p>
| jquery | [5] |
228,687 | 228,688 | Twitter Integration in Android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1782743/twitter-integration-on-android-app">twitter integration on android app</a> </p>
</blockquote>
<p>How can I integrate Twitter with my Android application?</p>
| android | [4] |
5,342,945 | 5,342,946 | Building android application using platform tools | <p>Does anybody know sources in internet where described how to build an android application using it's native components such as aapt, aidl, dex, apkbuilder, etc.? Because in <a href="http://developer.android.com/guide/developing/building/building-cmdline.html" rel="nofollow">this</a> link there is only description of how to build an application using ant tool.</p>
| android | [4] |
1,844,563 | 1,844,564 | PHP---if(!session_is_registered deprecated? | <p>This if statement has been deprecated</p>
<pre><code>if(!session_is_registered('firstname')){
header("location: index.php"); // << makes the script send them to any page we set
} else {
print "<h2>Could not log you out, sorry the system encountered an error.</h2>";
exit();
}
</code></pre>
<p>I replaced it with </p>
<pre><code>if ( isset( $_SESSION['firstname'] ) ){
header("location: index.php"); // << makes the script send them to any page we set
} else {
print "<h2>Could not log you out, sorry the system encountered an error.</h2>";
exit();
</code></pre>
<p>the initial code is attached to my logout.php script. When i then go to the link logout.php, this is displayed "Could not log you out, sorry the system encountered an error."</p>
<p>Is that the right solution since i had no problem with the code</p>
| php | [2] |
2,825,185 | 2,825,186 | Hide element when clicked anywhere outside | <p>Yes this question has been asked before, but it didn't solve my problem.</p>
<p>So consider this situation, say i have a div let's call it <code>container</code>, now this div contains <strong>a lot</strong> of other various objects like <code><a>, <img />, <div>, <ul></code> well you get the point...</p>
<p>Now, user can do stuff in that div, write messages etc... but when he clicks anywhere outside that <code>container</code> element it should dissapear, so that's simple right?</p>
<pre><code>$(document).on("click", document, function(event){
if($(event.target).is(".container")) return;
$(".container").hide();
});
</code></pre>
<p>Well indeed this would work and at the same time not, since it would only check if the target is not <code>container</code>, if you would click say on some button it would dissapear as well, well i could just include every single element in that <code>if</code> statement, oh but in my case it would be a very very long list... so there has to be a better way</p>
<p>And yes i did try to use <code>event.stopPropagation()</code> but it didn't work, i guess it's because i'm using <code>on</code> instead of simple <code>click</code> event, please help me out with this...</p>
<p>Also I have setup this fiddle for you: <a href="http://jsfiddle.net/nVfJ5/" rel="nofollow">http://jsfiddle.net/nVfJ5/</a></p>
| jquery | [5] |
4,910,561 | 4,910,562 | Unable to retrieve intent's extras | <p>I have an activity that I use in multiples modes, so I have to do things like this:</p>
<pre><code> Intent i = new Intent(MainListActivity.this,MainActivity.class);
extras.putInt("id", c.getId());
extras.putInt("mode", AREA_MODE);
i.putExtra("extras", extras);
startActivity(i);
</code></pre>
<p>and in the <code>onCreate</code>:</p>
<pre><code> Intent i = this.getIntent();
extras = i.getBundleExtra("extras");
if(extras!=null){
id = extras.getInt("id", -1);
mode = extras.getInt("mode", COUNTRY_MODE);
}
</code></pre>
<p>But the intent extras are always null. Am I missing something? Is there any way to do this?</p>
<p>EDIT: For some reason, the <code>getIntent()</code> method returns the previous <code>Intent</code> which in my case has no extra (main intent). I'm trying to figure out why.</p>
| android | [4] |
2,927,004 | 2,927,005 | How to stop the user sending post requests | <pre><code> if($_POST)
{
if($this->session->userdata('just_sended'))
{
echo 'just sended';
exit();
}
$newdata = array(
'just_sended' => true
);
$this->session->set_userdata($newdata);
}
else
{
$newdata = array(
'just_sended' => false
);
$this->session->set_userdata($newdata);
}
</code></pre>
<p>This is my code when the user send a post request, but i can't figure it out why it not works, the user spams the button "send" and in my database appears duplicates, any ideas?</p>
| php | [2] |
5,313,087 | 5,313,088 | EJB entity manager remove() result in Cannot delete or update a parent row | <p>I use jquery <code>.find('input')[0]</code> which gives me a element like this </p>
<pre><code><input name='world' value='hello'>
</code></pre>
<p>I want to change the value of this textfield. I then <code>find('input')[0].val('')</code>, but it gave me a type error. Any insight please ?</p>
| jquery | [5] |
3,862,913 | 3,862,914 | How to convert an object to a byte array in C# | <p>I have a collection of objects that I need to write to a binary file. </p>
<p>I need the bytes in the file to be compact so I can't use BinaryFormatter. BinaryFormatter throws in all sorts of info for deserialization needs.</p>
<p>If I try byte[] myBytes = (byte[])myObject I get a runtime exception.</p>
<p>I need this to be fast so I'd rather not be copying arrays of bytes around. I'd just like the cast byte[] myBytes = (byte[])myObject to work!</p>
<p> OK just to be clear, I cannot have <em>any</em> metadata in the output file. Just the object bytes. Packed object-to-object. Based on answers received, it looks like I'll be writing low-level Buffer.BlockCopy code. Perhaps using unsafe code. </p>
| c# | [0] |
4,378,745 | 4,378,746 | I want to browse files and folders in a folder recursively using treeview in asp.net | <p>I am looking for a control or a sample project to browse files and folders of a defined folder recursively with asp.net using treeview.</p>
<p>I dont know if there is such as a free control/sample project like this?</p>
<p>Thanks in advance. </p>
| asp.net | [9] |
2,232,306 | 2,232,307 | string compare in java | <p>I have a ArrayList, with elements something like:</p>
<pre><code>[string,has,was,hctam,gnirts,saw,match,sah]
</code></pre>
<p>I would like to delete the ones which are repeating itself, such as string and gnirts, and delete the other(gnirts). How do I go about achieving something as above?</p>
<p><strong>Edit</strong>: I would like to rephrase the question:</p>
<p>Given an arrayList of strings, how does one go about deleting elements containing reversed strings?
Given the following input:</p>
<pre><code>[string,has,was,hctam,gnirts,saw,match,sah]
</code></pre>
<p>How does one reach the following output:</p>
<pre><code>[string,has,was,match]
</code></pre>
| java | [1] |
1,804,920 | 1,804,921 | Class.getResourceAsStream() issue | <p>I have a JAR-archive with java classes. One of them uses some resource that is embedded into the same JAR. In order to load that resource I use </p>
<pre><code>MyClass.class.getResourceAsStream(myResourceName);
</code></pre>
<p>One thing that bothers me though is whether it is guaranteed that required resource will be loaded from within the same JAR. The documentation for "getResourceAsStream()" method (and corresponding ClassLoader's method) is not really clear to me. </p>
<p>What would happen if there's a resource with the same name located somewhere in JVM classpath before my JAR? Will that resource be loaded instead of the one embedded in my JAR? Is there any other way to substitute resource embedded in JAR?</p>
| java | [1] |
934,697 | 934,698 | Android Spinners dimensions | <p>I have a confusion. When i design my own custom spinner what dimension should I export it as?
I created the design in adobe illustrator and exporting it in adobe photoshop for png alpha transparency.When I export it from photoshop thats where I get confused as to what dimension should the spinners be. Is it the same as icon launchers 32x32, 48x48, 96x96 or is there a general dimension specifically for the spinners. </p>
| android | [4] |
4,730,152 | 4,730,153 | Run function IF :has :not class | <p>I only want this function to run if <code>.toolbar li</code> does not have the class .Oactive:</p>
<pre><code>$(".prod_description").mousedown(function(){
$(this).parent().parent().addClass('mousedown');
$(this).parent().parent().parent().addClass('mousedown');
})
.mouseup(function(){
$(this).parent().parent().removeClass('mousedown');
$(this).parent().parent().parent().removeClass('mousedown');
});
</code></pre>
<p>What do I need to wrap this in to ensure this?</p>
<pre><code>something like: if $(.toolbar li):not(:has .Oactive) {
}
</code></pre>
| jquery | [5] |
15,949 | 15,950 | Regarding constructor overloading | <p>I was doing research on constructor overloading , below is my code </p>
<pre><code>class Philosopher {
Philosopher(String s) {
System.out.print(s + " ");
}
}
public class Kant extends Philosopher {
// insert code here
Kant() {
this("Bart"); //constructor overloading
//super("Bart"); //-->can also write this
}
Kant(String s) {
super(s);
}
public static void main(String[] args) {
new Kant("Homer");
new Kant();
}
}
</code></pre>
<p>Now my query is that in class Kant inside it's default constructor where we are writing this("Bart"); which is making call to another constructor within class itself , can't we use super("Bart") , it will do also the same functionality, please advise.</p>
| java | [1] |
5,496,813 | 5,496,814 | Problem reading and writing from same file within same program... C++ | <p>I'm working on a program, that needs to load data from a text file upon starting and save data to THE SAME text file upon exit. I have the load working, and i have the save working, but for some reason I cant seem to have them both work within the same program.</p>
<p>This doesnt work...</p>
<pre><code>ifstream loadfile("test.txt");
ofstream savefile("test.txt");
void load()
{
string name;
while(!loadfile.eof())
{
getline(loadfile,name);
cout<<"name " << name<<"\n";
}
}
void save(User &name)
{
savefile << name.getName() << endl;
}
</code></pre>
<p>Neither does this...</p>
<pre><code>fstream file("test.txt");
void load()
{
string name;
while(! file.eof())
{
getline(file,name);
cout<<"name " << name<<"\n";
}
}
void save(User &name)
{
file << name.getName() << endl;
}
</code></pre>
<p>The thing is, I can save a list of names, which works fine... but as soon as i start the program, all the names from the list delete from the text file.</p>
<p>Also, I know that getline() gets the data from the text file as a string type, but how would i convert that to something like an int.</p>
<p>Thanks</p>
| c++ | [6] |
81,966 | 81,967 | Python variables in for loop returning TypeError | <p>I am calling a function and need to loop through a range calling the function for each value in the range. The max value is returned by a different function (findPageCount()) than the one I am having a problem with. </p>
<p>For MakeRequest() I can run it with the values hard-coded and it works just fine. When I add the for loop in and pass the integer in to the two lines of the function, I the the error listed at the bottom. I think this is a small formatting difference but I have not had success in tracking it down so far. </p>
<p>The goal is to pass the i value in the for loop into the request in the xml string so the next page is shown and into the f = open statement so that a new file is created for that page. </p>
<p>I appreciate any help offered.</p>
<pre><code>def MakeRequest(i):
# some code to call api removed
xml_string = "<list><FilterItems><FilterItem attribute='pageNumber' value='%d' /></FilterItems><SortItems><SortItem attribute ='activity_aud_mem_id' sortOrder='0'/></SortItems></list>" % i
f = open('/Users/output_test_%d.txt', 'w') % i
for line in r:
try:
f.write('%s\n' % line)
except UnicodeEncodeError:
pass
f.close()
max_page = findPageCount()
for i in range(0, max_page):
MakeRequest(i);
</code></pre>
<p>I get the following error at the f = open line.</p>
<pre><code>TypeError: "unsupported operand type(s) for %: 'file' and 'int'"
</code></pre>
| python | [7] |
3,593,746 | 3,593,747 | Fade all images other than the focused image - jQuery Slider | <p>I have set up a responsive slider and would like to have all images other than the focused one to be transparent (opacity 50%). The focused image would be the image furthest to the left.</p>
<p>I have used the following plug-in for the slider:</p>
<p><a href="http://matthewtoledo.com/creations/responsive-carousel/example/example-1.html" rel="nofollow">http://matthewtoledo.com/creations/responsive-carousel/example/example-1.html</a></p>
<p>and have it implemented at:</p>
<p><a href="http://www.schafrick.com/portfolio-clients-nike.html" rel="nofollow">http://www.schafrick.com/portfolio-clients-nike.html</a></p>
<p>My jQuery knowledge is very poor and I am unsure where to start. Any help would be very much appreciated. Thanks</p>
<p><em>Please keep in mind that when I say "focused" I am not referring to mousevents but am talking about the image furthest to the left.</em> </p>
| jquery | [5] |
358,315 | 358,316 | Closest to “Mathematica Graphics[]" drawing environment for Python | <p>Being only familiar with Mathematica and its Graphics, I have now to learn to draw Graphics using Python for a server.</p>
<p>Mostly conditional combination of simple shape.</p>
<p><strong>What would be a package for Python that make drawing Graphics as close as possible as the Mathematica Graphics environment ?</strong></p>
<p>For Example, I would need to do such thing as in :</p>
<p><a href="http://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution-of-squares-coordinates#comment2475_1010">http://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution-of-squares-coordinates#comment2475_1010</a></p>
| python | [7] |
3,185,784 | 3,185,785 | jquery pulling a dynamic value for an ajax data value | <p>How would I go about pulling '&something=' if there is no static value to pull? How would combine 'commentBox' and var id if that is a possible solution?</p>
<pre><code>// process addComment()
jQuery(".textbox1").keydown(function(event) {
var keyCode = event.keyCode || event.which;
if (keyCode === 13) {
addComment(this);
}
});
function addComment() {
var id = jQuery(e).attr("id");
var newId = id.replace("commentBox-", "");
var dataString = '&something=' + newId;
// proceed with ajax call
}
</code></pre>
| jquery | [5] |
5,999,407 | 5,999,408 | 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] |
452,825 | 452,826 | Printing a list using python | <p>I have a list compiled from excel cells, using python - say <code>listlist</code>. Each element in the cell/list is in unicode. When I print the list as </p>
<pre><code>print listlist
</code></pre>
<p>I see 'u' prepended to each member of the list. But when I print the list like</p>
<pre><code>for member in listlist:
print member
</code></pre>
<p>I do not see the 'u' prepended to the member.</p>
<p>Can someone please explain to me why there is this difference? Is it defined in the xlrd module?</p>
| python | [7] |
3,519,495 | 3,519,496 | Why should I use View argument instead of whatever I want? | <p>Here is my simple example. I defined a button in main.xml file, and 'on Click' property to call my onClickk method when button01 is tapped. It is perfectly fine, but I don't understand why should I pass <code>View</code> object when I want to pass simply <code>Button</code> and do no casting.</p>
<p>If I'm passing the button as Button the application stops unexpectedly when I tap the button.</p>
<pre><code>public class Als extends Activity {
Button button01;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button01 = (Button) findViewById(R.id.Button01);
button01.setText("something");
}
public void onClickk(View button01) {
Button but = (Button) button01;
but.setText("Cooool");
}
}
</code></pre>
| android | [4] |
3,941,100 | 3,941,101 | changing SharedPreferences default value in app update | <p>I released a free and pro version of an app. To prevent full functionality of the free version, I disabled some of the options in the options menu (and initialized them to being turned off). Therefore not allowing the user to turn them on, but allowing them to see what they were missing.</p>
<p>I've now released an update, and would like to introduce certain features into the free version that were previously disabled. The tricky part is I would like these features to be turned on by default, as I worry people may not release/bother checking the options menu.</p>
<p>As far as I understand, even if I make these options default to 'on' in the update, the user will have the settings from the previous version already, and they will be to the effect of having these options to remain turned off.</p>
<p>Is there a way to achieve what I'm trying to do? I suppose at a stretch, it would be just about fine to force a deletion of the user preferences on install.</p>
| android | [4] |
1,872,026 | 1,872,027 | C# get and set the high order word of an integer | <p>What's an efficient or syntactically simple way to get and set the high order part of an integer?</p>
| c# | [0] |
140,911 | 140,912 | How do I find the min value from randomised set of numbers? | <p>see <a href="http://jsfiddle.net/JPxXp/" rel="nofollow">http://jsfiddle.net/JPxXp/</a></p>
<p>I understand as to why I keep getting 1 as the minimum ball number; do I create another variable / array that holds the 6 randomised numbers (if so, how - I don't fully understand how to do this).</p>
| javascript | [3] |
1,119,955 | 1,119,956 | javascript function input validation | <p>I am trying to write a javascript function which is called input() (performing input validation) and it will contain 3 arguments - the arguments are message, min and max.</p>
<p>I am having trouble bringing/writing the the function as a whole, have managed to work out bits of the function though - any help appreciated!</p>
<p>Code so far:</p>
<pre><code> // declare variables
var min = 5
var max = 20
var message = 'input must be between 5 and 20';
// get user input
input = parseInt(prompt(message));
// check range
while(isNaN(input) || input<min || input>max) {
alert('input was invalid');
input = parseInt(prompt(message));
}
// output validation
alert('input was accepted');
</code></pre>
<p>(from <a href="http://jsfiddle.net/AnJym/2/" rel="nofollow">http://jsfiddle.net/AnJym/2/</a>)</p>
| javascript | [3] |
4,033,112 | 4,033,113 | How do I make a method loop every 7 days at the same time based on real time? | <p>pastebin.com/zgedMeaa I've got it to loop at a certain time. What I need to do now is make it so that when I start the script it will finish at 12AM Monday 4 weeks later. Also; When I run my current script (Pastebin Link) The output is this: 1.001495E7, There is letters and that doesn't seem right. Could you tell me why it doesn't show the 14.95% Interest added onto the 100k?</p>
| java | [1] |
3,403,136 | 3,403,137 | jQuery: Convert numeric string in to some standard format | <p>Is there any jQuery plugin which convert numeric string into a standard format let say:</p>
<pre><code>200000 to 2,00,000
1000 to 1,000
398740 to 3,987,40
</code></pre>
<p>and so on..</p>
| jquery | [5] |
3,606,454 | 3,606,455 | Java: Taking file contents into a vector | <p>i'm trying to read in the file contents and put them in a vector and print it out but I'm having some issues where it prints the contents repeatedly! Please help to see what's wrong with my code! Thank you!</p>
<p>This is my code:</p>
<pre><code>public class Program5 {
public static void main(String[] args) throws Exception
{
Vector<Product> productList = new Vector<Product>();
FileReader fr = new FileReader("Catalog.txt");
Scanner in = new Scanner(fr);
while(in.hasNextLine())
{
String data = in.nextLine();
String[] result = data.split("\\, ");
String code = result[0];
String desc = result[1];
String price = result[2];
String unit = result[3];
Product a = new Product(desc, code, price, unit);
productList.add(a);
for(int j=0;j<productList.size();j++)
{
Product aProduct = productList.get(j);
System.out.println(aProduct.code+", "+aProduct.desc+", "+aProduct.price+" "+aProduct.unit+" ");
}
}
}
</code></pre>
<p>}</p>
<p>And this is the content of the file I'm trying to read in and what it should print from my code:</p>
<p>K3876, Distilled Moonbeams, $3.00, a dozen<br>
P3487, Condensed Powdered water, $2.50, per packet<br>
Z9983, Anti-Gravity Pills, $12.75, for 60<br></p>
<p>But this is what i got from running the code:</p>
<p>K3876, Distilled Moonbeams, $3.00 a dozen<br>
K3876, Distilled Moonbeams, $3.00 a dozen<br>
P3487, Condensed Powdered water, $2.50 per packet<br>
K3876, Distilled Moonbeams, $3.00 a dozen<br>
P3487, Condensed Powdered water, $2.50 per packet<br>
Z9983, Anti-Gravity Pills, $12.75 for 60<br></p>
| java | [1] |
5,597,476 | 5,597,477 | Need to bring a pop up using service | <p>I have a service running in the background which check for some data using webservice.If there is data then i need to show a pop up in my application.And i need a provision to a button to send back the status as i have viewd the data by clicking the button.</p>
<p>Will any one help me with sample code.</p>
| android | [4] |
1,877,750 | 1,877,751 | Javascript to scrape its own instance of a page | <p>My javascript foo is a bit weak, is it possible to use javascript to scrape the page its on into a string? I don't want it to make another request for the webpage, I need it to read in itself and any other source sitting on the page which will include a unique token generated for each page request, hence the need for it to read in all data on that instance of the page.</p>
<p>It also needs to be everything on that page, including comments as I would like to create a md5 hash from it, is this possible at all?</p>
<p>The html that needs to be scraped is that representing the DOM after the page initially completes loading.</p>
| javascript | [3] |
1,709,794 | 1,709,795 | How to represent and program relationships between people, items etc. in Java game | <p>I'm going to be developing a game which will be simulating an environment of people interacting with each other and the goal of the game will be to become to rise to the top by doing activities, buying weapons, items, etc.. There will be a lot of names for the items and simulated people, and i was wondering how i could store and retrieve such information. Could i use something like XML or any other related language to do it? I will be developing this using java btw</p>
<p>Thanks.</p>
| java | [1] |
762,862 | 762,863 | Business object persistence on postback | <p>Say I have a page in my web application that lets a user update their contact information. Pretend in order to retrieve or save this information I have the following class:</p>
<pre><code>public class User
{
DataAccesClass dataAccesClass = new DataAccesClass()
public string UserName {get;set;}
public string Address {get;set;}
public string EmailAddress {get;set;}
public User(){}
public static User GetUser(int userID)
{
User user = dataAccesClass.GetUser(userID); //
return user;
}
public void Save()
{
dataAccesClass.SaveUser(this);
}
}
</code></pre>
<p>Say that on my Page_Load event I create a new instance of my User class (wrapped in a !isPostBack). I then use it's public properties to populate text fields on said page in my web application. Now the question is... When the page is posted back, what is the correct way to rebuild this class to then save the updated information? Because the class was created on Page_Load !isPostBack event it is not available. What is the correct way to handle this? Should I store it in a Session? ViewState? Should I simply rebuild it every post back? The User class in this example is small so that might influence the correct way to do it but I'd like to be able to take the same approach for much larger and more complex classes. Also, would this class be considered an acceptable business object?</p>
| asp.net | [9] |
3,834,379 | 3,834,380 | pull all images from a specified directory and then display them | <p>how to display the image from a specified directory? like i want to display all the png images from a directory, in my case my directory is media/images/iconized.</p>
<p>i tried to look around but seems none of them fits what i really needed.</p>
<p>but here's my try.</p>
<pre><code>$dirname = "media/images/iconized/";
$images = scandir($dirname);
$ignore = Array(".", "..");
foreach($images as $curimg){
if(!in_array($curimg, $ignore)) {
echo "<img src='media/images/iconized/$curimg' /><br>\n";
};
}
</code></pre>
<p>hope someone here could help. Im open in any ideas, recommendation and suggestion, thank you.</p>
| php | [2] |
2,411,830 | 2,411,831 | A generic base class for business objects that implements IBindingListView sort, filter, find (c#) | <p>I have business objects: </p>
<pre><code>public abstract class BoBase : IDataErrorInfo, INotifyPropertyChanged
</code></pre>
<p>...that all inherit from a standard abstract class like so: </p>
<pre><code>public class Shipment : BoBase
</code></pre>
<p>I wrap those with a basic list/collection base:</p>
<pre><code>public abstract class BoListBase<T> : BindingList<T> where T : BoBase, new()
</code></pre>
<p>Now I want to add filtering, etc., so I'm trying to implement IBindingListView:</p>
<pre><code>public abstract class BoFilteredListBase<T> : BindingList<T>, IBindingListView where T : BoBase
</code></pre>
<p>I'm wondering if anyone has a good GENERIC implementation of this that can be applied to any business object. I've found a FEW examples... the best one so far is this: </p>
<p><a href="http://blogs.msdn.com/b/winformsue/archive/2008/05/19/implementing-filtering-on-the-ibindinglistview.aspx" rel="nofollow">http://blogs.msdn.com/b/winformsue/archive/2008/05/19/implementing-filtering-on-the-ibindinglistview.aspx</a></p>
<p>... but needs tweaking to make it generic, does not contain more extended filtering such as "like %something", and the sort seems to be broken. </p>
<p>So, before I hack it up, I thought I would ask. Anyone have any good examples ?</p>
<p>Thanks!</p>
| c# | [0] |
5,070,333 | 5,070,334 | Android sound pool function | <p>is it possible to check the status of "Sound pool". i want to perform some function when it will start and stop. like ;mediaplayer's function "isplaying() ". is sound pool has this type of functionality... </p>
| android | [4] |
3,418,503 | 3,418,504 | can any one give me the code for sample registartion page with validations in android | <p>Hai all,
I preapared one registration page with the fields like username ,password,email and mobilenumber.It runs successfully.But i want to validate all those fields now...any one help me how to validate...thanks in advance</p>
| android | [4] |
5,893,056 | 5,893,057 | simple copy paste function in javascript | <p>Hi All
how i can make simple copy and paste in javascript</p>
| javascript | [3] |
1,468,034 | 1,468,035 | delay background effect with jquery? | <p>i am trying to change the background on hover of some divs, but for some reason i can not make it with jquery.
what i want is give an effect that shows from the images to the image on hover, because with css the change is too fast and doesnt look good at all.
any suggestion?
this is my code</p>
<pre><code>#siman{
background: url(images/siman.png) left top no-repeat;
}
#vogue{
background: url(images/vogue.png) top left no-repeat;
}
#consejo{
background: url(images/consejodelcafe.png) top left no-repeat;
}
#digicel{
background: url(images/digicel.png) top left no-repeat;
}
#siman:hover, #vogue:hover, #consejo:hover, #digicel:hover{
background-position: left -96px
}
</code></pre>
| jquery | [5] |
3,818,537 | 3,818,538 | javascript to calculate simple multiplication automatically upon changing any number | <p>I'm not a javascript programmer, but I have to use it for a calculation I need to do on a wordpress page. </p>
<p>Here is what I need:</p>
<ul>
<li>3 fields in html where I can enter a number (a form). </li>
<li>a text field where the multiplication is "printed" </li>
<li>if I change one element, a new result must apear, without me needing to push any button. </li>
</ul>
<p>any idea on how to do this?
I know how to do the calculation as such, but not that it works automatically. </p>
<p>HEre is what I got so far:</p>
<pre><code> <html>
<head>
<title>Simple Javascript Calculator - Basic Arithmetic Operations</title>
<script language="javascript" type="text/javascript">
function multiply(){
a=Number(document.calculator.number1.value);
b=Number(document.calculator.number2.value);
c=a*b;
document.calculator.total.value=c;
}
</script>
</head>
<body>
<!-- Opening a HTML Form. -->
<form name="calculator">
<!-- Here user will enter 1st number. -->
Number 1: <input type="text" name="number1">
<!-- Here user will enter 2nd number. -->
Number 2: <input type="text" name="number2">
<!-- Here result will be displayed. -->
Get Result: <input type="text" name="total">
<!-- Here respective button when clicked, calls only respective artimetic function. -->
<<input type="button" value="MUL" onclick="javascript:multiply();">
</form>
</body>
</html>
</code></pre>
<p>thanks</p>
| javascript | [3] |
4,703,885 | 4,703,886 | Get std::list by reference | <p>I have a <code>Poly3D</code> class in C++, which has a sole member: <code>list<Point_3></code></p>
<pre><code>using namespace std;
struct Poly3D
{
public:
Poly3D(const list<Point_3> &ptList);
private:
list<Point_3> ptList;
};
</code></pre>
<p>My question is, how to GET ( in the sense of C#) by reference, so that the same copy with be returned every time I access the <code>Poly3D.ptList</code>?</p>
| c++ | [6] |
513,956 | 513,957 | How to use remember me function in my android login application | <p>I am using the code for remember my username and password. i have tried a lot of hours for the code for remember my username name and password but i cant success in it.</p>
<p>Here is my code which i have download from internet but it didn't work for me.</p>
<p>I have declared this variable in the extends activity.</p>
<pre><code> public static final String PREFS_NAME = "MyPrefsFile";
public static final String PREFS_USER = "prefsUsername";
public static final String PREFS_PASS = "prefsPassword";
</code></pre>
<p>after that I have also declare different variable like below.</p>
<pre><code> public String PREFS_USERS;
public String PREFS_PASS;
String username;
String upass;
</code></pre>
<p>and in the click listener i have given the following code.</p>
<pre><code> SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);
username = etUsername.getText().toString();
upass = etPassword.getText().toString();
getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
.edit()
.putString(PREFS_USERS, username)
.putString(PREFS_PASS, upass)
.commit();
</code></pre>
<p>and at the time at retry i have return the following code in the <code>oncreate</code> activity to retry my user name and password.</p>
<pre><code> SharedPreferences pref = getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
username = pref.getString(PREFS_USERS, "");
upass = pref.getString(PREFS_PASS, "");
</code></pre>
<p>But when I run the application i cant get the username and password.First time when i load the application i checked the remember me check box after log in and log out back from the application and close the application and when come back to it.it was not saved for me. </p>
| android | [4] |
5,793,016 | 5,793,017 | how to set focus on top of the page | <p>How do I set focus to the top of a page?</p>
| javascript | [3] |
4,380,697 | 4,380,698 | getText from an EditText that is updated | <p>I have a layout where I have an EditText with a predefined text.</p>
<p>Then I have a button that, when is pressed, displays a dialog with another EditText that gets the text of the previous EditText.</p>
<p>This works fine. But when I edit the first EditText, and press the button again, it displays the old text, not the new.</p>
<p>How can I get the updated text?</p>
<p>This is the code (inside onCreateDialog) where I get the text from the first EditText:</p>
<pre><code>final View notesDialogLayout = getLayoutInflater().inflate(R.layout.notes_dialog, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(notesDialogLayout)
.setCancelable(false)
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
AlertDialog alert = builder.create();
mNotesEdit = (EditText) notesDialogLayout.findViewById(R.id.task_notes_dialog);
mNotesEdit.setText(mNotes.getText());
</code></pre>
<p>mNotes is just an EditText.</p>
<p>The first time the Dialog opens, it gets the updated text. From the second time, it gets always the same text, even if I edit it.</p>
| android | [4] |
3,128,259 | 3,128,260 | How to add a fadeIn() hide-to-show effect without edit css | <p>I have this jQuery code :</p>
<pre><code>$('.tracklistOff').find('.trackon').clone().insertAfter(($(param).parents('.trackon')));
</code></pre>
<p>When I insert that <code>$('.tracklistOff').find('.trackon').clone()</code> I'd like to apply an effect to it, like fadeIn() hide-to-show. </p>
<p>Tried <code>$('.tracklistOff').find('.trackon').clone().fadeIn()</code> but it go to show-hide-to-show, and that I want is just hide-to-show, without edit CSS adding <code>display:none;</code></p>
<p>How can I do this?</p>
| jquery | [5] |
5,596,860 | 5,596,861 | How to pass optional parameters to a method in C++? | <p>How to pass optional parameters to a method in C++ ?
Any code snippet...</p>
| c++ | [6] |
1,068,078 | 1,068,079 | I am passing an external link(site link) in url and also i decoded it?it works in windows,but not in linux? | <p>I am passing an external link in url as shown below,</p>
<pre><code>http://livedirectory/user/http://www.google.com
</code></pre>
<p>i decoded <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> it works in windows,</p>
<p>but in linux its not working y??</p>
<p>i used urlencode,utf8_encode,it works in windows</p>
<pre><code>http://livedirectory/user/`http://www.google.com` the http://www.google.com is encoded
</code></pre>
<p>but in bluehost server,the <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> is not encoded,i dont know y,how to encode in linux server Mr.pekka....</p>
| php | [2] |
5,131,620 | 5,131,621 | is stripslashes() necessary for all text from db that were mysql_real_escape()'d on the way in? | <p>When i add something to my mysql db, i use mysql_real_escape_string(), then put it in the database.</p>
<p>do i need to stripslashes() when i later get it from the db with mysql_query() and mysql_fetch_array(), or does one of these functions do it for me, or is it just not necesseary?</p>
| php | [2] |
1,518,075 | 1,518,076 | Problem with Date Format in Java | <p>I have a problem with this code </p>
<pre><code>public static void main(String[] args) throws IOException, ParseException {
String strDate = "2011-01-12 07:50:00";
DateFormat formatter = new SimpleDateFormat("yyyy-mm-dd H:M:S");
Date date = formatter.parse(strDate);
System.out.println("Date="+date);
}
</code></pre>
<p>The output is:<br>
Date=Thu Feb 12 07:<strong>01</strong>:00 EET <strong>2015</strong><br>
What am i doing wrong??</p>
| java | [1] |
4,409,808 | 4,409,809 | ho to upload multiple images in dot net | <p>the conventional file uploader allows a single image to uplaod
i want to select multiple images when i click the "BROWSE" button</p>
<p>how is it possible???</p>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.