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 |
|---|---|---|---|---|---|
4,277,275 | 4,277,276 | When a method depends on another method | <p>What is the best way to deal with the following situation in JavaScript.</p>
<p>I have three methods (<code>m1</code>, <code>m2</code>, <code>m3</code>) and the last one (<code>m3</code>) depends from the results of the others two (<code>m1</code>, <code>m2</code>).</p>
<p>In this way it works, but I am curious to know if there is a better way to write the code in this situation, especially for future developers that will read the code.</p>
<pre><code>var O = function () {
this.p = 0;
}
O.prototype.makesomething = function () {
var that = this;
that.m1();
that.m2();
that.m3();
}
O.prototype.m1 = function () {O.p++}; // it changes the value O.p
O.prototype.m2 = function () {O.p++}; // it changes the value O.p
O.prototype.m3 = function () {return O.p}; // m3 depends by m1, m2 because it needs to get the update value of O.p
</code></pre>
| javascript | [3] |
4,634,984 | 4,634,985 | regarding calling a javascript function in asp.net | <p>In this "onclick" is working but it is not calling javascript function.please help how to execute both onclick and onclientclick at the same time.</p>
<pre><code><asp:Button ID="btnFare" OnClientClick="return initialize();" runat="server" Text="Calculate Fare" onclick="btnFare_Click"/>
</code></pre>
<p>please suggest way to overcome this problem.</p>
<p>Thanks in advance</p>
| asp.net | [9] |
1,948,763 | 1,948,764 | Fetch User EmailId from Twitter API in IPhone | <p>Can any one tell me is this passible with twitter API in iPhone to fetch the user email ID.
Please give me a proper way to getting the user information(Email Id) through the twitter API in iPhone.</p>
<p>Thanks
sandeep</p>
| iphone | [8] |
3,907,701 | 3,907,702 | De-Duplication API in Java | <p>Are there any De-Duplication API in Java? I want to eliminate redundant items (for e.g. duplicate fingerprints) from the database, how is it possible through Java programming?</p>
| java | [1] |
1,192,799 | 1,192,800 | OnStop() does not affect MediaPlayer | <p>I have a mediaplayer object inside an activity that plays from mp3 files situated in the res/raw folder. The </p>
<pre><code>MediaPlayer.create(Context context, int resid)
</code></pre>
<p>method is used to create and return a mediaPlayer object to play this track.</p>
<p>What I have noticed is that when the activity is obscured by another activity and hence the "onStop()" method is called , the music continues to play. Can anyone explain why this occurs? I though that onStop would essentially freeze any actions taking place by objects associated with the activity, except for services etc</p>
| android | [4] |
3,165,631 | 3,165,632 | Do something if e.target is not child of xxx | <p>I want to do change the z-index of an element when the user hover it, and reinitialize it when the user mouseout.</p>
<p>But my problem is that I can't find how to know when the user is hovering a child of my element to hover, or if he's leaving the element. </p>
<p>I tried that:</p>
<pre><code> var controlsWrapper = $('#controls-wrapper');
controlsWrapper.on('mouseover', function() {
console.log('in');
})
controlsWrapper.on('mouseout', function(e) {
if(!controlsWrapper.has(e.target)) {
console.log('out');
}
})
</code></pre>
| jquery | [5] |
5,044,978 | 5,044,979 | javascript select element | <p>I have a select element like this</p>
<pre><code><select name ="cars">
<option value="frd"> Ford </option>
<option value="hdn"> Holden </option>
<option value="nsn"> Nissan </option>
</select>
</code></pre>
<p>I want to set selected to "Holden" with javascript without selected by value. how can I achieve this?</p>
<p>Thanks in advance</p>
| javascript | [3] |
2,082,312 | 2,082,313 | Converting array of type char into a int variable | <p>Compiling this on <a href="http://codepad.org/vlhwNjBN" rel="nofollow">Codepad</a>:</p>
<pre><code>#include <iostream>
using namespace std;
void main (void)
{
char ch[2];
int value;
cout<<"Enter two integers between 0-9"<<endl;
cin.getline(ch,2);
//testing with char array
//(...)
//how could I do operations like '*', '+', '-', or '/' to the char arrays
}
</code></pre>
<p>Gives:</p>
<blockquote>
<p>Line 4: error: '::main' must return 'int'
compilation terminated due to -Wfatal-errors.</p>
</blockquote>
<p>For example:</p>
<p>Lets say <code>ch[0]='5'</code> and <code>ch[1]='3'</code></p>
<p>what do I need to do so I can do ch[0] - ch[1] = 2 and store into an int value</p>
| c++ | [6] |
1,011,537 | 1,011,538 | Split an IP address into Octets, then do some math on each of the Octets | <p>I actually have this working, but its very ugly, and its keeping me awake at night trying to come up with an eloquent piece of code to accomplish it.</p>
<p>I need to take a series of strings representing IP Ranges and determine how many actual IP address that string would represent. My approach has been to split that into 4 octets, then attempt to split each octet and do the math from there. </p>
<p>e.g.: 1.2.3.4-6 represents 1.2.3.4, 1.2.3.5, and 1.2.3.6, thus I want to get the answer of 3 from this range.</p>
<p>To further complicate it, the string I'm starting with can be a list of such ranges from a text box, separated by newlines, so I need to look at each line individually, get the count of represented IP address, and finally, how many of the submitted ranges have this condition.</p>
<pre><code>1.1.1.4-6 /* Represents 3 actual IP Addresses, need to know "3" */
2.2.3-10.255 /* Represents 8 actual IP Addresses, need to know "8" */
3.3.3.3 /* No ranges specified, skip this
4.4.4.4 /* No ranges specified, skip this
</code></pre>
<p>Net result is that I want to know is that 2 lines contained a "range", which represent 8 IP addresses (3+8)</p>
<p>Any eloquent solutions would be appreciated by my sleep schedule. :
)</p>
| javascript | [3] |
4,771,437 | 4,771,438 | jQuery: Select to find last li of nested lists | <p>I am looking for a jQuery selector to find the last li of several nested lists. The structure will be deeper than this in reality, but I figure a selector that could get these two should probably work.</p>
<pre><code><ul>
<li>
<a>some link</a>
<ul>
<li>
<a>not this one</a>
</li>
<li>
<a>this one</a>
<ul>
<li>
<a>also not this one</a>
</li>
<li>
<a>and this one too</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</code></pre>
| jquery | [5] |
3,234,512 | 3,234,513 | how to obtain available free space on sdcard from android application? | <p>I am developing an android application where i need to determine the free space available on the sdcard. Can anyone give me some suggestion regarding this please.</p>
<p>thanks
kaisar</p>
| android | [4] |
575,058 | 575,059 | What is your favorite resource for UITableView related stuff? | <p>What resources do folks use for UITableView related stuff? <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006943-CH3-SW20" rel="nofollow">Apple's Docs</a> seem sufficient , but am sure everyone has a UITableView reference that they use when implementing table views.</p>
| iphone | [8] |
2,072,692 | 2,072,693 | how to access the list of received sms for iphone? | <p>me if possible way is there menas.</p>
| iphone | [8] |
2,195,127 | 2,195,128 | webbrowser modules only opens url in mozilla? | <pre><code>import webbrowser
webbrowser.open(url)
</code></pre>
<p>I am using this to open url in browser. But it opens only in <code>'Mozilla'</code> why?</p>
| python | [7] |
5,552,129 | 5,552,130 | Clear the Activity stack when I go to an activity | <p>I am working on an application with several Activities, problem is that I want the user to be able to log out by pressing a button.</p>
<p>Suppose we have 4 Activity named A,B,C,D. Navigation of the activity like B->C->D. </p>
<p>On Activity D user have options for logout. When user click on the Logout button the he go to Activity A which is not called in the navigation. Now, user click on the back button then he got to previous activity like Activity D.</p>
<p>I already tried to launch the Activity with the two following flags: </p>
<pre><code>Intent intent = new Intent(this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
</code></pre>
<p>Can anyone help?</p>
| android | [4] |
3,710,626 | 3,710,627 | Building a list of months by iterating between two dates in a list (Python) | <p>I have an ordered (i.e. sorted) list that contains dates sorted (as datetime objects) in ascending order.</p>
<p>I want to write a function that iterates through this list and generates another list of the first available dates for each month.</p>
<p>For example, suppose my sorted list contains the following data:</p>
<pre><code>A = [
'2001/01/01',
'2001/01/03',
'2001/01/05',
'2001/02/04',
'2001/02/05',
'2001/03/01',
'2001/03/02',
'2001/04/10',
'2001/04/11',
'2001/04/15',
'2001/05/07',
'2001/05/12',
'2001/07/01',
'2001/07/10',
'2002/03/01',
'2002/04/01',
]
</code></pre>
<p>The returned list would be </p>
<pre><code>B = [
'2001/01/01',
'2001/02/04',
'2001/03/01',
'2001/04/10',
'2001/05/07',
'2001/07/01',
'2002/03/01',
'2002/04/01',
]
</code></pre>
<p>The logic I propose would be something like this:</p>
<pre><code>def extract_month_first_dates(input_list, start_date, end_date):
#note: start_date and end_date DEFINITELY exist in the passed in list
prev_dates, output = [],[] # <- is this even legal?
for (curr_date in input_list):
if ((curr_date < start_date) or (curr_date > end_date)):
continue
curr_month = curr_date.date.month
curr_year = curr_date.date.year
date_key = "{0}-{1}".format(curr_year, curr_month)
if (date_key in prev_dates):
continue
else:
output.append(curr_date)
prev_dates.append(date_key)
return output
</code></pre>
<p>Any comments, suggestions? - can this be improved to be more 'Pythonic' ?</p>
| python | [7] |
3,640,970 | 3,640,971 | How to use ifstream of C++ to read from a file using length of the data rather than new line? | <p>Instead of the ifstream >> terminating reading for a file whenever it finds newline, I would like to read from a file using data size. Is there a way to do this?</p>
<p>Currently I use mystream.read(string, length), but I would like to used the ">>" operator instead of read. </p>
| c++ | [6] |
4,292,807 | 4,292,808 | Adding View to a Custom ViewGroup | <p>I am trying to add Views to a custom ViewGroup. The ViewGroup gets drawn, but no Views that were added to it are visible. LineView's (which extends a View) onDraw() method does not get called. What am I doing wrong?</p>
<pre><code> public class TestActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ShapeView shapeView = new ShapeView(this);
shapeView.setBackgroundColor(Color.RED);
drawContainer = (RelativeLayout)findViewById(R.id.draw_container);
drawContainer.addView(shapeView);
}
}
public class ShapeView extends ViewGroup {
private LineView mLineView;
public ShapeView (Context context) {
super(context);
RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(200, 200);
this.setLayoutParams(p);
mLineView = new LineView(context);
this.addView(mLineView);
}
}
</code></pre>
| android | [4] |
38,914 | 38,915 | Cannot find Decimal Format class in Java | <p>I cant get this code to work... I don't know why. </p>
<p>It is the same code as in this tutorial <a href="http://www.youtube.com/watch?v=meKpmuUI0ds&feature=related" rel="nofollow">http://www.youtube.com/watch?v=meKpmuUI0ds&feature=related</a>. </p>
<p>The code works when this guy does it, but I get these 2 errors:</p>
<blockquote>
<p>Test.java:4: cannot fin symbol symbol: class decimalFormat </p>
<p>location: class Test</p>
<pre><code>decimalFormat decFor = new decimalFormat("0.00");
</code></pre>
<p>^</p>
<p>Test.java:4: cannot find symbol</p>
<p>symbol: class decimalFormat</p>
<p>location: class Test</p>
<pre><code>decimalFormat decFor = new decimalFormat("0.00");
^
</code></pre>
<p>2 errors.</p>
</blockquote>
<p><strong>Here's my code</strong>:</p>
<pre><code>public class Test {
public static void main(String[] args) {
decimalFormat decFor = new decimalFormat("0.00");
double money = 15.9;
double mula = 36.6789;
double product = money * mula;
System.out.println(decFor.format(product));
}
}
</code></pre>
| java | [1] |
815,107 | 815,108 | How to read a encrypted pdf file in Android | <p>I want to build an ebook reader for android in java. Suppose I have a pdf file which is encrypted by my program. Now I want to read that encrypted file in the ebook reader project of android. What can I do for this?</p>
<p>If you want to ask why this has to be done, then I can tell you the specific requirement of my project. But that is another matter.</p>
<p>Please help me by telling me how to do the task that is described above. I will be grateful to all of you. </p>
| android | [4] |
5,036,653 | 5,036,654 | Need Explanation on ID mapping | <p>Can anyone please tell me about ID mapping?? Please share some tutorials which will be helpful for me... Can we use ID mapping in android?? </p>
<p>Thanks in advance..</p>
| android | [4] |
4,108,775 | 4,108,776 | Live Tile Background worder fails silently if referencing HttpClient or WebView | <p>My Windows 8 Background task DLL project fails silently at runtime when I simply reference either WebView or HttpClient.</p>
<p>So, this works fine:</p>
<pre><code>public sealed class TileUpdater : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
var defferal = taskInstance.GetDeferral();
await GetContent();
defferal.Complete();
}
private async Task GetContent()
{
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
//updater.EnableNotificationQueue(true);
updater.Clear();
for (int i = 1; i < 6; i++)
{
var tile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
tile.GetElementsByTagName("text")[0].InnerText = "Tile " + i;
tile.GetElementsByTagName("text")[1].InnerText = DateTime.Now.ToString("hh-mm");
updater.Update(new TileNotification(tile));
}
}
}
</code></pre>
<p>And this just fails silently (either WebView or HttpClient):</p>
<pre><code>public sealed class TileUpdater : IBackgroundTask
{
public async void Run(IBackgroundTaskInstance taskInstance)
{
var defferal = taskInstance.GetDeferral();
await GetContent();
defferal.Complete();
}
private async Task GetContent()
{
var hc = new HttpClient();
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
//updater.EnableNotificationQueue(true);
updater.Clear();
for (int i = 1; i < 6; i++)
{
var tile = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
tile.GetElementsByTagName("text")[0].InnerText = "Tile " + i;
tile.GetElementsByTagName("text")[1].InnerText = DateTime.Now.ToString("hh-mm");
updater.Update(new TileNotification(tile));
}
}
}
</code></pre>
| c# | [0] |
5,460,114 | 5,460,115 | Jquery pagination for a table | <p>Im using this javascript</p>
<p><a href="http://www.digcode.com/default.aspx?g=posts&t=889" rel="nofollow">http://www.digcode.com/default.aspx?g=posts&t=889</a></p>
<p>but I need in addition to dynamic pages I need to display static numbering if no data are available the number will be disabled .</p>
| jquery | [5] |
812,742 | 812,743 | How can i stop to be refreshed my values in android activity. | <p>I am working in android. i am designing a file upload fuctionality.</p>
<p>this is my layout:-
<img src="http://i.stack.imgur.com/EtM7F.png" alt="enter image description here"></p>
<p>if i fill my entries like as title,price,category and then i press browse button for browse option then i go to BrowseActivity using startActivity(). But when i come back to this activity then all entries which were filled by me disappear. please suggest me what should i do for this so my entered entries save. if i do browse first then fill entries then it works properly.</p>
<p>please suggest me what should i do for the case in which user first fill entries and then click on the browse button.</p>
<p>Thank you in advance...</p>
| android | [4] |
4,958,940 | 4,958,941 | Javascript not acquiring dropdown value | <p>I have a list of 2 values in dropdown list as...</p>
<pre><code> <select id="prop">
<option value="Caa:123">Ca</option>
<option value="Cb:745">Cb</option>
</select>
</code></pre>
<p>...and in javascript i used...</p>
<pre><code> var p = document.getElementById('prop');
var q = p.options[p.selectedIndex].value;
alert(q);
</code></pre>
<p>...but I am not getting no alert and an error "Index or size is negative or greater than the allowed amount" code: "1 "
Kindly help I trapped in this problem</p>
| javascript | [3] |
29,019 | 29,020 | 'while(doSome())' can i do this? | <p>So...</p>
<pre><code>class postQuery {
public function __construct($args = NULL){
$post_type = $args['post_type'];
$limit = $args['limit'];
$category = $args['cat'];
global $sql;
$sql = $sql->query('SELECT * FROM posts');
$sql = $sql->fetchAll(PDO::FETCH_ASSOC);
}
public function havePosts() {
global $sql;
global $rowNum;
$rowNum = 0;
$rowMax = count($sql);
while($rowNum <= $rowMax) {
return $rowNum;
$rowNum++;
}
}
}
</code></pre>
<p>the havePosts() function should run while $rowNum < $rowMax... everything ok this far...</p>
<p>but now, i want to create a while statement with this function, like this:</p>
<pre><code>$con = new postQuery();
while($con->havePosts()){
global $sql;
global $rowNum;
return $sql[$rowNum]['title'];
}
</code></pre>
<p>How can i return the data given by my WHILE inside the Function one by one?</p>
| php | [2] |
2,159,324 | 2,159,325 | PHP Upload and Download Scipt | <p>First off let me just say, i dont want anyone to post solutions because I get more satisfaction coding myself so I would appreciate guidance and ideas. </p>
<p>So i want to build a site, that lets me upload a file, store it, display a list of all uploaded files, and then download a selected file.</p>
<p>Any help as to how I may do this?</p>
<p>In more detail. </p>
<p>step 1:</p>
<p>user selects a button upload file. </p>
<p>step 1: it shows the window where they can browse through their locally stored files and select one of them. </p>
<p>step 3:</p>
<p>They click upload. </p>
<p>step 4: this gets stored (perhaps in mysql database, dont know much about how to do this).</p>
<p>step 5: The user clicks the button 'browse uploaded files'</p>
<p>step 6: the user is shown a list of all the uploaded files</p>
<p>step 7: the user selects one of the files and clicks download. </p>
<p>I hope this has made it clearer</p>
<p>Also I just would like someone to show me where to start really.</p>
<p>Thankyou</p>
| php | [2] |
5,559,640 | 5,559,641 | JQuery: Check if previous sibling is first-child | <p>Using JQuery, how do you check if an element's previous sibling is the first-child?</p>
<p>I have tried the following code but it does not work:</p>
<pre><code>if( $(this).prev() === $(this).siblings(":first-child") ){
//do something
}
</code></pre>
<p><b>An example using the above <code>===</code> approach: <a href="http://jsfiddle.net/xnHfM/" rel="nofollow">http://jsfiddle.net/xnHfM/</a></b></p>
| jquery | [5] |
1,462,469 | 1,462,470 | How to package a python program for distribution on a network | <p>I'm not sure if I'm even asking this question correctly. I just built my first real program and I want to make it available to people in my office. I'm not sure if I will have access to the shared server, but I was hoping I could simply package the program (I hope I'm using this term correctly) and upload it to a website for my coworkers to download. </p>
<p>I know how to zip a file, but something tells me it's a little more complicated than that :) In fact, some of the people in my office who need the program installed do not have python on their computers already, and I would rather avoid asking everyone to install python before downloading my .py files from my hosting server.</p>
<p>So, is there an easy way to package my program, along with python and the other dependencies, for simple distribution from a website? I tried searching for the answer but I can't find exactly what I'm looking for. Oh, and since this is the first time I have done this- are there any precautions I need to take when sharing these files so that everything runs smoothly?</p>
| python | [7] |
685,344 | 685,345 | Remove specific objects from a list | <p>I have a class that has an <code>list<Book></code> in it, and those <code>Book</code> objects has many many properties.
How can I remove from that list every Book that his <code>level</code> value is different than, for example, 5?</p>
| c# | [0] |
4,420,836 | 4,420,837 | Detect from browser if a specific application is installed in Android | <p>I'm looking for a way to find out if a specific application is installed from a client-side web browser. The platform is Android.</p>
| android | [4] |
5,428,220 | 5,428,221 | PhoneSateIntentReceiver.NotifyPhoneCallState in android | <p>Hello can anyone explain the use of <strong>PhoneSateIntentReceiver.NotifyPhoneCallState in android</strong> and when this can be used...?? </p>
<p>It would be great if you can give some example also.</p>
<p>thanks a lot.</p>
| android | [4] |
5,632,197 | 5,632,198 | Error when running simple python script | <p>When I run the following:</p>
<pre><code>import sys
if __name__ == '__main__':
print 'before exit'
sys.exit(0)
</code></pre>
<p>The output is:</p>
<pre><code>before exit
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
</code></pre>
<p>I don't know why the exception occurs, but it was suggested that it could be an improper installation of Python. I was wondering if anyone knew of a way to fix this? I am running Windows 7 x64, but with an x32 install of everything. </p>
| python | [7] |
1,594,599 | 1,594,600 | Getting array of vertices using Lib3ds | <p>I'm trying to get the vertices out of a file parsed by lib3ds and I'm having a lot of issues. Namely I'm not getting the vertices I was out. The code where I try to do this is:</p>
<pre><code>//loop through meshes
for(int i = 0; i < model->meshes_size; i++)
{
Lib3dsMesh* mesh = model->meshes[i];
//loop through the faces in that mesh
for(int j = 0; j < model->meshes[i]->nfaces; j++)
{
int testv = mesh->nvertices;
Lib3dsFace face = mesh->faces[i];
//loop through the vertices in each face
for(int k = 0; k < 3; k++)
{
myVertices[index] = model->meshes[i]->faces[j].index[0];
myVertices[index + 1] = model->meshes[i]->faces[j].index[1];
myVertices[index + 2] = model->meshes[i]->faces[j].index[2];
index += 3;
}
}
}
</code></pre>
<p>Unfortunately the documentation for lib3ds is non-existent and so I can't figure this out. How do you go about getting an array of vertices using this library? Also I'm aware that 3ds is old but the format and the way the library is set up suits my purpose so please don't suggest switching to another format.</p>
| c++ | [6] |
2,144,690 | 2,144,691 | Enable/disable the Add/edit/delete buttons of the jqgrid | <p>Is it posible to conditionally enable/disable the Add/edit/delete buttons of the jqgrid? I would like to enable/disable based upon the variable value iam setting. </p>
| jquery | [5] |
412,834 | 412,835 | PHP> Extracting html data from an html file? | <p>What I've been trying to do recently is to extract listing information from a given html file,</p>
<p>For example, I have an html page that has a list of many companys, with their phone number, address, etc'</p>
<p>Each company is in it's own table, every table started like that: <code><table border="0"></code></p>
<p>I tried to use PHP to get all of the information, and use it later, like put it in a txt file, or just import into a database.</p>
<p>I assume that the way to achieve my goal is by using regex, which is one of the things that I really have problems with in php,</p>
<p>I would appreciate if you guys could help me here.
(I only need to know what to look for, or atleast something that could help me a little, not a complete code or anything like that)</p>
<p>Thanks in advance!!</p>
| php | [2] |
3,357,297 | 3,357,298 | javascript testing for object property | <p>I have a string like this:</p>
<pre><code>var TheDate = "6.14.2012";
</code></pre>
<p>and I have an object <code>MyObject</code> that has properties that may match that string. However, when I write this:</p>
<pre><code>if (MyObject[TheDate] === null || MyObject[TheDate] === 'undefined') { .... }
</code></pre>
<p>the conditions never seem to evaluate to true even though I know the property doesn't exist. </p>
<p>What am I missing??</p>
<p>Thanks.</p>
| javascript | [3] |
2,929,584 | 2,929,585 | Hide and Show same div using Jquery | <p>Hi im trying to figure out how to hide and show content using multiple links. Ex.</p>
<pre><code><a href="#">Content 1</a>
<a href="#">Content 2</a>
<a href="#">Content 3</a>
<div class="show">content #1</div>
<div class="hidden">content #2</div>
<div class="hidden">content #3</div>
</code></pre>
<p>So when someone clicks Content #2, it shows content #2 and hides content #1</p>
| jquery | [5] |
4,351,485 | 4,351,486 | how to use progressbar without using thread and handler? | <p>How to use Progressbar without using thread and handler?
i used following code but this is not working.</p>
<pre>
ProgressDialog prd=new ProgressDialog(this);
prd.setTitle("Please Wait........");
prd.show();
</pre>
| android | [4] |
2,209,898 | 2,209,899 | Get frame contents with jQuery | <p><strong>main.html</strong> has this code:</p>
<pre><code><iframe id="myframe" src="myframe.html"></iframe>
</code></pre>
<p>and I trigger this code inside main.html:</p>
<pre><code>alert($('#myframe').contents().find('#mypage').contents().find('html').html());
</code></pre>
<p><strong>myframe.html</strong> has this code:</p>
<pre><code><frameset>
<frame id="mypage" src="mypage.html">
</frameset>
</code></pre>
<p><strong>mypage.html</strong> has all this code:</p>
<pre><code><!DOCTYPE HTML>
<html>
<head>
</head>
hello world!
</html>
</code></pre>
<p>I want to get all the HTML code of the mypage.html from within the main.html page, but I fail. What is the problem with the way I do it?</p>
| jquery | [5] |
4,263,323 | 4,263,324 | How to change the text color in Python Shell? | <p>Like say, I want to make a simple print statement like:</p>
<p>print("It's so <em>hot</em> outside today.")</p>
<p>How could I make "hot" as the color red, in Python Shell?</p>
| python | [7] |
4,192,673 | 4,192,674 | Automatically clear users cache on app update in android | <p>Is there any method in the android API (ideally for 2.3.6 and onwards) that clears the users cache if they download a new version of an app? Looking around there doesn't seem to be any mention of one - or am I off the ball completely and the cache is emptied when a new version is installed?</p>
| android | [4] |
111,625 | 111,626 | Use of mouselisteners in a jTable | <p>I have a jTable with columns 'Job_no' and 'Status'with values such as:</p>
<pre><code> Job_no Status
1 Active
2 Pending
3 Pending
</code></pre>
<p>I would like it so that if a user clicks on a Status say in this case the first 'Pending'(where Job_no = 2) an inputDialog pops up allowing the user to change the status of the cell clicked-how can I do this? Bear in mind you will also have to retrieve the Job_no(that corresponds to that status) somehow, and that, though I'm OK with JOptionPane's, I'm new to JTables. I'm using JDBC(mySQL) and have a table 'Jobs' which amongst other things, has column Job_no and status.</p>
<p>Thanks for your help. </p>
| java | [1] |
5,737,626 | 5,737,627 | detect unchecked checkbox php | <p>Is there a way to check of a checkbox is unchecked with php? I know you can do a hidden field type in html but what about with just php when the form is submitted? I tried below no luck.</p>
<pre><code>if(!isset($_POST['server'])||$_POST['server']!="yes"){
$_POST['server'] == "No";
}
</code></pre>
| php | [2] |
1,897,610 | 1,897,611 | How to edit php files locally? | <p>With HTML files, I can work locally and preview the files in my browser after I've saved and made changes (and use LiveReload), but with PHP the browser just loads the code. Do I need to run a local server to work on it locally, or is there an easier way?</p>
<p>The extent of my PHP is using include statements for headers and footers.</p>
| php | [2] |
3,800,096 | 3,800,097 | C# inheritance issue to do with collections | <p>In my application I access a number of companies of different types, say TypeA, TypeB and TypeC. So I have a company class and inherited from Company is TypeA, TypeB, TypeC.</p>
<p>So I have a view where the user wants to do a search on TypeA. The search fields include fields in Company and fields in TypeA.
However if I have a collection of TypeA, say IEnumberable, how do I filter the fields in the Company class before I filter them in the TypeA class?</p>
<p>EDIT</p>
<p>So this is my pseudo code</p>
<pre><code>public abstract class Company
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}
public class TypeA : Company
{
public string Property3 {get; set; }
}
public class TypeB : Company
{
public string Property4 {get; set; }
}
public abstract class SearchCompany
{
protected SearchCompany(string searchpProperty1, string searchProperty2)
{
// assign property code elided
}
public string SearchProperty1 { get; set; }
public string SearchProperty2 { get; set; }
}
public class SearchTypeA : SearchCompany
{
public SearchTypeA (string searchpProperty1, string searchProperty2, string searchProperty3)
: base (searchpProperty1, searchProperty2)
{
// assign property code elided
this.TypeAList = CacheObjects.TypeAList;
this.TypeAList = // this.TypeAList filtered by searchProperty3 depending on the wildcard
}
public string SearchProperty3 { get; set; }
public IList<TypeA> TypeAList { get; set; }
}
</code></pre>
<p>I want to filter on properties 1 and 2 as well.</p>
| c# | [0] |
1,179,199 | 1,179,200 | G729 codec for Linphone Android | <p>I have compiled and build the bcg729 codec for the linphone android implementation. How do i enable and use it? I have the g729 royalties taken care of. When i run my final app, i don't see this enabled. </p>
| android | [4] |
4,052,933 | 4,052,934 | How to Simplify Javascript Dynamic IDs? | <p>I am new to JS and I'm running a CMS, I have a dynamic Ids, my concern is, I would to simplify IDs to lessen JS codes by adding arrays of IDs.</p>
<p>Can you guys help me how to simplify this code</p>
<pre><code>$x1(document).ready(function () {
//
// Id1 = #options_1_text
// Id2 = #option_2_text
// Id3 = #option_3_text
// Id(n) = so on..
$x1("#options_1_text").miniColors({
letterCase: 'uppercase',
change: function (hex, rgb) {
logData('change', hex, rgb);
}
});
$x1("#options_2_text").miniColors({
letterCase: 'uppercase',
change: function (hex, rgb) {
logData('change', hex, rgb);
}
});
$x1("#options_3_text").miniColors({
letterCase: 'uppercase',
change: function (hex, rgb) {
logData('change', hex, rgb);
}
});
// so on..
});
</code></pre>
<p>You're help is greatly appreciated! </p>
<p>Thanks!</p>
| javascript | [3] |
5,168,740 | 5,168,741 | PHP execute code on page close | <p>I am trying to find a method to execute some PHP code once a user closes the page. In my application, once the user closes or navigates away from the page the server will state the user as 'Offline' in the database. This requires the code to know when the user has navigated away from the page. My application also has an endless load (i.e. it will sleep until the user closes the page).</p>
<p><strong>Edit:</strong></p>
<p>Thanks for the answers. I decided to go with Pekka's session method, as this seemed the most logical for my application.</p>
<p>Cheers</p>
| php | [2] |
2,077,105 | 2,077,106 | Only Text in EditText on Android? | <p>I want to only text (input) in edittext in App Android.!
example: Only type "Text: A-> Z", Not allow number or special character.?</p>
<p>Please give me idea, how should it be done?
Thank very much.! </p>
| android | [4] |
3,744,583 | 3,744,584 | how to set UIView background programmatically | <p>in the interface builder,i can find the background tag,and select the color and the opacity.</p>
<p>if I create the UIView programmatically,if I want to change color,I can set the backgroundColor property</p>
<p>the question is if I want to change the opactiy,What is the property should I change?</p>
<p>Thanks a lot.</p>
| iphone | [8] |
5,015,643 | 5,015,644 | Servlets and JSP or Android? | <p>Guys, what do you think, is it more perspective to learn Servlets and JSP or Android? I heard that servlets and JSP are losing its popularity and people more using .NET for websites and developing for Android is more in demand these days.</p>
| java | [1] |
1,454,035 | 1,454,036 | Find and delete value in a vector | <pre><code>class Catalog
{
// string StationTitle;
string StationLocation;
public:
string StationTitle;
Catalog()
{
StationTitle = "";
StationLocation = "";
}
Catalog(string Title, string Location)
{
StationTitle = Title;
StationLocation = Location
}
void SetTitle(string Title) { StationTitle = Title; }
void SetLocation(string Location) { StationLocation = Location; }
string GetTitle() { return StationTitle; }
string GetLocation() { return StationLocation; }
};
class StationList
{
vector<Catalog> List; //create the vector
vector<Catalog>::iterator Transit;
public:
void Fill();
void Remove();
void Show();
};
void StationList::Remove()
{
string ToDelete;
cout << "Enter title to delete: " << endl;
cin >> ToDelete;
for(Transit = List.begin() ; Transit !=List.end() ; Transit++)
{
if(Transit->StationTitle() == ToDelete)
{
List.erase(Transit); //line 145
return;
}
}
}
</code></pre>
<p>I would like the user to enter in a StationTitle and for the program to locate the title and delete it if found. This is what I have come up with so far.<br>
It is giving me a compile error: chief.cpp:145: error: no match for call to ‘(std::string) ()’</p>
| c++ | [6] |
4,142,812 | 4,142,813 | How can I perform a "like" or "contains" search on a string? | <p>Can I compare an especific value of an array in a if() conditional ?</p>
<p>Ex.:</p>
<pre><code>// teacher object
function Prof(id,tab,nome,ocupacao,email,tel,foto)
{
this.id = id;
this.tab = tab;
this.nome = nome;
this.ocupacao= ocupacao;
this.email = email;
this.tel = tel;
this.foto = foto;
}
//teachers array
var arr = new Array();
arr[0] = new Prof('pf1','dir','Mario','Diretor','mail@mail.com','tel','foto');
arr[1] = new Prof('pf2','dir','Joao','t1 t3 t7','...','...','...');
...
// So now i will get the array value of "ocupacao" and see if this value has
// an specific value that i´ve defined in the conditional:
...
if(arr[i].ocupacao (has value) t7)
{
//do something
}
</code></pre>
<p>NOTE; There is something that i can use like in PHP or ASP: "LIKE" or "%value%"?</p>
| javascript | [3] |
3,207,280 | 3,207,281 | Android Round Button and Spinner inside Activity Group | <p>I have a Spinner and 2 buttons in an Activity Group. I want to apply rounded corner to the buttons. I have created shape xml resource file for round button in Android. I have assigned this resource file as background to the button while creating the button in Layout. But the change is not reflected after executing the application.</p>
<p>I have set the ContentView for that screen as :</p>
<pre><code>setContentView(LayoutInflater.from(getParent()).inflate(R.layout.textmessage,null));
</code></pre>
<p>This has to be done to make spinner work in an Activity Group.
How can I make the Button as round corner in an Activity Group having Spinner?</p>
<p>Any help would be appreciated. Thanks in Advance.</p>
| android | [4] |
3,582,513 | 3,582,514 | make a dynamic web site | <p>i want to make a online contact book. and this contact book get the suer name and password the show the next page in which we show the different utilities like add contact, delete, edit, and many more. and face a problem of making a inbox and signup page.</p>
| php | [2] |
2,924,712 | 2,924,713 | How to unquote URL quoted UTF-8 strings in Python | <pre><code>thestring = urllib.quote(thestring.encode('utf-8'))
</code></pre>
<p>This will encode it. How to decode it?</p>
| python | [7] |
5,143,115 | 5,143,116 | JavaScript: force the order in which function properties of a module can be called | <p>I wish to create an API that can be called in the following fashion:</p>
<pre><code>var f = foo().bar().barAgain().barTheThird();
</code></pre>
<p>but not:</p>
<pre><code>var f2 = foo().bar().barTheThird();
</code></pre>
<p><em>barAgain()</em> can only be called after calling <em>bar()</em>, <em>barTheThird()</em> can only be called after calling <em>barAgain()</em> and so on.</p>
<pre><code>function foo() {
var that = {};
var _bar = function () {
return that;
};
var _barAgain = function () {
return that;
};
var _barTheThird = function () {
return that;
};
_barAgain.barTheThird = _barTheThird;
_bar.barAgain = _barAgain;
that.bar = _bar;
return that;
};
</code></pre>
<p>The above does not work. <em>foo().bar()</em> is called via the method invocation pattern, therefore the keyword <em>this</em> is bound to the object <em>that</em> within _<em>bar</em>.</p>
<p>I have found one solution:</p>
<pre><code>var _bar = function () {
that.barAgain = _barAgain;
delete that.bar;
return that;
};
</code></pre>
<p>But this does not feel particularly clean or elegant.</p>
<p>Has anyone come across this sort of problem before? Any suggestions for a more elegant solution?</p>
<p>Thanks in advance!</p>
| javascript | [3] |
2,882,588 | 2,882,589 | Alternative to filter_var | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/13648117/filter-var-in-php-5-3-8">filter_var in php 5.3.8</a> </p>
</blockquote>
<p>I recently upgraded to php 5.3.8 and I am having problem validating an email address a user enters into a registration form using "filter_var".
I want to ensure that when a valid email address is entered I post it to a database and if for some reason the format of the email address is incorrect I inform the user to enter a valid email address.
So I checked php.net and it turns out filter_var does not exist in php 5.3.8
Does anyone know of an alternative to filter_var in php 5.3.8</p>
| php | [2] |
6,029,910 | 6,029,911 | Best analytics offering for iPhone | <p>What is the best iPhone analytics offering out there? I've seen <a href="http://www.pinchmedia.com" rel="nofollow">Pinchmedia</a> but I'm not sure about it since the default application page says "Last Updated July 2008".</p>
| iphone | [8] |
2,007,182 | 2,007,183 | why is javascript date an hour behind? | <p>Hi I am trying to create a unix timestamp to represent the latest time of the current day (23:59:59) like so:</p>
<pre><code>current_date = new Date();
end = new Date(current_date.getFullYear(), current_date.getMonth(), current_date.getDate(),23,59,59);
end = end.getTime() / 1000;
</code></pre>
<p>When I alert out the unix timestamp and convert it back into a datetime though it is an hour behind and represents 22:59:59 rather than 23:59:59.</p>
<p>I have to pass 24 to the date function for the hour parameter instead of 23 if I want 11pm is this right?</p>
<p>I am located in England so my time should be in GMT</p>
| javascript | [3] |
433,514 | 433,515 | Screen orientation For tablets And devices | <p>I am using the same code for both tablets as well as device,Here is my problem while coming to mobile in both orientation it should load list view, coming to tablet in portrait it need to load listview and then coming to landscape it should load gridview?</p>
<p>Thanks</p>
<p>I have used this code any one can help me plz..</p>
<pre><code> Configuration config = getResources().getConfiguration();
if((config.screenLayout & Configuration.ORIENTATION_LANDSCAPE) ==
Configuration.SCREENLAYOUT_SIZE_XLARGE));
{
this.gridView();
}else{
this.listview();
}
</code></pre>
| android | [4] |
4,676,866 | 4,676,867 | How to add Daemon services and where i get best tutorial or best practices in iphone? | <p>Thanks for helping me answering this question,
I want to update the user's location and a timer frequently in my application in background. I have heard that the iPhone SDK only provides support for push notification services. Is there a way using the iPhone SDK to add Daemon services? Where can I find a good tutorial?</p>
| iphone | [8] |
3,285,214 | 3,285,215 | can i send a server control from the aspx.cs page | <p>can i send a server control from the aspx.cs page</p>
| asp.net | [9] |
4,931,814 | 4,931,815 | CollectionChanged event of observablecollection in c# | <p>How can write this code better:</p>
<pre><code>void CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (sender is ObservableCollection<PromotionPurchaseAmount>)
{
if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (PromotionPurchaseAmount item in e.NewItems)
{
//Removed items
item.PropertyChanged -= EntityViewModelPropertyChanged;
}
}
else if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (PromotionPurchaseAmount item in e.NewItems)
{
//Added items
item.PropertyChanged += EntityViewModelPropertyChanged;
}
}
}
else if (sender is ObservableCollection<PromotionItemPricing>)
{
if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (PromotionItemPricing item in e.NewItems)
{
//Removed items
item.PropertyChanged -= EntityViewModelPropertyChanged;
}
}
else if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (PromotionItemPricing item in e.NewItems)
{
//Added items
item.PropertyChanged += EntityViewModelPropertyChanged;
}
}
}
else if (sender is ObservableCollection<PromotionItem>)
{
if (e.Action == NotifyCollectionChangedAction.Remove)
{
foreach (PromotionItem item in e.NewItems)
{
//Removed items
item.PropertyChanged -= EntityViewModelPropertyChanged;
}
}
else if (e.Action == NotifyCollectionChangedAction.Add)
{
foreach (PromotionItem item in e.NewItems)
{
//Added items
item.PropertyChanged += EntityViewModelPropertyChanged;
}
}
}
}
</code></pre>
| c# | [0] |
2,184,015 | 2,184,016 | read parameter on js file | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1017424/pass-vars-to-javascript-via-the-src-attribute">Pass vars to JavaScript via the SRC attribute</a> </p>
</blockquote>
<p>May I know how to read get the <strong>p</strong> value on js file link like filename.js?p=value with local javascript in the js file? Any function to work like the $_GET['p'] in php? Thanks. </p>
| javascript | [3] |
2,986,976 | 2,986,977 | Gridview pagination in android | <p>i retrieved texts+images from DB and displayed it in a gridview.i.e.each gridview cell consists of one image+one text.Now i've to do pagination for that.i've to allow it to display 4 cells per page.How could i do that?Example link or code is much appreciated.</p>
| android | [4] |
4,436,858 | 4,436,859 | How can I manage audio volumes sanely in my Android app? | <p>I have an app that plays intermittent sounds while its activity is open, and the user is always expecting it to make these noises, but unfortunately it is constrained by the music stream volume. The options I have discovered are thus:</p>
<ol>
<li>Adjust the music stream's volume, possibly deafening the user if they happen to be playing music at the time.</li>
<li>Call MediaPlayer.setVolume() which is ineffective if the music stream's volume is 0.</li>
<li>Handle volume button presses myself which presents two issues: volume button presses adjust the ringer volume unless my audio is playing, and I have been as of yet unable to catch the onKey event for a volume button press using my OnKeyListener. If there were some way to force the adjustment to apply to the music stream while my activity has focus, or to just catch the button presses myself this would work.</li>
<li>Play a silent looping piece of audio in the background to keep the music stream in context for volume adjustments.</li>
</ol>
<p>I think the 3rd option is probably best since it cedes control of the volume to the user, but if there were some way to just override the system volume in a single mediaplayer instance that would work too.</p>
| android | [4] |
5,100,024 | 5,100,025 | C++ -- Question about typedef | <p>Given the following code:</p>
<pre><code>typedef struct IntElement
{
struct IntElement *next; // use struct IntElement
int data;
} IntElement;
typedef struct IntElement
{
IntElement *next; // Use IntElement
int data;
} IntElement; // why I can re-use IntElement here?
</code></pre>
<p>I use above data structure to define a linked-list node.</p>
<ol>
<li>Which is better one?</li>
<li>Why I can use duplicated name (i.e. struct IntElement and IntElement in the typedef end)?</li>
</ol>
| c++ | [6] |
2,777,099 | 2,777,100 | Map sequence of integers into repeating sequence | <p>I have a continuous, ordered sequence of integers that start less than zero and go above zero; for instance <code>...,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7</code>. I need to map these into a repeating sequence <code>3,6,9,12</code>, with the initial condition that <code>f(0)=3</code>. So for instance <code>f(-2)=9, f(-1)=12, f(0)=3, f(1)=6, f(2)=9, f(3)=12, f(4)=3</code> and so on. Is there a compact way to express this operation in Java, so that we are able to just use the remainder (%) operator and avoid any if/else statements?</p>
| java | [1] |
3,702,361 | 3,702,362 | android listview intent | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7005309/android-listview-intent">android listview intent</a> </p>
</blockquote>
<p>I am not able to create an intent after click in my Listview. After completing It gives an error The application has stopped unexpectedly, please try again. My class ListActivityImage extends ListActivity</p>
<pre><code> Intent IntentDiscution = new Intent(view.getContext(), ListActivityImage.class);
startActivityForResult(IntentDiscution, 0);
</code></pre>
| android | [4] |
4,935,230 | 4,935,231 | Document.write not working | <p>I have a javascript function to calculate total amount :</p>
<pre><code><script>
function calculate(v)
{
v = parseFloat(v);
v = v + 19;
//alert(v);
document.write.getElementById("total") = v;
}
</script>
</code></pre>
<p>which is within <code><head></head></code> section . I am calling this function from :</p>
<pre><code>Select amount you want to buy : <input type="text" name="qty" onkeyup="calculate(this.value)"/> grams
</code></pre>
<p>And I am trying to display value of <code>v</code> here :</p>
<pre><code><div id="total"><script> document.write(v);</script></div>
</code></pre>
<p>But it is not showing anything. Why?</p>
| javascript | [3] |
3,889,005 | 3,889,006 | Clearing JavaScript variables in AJAX loaded content | <p>I'm working on a UI where I have a menu that loads a div via AJAX with content based on the menu item clicked. My problem is I have a view that has a setInterval call in a script block and when I navigate to another view the script continues to run even though the script block has been removed. What is the best practice to truly remove a script block and stop the execution of the interval?</p>
| javascript | [3] |
2,877,616 | 2,877,617 | Text box validataion for Decimal value | <p>I have application in which i want validate a text box that it will take decimal value.
I am using Regular expression validater for this help ma for for the expression for decimal value.</p>
| asp.net | [9] |
733,329 | 733,330 | jQuery excluding certain columns from selection | <p>I have a table where each row is clickable. Some columns in this table have links in them. I'd like to exclude 'link' columns from jQuery selection. </p>
<p>My first column, and third column contains links, so I'm doing the following after iterating through each row in the table:</p>
<pre><code>row.children('td:gt(2)') // for column 3+
row.children('td:lt(2)') // for columns 0 and 1
</code></pre>
<p>Is there any way to join these two lines?</p>
| jquery | [5] |
3,616,637 | 3,616,638 | How can I backup and restore my application on Android? | <p>How can I backup and restore my application on Android?</p>
<p>I have installed a backup application which will backup all installed applications to the SD card and also restore them to the device.</p>
<p>I want to give this facility with my application.</p>
| android | [4] |
3,941,988 | 3,941,989 | Object should be created only one time for each user | <p>I am doing a project on .NET. I need an object that should be created only one time for each user that using a page. And also this object should be declared as global because many methods are using it. I looked at some of design patterns but I coudlnt find something related on this issue. </p>
<p>Thanks in advance.</p>
| asp.net | [9] |
3,668,693 | 3,668,694 | Is it wise to always return in functions? | <p>I read somewhere a while back (unfortunately can't remember where), that it was wise to always put a <code>return</code> statement at the end of every function in JavaScript, because it clears the memory of objects and variables created in that function.</p>
<p>Is there any truth to that?</p>
| javascript | [3] |
4,520,729 | 4,520,730 | Console.WriteLine not showing message | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/137660/where-does-console-writeline-go-in-asp-net">Where does Console.WriteLine go in ASP.NET?</a> </p>
</blockquote>
<p>I know the delete is occuring has I checked the database</p>
<p>code:</p>
<pre><code> try
{
MyCommand.Connection.Open();
int count = MyCommand.ExecuteNonQuery();
if (count > 0)
{
Console.WriteLine("Delete Success!!!");
//lblMessage.Text = tbTourName.Text + " Deleted!";
}
else
{
Console.WriteLine("No Delete!!!");
}
Console.ReadLine();
}
catch (SqlException ex)
{
Console.WriteLine("Delete Failed coz.. " + ex.Message);
}
finally
{
MyCommand.Connection.Close();
}
</code></pre>
<p>Does it supposed to show the message on webpage itself?</p>
<p>Regards
Tea</p>
| asp.net | [9] |
1,677,088 | 1,677,089 | How to convert object to object[] | <p>I have an <code>object</code> whose value may be one of several array types like <code>int[]</code> or <code>string[]</code>, and I want to convert it to a <code>string[]</code>. My first attempt failed:</p>
<pre><code>void Do(object value)
{
if (value.GetType().IsArray)
{
object[] array = (object[])value;
string[] strings = Array.ConvertAll(array, item => item.ToString());
// ...
}
}
</code></pre>
<p>with the runtime error <code>Unable to cast object of type 'System.Int32[]' to type 'System.Object[]'</code>, which makes sense in retrospect since my <code>int[]</code> doesn't contain boxed integers.</p>
<p>After poking around I arrived at this working version:</p>
<pre><code>void Do(object value)
{
if (value.GetType().IsArray)
{
object[] array = ((Array)value).Cast<object>().ToArray();
string[] strings = Array.ConvertAll(array, item => item.ToString());
// ...
}
}
</code></pre>
<p>I guess this is OK, but it seems pretty convoluted. Anyone have a simpler way?</p>
| c# | [0] |
5,885,008 | 5,885,009 | getting file path from command line argument in python | <p>Can anyone guide me how can I get file path if we pass file from command line argument and extract file also. In case we also need to check if the file exist into particular directory</p>
<pre><code>python.py /home/abhishek/test.txt
</code></pre>
<p>get file path and check test.txt exist into abhishek folder.</p>
<p>I know it may be very easy but I am bit new to pytho</p>
| python | [7] |
3,549,764 | 3,549,765 | JQuery .html() working in IE but not in Firefox | <p>I have a div with id= slRecipelList and a textbox with id= txtRecipesWk1 containing a HTML string. I want to copy the HTML string from the textbox to the div, here is my code:</p>
<pre><code> $('#slRecipelList').html($('#txtRecipesWk1').val());
</code></pre>
<p>The code works fine in IE (V 8) but not in Firefox (V 3.6.18), when I step through the code and do console.log($('#slRecipelList').html()), it returns null.
I’ve also tried append (after emptying the div) with same result – okay in IE, not working in Firefox
Am I missing something obvious or silly here?</p>
| jquery | [5] |
621,310 | 621,311 | php loop display sum before loop that does calculation | <p>Is it possible for me to display the sum at the heading before the program runs through?</p>
<pre><code>while (($data = fgetcsv($handle, 1000, ","))) {
if($data[2] != $prevRow2) {
echo '</div>';
if ($prevRow2 != '') {
$stringData .= '</Payment>';
}
echo "<div id=\"row\">";
echo $sum;
$row++;
$sum = 0;
}
else { echo "<div id=\"filler\"></div>";}
foreach ($data as $key => $d) {
if ($key != 1) {
echo "<div class=\"field\">" .$d . "</div>";
}
}
$sum +=$data[6];
echo "<br/>";
echo "<div id=\"filler\"></div>";
$prevRow2 = $data[2];
}
fclose($handle);
}
</code></pre>
| php | [2] |
1,256,198 | 1,256,199 | Read line x of string? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/11491835/get-nth-line-of-string-in-python">get nth line of string in python</a> </p>
</blockquote>
<p>Is there a way to get a specified line from a multiline string in Python? For example:</p>
<pre><code>>>> someString = 'Hello\nthere\npeople\nof\nEarth'
>>> aNewString = someString.line(1)
>>> print aNewString
there
</code></pre>
<p>I'd like to make a simple "interpreter" style script, looping through every line of the file it's fed.</p>
| python | [7] |
666,833 | 666,834 | get the text of only the selected element not its descendants in jquery | <p>I have this code : </p>
<pre><code>$('p:not(:has(iframe))').filter(function(){
return $(this).text().length > 150;})
.slice(0,1).parent();
</code></pre>
<p>According to the docs, .text gets the text of the descendants also, and I was wondering how I could select only the text of ONLY the selected element, not its descendants.</p>
| jquery | [5] |
1,793,811 | 1,793,812 | $_SERVER['REQUEST_URI'] generating extra & in URL | <p>Having an issue here where the </p>
<pre><code>$_SERVER['REQUEST_URI']
</code></pre>
<p>is spitting out:
<code>/dev/nava2/store/index.php?route=product/product&amp;product_id=48</code> </p>
<p>the actual URL is <code>/dev/nava2/store/index.php?route=product/product&product_id=48</code> </p>
<p>obviously, the difference being the <code>&amp;</code> on the top vs. the <code>&</code> on the bottom</p>
<p>full code looks like this: </p>
<pre><code>$currentpage = $_SERVER['REQUEST_URI'];
$classic = "/dev/nava2/store/index.php?route=product/product&product_id=48";
if ($currentpage == $classic)
{ $classicclass = "current";
}
else { echo "";}
</code></pre>
<p>Any suggestions?</p>
| php | [2] |
4,493,173 | 4,493,174 | Php login panel | <p>I have developed a small application. I created a login panel for it. I have only one user so, I hard coded both user name and password. Below is the code but it is not working.I don’t have any db for this bcoz, it will have only 1 user.
Any help ii be appreciated.
Thanks in advance.</p>
<pre><code><?php
if(($_POST['na'] = 'admin') == ($_POST['pwd'] = 'zucker'))
{
header("location:first.php");
}
else
{
header("location:index.php?msg=enter correct user name and password");
}
?>
</code></pre>
| php | [2] |
4,056,309 | 4,056,310 | writing arraylist of objects in file | <p>I want to write arraylist of objects in a file. But only one object in going in file.Atfirst I am fetching all the stored objects and then appending new object after that I write whole arrayList to the file.</p>
<p>Here is my code....</p>
<pre><code>public void write(UserDetail u1) throws FileNotFoundException {
ArrayList<UserDetail> al = new ArrayList<UserDetail>();
FileInputStream fin = new FileInputStream(FILEPATH);
try {
if (fin.available() != 0) {
ObjectInputStream ois = new ObjectInputStream(fin);
while (fin.available() != 0 && ois.available() != 0) {
try {
al.add((UserDetail) ois.readObject());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (ois != null) {
ois.close();
}
}
}
}
al.add(u1);
FileOutputStream fos = new FileOutputStream(FILEPATH);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(al);
oos.flush();
oos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
throw e;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
</code></pre>
<p>help me......thnx in advance</p>
| java | [1] |
57,312 | 57,313 | json parsing error because of datas in different lines | <p>Now I am doing an Android application. Now I am facing a problem in json parsing.My json page structure is like this.</p>
<pre><code>[
{
"id":3,
"name":"dd"
},
{
"id":4,
"name":"ggg"
}
]
</code></pre>
<p>I tried with the following code.</p>
<pre><code>URL website = new URL("url");
InputStream in = website.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
while ((line = reader.readLine()) != null) {
JSONArray ary=new JSONArray(line);
}
</code></pre>
<p>but I am getting exception.Because all the datas are in different lines.if it in the same line
[{"id":3,"name":"dd"},{"id":4,"name":"ggg"}] then i can do easily...but they provide all datas in separate line ..thats the problem..Pls help me friends</p>
| android | [4] |
1,196,641 | 1,196,642 | How to get the date by passing a day in Java | <p>I have 2 days and need to find the whether the given day is within the inputs.
<br/>All i have is only days.</p>
<p>For example: if my start time is wednesday ,end time is sunday and current day is thursday, I should check the time span between current week wednesday and next sunday, then the function should return boolean value yes.</p>
<p>Example 2: if start day is friday ,end day is monday and current day is thursday,i should check within current week friday and upcoming Monday(which is on next week), It should return false in this case.</p>
| java | [1] |
4,696,960 | 4,696,961 | python factorial series to match first pair in range | <p>I'm a newbie and I'm trying to code the following factorial series in python to calculate the first matching number in a series within a finite range.
kd×d×(d−1)×⋯×(d−k+1)d×d×⋯d=k(d−1)!dk(d−k)!
so the expected value for the number needed for a match is
∑k=1d(k+1)k(d−1)!dk(d−k)!.</p>
<p>Due to the size of the numbers it errors:
OverflowError: long int too large to convert to float
So I'm using logs but still getting an error. Wondering if anyone has an good idea on this. </p>
<pre><code> m = 365
q = 1
a=[]
for x in range(q,m):
#y = y + x*(1/365)
#####y = y + (factorial(x)/(factorial(m-x)*(exponent(m,x))))
a.append((log((factorial(m))/exponent(m,x)))*log((q+x)/m))
#y = [(m-x)*factorial(m-x)/m]
#print ("x: ",x," y: ",y)
#return "a:",a," product-sum:",[a*a for a in a]
return sum(a)
</code></pre>
<p>Sorry I see the equation above isn't clear. Here's what I'm trying to get at:
<a href="http://en.wikipedia.org/wiki/Birthday_problem#Average_number_of_people" rel="nofollow">http://en.wikipedia.org/wiki/Birthday_problem#Average_number_of_people</a></p>
| python | [7] |
5,804,906 | 5,804,907 | php compression for images | <p>I am using following code to zip images folder at once:</p>
<pre><code><?php
// increase script timeout value
ini_set("max_execution_time", 300);
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open("my-archive.zip", ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("images"));
// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
$zip->addFile(realpath($key), $key) or die ("ERROR: Could not add file: $key");
}
// close and save archive
$zip->close();
echo "Archive created successfully.";
?>
</code></pre>
<p>But images are too much to compress at once. I have 70% of the images and want to zip only 30% of the images. Last image name is XYZ.jpg. So i want to zip all images after this last images. But i am not able to figure out how to do this ?</p>
| php | [2] |
3,312,069 | 3,312,070 | How to add our own created framework into iphone sdk | <p>I want to add my own framework into my app so can any one tell me the step by step process to how to add our own framework in iphone sdk</p>
<p>Thank you to All...</p>
| iphone | [8] |
4,943,907 | 4,943,908 | Get notified/receive explicit intents when an activity starts | <p>I am developing an application that gets notified when an <code>Activity</code> chosen by a user is started. For this to work, the best approach would be to register a <code>BroadcastReceiver</code> for <code>ACTION_MAIN</code> explicit <code>Intent</code>s, which as far as I know doesn't work (because these <code>Intent</code>s have specific targets). Another, probably less efficient approach, is to use the system <code>ActivityManager</code> and poll on the <code>getRunningTask()</code> which returns a list of all running tasks at the moment. The polling can be done by a background service. By monitoring the changes in this list, I can see whether an activity is running or not, so that my application can get notified. The downside is of course the polling. I have not tried this yet, but I think that this last approach will probably work.</p>
<p>Does anyone know of a better approach(es) or suggestions which are less intensive?</p>
| android | [4] |
3,848,873 | 3,848,874 | How to deal with a view with 14 buttons? | <p>I have a view with 14 buttons, it looks quite ugly now. I use round rect button, and put the buttons 7 each side.</p>
<p>Maybe someone could recommend me some good custom button style?</p>
<p>here comes the screenshot.</p>
<p>I don't see any way to reduce number of buttons, so may be I can change the button style to make it look better, any recommend button style?</p>
<p><img src="http://i.stack.imgur.com/lRz1i.png" alt="enter image description here"></p>
| iphone | [8] |
3,687,461 | 3,687,462 | What does the JavaScript [+num] syntax do? | <p>I have come across a refernce to a JavaScript syntax that I don't understand and cannot find any references to online.</p>
<pre><code>[+num]
</code></pre>
<p>What does this syntax do and when is it used?</p>
| javascript | [3] |
5,369,988 | 5,369,989 | echo for style in table row and table data | <pre><code><tr <?php if($isOverDeadline)
{
echo ' style="background-color:#CC3300"';
}
?>><td width="250" <?php
if($isOverDeadline)
{
echo ' style="color:#fff"';
}
?>><?php echo $something; ?> </td></tr>
</code></pre>
<p>I find that the nested php blocks inside tr and td do not work. Could someone tell me what is wrong ?</p>
| php | [2] |
5,556,412 | 5,556,413 | PHP while loop Error | <p>My query is right but its fetch zero result so why this while loop is print ones this statement No error please tell thanks in advance </p>
<pre><code>while(mysql_fetch_array($query))
{ echo "<br>"."No Error"."<br>"; }
</code></pre>
| php | [2] |
1,504,652 | 1,504,653 | Wrapping effect with 9 png, trying to make simple progress bar | <p>I'm making a simple progress bar. I have a full progress bar png on top of an empty progressbar png:</p>
<pre><code><RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="20dip"
android:background="@drawable/empty.9.png"
/>
<ImageView
android:layout_width="50dip" // some computed percentage width.
android:layout_height="20dip"
android:background="@drawable/full.9.png"
/>
</code></pre>
<p></p>
<p>It almost works - the idea was to set the "full" imageview's width to whatever percentage I need, since it's sitting on top of the empty one in the relative layout. </p>
<p>For some reason, the imageview is wrapping the graphic around on itself. Might be because it's a 9 png stretchable? The effect looks like the ImageView is drawing the first 50dip of the png, then moves back to its 0,0 coordinate, and draws the last 50dip of the png. Very strange! The png under it is fine, stretches as expected.</p>
<p>I basically just want to show N pixels worth of the full.9.png by setting the ImageView's width to a variable amount.</p>
<p>Thanks</p>
| android | [4] |
4,957,588 | 4,957,589 | creating loop for jquery datatables? | <pre><code>/*
* SQL queries
* Get data to display
*/
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS `" . str_replace(" , ", " ", implode("`, `", $aColumns)) . "`
FROM $sTable
$sWhere
$sOrder
$sLimit
";
$rResult = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
</code></pre>
<p>It is how specified in datatables...but my cindition is like this..</p>
<pre><code>for($i==0;$i<count($val);$i++){
$con ='ID='.$val[$i];
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS `" . str_replace(" , ", " ", implode("`, `", $aColumns)) . "`
FROM $sTable
$sWhere
$con
$sOrder
$sLimit
";
$rResult = mysql_query($sQuery, $gaSql['link']) or fatal_error('MySQL Error: ' . mysql_errno());
}
</code></pre>
<p>Can i use like this or cant...will datatables support it ...or can we encode that array result?</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.