Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,651,004
1,651,005
PHP fgetcsv error - How can I arrange it?
<p>I am getting the following error:</p> <p>"Notice: fgetcsv() [function.fgetcsv]: delimiter must be a single character" in my browser</p> <p>My PHP Code is as follows - can someone rearrange it please?</p> <pre><code>$fh = fopen('notes.txt', 'r') or die('Unable to open notes.txt'); while(($line = fgetcsv($fh, 0, '||')) !== FALSE) if ($line[0] == $name) { echo &lt;&lt;&lt;EOL My color is $line[2] EOL; break; // if there's only ever one '5678' line in the, get out now. } fclose($fh); </code></pre>
php
[2]
3,277,620
3,277,621
Android Business app development according to website Database
<p>I have a website in which orders, reviews, n new users are submitted. So i want to develop a android app to notify admin that user, android or reviews are submitted on to web site. So is it possible? If yes, can you please give me some brief answer about my question?</p>
android
[4]
6,001,386
6,001,387
Get image width of images in divs with jquery
<p>Is it possible to get the width of all images the divs and then set #content css to that value with jquery? Im using a horizontal layout for a project and need to add images from time to time. </p> <pre><code>&lt;div id="content"&gt; &lt;div class="entry"&gt; image image &lt;/div&gt; &lt;div class="entry"&gt; image image &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
3,877,310
3,877,311
JavaScript - I get an error in Firebug
<p>I am searching through a string trying to count the number of occurrences of @@ (two @ signs in a row). My code works well when the count is greater than 0, but I get an error in Firebug when the occurrence is zero.</p> <p>This throws an error:</p> <pre><code>var str = "This string has no at signs!"; var pcount = str.match(/@@/g).length; alert(pcount); var str = "This string has @@ one pair of signs!"; var pcount = str.match(/@@/g).length; alert(pcount); var str = "This @@ string has @@ two pairs of signs!"; var pcount = str.match(/@@/g).length; alert(pcount); </code></pre> <p>The error I get in Firebug is:</p> <pre><code>str.match(/@@/g) is null [Break On This Error] var pcount = str.match(/@@/g).length; </code></pre> <p>What I want is for pcount to be zero if no @@ is found.</p> <p>Can you help? </p> <p>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ANSWER</p> <p>I ended up using a combination of your answers. Thanks so much for your help!!!</p> <pre><code>var NewRows = getRowCount(ThisTextLen); var Match = ThisText.match(/@@/g); var ParagraphCount = 0; if (Match != null) { ParagraphCount = ThisText.match(/@@/g).length; NewRows = NewRows + ParagraphCount; } </code></pre>
javascript
[3]
5,492,629
5,492,630
Replacing variables in text with random values
<p>I have a block of text that contains a variable:</p> <pre><code>Hello my name is john #last# </code></pre> <p>I have 20 different last names in a array that can be used, how can I replace #last# with a random last name from the array? Meaning how can I read between the #'s and get "last" then use that to determine which array to grab from and input a random value</p>
php
[2]
5,900,436
5,900,437
Is it possible to determine if an object is being referenced by another object?
<p>I have a memory leak in my C# program and cannot determine who is holding the reference to my object. Is there a way at runtime to determine which objects are holding a reference to a specific object?</p> <p>In this economy my budget is zero, so a native or free solution is my only choice.</p>
c#
[0]
1,512,381
1,512,382
iPhone - defining a conditional variable without a method
<p>I have a file called myConstants.h that I use to put all the constants used by the app. This file is imported in any class that needs to access one of the variables.</p> <p>I am building a universal app and I have variables that I need to have different values if they are running on iPad or iPhone.</p> <p>I give you a generic example of what I mean.</p> <p>In my main code I may have something like:</p> <pre><code>self.DEVICE = @"iphone"; self.IPAD = NO; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { self.DEVICE = @"ipad"; self.IPAD = YES; } </code></pre> <p>But this is define on the main code. If I need a class to use one of these two variables I need to construct complex methods to reference the main class and read the variables there.</p> <p>My idea is to include this in <code>myConstants.h</code>.</p> <p>But how can I do that if myConstants.h is just a plain file where every line is a <code>#define</code> entry without any method?</p> <p>My idea is to have <code>DEVICE</code> and <code>IPAD</code> variables as globals for the entire app and make them available to any class by just <code>#import "myConstants.h"</code>.</p> <p>Is this possible? How?</p> <p>thanks</p>
iphone
[8]
4,040,966
4,040,967
XML parsing in android
<p>Hello I have parsed the xml file. now aim is to display contents using list view as dynamiclly.. How it is possible?</p>
android
[4]
3,426,042
3,426,043
Get the name of the variable which has the highest/biggest value with PHP
<p>I have 4 variables and each of those have an integer assigned to them. Could anybody please let me know how I can get the name of the variable which has the highest value?</p> <p>Thanks in advance.</p>
php
[2]
969,181
969,182
Error while printing a string at the console
<pre><code>for i in table.keys(): if table[i]==18798965: first=i if table[i]==12738624: second=i &gt;&gt;&gt; print ("the encyrpted word is: %s%s") %(first,second); the encyrpted word is: %s%s Traceback (most recent call last): File "&lt;pyshell#31&gt;", line 1, in &lt;module&gt; print ("the encyrpted word is: %s%s") %(first,second); TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple' </code></pre> <p>I think that the version of python at university is different than the one i'm using at home.</p> <p>Can anybody help me with this error?</p>
python
[7]
941,015
941,016
Creating of multiple instance of the same Activity?
<p>I am creating a chat application &amp; for that purpose i have used TabHost.</p> <p>In that first tab contains List of Buddies, and as soon as user clicks on any of the buddy </p> <p>from buddy it should create another tab for that buddy in order to chat.</p> <p>I am completed up to this but my problem is I am using a single Activity to perform Chat</p> <p>but It always shows the same activity for each buddy.</p> <p>Any Help will be highly appreciated. Here is my code,</p> <pre><code>public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { RosterEntry entry = List.get(position); String userName = entry.getName(); Intent intent = new Intent().setClass(RosterScreen.this, com.spotonsoft.chatspot.ui.ChatScreen.class); TabSpec tabSpec = Home.tabHost.newTabSpec("chat").setIndicator(userName).setContent(intent); Home.tabHost.addTab(tabSpec); } </code></pre> <p>Best Regards,</p> <p>~Anup</p>
android
[4]
5,297,402
5,297,403
How to make a connection between Android device and printers via USB
<p>I am trying to take a print of some pdf file from my android phone.I want to use cable to connect device with printer(USB port). </p> <p>How can I start to achieve this task? Are there any api's for doing this?</p> <p>I searched in SO but didnt find any thing.</p> <p>please help</p> <p>Thanks in advance</p>
android
[4]
1,246,328
1,246,329
How to write javascript to div that self executes
<p>My application is retrieving content from an XML file that has javascript in it. I am taking the javascript and placing it into my DOM, but the script is not executing.</p> <p>How do I write javascript onto my page that will then execute?</p> <p>My app goes something like this...</p> <pre><code>var javaScriptFromFile = getJS(); myDiv.innerHTML = javaScriptFromFile; //Next, how do I execute the javascript? //Can I make the javascript in the innerHTML self executing? </code></pre>
javascript
[3]
4,358,301
4,358,302
imageview not set full screen
<p>I set image view to full screen but it doesn't work: there is some space in between left and right side. How to set the <code>imageview</code> to full screen?</p> <p>this is my XML code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ImageView android:id="@+id/imageView" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;/ImageView&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
2,492,629
2,492,630
Pulling data from ELM327
<p>am developing an application where I can get data from ELM327 and display it on an android device.But I have a doubt,the ELM327 is not controllable,I mean it cant keep sending data automatically to the android device,so how would I be able to pull data from the ELM327.I am really stuck here.So help would be appreciated.Thank you!</p> <hr> <p>Can anyone help me with the type of commands I have to use in android to get responses from ELM 327?How would I only receive speed and rpm?How can I read that data and display it on the android device?</p>
android
[4]
487,030
487,031
Update rss feed with Informa?
<p>I am very new to using the Informa library. I cannot seem to figure out how to update my feed. </p> <p>Whenever I start my app for the first time it loads the feeds just fine. Then then I restart my app it loads the same (non-updated) feed.</p> <p>How do I force it to update every time I start the app?</p> <p>Here is my simple implementation:</p> <pre><code>ChannelIF channel = FeedParser.parse(new ChannelBuilder(), "URL_to_my_feed"); Set&lt;ItemIF&gt; posts = channel.getItems(); for (Iterator&lt;ItemIF&gt; it = posts.iterator(); it.hasNext();) { ItemIF entry = it.next(); System.out.println(entry.getDescription()); } </code></pre>
java
[1]
1,951,811
1,951,812
Difference between undefined and not being defined in Javascript
<p>See <a href="http://jsfiddle.net/FDhQF/1/" rel="nofollow">http://jsfiddle.net/FDhQF/1/</a> for a trivial example.</p> <p>What's the difference between something being undefined and something not being defined in Javascript? For instance, trying to access a property for an object (effectively, trying to access a variable) that isn't defined will return <code>undefined</code>. But you can also set something <code>= undefined</code>. When you do that, trying to access it still return undefined, but the pointer is still there. An example, as above, is how iterating over an object still goes over the property that you've (re)declared as undefined. It seems like there are two different sorts of undefined. Can anyone shed some light on the situation?</p>
javascript
[3]
2,611,991
2,611,992
2d games in openGL
<p>hai I am new to iphone development. I used NSTimer scheduledTimerWithTimeInterval 0.01 seconds for game loop. The game consists drawscreen function inwhich I use CGContextClipToRect to clip the large images for animation. But the speed 0.01 seconds is working in simulator only not in the iphone(device). How can i overcome this problem? I respect your reply......you have told about it in previous post. But i could not understand..... can anyone give tutorial to do this in openGL like (CGContextClipToRect in openGL),animation of 2d images,drawing,clipping etc,sample source code.....</p>
iphone
[8]
5,375,108
5,375,109
save object after installation
<p>I'm developing an app in with all functionalities are done over an object this object is constructed after heavy , time consuming data processing. This heavy processing is needed just once after installation and no more. How can I save this object in background in order not to construct it with each application lunch ? I mean I don't want to do this time consuming data processing each time user run the application</p>
android
[4]
881,240
881,241
what is the difference between calling function with () and without(). When we assign functions to variables?
<p>I want to know what is the difference , when we call function with round Brackets() and without brackets (). Suppose if i have a function like</p> <pre><code>function($) { var hideAnswers = function() { $('#faqGrid tr td').each(function(){ var $td = $(this); $td.children('div .answer').hide(); }); //end of $('#faqGrid tr td').each(fn) }; //end of var hideAnswers = function() {} var showMessage = function(message){ alert(message); }; //end of var showMessage = function(){} hideAnswers(); //working hideAnswers; // not working }(jQuery); // end of function($) { </code></pre> <p>The second one <strong>hideAnswers;</strong> is now working in this case. Also i want to ask when we assign function to variable and when we don't?</p> <p>Also suppose if i have a button, on click of which i want to call this function then how can we call it Like</p> <pre><code>&lt;input type="button" onclick = hideAnswers(); /&gt; // is it right? </code></pre> <p>And what if i also want to pass value to this function on my xhtml page. Like</p> <pre><code>&lt;input type="button" onclick = showMessage("what is your name "); /&gt; // is it right? </code></pre> <p>Thanks</p>
jquery
[5]
504,073
504,074
Modifying a JSON object by creating a New Field using existing Elements
<p>I have a javascript object that goes like this:</p> <pre><code>var obj = {"data": [ {"name":"Alan","height":1.71,"weight":66}, {"name":"Ben","height":1.82,"weight":90}, {"name":"Chris","height":1.63,"weight":71} ] ,"school":"Dover Secondary" } </code></pre> <p>How do I create a new field called BMI using weight/(height)^2 such that the new object becomes:</p> <pre><code>var new_obj = {"data": [ {"name":"Alan","height":1.71,"weight":66,"BMI":22.6}, {"name":"Ben","height":1.82,"weight":90,"BMI":27.2}, {"name":"Chris","height":1.63,"weight":71,"BMI":26.7} ] ,"school":"Dover Secondary" } </code></pre>
javascript
[3]
3,173,258
3,173,259
Removing the last digits in string
<p>I have a string that looks like this:</p> <pre><code>[APPLE PIE] Sei Shoujo Sentai Lakers 3 Battle Team Lakers 3 (100% FULL-PIC)_20121104_032834 </code></pre> <p>I want to remove the digits at the end of the string, basically the 16 digits at the end of the string. In the end it should look like this:</p> <pre><code>[APPLE PIE] Sei Shoujo Sentai Lakers 3 Battle Team Lakers 3 (100% FULL-PIC) </code></pre> <p>This is my code that I have written so far</p> <pre><code>var str="[APPLE PIE] Sei Shoujo Sentai Lakers 3 Battle Team Lakers 3 (100% FULL-PIC)_20121104_032834"; var n=str.substr(1,74); document.write(n); </code></pre> <p>The problem is the string will be different so each will have different amount of characters. So how I remove the digits at the end of the string in javascript?</p>
javascript
[3]
319,133
319,134
To get a value of a TD using JQuery
<p>I got a very simple Table with only two rows. <br/> I was thinking what is the best way to get the value from the TD with ID "row2".<br/></p> <pre><code>&lt;Table id="testing&gt; &lt;tr&gt; &lt;th&gt; &lt;/th&gt; &lt;td id="row1"&gt;hello&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt; &lt;/th&gt; &lt;td id="row2"&gt;world&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Here is my attempt:<br/></p> <pre><code>$(document).ready(function(){ var r=$("#testing":row2).val(); alert(r); }); </code></pre> <p>But I couldn't see any message pop up. What shall I do in the JQuery code if I want to specify the Table ID along with the TD ID?<br/></p> <pre><code> var r=$("#testing":row2).text(); var r=$("#testing").children("row2").text(); </code></pre>
jquery
[5]
4,706,384
4,706,385
enabling '&' and special characters in url
<p>How could i enable '&amp;' and some others specials characters like '*,@,%' in url without changing registry value to allow restricted characters in iis. Is there any solution that can be solved through web.config file in asp.net?</p>
asp.net
[9]
3,608,813
3,608,814
tictactoe and copying an array
<p>Hello I am working on a tic-tac-toe project on my own. I am not taking a programming class so its not homework. </p> <p>I have written pretty much the rest of the code and am now working on the AI. </p> <p>For the AI i am going to have it take a copy of the (2 dimensional array) and it check if it can win in a move, then if the player can, then if it can in 2 moves, then the player and so on, there are some other things i will include. So in order to do this i think i need to pass a copy of the array, but i am not sure how to copy an array. So that is basically my question, how do you copy an array? </p>
c++
[6]
1,302,448
1,302,449
How to construct multipledata in a excel cell using Java
<p>I am reading an excel sheet in netbeans using Java. In ONE CELL, i have multiple values in each line, like : 39N 98N 99N 12N and so on..</p> <p>I did this,</p> <pre><code>for (Row row : sheet) { if(row.getCell(0) != NULL) { ..... // get all the 4 values separately } } </code></pre> <p>I get all the 4 rows of data if its printed. But, how to get each row of data and store it separately?</p> <p>Thanks Ramm</p>
java
[1]
250,785
250,786
How to parse byte using bits value
<p>I have to get values from a byte saved in three parts of bit combination.</p> <p>Bit Combination is following</p> <p>| - - | - - - | - - - |</p> <p>first portion contains two bits Second portion contains 3 bits Third portion contains 3 bits </p> <p>sample value is</p> <p>11010001 = 209 decimal</p> <p>What I want is create Three different Properties which get me decimal value of three portion of given bit as defined above.</p> <p>how can i get Bit values from this decimal number and then get decimal value from respective bits..</p>
c#
[0]
2,029,609
2,029,610
problem with angles
<p>Hi this a part of my code : I have a list which its size is three and I consider that 2 last items are in one line (p and q) I need to get the angle between the first item of this list and these two points (p,q)</p> <pre><code> private Point partition(List&lt;Point&gt; list, Point p, Point q) { double x1 = p.getX(); double x2 = q.getX(); double y1 = p.getY(); double y2 = q.getY(); double pQ = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); for (int i = 0; i &lt; list.size()-2; i++) { double pointX = list.get(i).getX(); double pointY = list.get(i).getY(); double pointQ = Math.sqrt((x2 - pointX) * (x2 - pointX) + (y2 - pointY) * (y2 - pointY)); double pointP = Math.sqrt((pointX - x1) * (pointX - x1) + (pointY - y1) * (pointY - y1)); double angle = Math.acos((pQ * pQ - pointP * pointP - pointQ * pointQ) /(- 2 * pointP * pointQ)); System.out.println(angle); } </code></pre> <p>but instead of printing an angle for the first item it will print :(first item is not in the line of two last items).</p> <pre><code>1.6288442476732894 </code></pre> <p>those points that print this result are :</p> <pre><code>[X :143.0 Y: 217.0, X :93.0 Y: 163.0, X :193.0 Y: 165.0] </code></pre> <p>please help me thanks.</p> <p>EDITED : really it makes me confused .in such a way it will print this value ,sorry all !!!</p>
java
[1]
2,602,912
2,602,913
Datetime conversion in JavaScript or jQuery
<p>How to convert 10/jan/2010 to 10/01/2010 using JavaScript or jQuery</p> <p>Kindly help me</p>
javascript
[3]
5,038,643
5,038,644
How to make a countdown timer run in background in android?
<p>I am revoking a timer in android using intent now if i want to put that timer in a background when user clicks on directly back button then how do i do that? and then when i see background apps running it should be working and can be brought to front.</p>
android
[4]
2,588,990
2,588,991
Web Site Thumbnail?
<p>I posted a link of my website on facebook, but it uses an image for a thumbnail that I don't want(it is an image inside my website). How can I govern which thumbnail is used for my web site on any web page(facebook etc) ?</p> <p>Thank You</p>
asp.net
[9]
1,170,230
1,170,231
Why are certain elements of this python list ignored?
<p>I'm new to Python, and i'm struggling to understand the output of this simple program:</p> <pre><code>list = os.listdir(os.getcwd()) print(list) print() for element in list: print(element) if 'txt' not in element: list.remove(element) </code></pre> <p>Which gives me this output :</p> <pre><code>['examples_list.txt', 'generate_patterns.py', 'lehoczky_example_3.txt', 'patterns', 'test.py', 'test2.py'] examples_list.txt generate_patterns.py patterns test2.py </code></pre> <p>why are certain elements (such as 'lehoczky_example_3.txt'), ignored by the "for" loop?</p>
python
[7]
3,081,960
3,081,961
Python 3.1 books still directly applicable to learning Python 2.7?
<p>I need to learn Python (v2.7) for my job, and looking for the best intro book for professional programmers.</p> <p>I found (via amazon) that "The Quick Python Book" is the best, but it's for Python 3.1</p> <p>I know there's a lot of similarities in 2.7 and 3.1, and somewhere read that you can mostly use 3.1 syntax in 2.7 as a good "future practice".</p> <p>Can someone with experience please verify that a book for learning Python3 would still be directly applicable for 2.7?</p> <p>Thank you very much. </p> <p>edit: "The Quick Python Book" is for 3.1</p>
python
[7]
1,348,377
1,348,378
In ASP.Net, what is the difference between <%= and <%#
<p>In ASP.Net, what is the difference between <code>&lt;%= x %&gt;</code> and <code>&lt;%# x %&gt;</code>?</p>
asp.net
[9]
5,151,038
5,151,039
Android: dynamically change ActionBar icon?
<p>I would like to dynamically change the "home" icon in the ActionBar. This is easily done in v14 with ActionBar.setIcon(...), but I can't find anyway to accomplish this in previous versions. </p>
android
[4]
369,648
369,649
can not import the module deepcopy
<p>i've ran into this wierd error since few days where most of the applications/frameworks/modules will refuse to run , because of of the unavailability of the module deepcopy i can't understand why is that so ? </p> <pre><code> Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "/usr/lib/pymodules/python2.6/django/http/__init__.py", line 13, in &lt;module&gt; from django.utils.datastructures import MultiValueDict, ImmutableList File "/usr/lib/pymodules/python2.6/django/utils/datastructures.py", line 3, in &lt;module&gt; from django.utils.copycompat import deepcopy ImportError: cannot import name deepcopy </code></pre> <p>why is that so ? and how it can be fixed ? </p>
python
[7]
3,357,140
3,357,141
How to Inheried Interface methods through to the subclasses in C#
<p>I have:</p> <p>I:</p> <pre><code>public interface I { void Something(); } </code></pre> <p>A:</p> <pre><code>public class A : I { public void Something() { } } </code></pre> <p>B:</p> <pre><code>public class B : A { } </code></pre> <p>Why isn't B forced to implement (the decired) Something method, as expected?</p> <p>Do I really have to inheried I on all my B's(subclasses to A)?</p> <pre><code>public class B : A, I { public void Something() { } } </code></pre>
c#
[0]
409,134
409,135
How can I delete files in Python
<p>I have several *.dbf files in a folder. Their names are of 8 digits such as 00043232.dbf, 00458283.dbf, 32349999.dbf, 83721092.dbf, 12139999.dbf, 48729999.dbf, ...</p> <p>I want to delete files that end with 9999. So, in this case, I want to erase 32349999.dbf, 12139999.dbf, 48729999.dbf.</p> <p>I can I do that in Python?</p>
python
[7]
3,347,753
3,347,754
UTF-8 encoding vs Base-64 Encoding
<p>I want to encode a file it may be image or any pdf and send it to server. Which type of Encoding and decoding I have to follow. (Both server and client is in our company. we can write logic in both place). <strong>UTF-8 Encoding</strong> is by default supported in java. and to use <strong>Base-64</strong> encoding I have to import external jar. for simple texts both the ways are working fine. I am using tcp socket programming.</p> <p><strong>Using UTF-8 Encoding</strong></p> <pre><code>String str = "This is my Sample application"; String urlEncodedData = URLEncoder.encode(str, "UTF-8"); // Encoding with UTF-8 System.out.println("..after URL Encodingencoding..."+urlEncodedData ); String retrievedData = URLDecoder.decode(urlEncodedData , "UTF-8");// Decoding with UTF-8 System.out.println("..after decoding..."+retrievedData ); </code></pre> <p><strong>Using Base-64 (Using commons.codec jar of apache</strong></p> <pre><code>byte[] b =Base64.encodeBase64(str.getBytes()); //Encoding base 64 Base64.decodeBase64(b); // Decoding with Base 64 </code></pre>
java
[1]
2,868,155
2,868,156
How to check null condition for the boolean variable
<p>I have a class as shown </p> <pre><code>package com; public class Person { boolean registered; public boolean isRegistered() { return registered; } public void setRegistered(boolean registered) { this.registered = registered; } } </code></pre> <p>The Data to Person Object will be set based on the Data present in DB . The problem is that for older records the registered filed is not present . </p> <p>so i how can i test if the filed is present or not ??</p> <p>package com;</p> <pre><code>public class Test { public static void main(String args[]) { Person per = new Person(); if (per.isRegistered()) { } } } </code></pre> <p>How can i check if the per.isRegistered() field is present or not for that Person Object ??</p>
java
[1]
1,523,230
1,523,231
Native language problem in text() and html in jQuery
<p>There is native language problem text() and html in jQuery :</p> <pre><code>$("li p span").html(""); $("li.checked p span").html('çşğü : ' + myVar); </code></pre> <p>The output is not similar to html() and look like unknown characters.</p> <p>Im not using any serverside language and meta charset is <code>charset=utf-8</code>. How can I solve this problem. Thanks in advance</p>
jquery
[5]
2,356,901
2,356,902
How can I get the date and version of drivers in C#?
<p>This is my code, I can get name, description...</p> <pre><code>ManagementClass MgmtClass = new ManagementClass("Win32_SystemDriver"); foreach (ManagementObject mo in MgmtClass.GetInstances()) { name=mo["Name"]; Dis=mo["Description"]; ... } </code></pre> <p>How can I get the date and version of drivers?</p>
c#
[0]
2,277,264
2,277,265
Why we call always base class method like base.OnInit()
<p>Hi I am new in asp .net.I am not able to undestand why we call base class method when we override methods/events.Like automatically visual studio will put base.OnInit() if you are overriding OnInit.</p> <pre><code> protected override void OnInit(EventArgs e) { base.OnInit(e); } </code></pre> <p>same is the case of Finalize. In derived we call base.Finalize()</p> <p>Is there any need of calling these base class methods ?</p> <p>Thanks</p> <p>Ritu</p>
asp.net
[9]
2,437,919
2,437,920
webView loads in simulator but not on the device
<p>The following line works in the device and simulator just fine:</p> <pre><code>[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.myURLgoesHere.com"]]]; </code></pre> <p>The following lines (in various versions) works fine in the simulator, but won't load the page in the device. Any Suggestions?</p> <pre><code>NSURL *tempURL = [NSURL URLWithString:[SharedClass sharedSharedClass].myURL]; // myURL is a NSString in my shared class [webView loadRequest:[NSURLRequest requestWithURL:tempURL]]; </code></pre> <p>Why would this quit working when I go from a hardcoded string to my shared string? The shared string works fine in other views and even gets stored to a plist file just fine.</p>
iphone
[8]
834,608
834,609
How can I get the next (x) number of children/siblings of a particular element in jQuery?
<p>This is just an illustrative example, but say I had a list of divs containing elements:</p> <pre><code>&lt;div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;/div&gt; </code></pre> <p>My aim is to run a loop that goes through each div, gets the first 2 children and applies a particular CSS class to them.</p> <p>How would I go about achieving this?</p> <p><em>Note that this might not necessarily be two elements, at a later date it may become the first ten elements (or more).</em></p>
jquery
[5]
4,689,076
4,689,077
Calculate with Integers
<p>So I got to a site where it says Integers don't allow Calculate with it, + - * / % ^ etc.</p> <p>But I tried </p> <pre><code>Integer n=new Integer(8); n+=2; Integer m=new Integer(10); System.out.println(n+m); </code></pre> <p>and it prints out 20. So I am a little confused. I know this is a noob question but I really want to get this and I don't know what I am missing. So what does this actually mean "integers don't allow calculate with it"</p> <p>Thanks.</p> <p>EDIT: @people request :<a href="http://mindprod.com/jgloss/intvsinteger.html" rel="nofollow">Site providing accurate information?</a></p>
java
[1]
2,008,096
2,008,097
how to get songs from sd card and store the songs in database
<p>how to get songs from sd card and i have to store the songs in database and play the song. how to do that please assist me. how to store the songs from sd card to database.</p>
android
[4]
1,089,951
1,089,952
jQuery using .html & then window.scrollTo
<p>I'm doing the following:</p> <p>First, inject HTML into the page (a lot) which then increases the window scrollbar:</p> <pre><code>$("#XXXX").html("LOTS OF HTML").show(); </code></pre> <p>Then i want to scroll down to the end of the page:</p> <pre><code>window.scrollTo(0,$(document).height()); </code></pre> <p>Problem is the page never scrolls down. I did some console.logging and the scrollTo is running before the HTML from the inject html() is run. I tried this in the JS which injects the HTML, I then tried doing the scroll inside the HTML inject but that made no difference.</p> <p>Any ideas?</p>
jquery
[5]
3,066,366
3,066,367
Using existing cookies from outside the browser
<p>Ii want to download a file from site that need to be log-in. </p> <p>So i think if i use my browser to log-in and store cookie on hdd.</p> <p>Is it possible to download file with that cookie ?</p> <p>(its impossible to get cookie with program, anti-bot, etc)</p>
c#
[0]
1,317,206
1,317,207
If statement wont execute even though evaluation is true
<p>In the following code, the block under <code>if(timesout[entry] == "exit")</code> will never execute. I have verified <code>timesout[entry]</code> for the current loop is set as "exit" in debugging mode, as well as by printing out the variable before the if statement is evaluated, but no matter what, the block never executes when I enter <code>exit</code> at the prompt, and I am stumped as to why.</p> <pre><code>import java.util.Scanner; public class timetracker { public static void main(String args[]) { boolean exit = false; String[] reasons = new String[30]; String[] timesout = new String[30]; String[] timesin = new String[30]; int entry = 0; Scanner keyinput = new Scanner(System.in); recordloop: while(exit == false) { //record info System.out.println("Enter time out:"); timesout[entry] = keyinput.nextLine(); if(timesout[entry] == "exit") { exit = true; break recordloop; } System.out.println("Enter reason:"); reasons[entry] = keyinput.nextLine(); System.out.println("Enter time in:"); timesin[entry] = keyinput.nextLine(); entry = entry + 1; } System.out.println("Times away from phone:\n ----- \n"); int count = entry; entry = entry + 1; while(count &lt; entry) { System.out.println(reasons[count] + ": " + timesout[count] + " - " + timesin[count] + "\n"); count = count + 1; } } } </code></pre>
java
[1]
5,810,551
5,810,552
get Idictionnary from Ilist
<p>How to get a IDictionnay form a IList </p>
c#
[0]
2,433,202
2,433,203
How to add Tabs in the mid of screen
<p>I would like to know, how can i add Tabs in the mid of screen of Android. I am using Actionbarsherlock to get the look and feel of ICS. Here i can add tabs on top or at the bottom. </p> <p>Is there any way or sample example you know to add tabs in the middle of screen.</p>
android
[4]
1,090,013
1,090,014
what is the [object Window]?
<p>Google Translate, has some bookmark let for translate with 1 click, for example:</p> <pre><code>javascript:var t=((window.getSelection&amp;&amp;window.getSelection())||(document.getSelection&amp;&amp;document.getSelection())||(document.selection&amp;&amp;document.selection.createRange&amp;&amp;document.selection.createRange().text));var e=(document.charset||document.characterSet);if(t!=''){location.href='http://translate.google.com/?text='+t+'&amp;hl=en&amp;langpair=auto|en&amp;tbb=1&amp;ie='+e;}else{location.href='http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&amp;hl=en&amp;langpair=auto|en&amp;tbb=1&amp;ie='+e;}; </code></pre> <p>This javascript code, opens the translator page in the current page (target=_self), but I want it opens a new window (tab) for translate. so changed to:</p> <pre><code>javascript:var t=((window.getSelection&amp;&amp;window.getSelection())||(document.getSelection&amp;&amp;document.getSelection())||(document.selection&amp;&amp;document.selection.createRange&amp;&amp;document.selection.createRange().text));var e=(document.charset||document.characterSet);if(t!=''){window.open('http://translate.google.com/?text='+t+'&amp;hl=en&amp;langpair=auto|en&amp;tbb=1&amp;ie='+e);}else{window.open('http://translate.google.com/translate?u='+encodeURIComponent(location.href)+'&amp;hl=en&amp;langpair=auto|en&amp;tbb=1&amp;ie='+e);}; </code></pre> <p>My problem is here: when I run that code, it opens a new window for translate, and do it; but the non-english page content replaced with <code>[object Window]</code>, but I don't want to change original page content ... </p> <p>What Can I DO?</p> <p>Thank you ..</p>
javascript
[3]
1,499,593
1,499,594
How can we open a jpeg or an audio file in a c++ program
<p>I'm working on a C++ project. I need to include a .jpg file in my program and then display it on the output screen. For that we need to first read the data from the file. But i'm not getting that how to actually code the whole thing. Please help me.</p>
c++
[6]
1,779,291
1,779,292
What does this syntax mean?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1771786/question-mark-in-javascript">Question mark in JavaScript</a> </p> </blockquote> <p>I've seen this around a few times but I never knew what it meant. What is the name of it and how does it work?</p> <p>Here is the example I saw:</p> <pre><code>input.checked = input.type == "radio" ? true : false; </code></pre>
javascript
[3]
530,327
530,328
How to write c++ functions by returning parameters?
<p>Need help in figuring out how to write function and returning parameters. Wrote the question below and answer from solution manual, not sure how to write the function though very confused :( </p> <p>Here's what I've tried:</p> <pre><code>#include &lt;iostream&gt; using namespace std; char Answer; void max(); void main () { int max(int num1, int num2) { if (num1 &gt; num2) return num1; else return num2; } print(); system("pause"); } </code></pre>
c++
[6]
2,399,159
2,399,160
Trimming string removes more than needed
<p>The below code is meant to trim my string. Unfortunately it's removing more than the 'conf' value.</p> <p>Did I do this correctly?</p> <p>What this is doing is adding a double html response address, so i'm removing the first url which is 'conf'</p> <pre><code>String pageIdUrl = response.getRedirectUrl(); if(pageIdUrl.startsWith(conf.toString())); { pageIdUrl = pageIdUrl.substring(conf.toString().length()); } </code></pre>
java
[1]
5,502,189
5,502,190
i can't understand "key=>value" this code in php?
<p>I got a question about the "$key => $value" in the code below... I looked it up in google but it didn't returned any results.. All I know is that "=>" is used in arrays like x = array('a' => 'b'). </p> <pre><code>function _stripslashes_rcurs($variable,$top = true) { $clean_data = array(); foreach($variable as $key =&gt; $value) { $key = ($top) ? $key : stripslashes($key); $clean_data[$key] = (is_aray($value)) ? stripslashes_rcurs($value, false) : stripslashes($value); } return $clean_data; } </code></pre> <p>thank you for your help</p>
php
[2]
2,037,810
2,037,811
Error in my existing android project
<p>error:</p> <p>The project was not built due to "Resource already exists on disk: '/Project/bin/default.properties'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent Project Unknown Java Problem</p>
android
[4]
3,307,437
3,307,438
C# ISerializable question
<p>I am planning to use serialization to do clone. I have to make my class ISerializable. But how about its super classes and all referenced variable classes? do I need to make them all ISerializable?</p> <p>If I use ISerializable. I have to implement the GetObjectData(), what I should put inside that method? leave it empty is ok?</p>
c#
[0]
2,626,324
2,626,325
upload or copying files / deleting
<p>I am using a file in my main folder, httpdocs to execute this operations ( php ) on a "subdomain" folder that is outside the main folder.</p> <p>The problem is I can't copy files, delete into that folder... the following error appears:</p> <blockquote> <p>Warning: opendir() [function.opendir]: open_basedir restriction in effect. File(../ppp) is not within the allowed path(s): in / on line 25</p> <p>Warning: opendir(../ppp) [function.opendir]: failed to open dir: Operation not permitted in on line 25</p> </blockquote>
php
[2]
2,266,148
2,266,149
jet.OLEDB.4.0 provider Error that i get
<p>i try to install my C# program on Windows 7 64bit</p> <p>i installed Access too</p> <p>and i got this error:</p> <pre><code>The Microsoft.jet.OLEDB.4.0 provider is not registered on the local machine </code></pre> <p>that can be the problem ?</p> <p>thank's in advance</p>
c#
[0]
3,365,464
3,365,465
How to list all media in Android?
<p>I'm building a specialized media player for android and need a way to select a song from the device. I like how the builtin music player groups everything by artist/album, is that something I would have to write or is there something I can just plug in to get that functionality for free? </p> <p>What is the easiest way to list music files on the phone with some basic grouping by the idtag info?</p>
android
[4]
3,602,825
3,602,826
Javascript - SendKeystrokes
<p>Is there a way I can send a key stroke to the browser from JavaScript? For example: I would like to trigger the key F11 through JavaScript so that my browser goes to theater mode.</p>
javascript
[3]
534,992
534,993
convert array to string in javascript
<p>I want the text to be printed without commas.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Reverse&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="rev"&gt; Enter the string : &lt;input type="text" name="str"/&gt; &lt;input type="button" value="click" onclick="rev1()" /&gt;&lt;br&gt; reverse of given string : &lt;input type="text" name="res"/&gt; &lt;/form&gt; &lt;script type="text/JavaScript"&gt; function rev1(){ var a=rev.str.value; var b=[]; var i,j=0; for(i=a.length-1;i&gt;=0;i--){ b[j]=a[i]; j++ } //rev.res.value=b; alert(b); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>If I give the input as <code>abc</code> I am getting an output as <code>c,b,a</code>, but I want it as <code>cba</code>.</p>
javascript
[3]
4,937,319
4,937,320
Using this() in code
<p>I am new to CSharp.I have seen "this()" in some code.My question is Suppose if i call</p> <p>Paremeterized constructor ,am i invoking the paremeterless constructor forcefully?.But According to constructor construction ,i believe parameterless constructor will be executed first.Can you please explain this with simple example so that i can get exactly when should i call "this()".Thanks in advance.</p> <pre><code> public OrderHeader() { } public OrderHeader(string Number, DateTime OrderDate, int ItemQty) : this() { // Initialization goes here .... } </code></pre>
c#
[0]
3,375,979
3,375,980
Filter duplicated items from enumerable
<p>I have an unordered enumeration that may contain duplicates, and I want to remove ALL items that have duplicates, and keep only those that occur only once in the original enumeration.</p> <p>Example: A and C are removed since they occur more than once:</p> <p>input {A,C,B,A,C,D,A}<br> output {B,D}</p> <p>A quick and dirty implementation could be:</p> <pre><code>IEnumerable&lt;T&gt; Filter(IEnumerable&lt;T&gt; items) { items.Where(item =&gt; items.Count(x =&gt; x.Equals(item)) == 1); } </code></pre> <p>Obviously not quick or elegant. </p> <p>The example below is still quadratic (slightly faster), but requires a ToList() call on the input. </p> <pre><code>IEnumerable&lt;T&gt; Filter(IEnumerable&lt;T&gt; items) { List&lt;T&gt; src = items.ToList(); for(int i=0; i&lt;src.Count; i++) { if (src.IndexOf(src[i], i+1) &lt; 0) yield return src[i]; } } </code></pre> <p>How would you do this if you wanted it to be reasonably compact and readable (code wise) while still not brain-dead slow like these implementations?</p>
c#
[0]
834,407
834,408
array_unique causing undefined offset error
<p>I have been trying to use array_unique to remove duplicates from the search results I am populating. However, I am getting an undefined offset error. I was wondering if anyone knows what is causing this error and what I can do to fix it? As you can see below I am populating search results from two different places and trying to merge all matches into one array.</p> <p>Before array_unique: Array ( [0] => Bob Marley Footwear [1] => Bob Marley Footwear [2] => DVS Shoe Co. )</p> <p>After array_unique: Array ( [0] => Bob Marley Footwear [2] => DVS Shoe Co.)</p> <p><strong>Note:</strong> this causes an error message to appear when trying to access array slot 1 when iterating through array, to print out the results.</p> <pre><code> $results = mysql_query("SELECT keywords,name FROM files WHERE MATCH (keywords,name) AGAINST ('$searchfor')") or die(mysql_error()); $matches=Array(); $matches_final=Array(); while($row = mysql_fetch_array($results)){ $matches[] = $row['name']; } $matches_final = array_unique($matches); $results1 = mysql_query("SELECT name FROM files"); while($row1 = mysql_fetch_array($results1)){ $temp = explode(" ", $row1['name']); for($z=0; $z &lt; sizeof($search_words); $z++){ for($i=0; $i &lt; sizeof($temp); $i++){ if(((strcmp(strtolower($search_words[$z]), strtolower($temp[$i])))==0) and strlen($search_words[$z])&lt;=5){ $matches_final[] = $row1['name']; } } } } return $matches_final; </code></pre>
php
[2]
3,628,940
3,628,941
Is document.location.protocol ever invalid?
<p>I want to construct URLs with the same scheme (presumably, "http:" or "https:") as the page that loaded the currently-running JavaScript. Modern browsers support simply omitting the scheme (for example, <code>src="//example.com/test.js"</code>), but this isn't fully cross-browser compatible. (I've read that IE 6 is the only browser that doesn't support it, but I still need compatibility with that version.)</p> <p>The cross-browser way to do this seems to be to check <code>document.location.protocol</code>. For example, Google Analytics uses:</p> <pre><code>('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + ... </code></pre> <p>In Google's case, they wanted to use different domains depending on whether the request uses SSL, so that pattern makes sense. But I've seen others use the same pattern when only the scheme is changing:</p> <pre><code>('https:' == document.location.protocol ? 'https:' : 'http:') + "//example.com" </code></pre> <p>(One example is in the "Final Wufoo Snippet" at <a href="http://css-tricks.com/thinking-async/" rel="nofollow">http://css-tricks.com/thinking-async/</a>.)</p> <p>I'd prefer to use this simpler expression instead:</p> <pre><code>document.location.protocol + "//example.com" </code></pre> <p>Should I really be concerned about the possibility of <code>document.location.protocol</code> taking on some value other than "https:" or "http:" when my code is used on sites I don't control?</p>
javascript
[3]
284,455
284,456
Preload & Cache Images then Delete Older Images from Cache
<p>I'm building an Android app that displays a series of images. </p> <p>I want to preload the images in the background and put them in the cache. </p> <p>When a user sees an image, there is no need to continue caching the images since the user cannot go back to it so I want to remove them from the cache.</p> <p>Can anybody point me to web sites related to this?</p> <p>Thanks.</p>
android
[4]
4,038,181
4,038,182
cufon is not a function
<p>Offff dont understand why I get cufon.font is not a function error. I followed all the instructions at its website.</p> <pre><code>&lt;script type="text/javascript" src="js/cufon-yui.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/Futura_Lt_BT_400.font.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { Cufon.replace('.starter .content'); } &lt;div class="starter"&gt; &lt;div class="image-1"&gt; &lt;div class="wrapper"&gt; &lt;div class="content"&gt;Family guy funny show.&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="image-2"&gt; &lt;div class="wrapper"&gt; &lt;div class="content"&gt;Family guy funny show.&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- &lt;img src="images/logo_fg.png" alt="Logo" class="logo" /&gt; --&gt; &lt;/div&gt; </code></pre> <p>Website is at <a href="http://www.pangeaadvisors.org/IDC/" rel="nofollow">http://www.pangeaadvisors.org/IDC/</a></p> <p>Any suggestion appreciated!</p>
jquery
[5]
3,840,029
3,840,030
ConfigParser and 2 config files
<p>I want to split my config file to 2 config files: common.conf and particular.conf. It's possible parse 2 config files as one config ?</p>
python
[7]
601,563
601,564
Are the following structs the same type?
<p>I have a struct defined as the following:</p> <pre><code>typedef struct { string foo; } A, B; </code></pre> <p>I also have a set of functions as follows:</p> <pre><code>void Init(A *p) { p-&gt;foo; } void Init(B *p) { p-&gt;foo; } </code></pre> <p>The gcc complains that Init is being redefined. Can I simply delete the second Init function? Is A the same type as B?</p>
c++
[6]
3,009,112
3,009,113
iPhone:Google Maps and pin
<p>I am developing a map screen. I want to have a pin on the place of map, when particular latitude and longitude is selected. Also, clicking on a pin, it has to show an small view with some labels. Please share me some sample, so i can read and make us it.</p> <p>Thank you!</p>
iphone
[8]
2,928,368
2,928,369
Calling Method represented by string
<p>I am being passed a string similar to below.</p> <pre><code>"Users_Controller.login" </code></pre> <p>"Users_Controller" represents the object below. And "login" a method within it.</p> <pre><code>var Users_Controller = ( function () { return{ login : function(vo, callback) {......} } })(); </code></pre> <p>Given only the string as a pointer,is it possible call the method?</p>
javascript
[3]
5,967,953
5,967,954
get the values of a form field and save in database
<p>I have a form in which i use two dimensional array for field names.The fields names are below</p> <p>myform[message][]</p> <p>myform[name][]</p> <p>myform[add][]</p> <p>it means there are three arrays.Every array has arrays inside it.when i var_dump my form after putting values and submitting it.I get the below structure of 2d array.</p> <pre><code>array ''message'' =&gt; array 0 =&gt; string 'adnan' (length=5) 1 =&gt; string 'khan' (length=4) 2 =&gt; string 'salman' (length=6) ''name'' =&gt; array 0 =&gt; string 'khan' (length=4) 1 =&gt; string 'kamran' (length=6) 2 =&gt; string 'khan' (length=4) ''add'' =&gt; array 0 =&gt; string 'asad' (length=4) 1 =&gt; string 'khan' (length=4) 2 =&gt; string 'abrar' (length=5) </code></pre> <p>As you can see the associative array.I want to store the values of message,name and add in a database table having three fields to store the values of message,name and add fields in a single query by using some loop like foreach. when i use this code</p> <pre><code>foreach($_REQUEST['myform'] as $val) foreach($val as $v) { echo $v; } </code></pre> <p>I get all the values of the array.But i think i am unable to save it to database table</p> <p>as all the values are in the variable $v.How to store message in a message field,name in name field and add in an add field in a table of a db.</p> <p>please advice.Thanks</p>
php
[2]
2,930,650
2,930,651
Image on every page in iPhone application
<p>How can I add an image to the top of every page in an iPhone application?</p>
iphone
[8]
1,255,676
1,255,677
Showing of image in a word doc
<p>I am trying to convert HTML to WORD file. Able to convert text and download it, but unable to insert image in word file.</p> <p>I tried by giving physical path of image. Then image is included, but if the file is moved (downloaded in another system), then image is not displayed.</p> <p>How to include image in word file without using COM?</p> <p>Thanks in advance.</p>
php
[2]
3,536,523
3,536,524
onActivityResult() will not be called if call for camera
<p>My simple structure:</p> <ul> <li>List.java (Activity A)</li> <li>New.java (Activity B)</li> </ul> <p>Steps:</p> <ol> <li>Start A and use <code>startActivityForResult()</code> to turn to B by a button.</li> <li>Then in B, use <code>Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);</code> and <code>startActivityForResult()</code> to take a photo by call up camera.</li> <li>After that, <code>onActivityResult()</code> in B is called. Then I click a button to set a resultcode and close B.</li> </ol> <p>However, B is closed, but <code>onActivityResult()</code> in A is never called.</p> <p>If I skip the step to take a photo, click a button to set a resultcode and close B. <code>onActivityResult()</code> in A will be successfully called.</p> <p>I'm just confused about these two situations. Please anyone tell me why the first situation happens?</p> <p>Thank you very much.</p>
android
[4]
4,364,785
4,364,786
Backend server for Android clients - Possible to verify that the customer has bought the application?
<p>Scenario: Server providing a rest-api to Android clients. There are no subscriptions involved, but customers have to pay for the application in order to get access to the rest-service. </p> <p>Does Google offer an API the back-end server can use to query Google whether the given client has paid for the application? Perhaps by forwarding an installation / purchase id from the client? </p>
android
[4]
1,173,727
1,173,728
using jquery function to change tab selected
<p>is it possible to add a .click event inside a function which is called when something happens. </p> <p>for example if some one clicks a button other than the tab navigation that button function will change the select tab.</p> <p>how can I add it to this function function() { }</p>
jquery
[5]
3,710,508
3,710,509
Forms with a variable number of fields
<p>I'm attempting to create a sort of marketplace. Each item on the market has a type (i.e. the item being sold), a value, a quantity, a seller name, and an id, and all of this information is stored in a MySQL database.</p> <p>When the user views the market, all entries in the market are returned. In addition, an input text field appears at the end of each entry. The user can enter any number between leaving it blank (0) and the max quantity available.</p> <p>My problem is that since each input field is the result of a while loop of unknown iterations, I can't simply hard code a name into each field. I've tried using a counter variable to keep track and make names, but it doesn't seem to be working. For example: <code>name='.$i++.'</code></p> <p>On a related note, in order for the program to work, each field needs to send two values - the id (which I can use to look up the rest of the entry's values) and the quantity that the user wishes to purchase. I've been doing this with a hidden field before the input quantity field. I'm not sure if this is a good way of going about this, but I should note that there's no need as far as I can tell for the id to be kept secret.</p> <p>Just so everything's clear, here's a basic UI mockup: <a href="http://img850.imageshack.us/img850/2654/marketui.jpg" rel="nofollow">http://img850.imageshack.us/img850/2654/marketui.jpg</a></p> <p>Note that the column starting with consists of user inputted values (i.e. the 100s are the values of user-inputted text fields). The hitch is that while there are 2 rows in this example, the actual number is not deterministic, and so I can't hard code names for each input field.</p>
php
[2]
1,273,093
1,273,094
Downloading Android source code
<p>I am new to Android. I wanted take a look at the Andriod source and started the download process. I am having a problem in initialising the repo. I am getting a below error:</p> <pre><code>$ repo init -u https://android.googlesource.com/platform/manifest Traceback (most recent call last): File "/bin/repo", line 685, in &lt;module&gt; main(sys.argv[1:]) File "/bin/repo", line 652, in main _Init(args) File "/bin/repo", line 184, in _Init _CheckGitVersion() File "/bin/repo", line 209, in _CheckGitVersion proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) File "/usr/lib/python2.6/subprocess.py", line 633, in __init__ errread, errwrite) File "/usr/lib/python2.6/subprocess.py", line 1139, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory </code></pre>
android
[4]
2,150,478
2,150,479
How do I get the current screen cursor position?
<p>My objective is to get current position on the screen (out side the form), and save X, Y coords by press "C" for example. </p> <p>I google and found some suggestion to use api hooks, but i wonder are there a way we can do this task purely in C# code (.NET Lib) ? </p> <p>Please give me quick sample if possible because im new to c#.</p> <p>Thanks</p>
c#
[0]
3,367,991
3,367,992
Basic Java - Please help a stressed noob with a method?
<p>My name's Ali, I have just started two units of study with the Open University, so I am entirely fresh-faced to Java. I am trying to get the following code to compile but the lack of support i'm getting from my tutor is horrendous and the several books I have splayed out across my room aren't helping me get going.</p> <p>I have been given a method that I wish to answer some questions about:</p> <pre><code>public char[] methodA() { char[] alphas = {'s', 't', 'e', 'a', 'm'}; char temp = alphas[0]; int i = 0; while (i &lt; alphas.length - 1)//1 { alphas[i] = alphas[i+1]; //2 i++; } alphas[alphas.length-1]=temp; return alphas; } </code></pre> <p>How do I get this to compile successfully using my IDE? I have tried just enclosing it within the syntax for my 'main' method but it's not accepting it.</p> <p>Here is what I have at the moment:</p> <pre><code>package openuniversity; public class Main { public static void main(String[] args) { public static char[] methodA() { char[] alphas = {'s', 't', 'e', 'a', 'm'}; char temp = alphas[0]; int i = 0; while (i &lt; alphas.length - 1)//1 { alphas[i] = alphas[i+1]; //2 i++; } alphas[alphas.length-1]=temp; return alphas; } } } </code></pre> <p>Thanks to anyone who can help. Ali</p>
java
[1]
2,539,715
2,539,716
How to configure interactive python to allow blank lines inside methods
<p>Is it possible to test methods inside interactive python and retain blank lines within them?</p> <pre><code>def f1(): import random import time time.sleep(random.randint(1, 4)) </code></pre> <p>This gives the familiar error</p> <pre><code>IndentationError: unexpected indent </code></pre> <p>So, yes a workaround is to remove all blank lines inside functions. I'd like to know if that were truly mandatory to be able to run in interactive mode/REPL.</p> <p>thanks</p>
python
[7]
1,031,630
1,031,631
In c++ how can I make class to recognize structures without including the header?
<p>Hello I have class AA.h and inside I have defined structure: </p> <pre><code>#include "BB.h" Struct foo{ }; Class AA { … void funa() { BB bb; foo f; bb.func(f); } …. }; </code></pre> <p>My question is do I have to include the AA.h also in the BB.h file so it will recognize the foo struct or there is something else I can do ?</p>
c++
[6]
2,533,271
2,533,272
Exposing namespace from an assembly in C#
<p>I have a C# project which has a namespace A. The output of the project is a library(dll). When I try to add a reference to this dll file from another project, I am not able to see the namespace A present in the dll. Is there anything that I should do while creating the dll file so as to see the namespace? Please help me in this regard at the earliest.</p> <p>Thanks, Rakesh.</p>
c#
[0]
2,865,029
2,865,030
How to set onTouchEvent on Bitmap image using canvas.
<p>i'm new in android development. I wanted to set onTouchEvent particularly for an image. so that i can do some work ,like increase score etc....</p> <p>Here is the sample code i tried..</p> <pre><code> @Override protected void onDraw(Canvas canvas) { canvas.drawBitmap(image1, random.nextInt(455), random.nextInt(270), paint); canvas.drawText("SCORE = "+score, 10, 20, paint); } @Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub if(toggelFlag) { score = score+10; } return super.onTouchEvent(event); } </code></pre> <p>Actually i wanted to increase the score once i touch the image only. But here if i touch anywhere in the screen its increase the score. I want it for image only.</p>
android
[4]
1,393,462
1,393,463
Errors on uploading file images to server
<p>I want to upload file images to server but I get errors. I can't identify the problem</p> <p>I use this line of code to upload using asp.net <code>fileupload</code> control </p> <pre><code>FileUpload1.PostedFile.SaveAs(Server.MapPath("products_images/") + FileUpload1.PostedFile.FileName); </code></pre>
asp.net
[9]
80,131
80,132
String comparison C++
<p>I want to check <code>szDir</code> in <code>szSelectedDir</code>. I want the function to consider the below inputs are different. My sample function is not handling the scenario, please let me know the good solutions.</p> <pre><code>string szSelectedDir ="C:\\Windows1\Test"; string szDir="C:\\Windows"; void IsWindowsDirectory(const string szSpecialPath, const string szSelectedPath) { if(szSelectedPath.compare(szSpecialPath) == 0) { printf("Both paths are same "); } else if(szSelectedPath.find(szSpecialPath) != string::npos) { printf("Both paths are same "); } else { printf("Both paths are different "); } } </code></pre>
c++
[6]
3,272,320
3,272,321
can any one explain how uksort() in php works?
<p>I have read it in php manual ..and on may other website...but it is very difficult to understand.</p> <p>Can any one help me out? </p> <p>this is the example.</p> <pre><code> &lt;?php function my_sort($x, $y) { if ($x == $y) return 0; return ($x &gt; $y) ? -1 : 1; } $people = array("10" =&gt; "javascript", "20" =&gt; "php", "60" =&gt; "vbscript", "40" =&gt; "jsp"); uksort($people, "my_sort"); print_r ($people); ?&gt; </code></pre>
php
[2]
648,370
648,371
java programming - dynamic variable names
<p>I had a question regarding this program I was trying to write.</p> <pre><code>fin = new FileInputStream (args[0]); BufferedReader d = new BufferedReader(new InputStreamReader(fin)); String str; while ((str = d.readLine()) != null) { String [] string = str.split(" "); System.out.println(string[0]); int i=0; if(!(string[0].compareTo("INPUT")==0) || (string[0].compareTo("OUTPUT")==0)) { // solution goes here } } fin.close(); </code></pre> <p>So the question i have is that i am trying to create objects a1, a2, a3 etc of a class (say A) and then add them as a vertex to a graph. Is there a way to define them dynamically? Would this work?</p> <pre><code>A [] a; while(condition is true) { a[i].setParameters() // dont worry about this graph.addVertex(a[i]) i++; } </code></pre> <p>If not, can you tell me a better way of doing this? When i try this i get local variable not initialized error. I might be missing something trivial</p> <p>Note: The project is to design a logic circuit simulator and I am trying to implement a graph styled data structure where nodes depict gates and the interconnects will be edges (I have two classes called gates and interconnects)</p>
java
[1]
5,302,436
5,302,437
replace urlpath in php
<p>I am new to php.</p> <p>I am getting default image path as \xampp\htdocs\Sample\tmp/one.jpg</p> <p>and i have to replace \xampp\htdocs with http:\localhost </p> <p>If i use in this way i am getting required output</p> <pre><code>$absolute = "\xampp\htdocs"; $relative = "http:\\localhost"; $imagepathurl = "\xampp\htdocs\Sample\tmp\/safety-masks_5092610ad4f3f.jpg"; echo str_replace($absolute,$relative,$imagepathurl); </code></pre> <p>But i am getting the $imagepathurl from database. If i use this in same formate i am not getting result</p> <pre><code>$absolute = "\xampp\htdocs"; $relative = "http:\\localhost"; $imagepathurl = '"'.$imagepath.'"'; echo str_replace($absolute,$relative,$imagepathurl); </code></pre>
php
[2]
3,325,496
3,325,497
Is there a way in JavaScript which clicks an anchor
<p>Is there anyway in JavaScript which emulate user clicks an anchor?</p> <p>Mozilla(Firefox ) does not implement that. <a href="https://developer.mozilla.org/en/DOM/element.click" rel="nofollow">https://developer.mozilla.org/en/DOM/element.click</a></p> <p>But is there any browser which does?</p>
javascript
[3]
4,349,477
4,349,478
Function argument as filename
<p>Addig a file to MediaPlayer is easy:</p> <pre><code>mp = MediaPlayer.create(Myctivity.this, R.raw.sound); </code></pre> <p>But what if I have the filename as an argument coming from a function like this?</p> <pre><code> public void CreateSound(String filename, float volume) { mp = MediaPlayer.create(Myctivity.this, R.raw.???); mp.setVolume(volume, volume); try { mp.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } mp.start(); } </code></pre>
android
[4]
1,524,769
1,524,770
How to have PHP boolean FALSE to be output as FALSE only
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/10290278/transfer-a-variable-from-php-to-js">transfer a Variable from php to js</a> </p> </blockquote> <p>This might seem trivial. I am setting a PHP variable's value as false. Then after some processing I am outputting some JavaScript variables in a script. This is the code</p> <pre><code>$a = true; $b = false; echo '&lt;script type="text/javascript"&gt; var a = '.$a.'; var b = '.$b.'; &lt;/script&gt;'; </code></pre> <p>When the script finishes I get this output:</p> <pre><code>var a = 1; var b = ; </code></pre> <p>So I get syntax error in JavaScript. Now the question is, how to have those values as true boolean values in JavaScript as well? </p> <p>Intended output:</p> <pre><code>var a = true; var b = false; </code></pre> <p>I don't want string like <code>'true'</code> or <code>'false'</code>...or 1 and 0, but boolean <code>true</code> and <code>false</code> only. Any help regarding this, also with some explanation as to why PHP behaves this way?</p>
php
[2]
4,808,636
4,808,637
help with show/hide jquery script
<p>I need a js script show / hide with only shown one div at time others closed. By default any (only one) must be shown.</p> <p>I have got this script: <a href="http://jsfiddle.net/kolxoznik1/BFV9k/" rel="nofollow">http://jsfiddle.net/kolxoznik1/BFV9k/</a>.</p> <p>I want to add some class like <code>show</code>: </p> <pre><code> &lt;div class="toggle show"&gt;Content&lt;/div&gt; </code></pre> <p>If <code>show</code> will be added div will not be hided, he will heve status <code>show()</code> othervise all divs will be <code>hide()</code>.</p> <p>Suppose someone will help me with my small problem.</p>
jquery
[5]
4,506,057
4,506,058
How to get if item exist in IEnumerable using Linq
<p>How would you refactor this method?</p> <pre><code> private bool IsTermExist(string word) { var query = from term in m_xdoc.Descendants("Term") where term.Attribute("Name").Value.ToUpper().Contains(word.ToUpper()) select term; return query.Any(); } </code></pre>
c#
[0]
5,836,761
5,836,762
implementing Equals but not GetHashCode in c#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/371328/why-is-it-important-to-override-gethashcode-when-equals-method-is-overriden-in-c">Why is it important to override GetHashCode when Equals method is overriden in C#?</a> </p> </blockquote> <p>I dont implement the GetHashCode method of the Object class. so I get a number of warnings.</p> <p>Is there a way to check for equality where I just check the hash code in the Equals method, so implement both Equals and GetHashCode and not get the "Object.GetHashCode not implemented warning?".</p> <p>what will happen if i just implement the Equals and not implement the GetHashCode? instances of myclass are updatable in my application.</p> <pre><code>public class MyClass{ private string x; private string y; public override bool Equals(object obj) { try { return Object.Equals(this.x, obj.x) &amp;&amp; Object.Equals(this.y, obj.y); } catch(Exception Ex) { log.Debug(Ex.StackTrace); throw; } } } </code></pre>
c#
[0]