Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
5,910,013 | 5,910,014 | jquery + populate selectbox with numbers | <p>i want to populate selectbox dynamically with the count available from total number of text boxes,</p>
<p>i.e.</p>
<p>if i have text 2 textboxes then the selectbox should like</p>
<blockquote>
<pre><code><select>
<option value="1">1</option>
<option value="2">2</option>
</select>
</code></pre>
</blockquote>
<p>and when i add a new textbox dynamically i.e third textbox then the one more option should be added dynamically, like..</p>
<pre><code><select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</code></pre>
<p>please guide me with possible approach for this</p>
<p>thanks</p>
| jquery | [5] |
2,398,916 | 2,398,917 | How do you get hold of an Android Context for a Junit test from a Java Project? | <p>I need to access and Android context for a JUnit Test.</p>
<p>I have tried using MockContext and extending the AndroidTestCase but each time I get an error saying (stub!)</p>
| android | [4] |
2,166,899 | 2,166,900 | Submit tag-based form when hitting enter | <p>I have a tag-based search form (just like the tag-based text boxes you see on Facebook or S/O where you enter a word and press the corresponding delimiter key on the keyboard)</p>
<p>On my website, you type a word in the text field, and press enter to 'confirm' or 'accept' that keyword, which enables you to enter another.</p>
<p>The problem with this is, that even though you may have finished entering your search query, pressing enter does not submit the form (obviously), because e.preventDefault() has been enabled so i can use enter button to accept/confirm each tag.</p>
<p>What I want to do is, instead of (albeit, slightly) inconveciencing my users, is to submit the form when they press enter if they have not entered any (or any new) tags.</p>
<p>I'll try to explain it more clearly with this image:
<img src="http://i.stack.imgur.com/DsL0m.png" alt="enter image description here"></p>
<p>Would this at all be possible?</p>
| jquery | [5] |
1,152,849 | 1,152,850 | Looping through specific array elements | <p>I have a table and each row contains, among other things, 5 columns which may or may not contain an image file name. Let's say I've retrieved that row and put it into an assoc array. I want to loop through and echo those image file names (cols may or may not all be populated) into html tags, but only if that column has an image file name in it. Is there a better way to do it than this? </p>
<pre><code>for ($i = 1; $i < 6; $i++){
if($item_array['image_' . {$i}]{
echo "<li><img src=\"images/work-items/$item_array['image_' . {$i} . '.jpg'\"/></li>"
}
</code></pre>
| php | [2] |
4,000,958 | 4,000,959 | instance failure error in asp.net web site | <p>I have a website included login module.when i hosted the website in iis there is an error</p>
<pre><code>Server Error in "/" Application.
system.invalid operation Exception: Instance Failure
</code></pre>
<p>My ConnectionString is like this</p>
<pre><code><add name="MyConnectionstring" Connectionstring="Data Source=IP Address,1433;Network Library=DBMSSOCN;initial catalog=Databasename;integrated security=True" Provider Name="System.data.sqlclient"/>
</code></pre>
<p>How can i solve this problem?Any one knows Please help me</p>
| asp.net | [9] |
3,680,565 | 3,680,566 | How to refresh a particular div after closing a modal window? | <p>I have a modal window which closes when i add an item. The parent page will refresh once the modal window is closed. But i don't want the whole window to get closed, but i want a particular div to get refreshed. is there any javascript way to do it ?</p>
| javascript | [3] |
999,827 | 999,828 | iPhone: UIImage imageNamed doesn't show the image | <p><img src="http://i.stack.imgur.com/jbEHl.png" alt="enter image description here"></p>
<p>Hi,</p>
<p>I am trying to use the attached image in an UITableView cell. Images are in application bundle. Except this image and few images, other images are showing fine in the cell. I couldn't find whats the reason to not showing this image particularly. Could someone help me if you came across such problems?</p>
<pre><code>myImageView.image = [UIImage imageNamed:@"icontemp.png"]
</code></pre>
| iphone | [8] |
311,095 | 311,096 | How to detect if internet connection break while fetching data from internet | <p>I am working on an app which connects to internet to fetch data from server. When I first start network operation then I always check for network connectivity. But how can I manage my app if internet connection broken while fetching data from internet.</p>
| android | [4] |
282,238 | 282,239 | A basic Rock, Paper or Scissors program | <p>Updated code:</p>
<pre><code> #RockPS
import random
Choices=['R','P','S']
UserScore=0
CpuScore=0
Games=0
while Games<6:
UserChoice=input('Rock, paper or scissors? (Type R, P or S respectively)')
if UserChoice in Choices:
Games+=1
CpuChoice = random.choice(Choices)
if UserChoice == 'S' and CpuChoice == 'P':
UserScore+=1
if UserChoice == 'P' and CpuChoice == 'R':
UserScore+=1
if UserChoice == 'R' and CpuChoice == 'S':
UserScore+=1
if UserChoice == 'S' and CpuChoice == 'R':
CpuScore+=1
if UserChoice == 'P' and CpuChoice == 'S':
CpuScore+=1
if UserChoice == 'R' and CpuChoice == 'P':
CpuScore+=1
else:
print('Only R, P or S are allowed')
print(UserScore, CpuScore)
if UserScore>CpuScore:
print('Well done, you won!')
if UserScore==CpuScore:
print('You tied!')
if UserScore<CpuScore:
('Unlucky, you lost.')
</code></pre>
<p>There is still one problem. When the scores are printed it only every says 1 0 either way, assumingly to the player with the majority of wins. It should count each game, e.g 3 2 or 4 1</p>
| python | [7] |
2,365,339 | 2,365,340 | Operações antes e depois chamada de métodos | <p>Estou querendo que todos os métodos invocados realizem uma operação inicial e final quando invocados.
Como poderia fazer isso?
Marcio</p>
| python | [7] |
3,692,698 | 3,692,699 | php.ini to affect all sub-folders | <p>I need to add a php.ini in a specific folder in my server to set <code>allow_url_fopen = true</code> for a website. The website has its root folder an plenty of sub-folders that also have many sub-folders.</p>
<p>If I place the php.ini in the root of the website, it seems to only affect that folder (I've run phpconfig() there and in the subfolders.</p>
<p>Is it possible to make it somehow that affects all the subfolders without having to palce uno php.ini per sub-folder?</p>
| php | [2] |
4,627,382 | 4,627,383 | Why does the backing store of an array bind to the smallest type? | <p>In C# it is legal to write</p>
<pre><code>Animal[] a = new Giraffe[4]; //with obvious relationships
</code></pre>
<p>Because arrays are covariant. However, this is a breaking relationship. It's a runtime exception to then apply a different type of Animal to this array because the backing store is a <code>Giraffe</code>. </p>
<pre><code>a[0] = new Cat(); //KABOOM
</code></pre>
<p>Why doesn't the language create a covariant backing store? This doesn't appear to be a limitation of the language because I can create this type of data structure myself:</p>
<pre><code>class Program
{
static void Main(string[] args)
{
A[] a = new B[2];
a[0] = new B();
a[1] = new C();//runtime exception
var containerLegal = new Container<B, A>();
containerLegal.Add(new B());
containerLegal.Add(new C());//works fine
}
}
class A { }
class B : A { }
class C : A { }
class Container<T,S> where T: class, S
{
S[] s = new S[4];
int currentIndex = 0;
public void Add(S t)
{
s[currentIndex] = t;
currentIndex++;
}
}
</code></pre>
<p>I'm cheating a little bit cause I'm not using <code>T</code> in <code>Container<></code>...but I think its a fair relationship anyhow. </p>
| c# | [0] |
1,791,888 | 1,791,889 | Property 'length' not found on object of type 'id' | <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects){
if ([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CustomCell *) currentObject;
break;
}
}
}
cell.nameLabel.text = [arrareasdata objectAtIndex:indexPath.row];
cell.designLabel.text = [arrareasdata1 objectAtIndex:indexPath.row];
if(([arrareasdata2 objectAtIndex:indexPath.row].length > 0)
{
cell.emailLabel.text = [arrareasdata2 objectAtIndex:indexPath.row]
}
else
{
cell.emailLabel.text = @"";
}
cell.webLabel.text = [arrareasdata3 objectAtIndex:indexPath.row];
return cell;
}
</code></pre>
| iphone | [8] |
4,449,130 | 4,449,131 | Creating an "alert" mechanism | <p>Looking for a bit of help/advice on solving a particular problem. I've got a small-ish Silverlight application (C#, .Net 4), and I'd like to add the facility to display "alerts" to the user based on certain data meeting certain criteria. The alerts need to be displayed to the user somewhere on the page, and be displayed for a certain number of seconds (say 5 in this example) before showing the next one. Once all alerts have been displayed, the first alert needs to be shown again providing it's still "valid".</p>
<p>For example, the data meets certain criteria and I'll like to show:</p>
<pre><code>Alert A
Alert B
Alert C
</code></pre>
<p>.. the user would see "Alert A" for 5 seconds, then Alert B, then C, before cycling back to Alert A. Then Alert B is no longer necessary - the data has changed - whilst Alert A is being shown, so after Alert A has been on the screen for 5 seconds Alert C is shown. Then, the data meets some other criteria and <code>Alert D</code> is generated, so after Alert C has been shown for it's 5 seconds, Alert D is shown, and then back to A .. and so on.</p>
<p>I expect to do the actual UI update using some kind of Timer, but: I can't decide whether it would be better to evaluate the data for alert conditions every 5 seconds, and then juggle the "known" alerts accordingly, or to have some kind of "queue" to add/update alerts when the conditions are met - e.g. check if an alert is already in the "queue" and don't add it.</p>
<p>I'm probably overthinking this whole thing: does anyone have any advice on the best mechanism to use?</p>
| c# | [0] |
1,340,612 | 1,340,613 | check textfield value, if equal to given value then action if not then do nothing | <p>What I want is when the textfield <strong>#ItemAddress</strong> on focus, check another textfield #<strong>CAT_Custom_279176</strong> and if the value of which carried equals "<strong>SG</strong>", then clear the value of textfield #<strong>CAT_Custom_269379</strong> and #<strong>CAT_Custom_248591</strong>; if value is not "SG" then do nothing. The below code is not correct, please help... Many Thanks</p>
<pre><code> <script type="text/javascript">// if Singapore
$(function() {
$('#ItemAddress').focus(function() {
if ($('#CAT_Custom_279176').val('SG')) {
$('#CAT_Custom_269379').val(''); // clear value in state field
$('#CAT_Custom_248591').val(''); // clear value in city field
}
});
})
</script>
</code></pre>
| jquery | [5] |
4,058,778 | 4,058,779 | Stop .load from loading | <p>I have a file which loads content from another file on document.ready and I have a link which loads different content into the same container. I want to stop .load on document ready when hyperlink is being clicked?</p>
| jquery | [5] |
3,441,915 | 3,441,916 | Why doesn't this javascript code work? | <pre><code>function myFunction(messager) {
this.message = messager;
}
new myFunction("Hello");
document.write(myFunction.message);
</code></pre>
| javascript | [3] |
4,991,885 | 4,991,886 | Jquery file format | <p>HI.</p>
<p>I have multiple webpages. So I have a common external js file. And I have added this js file to every page. I have multiple check boxes in every page. And I have written the click event in the external, common js file. But I wonder how the js file should be?
Currently I have written like this.</p>
<pre><code>$(document).ready(function() {
$(".chk").click(function() {
alert("hi");
});
});
</code></pre>
<p>But whenever I click a checkbox the click event is fired twice. it should be once. I dont know where is the error, is there any error in writing the js file?
please comment.</p>
| jquery | [5] |
2,708,814 | 2,708,815 | how to check if my text has copyright symbol | <pre><code><ul class="scDetailLinks">
<li>
<h3> ONSTAR®</h3>
</li>
</ul>
</code></pre>
<p>how to check if h3 has the copyright symbol using jquery or javascript</p>
| jquery | [5] |
1,902,865 | 1,902,866 | Android Preventing Double Click On A Button | <p>What is the best way to prevent double clicks on a button in Android? </p>
| android | [4] |
5,857,271 | 5,857,272 | ClearInterval() and SetInterval() | <p>So in my javascript code, there is a part where if the user clicks on the checkbox I need to change the time delay used by <code>setInterval()</code>. At the moment, I used the <code>onchange</code> handler on the checkbox. Whenever the checkbox is changed, I call <code>clearInterval()</code> and <code>setInterval()</code>. I have the interval id as a global variable. Now if the user changes the checkbox before i have made my call to <code>clearInterval()</code> I expected there to be some issues, but nothing happened. Is there a better way to do this or is this way considered standard? Is there a way to check if there is an <code>interval</code> in existence?</p>
<p>PS.
I'm very new to Javascript, started it about 5 hours ago.</p>
| javascript | [3] |
2,062,250 | 2,062,251 | dbf file how to load a java resultset | <p>I have the following scenario in a Java desktop app;
I can upload a file as a dbf resultset with a query (sql), I have implemented a JFileChooser in which I get the file path for
then use it in reading.</p>
<p>thanks</p>
<p>regards</p>
| java | [1] |
3,234,053 | 3,234,054 | Video Player Restrictions | <p>I am working on redoing a website for a client that has produced a film and put it online for free. Within the video player he would like it set up so that when someone clicks to watch the film on his website and window pops up that requires the user to sign up for his e-mail list before it will allow the user to view the film. </p>
<p>The way I have it set up right now there is an image within the video player div that I have set up to call the Vimeo iframe into the div and it would be fantastic if I could work it so that when someone clicks on this image the window comes up.</p>
<p>Any suggestions anyone?</p>
<p>Thanks!</p>
| jquery | [5] |
5,976,347 | 5,976,348 | How to upload an image from iPhone into ASP.Net web server | <p>i want to upload images from my iPhone into asp.net web server. Iam new to iPhone developemnt. Please help...</p>
| iphone | [8] |
3,777,292 | 3,777,293 | How to convert a List<String> list to csv string | <p>I have a <code>List</code> of <em>Strings</em>. Is there a <em>Java</em> convenience method to convert this <code>List</code> to a <em>CSV</em> <code>String</code>? So "test1, test2, test3" is the result of a conversion of a List 3 String elements which contains "test1" "test2" "test3"</p>
<p>I could write the method myself to convert the <code>String</code> but maybe this is implemented by the <em>API</em> already ?</p>
| java | [1] |
1,442,746 | 1,442,747 | java instance variable and method having same name | <p>In java can an instance variable and a method have the same name without any instability or conflict?</p>
<p>I want to make sure if I can get away with compiling it, that it wont cause any error down the road.</p>
| java | [1] |
4,630,187 | 4,630,188 | Java method to print prime numbers from specific range | <p>I'm trying to make a method to copy all prime numbers from a specific range (provided by a constructor (int lowerBound, int upperBound) using these methods , can't seem to have much success. Can anyone help?</p>
<p>public class PrimesEnumerator {</p>
<pre><code>int upperBound;
int lowerBound;
int count = 0;
boolean b;
int num=0;
public PrimesEnumerator(int upperBound) {
this.upperBound = upperBound;
this.lowerBound = 2;
}
public PrimesEnumerator(int lowerBound, int upperBound) {
this.upperBound = upperBound;
this.lowerBound = lowerBound;
String str = num + ", ";
while (hasNext()) {
str += str;
lowerBound = num;
next();
System.out.println(str);
}
}
public static boolean isPrime(int number)
{
if (number ==1)
return false;
for(int i = 2; i * i <= number; i++)
if(number % i == 0)
return false;
return true;
}
public boolean hasNext() {
for (int j = lowerBound; j<=upperBound;j++)
{
if (isPrime(j)) {
num=j;
return true;
}
b = false;
}
return b;
}
public int next() {
if (hasNext()) {
return num;
}
else return(0);
}
</code></pre>
<p>}</p>
| java | [1] |
5,956,104 | 5,956,105 | How do you safely wrap a JS string variable in double quote chars? | <p>Obviously when you're creating an actual string literal yourself, you backslash escape the double quote characters yourself. </p>
<pre><code>var foo = "baz\"bat";
</code></pre>
<p>Just as you would with the handful of other control characters, like linebreaks and backslashes. </p>
<pre><code>var bar = "baz\\bat\nmynew line and a \"quote\" ";
</code></pre>
<p>but if you're just wrapping that existing variable in quote character, ie to give it to some other system that requires quoted input, there's some confusion. </p>
<p>Obviously you have to escape any potential double quote characters that are in the string. </p>
<pre><code>var doubleQuoteRe = /\"/g;
var quoted = "\"" + unquoted.replace(escaper, '\\\"') + "\"";
</code></pre>
<p>But according to some you <em>also</em> now have to worry about escaping literal backslash characters in the variable. In other words using much bigger hammer than my little regex. However i dont see why. </p>
| javascript | [3] |
1,371,118 | 1,371,119 | Android app too heavy | <p>can we delete android.jar from the signed apk file as explained by the author here - </p>
<p><a href="http://michaelpardo.com/2010/04/one-way-to-reduce-your-apk-file-size/" rel="nofollow">http://michaelpardo.com/2010/04/one-way-to-reduce-your-apk-file-size/</a></p>
<p>I want to be sure before trying. I have some 40 png files making my app very heavy. I also have some 20 music files which will make it even heavier. Any suggestion for compressing png and .mp3 files?</p>
| android | [4] |
540,991 | 540,992 | connect to oracle XE using c# 2010 express | <p>Just startted with c#. not sure the express version supports connection to oracle or not.
if it does, could anyone let me know the steps to do it?</p>
<p>Thanks guys.</p>
| c# | [0] |
4,051,016 | 4,051,017 | jquery elements, declared as variables | <p>I would like to know the best practices when declaring jquery dom elements as variables. Any difference between</p>
<pre><code>var div = $('div');
</code></pre>
<p>and</p>
<pre><code>var $div = $('div');
</code></pre>
<p>besides better readability? Thanks</p>
| jquery | [5] |
2,089,035 | 2,089,036 | How do I get the referrer's domain/host name using javascript? | <p>I know I can get the host name of the current page, by simply doing:</p>
<pre><code>var myhostname = location.hostname;
</code></pre>
<p>But how do I get the host name of the referrer? I can get the referrer by</p>
<pre><code>var referrer = document.referrer;
</code></pre>
<p>but unfortunately there's no <code>document.referrer.hostname</code> available in javascript. Any ideas how I can get this value?</p>
<p>An example of where this is useful is if somebody clicks a link on google.com, I want to be able to retrieve google.com from the referrer (not the page and the query string).</p>
| javascript | [3] |
1,630,305 | 1,630,306 | Is there an alternate/better way to do this simple logic in java? | <p>I have a method, say method1(), that takes a while to run. During it's execution, if there is another call to method1(), it should be ignored. I have, roughly, something like this</p>
<pre><code> boolean mFlag = false;
void method1()
{
if(!mFlag)
{
mFlag=true;
// do Stuff
mFlag=false;
}
}
</code></pre>
<p>This works. But I was wondering if there is a better way to do this preferably not involving any flags.</p>
| java | [1] |
3,875,876 | 3,875,877 | If no arguments are provided in the function, how do I test to see if it is left blank? | <pre><code><?php
/* Copyright Date
--------------------------*/
function copyright_date($creation_year) {
$current_year = date('Y');
if ($creation_year == $current_year || $creation_year == '') {
echo $current_year;
}
else {
echo $creation_year . '-' . $current_year;
}
}
?>
</code></pre>
<p>If someone forgets to add the argument (the year the website was created), e.g.</p>
<pre><code><?php copyright_date(); ?>
</code></pre>
<p>instead of:</p>
<pre><code><?php copyright_date(2009); ?>
</code></pre>
<p><strong>how would I test to see if the argument was left blank?</strong> In my if statement, that's what $creation_year == '' is for, but since the argument isn't a string, it doesn't work.</p>
| php | [2] |
3,285,037 | 3,285,038 | copying and fading HTML over to another spot on the page on hover | <p>I am trying to copy the HTML from the title and description spans within each li into the info div below. Preferably appending h2 tags around the title whilst fading it in. If another li is hovered the current selection should fade out and the new one fade in...</p>
<p>HTML</p>
<pre><code> <li>
<a class="sales1" href="#"><img alt="Sales" src="sample.png">
<span class="drinkTitle">Test Title<span>
<span class="drinkDesc">A test Description</span></span></a>
</li>
<div id="drinksInfo"></div>
</code></pre>
<p>JQUERY</p>
<pre><code>$('#drinksList ul li img').hover(function () {
var str = $(this).siblings('.drinksTitle').text();
$('#drinksInfo').html(str).fadein();
});
</code></pre>
<p>Any help would be appreciated.</p>
| jquery | [5] |
3,706,914 | 3,706,915 | Understanding instance and class variable python | <p>Let's suppose I have 2 classes in different scenario.</p>
<p><strong>Scenario 1</strong></p>
<pre><code>class MyClass():
temp = 5
</code></pre>
<p><strong>Scenario 2</strong></p>
<pre><code>class MyClass():
temp = 5
def myfunc(self):
print self.temp
</code></pre>
<p>Now when will variable <code>temp</code> will be treated as a class variable and instance variable. I am confused because in both the scenarios I am able to access the value of variable <code>temp</code> using both.</p>
<ol>
<li><p><code>Object.Temp</code> (behaving as instance variable) </p></li>
<li><p><code>ClassName.Temp</code> (behaving as class variable)</p></li>
</ol>
<p>I believe similar questions have been asked before but it will be a great help if someone can explain this in context of my question.</p>
| python | [7] |
2,012,513 | 2,012,514 | Uploading images to iphone withou resizing | <p>I want to create application that does something with users images that he can import from his computer. Problem is I need those images in original size. When I try to copy them through iTunes sync, they are resized to 640x480 or something and this is unacceptable for me :( Is there some setting in iTunes or iPhone that I missed that will allow me to sync images without resize?</p>
<p>Is there any other way how user can copy image from PC or mac to iPhone without iTunes? I want this to be as convenient as possible for user, ideally without forcing him to download and install any new software</p>
| iphone | [8] |
1,287,623 | 1,287,624 | Placement new issue | <p>In this <a href="http://stackoverflow.com/questions/3873625/i-need-c-array-class-template-which-is-fixed-size-stack-based-and-doesnt-req/3873706#3873706">http://stackoverflow.com/questions/3873625/i-need-c-array-class-template-which-is-fixed-size-stack-based-and-doesnt-req/3873706#3873706</a> answer I posted a piece of code, that is using placement new with char array. For me, this is something absolutely normal. But according to comments this code is wrong.</p>
<p>Can anyone explain in more detail?</p>
<p>Specifically what can go wrong with the array. What I understand from the comments is that <code>T x[size];</code> might not fit into <code>char x[size*sizeof(T)];</code>. I don't believe this is true.</p>
<p>EDIT:</p>
<p>I'm just more and more confused. I know what alignment is in case of structures. Yes, when you have a structure the attributes start on different offsets then you might think.</p>
<p>OK, now we are back to arrays. You are telling me that <code>T x[size];</code> is the same size as <code>char x[size*sizeof(T)];</code>, yet I cannot access the char array as T array because there might be some alignment. How can there be alignment when the arrays have the same size?</p>
<p>EDIT 2:</p>
<p>OK I finally get it, it may start on a wrong address.</p>
<p>EDIT 3:</p>
<p>Thx everyone, you can stop posting :-) Phew, this total blew my mind. I just never realized this was possible.</p>
| c++ | [6] |
3,290,943 | 3,290,944 | Customised Incoming call screen | <p>I am trying to add few views to the incoming call screen with required functionality.
Is it possible to do overide the exis android OS call screen?
Is there any way to achieve this as stand alone application.?</p>
<p>Thanks in advance.</p>
| android | [4] |
2,712,942 | 2,712,943 | load from a file object Enum | <p>I would load from a file a string and put in in a object enum.</p>
<p>I create into a class this:</p>
<pre><code>public Passenger{
private String pass_name;
public enum State{
b,c,d;
};
....
State reser;
public Passenger(String n,State r)
pass_name=n;
reser=r;
}
</code></pre>
<p>in another file I want read a file and put the string in the way i can create an object passenger such: </p>
<pre><code>Passenger p=new Passenger(p_name,What should i put here)?
</code></pre>
<p>here is the structure of my file:</p>
<pre><code>cod
passenger_name
reverved
</code></pre>
<p>cod and passenger will be rapresented by String while reserved should be rapresented through enum. I will read the file:</p>
<pre><code> BufferedReader reader=new BufferedReader(new FileReader(fname));
String cod=reader.readLine();
while(cod!=null){
String p_name=reader.readLine();
how can i load a enum type?
Passenger p=new Passenger(p_name,What should i put here)?
cod=reader.readLine();
}
</code></pre>
| java | [1] |
1,858,796 | 1,858,797 | Add files to the app on the run | <p>I was wondering if I could add the files to the app resources from an external url. As in suppose I see a url which has a nice image. Can I download that from the website and add it as a resource and use it locally for later use ? I am sure there is way But Need some guidance on how to approach the problem and The set of Classes that could be used with explanantion.</p>
<p>Thanks,</p>
| iphone | [8] |
1,806,131 | 1,806,132 | c#, hand held device | <p>I am currently working on NET 2.0. I need to develop a web page that can be called from desktop and also a hand held device(It has Windows CE on it). I've never tried anything like this before. Ideally, the requirement is to call my web page on the hand held device and produce the page on it. The page needs to perform some database interaction and return result.
I would really appreciate any guidance on this topic
Thanks in advance</p>
| c# | [0] |
2,607,590 | 2,607,591 | How can we add ASP.NET Machine account in windows server 2003 | <p>I wand to download the files in Windows server 2003. For that the ASP.Net application needs access control to the directory. I searched the ASP.NET Account. But I cannot find. How Can i find or add? Any one please help</p>
<p>IF I try to add the ASPNET account using User Accounts panel. I cannot open the localusers It says an error "the computer is a domain controller. This snap-in cannot be used on a domail controller. Domain accounts are managed with active directory users and computers snap-in" </p>
| asp.net | [9] |
683,234 | 683,235 | Data transaction between PHP and client - which way? | <p>I'll going to keep my question short. Which way sounds more professional?</p>
<p>This?</p>
<pre><code>PHP:
echo '<li>Link 1</li>';
echo '<li>Link 2</li>';
echo '<li>Link 3</li>';
jQuery:
for each <li>, add hover effect
</code></pre>
<p>or this?</p>
<pre><code>PHP:
echo json_decode(array('Link 1', 'Link 2', Link 3'));
jQuery:
Encode json value, extract values, add hover effect
</code></pre>
<p>or XML instead of JSON?</p>
<p>I'm asking this because I'm getting bored of coding repetitive things. I want things to be bridged so a JSON/XML standart seems a bit better for me.</p>
<p>What do you think? How can I improve this logic if I want my websites to be bridged?</p>
<p>Ps. Sorry if I couldn't explain myself well. Basically, my a.com website may want to use my b.com's news, so a standart while transacting/pulling these datas would be better. I'm not sure what other alternatives do I have, though.</p>
| php | [2] |
2,817,580 | 2,817,581 | server event of dropdown is not fired | <p>I have a dropdownlist, in the client side, i have it's on change event. If validation is passed, it's selected inded changed event should be fired(server side). My side, the server event is not getting fired. Autopostback is also set is true.</p>
<p>Any suggestion ?</p>
| asp.net | [9] |
3,024,722 | 3,024,723 | Updating the launcher icon at run-time | <p>Is it possible to update the launcher icon dynamically?
Currently it seems that it can only be set statically at build time using the android:icon attribute in the AndroidManifest.xml file. For example, to display a unique icon based on the device's location?</p>
<p>Is this something that can be achieved using aliases? If so, can an alias's launcher icon be enabled/disabled dynamically?</p>
| android | [4] |
1,688,116 | 1,688,117 | Jquery code works in firefox but not IE | <p>I have the following event binded to many hyperlinks with the class "riskInformationButton". It works fine in firefox but not in IE. </p>
<pre><code>$(".riskInformationButton").bind("click", function(e){
if (e.stopPropagation) e.stopPropagation( );
else e.cancelBubble = true;
var toggler = $(this).parent().parent().next();
while(!toggler.hasClass("spacerRow")){
toggler = toggler.toggleClass("hidden").toggleClass("visible").next();
}
});
</code></pre>
<p>Any help would be much appreciated.
Thanks in advance,</p>
<p>Shawn</p>
| jquery | [5] |
190,651 | 190,652 | jquery best way to remove all classes and all ids from div, ul, li, span, a | <p>What is the best way to remove all classes and all ids from all div, ul, li, span, a within a div with id="remove"?</p>
| jquery | [5] |
2,231,213 | 2,231,214 | How to convert int to 24bit string? | <p>for read I use:</p>
<pre><code>def UI24(t):
result = 0
for i in xrange(3):
result = (result << 8);
byte = unpack('>b',t[i-1])
result += byte;
return result
</code></pre>
<p>and for write ?</p>
| python | [7] |
1,170,840 | 1,170,841 | Open URL and login | <p>I have been given as task for reconsiling online reports with excel reports, making sure that the data in the two always match. I am doing it manual right now and thinking of automating it using C#. </p>
<p>Reading the excel files should not be difficult.<br>
However, for opening the online reports I have to open a URL, fill in the username and password, navigate to the report, fill-in the parameters for the report.<br>
One report displayed as online SSRS report and the other is just a web page. </p>
<p>I want to know how can I automate this task, meaning how can I programatically login to the page.</p>
| c# | [0] |
5,401,043 | 5,401,044 | changing the background color of menu | <p>Hello i have the following xml for menu i want to set the background color black like over <a href="http://android.ankara-gtug.org/guide/topics/ui/menus.html" rel="nofollow">here</a> . The other thing i want to set if the buttons are increased they should remain in one row instead of moving to next row . Thanks </p>
<pre><code><menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/Quit"
android:title="Quit"
android:icon="@drawable/icon" />
<item android:id="@+id/settings"
android:title="Settings"
android:icon="@drawable/icon" />
<item android:id="@+id/services"
android:title="Services"
android:icon="@drawable/icon" />
<item android:id="@+id/web"
android:title="web"
android:icon="@drawable/icon" />
</menu>
</code></pre>
| android | [4] |
3,682,346 | 3,682,347 | How could I get all applications that were installed by user? | <p>How could I get all applications that were installed by user?</p>
<p>I want to develop an app that can present all applications that were installed by user, but</p>
<p>I don't understand how to get them.</p>
<p>use <code>getExternalStorageDirectory()</code>?</p>
<p>or is there have other method? </p>
| android | [4] |
1,657,343 | 1,657,344 | Clean way to make a php login script on a site with includes? | <p>Basically I have an index.php file with navigation in form of includes <em>only</em>.</p>
<hr>
<ul>
<li><p>My script can check whether a user exists by checking a database.</p></li>
<li><p>It can also log you in if the check was successful.</p></li>
</ul>
<p>My problem is <strong>redirects</strong>! Do I really have to use
<code>echo "<meta http-equiv=refresh content=\"1; URL=index.php\">";</code>?</p>
<p>And I also have to make tons of if-statements to cover the entire possibilities of a users actions (have to take evil people into account).</p>
<p>Headers are already ruled out because I use includes and requires.</p>
<p>I'm on the brinck of switching to ASP.NET or something rediculous... This scripting is making me mad :P</p>
| php | [2] |
4,545,309 | 4,545,310 | C++ and initialize const variable | <p>I want to create class Test with const int variable with name "a". After that I need create constructor where variable "a" get value =10. I Create class test and in test.h I create <code>const int a;</code> in class Test.h and in test.cpp I have something like that:</p>
<pre><code>#include "stdafx.h"
#include "Test.h"
Test::Test(void)
{
a = 10;
b = 20;
size = 20;
tekst[size];
}
Test::~Test(void)
{
}
</code></pre>
<p>and this is test.h:</p>
<pre><code>#pragma once
class Test
{
const int a;
public:
Test(void);
~Test(void);
int b;
char *tekst;
int size;
static double d;
int y;
};
</code></pre>
<p>but I get error:</p>
<pre><code>Error 1 error C2758: 'Test::a' : must be initialized in constructor base/member initializer list c:\users\bożydar\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\test.cpp 6
Error 2 error C2166: l-value specifies const object c:\users\bożydar\documents\visual studio 2012\projects\consoleapplication1\consoleapplication1\test.cpp 7
</code></pre>
| c++ | [6] |
4,591,317 | 4,591,318 | Keeping your main form class short best practice | <p>I have a main form at present it has a tab control and 3 data grids (DevExpress xtragrid's). Along with the normal buttons combo boxes... I would say 2/3 rds of the methods in the main form are related to customizing the grids or their relevant event handlers to handle data input. This is making the main forms code become larger and larger. </p>
<p>What is an ok sort of code length for a main form?</p>
<p>How should I move around the code if necesary? I am currently thinking about creating a user control for each grid and dumping it's methods in there.</p>
| c# | [0] |
2,410,687 | 2,410,688 | Any way to keep track of the last 5 data points in python | <p>So I have an array that holds several numbers. As my script runs, more and more numbers are appended to this array. However, I am not interested in all the numbers but just want to keep track of the last 5 numbers.</p>
<p>Currently, I just store all the numbers in the array. However, this array gets really big and it's full of unnecessary information. </p>
<p>I have thought about making a function that when it adds an element to the array, also removes the last element if the array already contains 5 numbers. </p>
<p>I also thought about making a new class to create a data structure that does what I want. However, I only need to reference this array occasionally and is only a small part of the script. So I think it is overkill if I create a whole new class to do this. </p>
<p>What is the best way to do this?</p>
| python | [7] |
2,983,588 | 2,983,589 | Javascript attach event to class name | <p>If I have 10 items, with the class name <code>keyword</code>:</p>
<pre><code><div class="keyword"></div>
</code></pre>
<p>How can I attach an event, for example <code>click</code>, on this element.</p>
<p>I tried the following, but with no luck: (no alert comes up)</p>
<pre><code>document.getElementsByClassName('.keyword').onclick = function()
{
alert(true);
Search.addKey(this.getElementsByClassName('name')[0].innerHTML);
}
</code></pre>
<p>Requirements:</p>
<ul>
<li>Without the onclick attribute</li>
<li>no jQuery or any other library</li>
</ul>
<p>Note: the elements are not generated on page load. Their number can be different, each times you click a button for eg.</p>
<p>I need a way to attach to all tags with the class 'keyword' in the 'future'.</p>
| javascript | [3] |
2,560,598 | 2,560,599 | Passing variables values | <p>here is the simple script:</p>
<pre><code>function parentFunc() {
var x = 15;
process(x);
}
parentFunc();
function process(x) {
alert(x);
}
</code></pre>
<p>Now when the page loads, <code>parentFunc()</code> is being executed which calls <code>process()</code> function along with sending the paramter to it; Is there any way to make it so that when <code>parentFunc()</code> is called it just sends the parameters to <code>process()</code> function without executing it? I need a solution without global variables.</p>
| javascript | [3] |
3,270,443 | 3,270,444 | Unexpected tag T_ECHO in inline if | <p>I have something like this in one of my views</p>
<pre><code><li <?php $isCurrent ? echo 'class="current"' : ''?> >
<a href="SOME_LINK" class="SOME_CLASS">SOME_TEXT</a>
</li>
</code></pre>
<p>This causes a syntax error, unexpected T_ECHO. Changing <code>echo</code> for <code>print</code> solves the issue, but I would like to understand why I cannot use <code>echo</code>.</p>
| php | [2] |
873,468 | 873,469 | add dynamic lib in iphone application | <p>How do I add dynamic libraries in iphone xcode? I want to add the lib: "libcrypto.dylib" ( in /usr/lib ). Please guide me.</p>
| iphone | [8] |
3,384,253 | 3,384,254 | Object reference variable | <pre><code>String myString="Plz_help";
</code></pre>
<p>i came to know that 'myString' is not an object but a object reference variable which stores the base address of the actual object.So 'myString' should return an address when i execute </p>
<pre><code>System.out.println(myString);
</code></pre>
<p>but it is returning 'Plz_help' to the output.</p>
<pre><code>Myclass obj_ref_var=new Myclass();
</code></pre>
<p>When i use the same System.out.println(obj_ref_var) for other class which i had created ,it is returning the address.</p>
<p>plz help.im pretty new to java. </p>
| java | [1] |
5,737,548 | 5,737,549 | Convert List<int> to delimited string list | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1334072/most-elegant-way-to-return-a-string-from-listint">most elegant way to return a string from List<int></a> </p>
</blockquote>
<p>I'm not sure the easiest way to do this. I simply want to add a ; between each value and spit it out as one string. I don't see that you can do this with ToString(). I'd have to loop through and create a stringbuilder and append & add a ";".</p>
| c# | [0] |
4,527,687 | 4,527,688 | Get the current field name | <p>I called below function on body and what i want is when i press anything in textbox it will alert me the name of the textbox and i want to check name and than execute something .Checking name is working great in FF and not in IE.Thanks </p>
<pre><code><body bgcolor="#F2F2F2" OnKeyPress="return getFieldName(event);">
</code></pre>
<p>...</p>
<pre><code>function getFieldName(e) {
</code></pre>
<p>e = e || window.event;
var key = e.keyCode || e.which,
target = e.target || e.srcElement;</p>
<p>This works but target.name is not trappable in IE
for eg:</p>
<p>if(target.name == 'one') {
//we can reach here is FF and Not in IE</p>
<p>}</p>
<p>}</p>
| javascript | [3] |
210,640 | 210,641 | Save HTML Form data into a File using JavaScript | <p>I'm trying to write a code to extract some form data from a HTML file and save them in a file using Javascript.</p>
<p>Example: Name, Password and email should be stored in a file (text or XML) so that i can use it later.</p>
<p>How can i do it? i'm new to JavaScript !!! </p>
<p>Thanks in advance!</p>
| javascript | [3] |
1,127,437 | 1,127,438 | PagerTitleStrip overlaps with actual content | <p>I am using A custom viewpager with a PagerTitleStrip, both supported by the android compatibility package. As recommended I use it like this:</p>
<pre><code> <snok.stubefrie.DayPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<android.support.v4.view.PagerTitleStrip
android:id="@+id/strip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"/>
</snok.stubefrie.DayPager>
</code></pre>
<p>However the titlestrip overlaps with the actual content of my viewpager (Both starting at 0,0). Any ideas?</p>
| android | [4] |
2,045,702 | 2,045,703 | How to make list items wrap content? | <p>I have the following list view:</p>
<pre><code><ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false" />
</code></pre>
<p>The problem here is that if the list item contains a lot of text, not all of it is shown. Is there a way to make every list item high enough to show all of its content?</p>
| android | [4] |
462,021 | 462,022 | encode html in php and decode in javascript | <p>I have some html code I want to store in a database. I need a way to encode it in php so all the special characters don't break the db INSERT (the html can include all sorts of spec chars) and then a way to unencode that at the other end in javascript once i've passed it via JSON so that the html is rendered correctly.</p>
<p>IS there any way I can do this?</p>
| php | [2] |
1,224,506 | 1,224,507 | How to remove <br /> tags and more from a string? | <p>I need to strip all <code><br /></code> and all 'quotes' (<code>"</code>) and all 'ands' (<code>&</code>) and replace them with a space only ...</p>
<p>How can I do this? (in PHP)</p>
<p>I have tried this for the <code><br /></code>:</p>
<pre><code> $description = preg_replace('<br />', '', $description);
</code></pre>
<p>But it returned <code><></code> in place of every <code><br /></code>...</p>
<p>Thanks</p>
| php | [2] |
4,866,145 | 4,866,146 | How to solve java.lang.NullPointerException | <p>I am getting the <code>java.lang.NullPointerException</code> on the <code>cars.add(car);</code> line and I am really unsure how to solve it, I have read some of the other threads relating to this error, but the answer still seems to have eluded me. </p>
<pre><code>public class RentalCompany {
private ArrayList<Car> cars;
private String description;
private int carDownPayment;
private int rate;
private int carNumber;
public void addCar(String descriptionOfTheCar, int downPayment,
int dailyRate) {
Car car = new Car(descriptionOfTheCar, downPayment, dailyRate);
cars.add(car);
}
}
</code></pre>
<p>If anyone can offer any advice I would be very much obliged, thanks in advance. </p>
| java | [1] |
596,060 | 596,061 | What should be the format string to print "0x0" with swprintf()? | <p>I tried with <code>swprintf(buff, 4, L"%#03x", value)</code>, but when <code>value = 0</code>, I get <code>000</code> instead of <code>0x0</code>. </p>
| c++ | [6] |
2,554,177 | 2,554,178 | how to get Updated location & Disable GPS after getting it in android? | <p>friends,</p>
<p>i am using following code to get GPS location </p>
<p>it is causing two problems</p>
<p>1) when my location is changed / I move my phone from one area to another I dont get updated gps location(latitude/longitude)</p>
<p>2) after getting gps location my gps of phone is enabled how to disable it?</p>
<pre><code> double MyDeviceLatitude,MyDeviceLongitude;
public void GetGPSLocation()
{
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener myLocationListener = new CurrentLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30, 30, myLocationListener);
Location currentLocation = locationManager.getLastKnownLocation("gps");
if(currentLocation != null)
{
MyDeviceLatitude = currentLocation.getLatitude();
MyDeviceLongitude = currentLocation.getLongitude();
}else
{
currentLocation = locationManager.getLastKnownLocation("network");
MyDeviceLatitude = currentLocation.getLatitude();
MyDeviceLongitude = currentLocation.getLongitude();
}
public class CurrentLocationListener implements LocationListener{
public void onLocationChanged(Location argLocation)
{
if (argLocation != null)
{
MyDeviceLatitude = argLocation.getLatitude();
MyDeviceLongitude = argLocation.getLongitude();
}
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle arg2) {
}
}
</code></pre>
<p>}</p>
<p>any help would be appreciated.</p>
| android | [4] |
3,177,800 | 3,177,801 | How can this be made to do fewer calculations? It is very inefficient with large numbers | <pre><code>num = input ()
fact = 0
while fact != num:
fact = fact + 1
rem = num % fact
if rem == 0:
print fact
</code></pre>
| python | [7] |
4,007,035 | 4,007,036 | Change ImageView image inside onClick event | <p>I have an ImageView working as a button in my program. I need it to be an ImageView since I want just the image to be shown, not the borders.</p>
<p>This button is a lamp, if the data in database says it's visible, the lamp must be "on", when you click the button, it will check the data from bank and change it to "off" if it's on and vice-versa.</p>
<p><strong>So, the change of image will happen inside a onClick event.</strong></p>
<p>Here is my code:</p>
<pre><code>btnVisualizar.setClickable(true);
btnVisualizar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
if (visivelBanco.getText().equals("Y")) {
btnVisualizar.setImageResource(this.getResources().getIdentifier(
"drawable/visible_off", null, this.getPackageName()));
} else {
btnVisualizar.setImageResource(
this.getResources().getIdentifier("drawable/visible_on", null, this.getPackageName()));
}
} catch (Exception e) {
Toast.makeText(
getBaseContext(),
"Falha ao modificar visibilidade do item!",
Toast.LENGTH_SHORT).show();
}
}
});
</code></pre>
<p>However the compiler doesn't recognize the method getResources() and getPackageName().</p>
<p>What am I doing wrong?</p>
<p>Any help is appreciatted.</p>
| android | [4] |
1,504,491 | 1,504,492 | System.data.datarow | <pre><code> [WebMethod]
public List< string> HelloWorld(string prefixText)
{
SqlConnection con = new SqlConnection("Database=bluedd;Server=(local);Integrated Security=SSPI");
con.Open();
SqlCommand cmd = new SqlCommand("select user_master.first_name from user_master where first_name like @Name+'%'", con);
cmd.Parameters.AddWithValue("@Name", prefixText);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
List<string> CountryNames = new List<string>();
for (int i = 0; i < dt.Rows.Count; i++)
{
CountryNames.Add(dt.Rows[i].ToString());
}
return CountryNames;
}
</code></pre>
<p>This code returns System.Data.DataRow is there any casting problem<br/>I am very new in s/w Development, any help will be appreciated<br/></p>
| asp.net | [9] |
673,398 | 673,399 | Reading file's content and writing to console | <p>I have a program which reads contents from a file and prints it on the screen. But program prints every other line i.e., skips every other line.
package InputOutput;</p>
<pre><code>import java.io.*;
public class CharacterFileReaderAndFileWriter{
private BufferedReader br = null;
private PrintWriter pw = new PrintWriter(System.out, true);
/* Read from file and print to console */
public void readFromFile() throws IOException{
try{
br = new BufferedReader(new FileReader("E:\\Programming\\Class files\\practice\\src\\InputOutput\\test.txt"));
}
catch(FileNotFoundException ex){
ex.printStackTrace();
}
String s = null;
do{
s = br.readLine();
pw.println(s);
}
while((s = br.readLine())!=null);
br.close();
}
/* Main method */
public static void main(String[] args) throws IOException{
CharacterFileReaderAndFileWriter cfr = new CharacterFileReaderAndFileWriter();
cfr.readFromFile();
}
}
</code></pre>
| java | [1] |
1,447,160 | 1,447,161 | How do i get text from one activity and put it on a button in another activity. | <p>I want to know how I can get the text from an edittext in Activity B and put that text on the button of Activity A. I want to make it so that when i press the "enter" button on activity b it will get the text of the edittext and replace the text of a button in activity A. I think its something like this </p>
<pre><code> public void pressEnter (View v){
EditText et = (EditText) findViewById(R.id.editText1);
String t = et.getText().toString();
Button p1_button = (Button)findViewById(R.id.button1);
p1_button.setText(t);
}
</code></pre>
<p>but i dont know how to get the ID of the button from activity A that I want to set the text to.</p>
| android | [4] |
4,657,298 | 4,657,299 | How to pass function as param to a class's local var | <p>How to pass function to a class as param then assign it to local class's var!</p>
<p>This is my scenario, can this be solved?</p>
<pre class="lang-php prettyprint-override"><code><?php
class a {
protected $var;
function __construct($fun) {
echo $fun('world'); // This is working perfect
$this->var = $fun;
}
function checkit($x) {
return $this->var($x); // This is not working [ Call to undefined method a::var() ]
}
}
$mth = 'mathm';
$cls = new a(&$mth); // result [ hello (world) ]
echo $cls->checkit('universe'); // <- not working as it fail
function mathm($i) {
return 'hello (' . $i . ')';
}
?>
</code></pre>
| php | [2] |
5,871,807 | 5,871,808 | Ideal way to encrypt user passwords | <p>I initially used MD5 when i first started out coding to hash user passwords.</p>
<pre><code> $password1 = md5($password);
</code></pre>
<p>After reading countless of pages with different opinions, what shall i be using? <code>crypt</code>,<code>SHA1</code>,<code>SHA256</code>... here is an example of how i revised code by using SHA1 and static salting.</p>
<pre><code>$salt = '324912343223942833294328432392';
$passwordarray = str_split($password,2);
$password1 = sha1($passwordarray[0].$salt.$passwordarray[1]);
//insert $password1 into database
</code></pre>
<p>when logging in and checking password..</p>
<pre><code>$salt = '324912343223942833294328432392';
$passwordarray = str_split($password,2);
$dbpasswordarray = str_split($dbpasswordarray,2);
$password = sha1($passwordarray[0].$salt.$passwordarray[1]);
$dbpassword = sha1($dbpasswordarray[0].$salt.$dbpasswordarray[1]);
if ($username==$dbusername&&md5($password3)==$dbpassword)
{
</code></pre>
<p>What shall i do to improve/change this code and make it more secure? .. can i have an example.. Shall i do dynamic salting and add a unique salt to each user in the database?</p>
| php | [2] |
4,710,064 | 4,710,065 | Reading integers from a file separated by space in java | <p>Input file containing integers will be like this:</p>
<pre><code> 5 2 3 5
2 4 23 4 5 6 4
</code></pre>
<p>So how would I read the first line, separate it by space and add these numbers to Arraylist1. Then read the second line, separate it by space and add the numbers to ArrayList2 and so on. (So Arraylist1 will contain [5,2,3,5] etc)</p>
<pre><code> FileInputStream fstream = new FileInputStream("file.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String data;
while ((data = br.readLine()) != null) {
//How can I do what I described above here?
}
</code></pre>
| java | [1] |
1,151,832 | 1,151,833 | ASP.NET: Static Class in App_Code | <p>If a static class is put in App_Code, does that imply only <strong>one instance</strong> will be created, shared by different http requests?</p>
<p>Or each request still brings one request?</p>
<p>Thanks.</p>
| asp.net | [9] |
4,425,051 | 4,425,052 | Looking for beginner Python project ideas to learn the language | <p>I've read through "Python for Dummies" and I'm ready to take the next step. I hear that practicing coding with the goal of creating something is the best way to learn. I'm a beginner in Python, and I'm looking for project ideas that I should attempt.</p>
<p>I'm looking to learn web app programming, so any project that would teach me this area would be greatly appreciated.</p>
<p>I'd also like to send my code to anyone who proposes a project for me so I could get feedback.</p>
| python | [7] |
584,581 | 584,582 | Covering a div with an image | <p>I'm writing a memory game, like <a href="http://www.mathsisfun.com/games/memory/index.html" rel="nofollow">concentration</a>. Using jQuery, how do I cover over the square but not lose the contents that are inside the div?</p>
| jquery | [5] |
83,723 | 83,724 | Storing button inside of php variable | <p>I have following code:</p>
<pre><code>$boxId = 1;
$explainationBox='<input type="button" id="<?php echo $boxId; ?>" value="send" onmousedown="javascript:callthis(<?php echo $buttonId; ?>);" class="button" />';
echo $explainationBox;
</code></pre>
<p>I am trying to save these values as html button inside of php variable explainationBox. But its not saving actual value of $boxId. It is just saving it as $boxId. As boxId is inside a for loop and will keep on changing. How can i do this?</p>
| php | [2] |
2,916,919 | 2,916,920 | android_listview | <p>I want to open a new activity when an item is clicked in listview. How to do this.?
Here is the code :</p>
<pre><code>package com.example.c_progams;
</code></pre>
<p>public class Second_listview extends ListActivity{</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second_listview);
setListAdapter (new ArrayAdapter<String>(this, R.layout.second_listview, type));
ListView list = getListView();
list.setTextFilterEnabled(true);
list.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
});
}
</code></pre>
<p>static final String[] type = new String[]{</p>
<pre><code>"Array", "Operator Overloading", "Inheritence", "Strings", "Pointers", "Files", "Misclaneous"
</code></pre>
<p>};</p>
<p>}</p>
| android | [4] |
722,130 | 722,131 | fast binary data conversion in Python | <p>What is the fastest method for converting a binary data string to a numeric value in Python?</p>
<p>I am using <code>struct.unpack_from()</code>, but am hitting a performance limit. </p>
<p>Context: an incoming stream is mixed binary and ASCII data. The ASCII data conversion is done in C though ctypes. Implementing the unpacking in C through ctypes yielded similar performance to unpack. My guess is the call overhead was too much of a factor. I was hoping to find a native C-like coercion method (however un-Pythonic). Most likely all of this code will need to move to C.</p>
<p>The stream is in network byte order (big-endian) and the machine is little-endian. An example conversion would be:</p>
<pre><code>import struct
network_stream = struct.pack('>I', 0x12345678)
(converted_int,) = struct.unpack_from('>I', network_stream, 0)
</code></pre>
<p>I am less concerned about handling the stream format, than the general case of binary conversion, and if there is even an alternative to <code>unpack</code>. For example, <code>socket.ntohl()</code> requires an int, and <code>int()</code> won't convert a binary data string.</p>
<p>Thanks for your suggestions!</p>
| python | [7] |
4,025,142 | 4,025,143 | PHP Proxy for getting other domain content | <p>Can I write a PHP file (index.php) that when someone point it browser to</p>
<p><a href="http://www.domain.org/some?params=a&b=1" rel="nofollow">http://www.domain.org/some?params=a&b=1</a></p>
<p>it returns the content of</p>
<p><a href="http://www.OTHERdomain.org/some?params=a&b=1" rel="nofollow">http://www.OTHERdomain.org/some?params=a&b=1</a></p>
<p>Should I use culr?</p>
| php | [2] |
2,604,885 | 2,604,886 | ANDROID. Emulate Hardware Keys with an IME. Doesn't work with Dialog and Spinner | <p>I have understand that the only way to inject KeyEvents in the Android System is to implement an Input Method.</p>
<p>I have created my IME with the purpose to control from remote the device.</p>
<p>I emulate the hardware keys using the method
<pre><code>private void keyDownUp(int keyEventCode) {
getCurrentInputConnection().sendKeyEvent(
new KeyEvent(KeyEvent.ACTION_DOWN, keyEventCode));
getCurrentInputConnection().sendKeyEvent(
new KeyEvent(KeyEvent.ACTION_UP, keyEventCode));
}
</pre></code>
in my class that extends InputMethodService.</p>
<p>It works fine until an AlertDialog, or the menu of a Spinner comes in foreground. Also the windows that appears when the Menu key is problematic.
My IME can't get focus on them, and the keyevents are sent to the activity behind them.</p>
<p>Using hardware keys, the Dialog get the focus and you can select the botton on the Dialog.
How can i emulate that, using the IME(or anything else)?</p>
| android | [4] |
1,252,163 | 1,252,164 | Styling textView externally | <p>I have number of text views which have the same attributes only the text changes... I believe there must be an easier way of defining them externally like style.xml or something? </p>
<pre><code> <TextView
android:layout_width="250px"
android:layout_height="100px"
android:textSize="13pt"
android:shadowColor="#000000"
android:shadowRadius="1"
android:shadowDx="1"
android:shadowDy="1"
android:textStyle="bold"
android:text="Look Up"
android:textColor="#084b7e" />
</code></pre>
<p>Tnx in advacne!</p>
| android | [4] |
2,313,375 | 2,313,376 | How do I parse a text file in Objective-C? | <p>I need to parse a text file, one line at a time. Also, is there EOF in Objective-C?</p>
| iphone | [8] |
632,010 | 632,011 | How do I modify gitstats to only utilize a specified file extension for it's statistics? | <p>The website of the statistics generator in question is:</p>
<pre><code>http://gitstats.sourceforge.net/
</code></pre>
<p>Its git repository can be cloned from:</p>
<pre><code>git clone git://repo.or.cz/gitstats.git
</code></pre>
<p>What I want to do is something like:</p>
<pre><code>./gitstatus --ext=".py" /input/foo /output/bar
</code></pre>
<p>Failing being able to easily pass the above option without heavy modification, I'd just hardcore the file extension I want to be included.</p>
<p>However, I'm unsure of the relevant section of code to modify and even if I did no, I'm unsure of how to start such modifications.</p>
<p>It's seems like it'd be rather simple but alas...</p>
| python | [7] |
507,596 | 507,597 | Load image from a stored png | <p>How does one load or fetch an image that was saved to disk?</p>
<p>I wrote the image to the documents filepath using NSData and a PNG representation. How does one get this image back? UIImage.</p>
| iphone | [8] |
1,171,788 | 1,171,789 | Passing a reference of a data collection into a click handler's callback function | <p>Here's how my code is structured at the time being:</p>
<pre><code>$.post('includes/getPeople.php', {char: character}, function(data) {
var peopleData = data.people;
//generation of HTML markup...
$("#peopleTable a.nameLink").live("click", function(e) {
var index = $(this).attr("title");
console.log(peopleData[index].Email);
alert(peopleData[index].Email);
e.preventDefault();
});
}
</code></pre>
<p>Whenever I click on a link (which is the name of the person in the database), I get this error: "peopleData is undefined". Is there a way I could fix this?</p>
<p>Thank you.</p>
| jquery | [5] |
5,230,787 | 5,230,788 | Java Socket exception | <p>I am trying to write a simple client server program in Java :-
Running both server and client code on the same machine...but while running getting an error :- </p>
<pre>java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.(Unknown Source)
at java.net.Socket.(Unknown Source)
at Requester.run(Requester.java:13)
at Requester.main(Requester.java:68)
Exception in thread "main" java.lang.NullPointerException
at Requester.run(Requester.java:45)
at Requester.main(Requester.java:68)</pre>
<p>Can anyone help!</p>
| java | [1] |
2,418,523 | 2,418,524 | How to call back from a function to a listener in android? | <p>OK, I have a login class like the snippet below</p>
<pre><code>public class LoginClass {
public void login() {
login.authorize(username,password);
//run activity specific code here
}
</code></pre>
<p>}</p>
<p>This class is quite generic, but depending on which activity calls LoginClass.login(), I would like different actions to be performed.</p>
<p>I've seen some implementation where a function is passed into the class and this function is then run on completion. Can anyone give me a brief example on how to do this.</p>
| android | [4] |
3,390,892 | 3,390,893 | Custom listview drawing | <p>I am trying to draw an overlay above my ListView. So i went with the most obvious approach and put my custom drawing code beneath super.onDraw(canvas) in my ListView subclass.</p>
<p>To my surprise the list was rendered above my custom drawing. I know this can easily be done by wrapping the ListView in a FrameLayout but i don't think it is neccesary to inflate another view. A fix and an explanation of why i ran into this problem would be awesome, thanks!</p>
<p>My draw code looks something like this:</p>
<pre><code>@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRect(rect, paint);
}
</code></pre>
| android | [4] |
556,429 | 556,430 | Modify constructor parameter values before calling base class constructor | <p>I have following class hierarchy:</p>
<pre><code>class Base { // This class cannot be modified
public:
Base(int a, int b, int c) {
if ( a == 100 && b == 200 && c < 100 ) // whatever condition
throw "Error!";
}
};
class Derived : public Base { // this class can be modified
public:
Derived(int a, int b, int c) : Base(a, b, c) {}
};
</code></pre>
<p>class Derived is used in many places in code, so it cannot be replaced with some kind of factory function.</p>
<p>now the question is if there is some construct that would allow me to fix a,b,c values before calling Base constructor?</p>
<p>I know I can use functions like:</p>
<pre><code> Derived(int a, int b, int c) : Base(FixA(a), FixB(b), FixC(c)) {}
int FixA(int a) { /*fix a value*/ return a; }
int FixB(int b) { /*fix b value*/ return b; }
int FixC(int c) { /*fix c value*/ return c; }
</code></pre>
<p>but it wont allow me to set correct values in case when a b c values are dependent like in above Base class c-tor example.</p>
<p>I was thinking of extending this to:</p>
<pre><code> Derived(int a, int b, int c) : Base(FixA(a,b,c), FixB(a,b,c), FixC(a,b,c)) {}
int FixA(int a, int& b, int& c) { /*fix a b c values*/ return a; }
int FixB(int& a, int b, int& c) { /*fix a b c values*/ return b; }
int FixC(int& a, int& b, int c) { /*fix a b c values*/ return c; }
</code></pre>
<p>I suppose there should also be some kind of flag indicating that fix was already done. I am not sure if this is actually correct c++.</p>
<p>I know the best solution is to actually catch exception.</p>
| c++ | [6] |
3,312,742 | 3,312,743 | if isset not set - php | <pre><code>if(isset($_POST['text1']) && isset($_POST['text2'])) {
echo "xxxxxx";
echo "yyyyyyyyyy";
} else {
?>
<form>
</form>
<?php
}
?>
</code></pre>
<p>When isset is not set I want the form shown and when submitted form not shown, using PHP. This code when ! isset is activated, form is not shown, is it coding or syntax error</p>
| php | [2] |
644,624 | 644,625 | Android - access microphone from web browser | <p>Is the a way to access a microphone from web browser?</p>
<p>I want to create a web site where i want to record a user.</p>
<p>Workarounds and suggestions will be very appreciated! :)</p>
| android | [4] |
4,086,386 | 4,086,387 | what happens in syntax of splobjectstorage? | <p>The below is example2 from php.net's splobjectstorage documentation.
The lines using $s[$o1] and $s[$o2] is syntax I'm not familiar with and haven't seen yet for objects (still learning)</p>
<p>Is this a standard way of fetching properties from an object that would work with any class I've created?</p>
<p>Is this instead using a magic method or additional programmed functionality to create this syntax for just this class?</p>
<pre><code><?php
// As a map from objects to data
$s = new SplObjectStorage();
$o1 = new StdClass;
$o2 = new StdClass;
$o3 = new StdClass;
$s[$o1] = "data for object 1";
$s[$o2] = array(1,2,3);
if (isset($s[$o2])) {
var_dump($s[$o2]);
}
?>
</code></pre>
<p><a href="http://php.net/manual/en/class.splobjectstorage.php" rel="nofollow">http://php.net/manual/en/class.splobjectstorage.php</a></p>
| php | [2] |
2,807,181 | 2,807,182 | extract GET parameters from a user inputed url with javascript | <p>I am looking to use javascript to extract the GET parameters from a user inputed url.</p>
<p>For example is a user enters a url say:</p>
<p><a href="http://www.youtube.com/watch?v=ee925OTFBCA" rel="nofollow">http://www.youtube.com/watch?v=ee925OTFBCA</a></p>
<p>I could get the v parameter</p>
<p>'ee925OTFBCA' as a variable</p>
<p>Thanks in Advance.</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.