Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,889,676
3,889,677
what is ::* in C++
<p>I was reading a basic C++ tutorial when I faced </p> <pre><code>::* </code></pre> <p>in the following code. May I know what that is:</p> <pre><code>class A { public: protected: int i; }; class B : public A { friend void f(A*, B*); void g(A*); }; void f(A* pa, B* pb) { // pa-&gt;i = 1; pb-&gt;i = 2; // int A::* point_i = &amp;A::i; int A::* point_i2 = &amp;B::i; } void B::g(A* pa) { // pa-&gt;i = 1; i = 2; // int A::* point_i = &amp;A::i; int A::* point_i2 = &amp;B::i; } void h(A* pa, B* pb) { // pa-&gt;i = 1; // pb-&gt;i = 2; } int main() { } </code></pre> <p>based on my C++ knowledge so far, I can not comprehend something like </p> <pre><code>int A::* point_i2 </code></pre> <p>could you help me out?</p> <p>thank you.</p>
c++
[6]
3,012,892
3,012,893
Use of simple delegate
<p>a simple delegate just point a function and later when we call delegate then mapped function is invoke.</p> <p>i hardly use delegate.so i just want to know why one should use simple delegate. here i am giving a sample code of use delegate.</p> <pre><code>using System; using System.Windows.Forms; delegate void DisplayMessage(string message); public class TestCustomDelegate { public static void Main() { DisplayMessage messageTarget; if (Environment.GetCommandLineArgs().Length &gt; 1) messageTarget = ShowWindowsMessage; else messageTarget = Console.WriteLine; messageTarget("Hello, World!"); } private static void ShowWindowsMessage(string message) { MessageBox.Show(message); } } </code></pre> <p>in the above example a delegate just point a function and when we invoke delegate then a function is called which is mapped. here we can directly call the function then why one should use delegate. please explain with good sample which describe the advantage of delegate. in my above program we can directly call ShowWindowsMessage function and there delegate is not required.</p> <p>thanks</p>
c#
[0]
327,830
327,831
Android Move the whole screen upwards when softkeypad is opened?
<p>i just want to shift my whole activity screen upwards when the user clicks on the edit text... i mean the screen will shift upwards and below it we can see the soft keypad... I have tried using android:windowSoftInputMode="adjustPan|adjustResize" in my Manifest file but it doesn't make any sense.. thanks in advance ... </p>
android
[4]
3,193,354
3,193,355
PHP File Injection?
<p>I have a script that calls a bash script that does some processing, but the script calls the bash script using user inputed data.</p> <p>I am wondering if there is a way to make sure the person (it's a file upload) doesn't append like <code>;cd /;rm -rf *</code> to the end of the file. Or anything else like that. Would a normal MYSQL Injection methods work? Is there a better alternative?</p>
php
[2]
2,861,920
2,861,921
Hiding a table row according to a value
<p>I do not find the right expression to select table rows that must be hidden according to the value ofe the cell on which the user has clicked. I have several rows similar to this:</p> <pre><code>&lt;tr id='row2'&gt; &lt;td class='col1'&gt;val 1&lt;/td&gt; &lt;td class='col2'&gt;Val 2&lt;/td&gt; &lt;td class='col3'&gt;val 3&lt;/td&gt; &lt;td class='col4'&gt;Val 4&lt;/td&gt; &lt;td class='col5'&gt;Val 5&lt;/td&gt; &lt;td class='col6'&gt;Val 6&lt;/td&gt; &lt;td class='col7'&gt;Val 7&lt;/td&gt;&lt;/tr&gt; </code></pre> <p></p> <p>and different rows could have the same value on the same column. When che user clicks on a cell I wish to hide() all the cells that have a value different from the selected one.</p> <p>I have binded my click event and in the routine I have already got the class id of the column (let say: 'col 4') clicked and the value of the cell (let say: 'val 4'). I would expect that something like:</p> <pre><code>$('tr').not(...some expression...).contains('val 4').hide() </code></pre> <p>would save the day bu I have trouble to determine the proper expression. </p> <p>have some hints?</p> <p>Thanks</p>
jquery
[5]
1,915,431
1,915,432
Broadcast receiver not called
<p>I know this a basic problem but it is still driving me crazy. I am setting a repeating alarm but the receiver is never called.</p> <pre><code>Intent intent = new Intent(NewSchedule.this, RepeatingAlarm.class); PendingIntent sender = PendingIntent.getBroadcast(NewSchedule.this, 0, intent, 0); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 10); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, calendar.getTimeInMillis(), 5 * 1000, sender); Log.i("calendar",calendar.getTimeInMillis() + ""); Toast.makeText(NewSchedule.this, "repeating_scheduled", Toast.LENGTH_SHORT).show(); public class RepeatingAlarm extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, "repeating_received", Toast.LENGTH_LONG).show(); } } &lt;receiver android:name=".RepeatingAlarm" android:process=":remote" /&gt; </code></pre> <p>I am testing on my phone. The calendar log shows the exact time. I never get the Toast in the receiver class.</p>
android
[4]
5,823,355
5,823,356
Check whether list of number is sequential or not
<p>I have quite a layman question about Java programming.</p> <p>I would like to write a function to check whether a list of number is sequential or not.</p> <p>Say [1, 2, 3, 4, 5], the function will return true,</p> <p>but for [1, 3, 4, 9, 10], the function will return false.</p> <p>Could anyone help me?</p> <p>Thank so much!</p>
java
[1]
3,422,280
3,422,281
Bring multi-dimensional array down (unnest) one level
<p>Althoug this works well enough, I am curious if anyone knows of a prettier way of doing this as this situation seems to come up quite often. </p> <pre><code>&lt;?php //Initialy, data is nested up in $some_array[0] ... $some_array = array(array('somevar' =&gt; "someValue", "someOtherVar" =&gt; "someOtherValue")); print_r($some_array); </code></pre> <p>Array ( [0] => Array ( [somevar] => someValue [someOtherVar] => someOtherValue ) )</p> <pre><code>// Could the following line be achieved a more elegant fashion? $some_array = $some_array[0]; print_r($some_array); // Prints the intended result: </code></pre> <p>Array ( [somevar] => someValue [someOtherVar] => someOtherValue )</p> <p>Does anyone know of a way to achieve this with a native function or in a more elegant fashion?</p> <p>Thanks!</p>
php
[2]
936,270
936,271
Still no solution for sending android app from Win 7 to LG Optimus V
<p>We have a Dell MT560 running Windows 7 with Eclipse, JDK, and the Android SDK. At the other end of the USB cable is an LG Optimus V Android phone. We wrote a tiny app and all it does is display "Hello Ron". This works perfectly on the emulator, but we are having no success sending the app to the phone. The phone does state that the USB connection is successful. Windows Explorer does see the phone, because it treats the phone as an "I:" disk drive, and shows in Windows the folders that exist on the phone. But DDMS on Eclipse does not list the phone as a connected device. The docs on developer.ansdroid.sdk instruct us to do a "Run" and that then a Device Chooser dialog should appear where we can choose to run the app on the phone arther than the emulator, but that does not happen. We have edited the Eclipse manifest to indicate "Debuggable=True". We also upgraded the BIOS on our Dell to the latest version, "A06". Not sure what else to try. Four people kindly responded to my post earlier today, and we tried all their suggestions, to no avail. </p> <p>Hopefully, someone out there can help figure out what mistakes we are making, please. Or if someone wants to walk us through it on the phone, that would be even better. Regards, Ron and Diane</p>
android
[4]
1,312,550
1,312,551
PHP to randomise image
<p>I'm loading a folder full of images in, to create a jQuery Image Gallery.</p> <p>There are currently 100 images being loaded in to create the gallery. I've got all that to load without issue.</p> <p>All I want to do is make the image(s) that are loaded, load in randomly.</p> <p>How do I achieve this?</p> <p>My code is :</p> <pre><code>&lt;?php $folder = "images/"; $handle = opendir($folder); while(($file = readdir($handle)) !== false) { if($file != "." &amp;&amp; $file != "..") { echo ("&lt;img src=\"".$folder.$file."\"&gt;"); } } ?&gt; </code></pre> <p>Thanks in advance.</p>
php
[2]
141,092
141,093
how to redirect to onother page after if condition is satified in php?
<p>I have used a php code for redirect to another page, but its not working.I am at loss. please help me. I am giving the code snippet.</p> <pre><code>if($row-&gt;cnt==1){ echo "Succes."; // header ('Location:HomePage.php); header("Location:http://localhost/library/HomePage.php"); } </code></pre>
php
[2]
1,383,109
1,383,110
ArrayAdapter Help?
<p>Hi i want to display a list view in my application. Each row should contains a text and an image. i have used ArrayAdapter to display this, but how to insert an image after the text.Please help ?</p> <pre><code>String lvr[]={"Android","iPhone","BlackBerry","AndroidPeople"}; super.onCreate(savedInstanceState); setContentView(R.layout.main); list1 = (ListView) findViewById(R.id.cg_listview1); list1.setAdapter(new ArrayAdapter&lt;String&gt;(this,R.layout.alerts , lvr)); </code></pre> <p>Here alerts is my layout contains only textView.</p>
android
[4]
541,036
541,037
Creating a exponential function in python
<p>I want to write a function that takes a single floating-point parameter x and returns the value of the function e(to the power of x) . Using the Taylor series expansion to compute the return value, using a loop that terminates when the partial sum SN+1 of Eq. (2) is equal to SN.</p> <p>Dont know how to make to the power of so i'm putting in a link to the <a href="http://en.wikipedia.org/wiki/Taylor_series" rel="nofollow">Wikipedia article for the Taylor Series</a>.</p>
python
[7]
2,151,523
2,151,524
Add a bookmark to a pdf using itextsharp
<p>I'm trying to merge pdfs and add bookmarks to them, I found a way to add a bookmark, by chapter, but the chapter aperse on the page, is there a way to add only the bookmark, or to make the chapter not visible.</p> <p>Thanks.</p>
c#
[0]
4,617,324
4,617,325
What's the difference between this two ways of defining a function in JavaScript?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname">Javascript: var functionName = function() {} vs function functionName() {}</a> </p> </blockquote> <p>Way 1:</p> <pre><code>function fancy_function(){ // Fancy stuff happening here } </code></pre> <p>Way 2:</p> <pre><code>var fancy_function = function(){ // Fancy stuff happening here, too. } </code></pre> <p>I use the former when I'm just defining a "normal" function that I'm gonna use one or several times and the latter when I'm passing it a callback for another function or so, but it looks to work fine in the both ways.</p> <p>Is it really a difference in some way?</p>
javascript
[3]
4,972,573
4,972,574
How to know how many event listeners there are on the page
<p>I am building a fairly large application in Javascript. It is a single page that can change different views. All the views have their own variables, events, listeners, elements, etc.</p> <p>When working with large collections and multiple events it's sometimes good to know what exactly is happening on the page.</p> <p>I know all the browsers have developer tools, but sometimes it's hard to click trough all the elements etc. And some options I can not find.</p> <p>One thing I am interested in is to know how many events there currently listened for on the page. This way I can confirm that I am not creating zombies.</p> <p>If the sollution is a developer tool, please let me know where to look and what to do. And most important, which browser to choose.</p>
javascript
[3]
4,233,296
4,233,297
Calling char method into main method
<p>How do I call this method into my main method: </p> <pre><code> public static char shiftLetter(char aLetter, int offset){ if((aLetter &gt;= 65 &amp;&amp; aLetter &lt;= 90) || (aLetter &gt;=97 &amp;&amp; aLetter &lt;=122)){ char shifted = (char) (aLetter + offset); return shifted; }else{ return aLetter; } } </code></pre> <p>Here is my main method:</p> <pre><code> public static void main(String[]args){ Scanner in = new Scanner (System.in); String isAnswer = askQ(); if (isAnswer.equals("encode") || isAnswer.equals("decode")){ String text = isText(); int offset = isOffset(); char[] myString = text.toCharArray(); System.out.println(myString); </code></pre>
java
[1]
5,888,521
5,888,522
Replace a character in java?
<pre><code>public void sendData(){ try { URL data = new URL("http://mywebsite.net/isvalid.php?username=" + usernameField.getText() + "&amp;password=" + passwordField.getText()); BufferedReader in = new BufferedReader( new InputStreamReader(data.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) if(inputLine.length() &gt; 0) inputString = inputLine; in.close(); if(!inputString.equals("Incorrect password.")){ System.out.println("Correct password"); run(); dispose(); } else if(usernameField.getText().length() &gt; 0 &amp;&amp; passwordField.getText().length() &gt; 0) { invalidUP(); System.out.println("Invalid username or password."); } else if(usernameField.getText().length() &lt; 1 || (passwordField.getText().length() &lt; 1)) { System.out.println("No password or username entered."); upLength(); } } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>How would I check if usernameField or passwordField would have a space in it? And if it has, replace it with "_". </p> <p>Also, if you think this method is wrong to send data or it can be done easier/quicker, please elaborate.</p>
java
[1]
1,512,005
1,512,006
Best practice : Hide unused parameter
<p>This may sound a newbie question, anyway I would like to know how you are dealing with this.</p> <p>I'm adding a method in class which has some parameters but still needs to be implemented later.</p> <p>I.e. </p> <pre><code>void AAA::doSmth(const int32_t status) { // TODO : Add implementation } </code></pre> <p>During compilation I get warning about unused parameter. Basically what I want to do is to do some trick that makes compiler to not print warning about unused parameter, but still keep empty implementation.</p> <p>So I would like to know what is the best practice to have some "dummy" usage of parameter in order to avoid the warning during compilation ? What is the best practice ???</p> <p><strong>Please do not offer any IDE or compiler related option to hide the warning !!!</strong></p>
c++
[6]
91,582
91,583
Selection Start Row in DatagridView
<p>I am using the windows DataGridView, in this grid i allowed the multiple rows selection.</p> <p>When i am checking the <code>dataGridView1.SelectedRows[0].Index</code> it's giving last selected rows Index. Just i want from which row the selection started(Start Row).</p>
c#
[0]
1,862,964
1,862,965
how to check in onCreate that the previous android process of the same activity has been killed?
<p>I have an activity in whose onCreate method an Init function is called (the function calls some native code involving lot of stuffs and calls to the openSLES audio api). The point is that this Init function makes the app crash when called again, which happens on a screen rotation or when i close the activity using Back button and i launch it again (but if in the meanwhile the process is killed, i have no troubles). I can't change the beaviour of the Init function.</p> <p>I see that the process isn't killed when the activity is destroyed, I expected this after reading the docs, and it's a good thing since - if there is some audio signal playing - that continues playing after the activity has been destroyed, which is good for my purposes.</p> <p>I tried to perform a check on the initialization state using onSaveInstanceState, but that works well only on screen-rotation, that's when onSaveInstanceState is called. The callback is not called when i push the Back button.</p> <p>So i tried to use Shared Preferences, performing the state saving in onPause. But at this point i have the opposite problem: if the process is killed, the Shared Preferences values are kept, but in that case i need to perform Init again for the app to work properly.</p> <p>I guess i need a way to know for sure if my activity is created after a process kill or not, but at the moment i can't see how. I thought about using the bundle instance in onPause method, but i can't figure how and whether this is possible. Any kind of hint would be really appreciated.</p>
android
[4]
852,439
852,440
Slidetoggle a div based on the link clicked
<p>Trying to get the div with class sbox to slide up and down based on the stoggle that has been clicked. Can't figure this out. (I have hundreds of these so I'd like to set up something generic instead of multiple different classes.)</p> <pre><code>$(".stoggle").click(function () { $(this).slideToggle("fast"); }); &lt;div class="wrapper"&gt; &lt;a class="stoggle" href="#"&gt;Read Bio&lt;/a&gt; &lt;div class="sbox" style="display:none;"&gt; Cras porta orci blandit at magna. &lt;/div&gt; &lt;/div&gt; &lt;div class="wrapper"&gt; &lt;a class="stoggle" href="#"&gt;Read Bio&lt;/a&gt; &lt;div class="sbox" style="display:none;"&gt; Lorem Ipsum &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
5,950,083
5,950,084
Java SQLException error
<p>I have got bellow error when I called a java method from from flex application.</p> <pre><code>java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/testnew </code></pre> <p>How can I solve this issue?Please help me.</p>
java
[1]
5,736,281
5,736,282
How to run android .apk file on Device or emulator from iMAC
<p>I have .apk file . And I just want to install that .apk file on device or emulator, to verify that application is running properly and ready to upload on Android Market.</p>
android
[4]
1,093,703
1,093,704
Return XPath location with jQuery? Need some feedback on a function
<p>For the following project I will be using PHP and jQuery.</p> <p>I have the following code:</p> <pre><code>$('*').onclick(function(){ }); </code></pre> <p>Once a user clicks on an element I want it to return the XPath location of that element.</p> <p>What I want to do essentially is sort of a filtering system with a little help of jQuery.</p> <p>PHP will retrieve a document from an outside source with PHP, using jQuery a user click on an element/relevant parts of that document. This jQuery function will return the XPath location of where the user clicked and is stored and associated with that document.</p> <p>In the future if that document is updated, using the XPath, PHP will retrieve only the XPath that was selected by the user previously instead of the whole document.</p> <p>I will need this jQuery function to also return element attributes such as the title in a <code>&lt;p&gt;</code> or href location in an anchor link.</p> <p>Long story short: My question is, is this even possible in jQuery? Returning the XPath location of a selected element along with it's attributes? I have no idea what this would look like in jQuery so any help would be appreciated.</p> <p>Any other additional feedback would be great too. As far as I know I could be using the wrong tools... or something. Thanks.</p>
jquery
[5]
4,664,962
4,664,963
Concatenation inside a parameter
<p>I'm trying to concatenate my increment variable inside the getElementById parameter. I can concatenate using createElement using the increment value, however when I try to concatenate the variable inside getElementbyId, its a no go.</p> <pre><code>var newdiv = document.createElement("form"); newdiv.setAttribute('id', 'form' + t);//t == increment newdiv.innerHTML = "&lt;br/&gt;" + t + Menu(); $("newline").appendChild(newdiv); alert( document.getElementById("form" + t).innerHTML //does not work document.getElementById("form0").innerHTML //needs to "look" like ) </code></pre>
javascript
[3]
1,083,496
1,083,497
Python: Alphanumeric Serial Number with some rules
<p>I am trying to create a alphanumeric serial number in Python, the serial number is governed by the following rules:</p> <p>3-Digit Alphanumeric Series Allowed values 1-9 (Zero is excluded) and A-Z (All Capitals with exclusions of I and O) The code should be able to give the next number after getting the input number.</p> <p>For example: If the input number 11D then the output number should be 11E and if the input number is 119 then output should be 12A instead of 120. Please let me know if this description is good enough to explain my requirement.</p> <p>I am currently using the code mentioned below:</p> <pre><code>def next_string(self, s): strip_zs = s.rstrip('z') if strip_zs: return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs)) else: return 'a' * (len(s) + 1) </code></pre>
python
[7]
2,652,336
2,652,337
Will the same singleton instance be available after php script command line call?
<p>I have script with defined class (for instance, Singleton.php). This class implements classic singleton pattern as in PHP manual:</p> <pre><code> class Singleton { private static $instance; public static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c; } return self::$instance; } public function run() { // bunch of "thread safe" operations } } $inst = Singleton::getInstance(); $inst-&gt;run(); </code></pre> <p>Question. If I call this script twice from command line ('<code>php Singleton.php</code>'), will run() method be really "thread safe"? It seems that it will not. I used to imitate single-process run via text file where some flag is stored, but it seems that there might be other cases. Your thoughts?</p>
php
[2]
4,044,680
4,044,681
how to download the video using php script
<p>In my program I want to add a download option to download the currently straming video. I tried this code:</p> <pre><code>$psp = "Tom_20_amp__20Jerry_20race-1.flv"; header("Content-type:application/octet-stream"); header("Content-Disposition:attachment;filename=$psp"); </code></pre> <p>But I get this error:</p> <blockquote> <p>"C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\Tom_20_amp__20Jerry_20race-1-5.flv" is not a valid FLV file.</p> </blockquote> <p>the video streaming properly. please guide me</p>
php
[2]
5,690,690
5,690,691
Write ASP.NET aspx page output to server-side disk
<p>I am writing an application which produces reports. I want to save the generated html server side to the disk for another application to use.</p> <p>The response objects only expose streams for writing data. I need to read the data from the response and write it to disk.</p> <p>Is there a more graceful way of doing this than creating a front-end which receives the user request, programattically makes a separate report http request, saves the response to disk and writes it to the user?</p>
asp.net
[9]
4,820,200
4,820,201
android video playback
<p>I'm new to android. Can anyone help me how to display images from the Sd Card or play videos from Sd Card.. I tried it many ways but none of it is working..</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" android:orientation="vertical" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /&gt; &lt;VideoView android:id="@+id/videoView1" android:layout_width="243dp" android:layout_height="234dp" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
4,894,169
4,894,170
Exception problem when rebinding DataViewGrid
<p>I have a List&lt;> that I bind to a DataViewGrid using a Binding source. Like this:</p> <pre><code> private void BindGridView(DataGridView dgv, List&lt;KeyTextPair&gt; list, Func&lt;KeyTextPair, int, bool&gt; predicate) { BindingSource bs = new BindingSource(); bs.DataSource = list.Where(predicate); dgv.DataSource = bs; } </code></pre> <p>I have a collection of such lists, which the user can chose from to display in the DVG. However, upon attempting to change one list for another by rebinding I get the error:</p> <p>"Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function."</p> <p>I've looked around for a couple of hours but i still haven't figured out why this is happening.</p> <p>I'll be very happy if one of you guys can help me.</p> <p>Thanks.</p>
c#
[0]
796,113
796,114
Python read website data line by line when available
<p>I am using <code>urllib2</code> to read the data from the url, below is the code snippet :</p> <pre><code>data = urllib2.urlopen(urllink) for lines in data.readlines(): print lines </code></pre> <p>Url that I am opening is actually a cgi script which does some processing and prints the data in parallel. CGI script takes around 30 minutes to complete. So with the above code, I could see the output only after 3o minutes when the execution of CGI script is completed.</p> <p>How can I read the data from the url as soon as it is available and print it.</p>
python
[7]
1,803,617
1,803,618
Defining a dd/mm/yyyy field within an abstract table model
<p>I have defined an abstract table model but one of the columns should house date values as dd/mm/yyyy format not sure how to do this.</p> <p>I have a external global file and have hard coded the dates as dd/mm/yyyy.</p> <p>How can I define this column within my abstract table model so that to only allow only dates having dd/mm/yyyy format.</p> <pre><code>public class OptraderGlobalParameters { public static boolean DEBUG = true; //Set DEBUG = true for Debugging /*=========================*/ /*Table Array For Dividends*/ /*=========================*/ public static String[] columnNames = {"Date", "Dividend", "Actual", "Yield (%)" }; public static Object[][] data = { {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, {"dd/mm/yyyy", new Double(5), new Boolean(false), new Boolean(false)}, }; } </code></pre>
java
[1]
5,791,818
5,791,819
website folder layout
<p>I'm not going to ask <em>what is the best way to ...?</em> since they might be several ways to do it, I just want to know from your experience how to manage folders and files when starting to build a website ? (note: I'm not english native that is why I request here, I can't find right places to be answered).</p> <p>I've been coding for years but always on my own and I never share about how people structure their website before.</p> <p>As an information, I'm making a structure file at the root of my website, <em>struct.php</em> that contains the common layouts shared by the many pages in my website.</p> <p>If the user types <em>http://mywebsite.com/folder/</em> it requests the index file of the requested folder which just contains the 'struct' file importation, for the other variable parts like the metadatas of webpages, I'm creating a folder named <em>meta</em> which contains a file for any type of data (.title, .description, .keywords) and of course the struct file is fetching the content of these informative file and display them in their appropriate place in the document.</p> <p>I feel comfortable with that structure cause it's been a long time using it. But I'd really appreciate it if you were giving some advices or some useful links and/or tell me how you manage your own website.</p>
php
[2]
2,513,513
2,513,514
Recording screen activities
<p>I have a requirement in my app recording screen activities as a video file. i am new to android i dont know whether it is possible or not in andorid. if possible please suggest me a way to do that thanks in advance</p>
android
[4]
2,370,663
2,370,664
How can php read this parameter
<p>If I have a stored input string that looks like this </p> <pre><code>http://site.com/param1/value1 </code></pre> <p>how can php extract <code>value1</code>?</p> <hr> <p>I know how to extract parameters that look like this </p> <pre><code>http://site.com?param1=value1 </code></pre> <p>but it doesn't work for the format I'm asking about.</p>
php
[2]
5,787,016
5,787,017
list header not showing
<p>hi guys check out this method.... the header view of the list view doesnot displays...</p> <pre><code>private void displayResultList() { TextView tView = new TextView(this); tView.setText("This data is retrieved from the database and only 4 " + "of the results are displayed"); getListView().addHeaderView(tView); setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, results)); getListView().setTextFilterEnabled(true); } </code></pre>
android
[4]
582,924
582,925
Is this piece of Javascript inefficient?
<p>I was just wondering whether this snippet of Javascript is going to slow down my site:</p> <pre><code>$(function(){ var realLink = location.href; $( "#nav a" ).each( function( intIndex ){ String.prototype.startsWith = function(str){ return (this.indexOf(str) === 0); } var pageLink = $(this).attr("href"); if ( realLink.startsWith(pageLink) ) $(this).parent().addClass("active"); } ); }); </code></pre> <p>It only loops about 5-7 times, and I don't have very much Javascript looping experience.</p>
javascript
[3]
1,601,298
1,601,299
jquery $(document).ready and reading div content on load
<p>Anyone know why this isnt working?</p> <p><strong>css</strong></p> <pre><code>#test1 { height: 50px; border: 1px solid black; } #test2 { height: 50px; color: red; border: 1px solid black; } </code></pre> <p><strong>html</strong></p> <pre><code>&lt;div id="test1"&gt; test&lt;br /&gt; Text &lt;/div&gt; &lt;br /&gt; &lt;div id="test2"&gt; &lt;/div&gt; </code></pre> <p><strong>jquery</strong></p> <pre><code>$(document).ready(function(){ if($("#test1").val() != "") { $("#test2").val($("#test1").val()); $("#test2").val(""); } }); </code></pre> <p>I also have a link of the code here to play with: <a href="http://jsfiddle.net/FDe9N/4/" rel="nofollow">http://jsfiddle.net/FDe9N/4/</a></p> <p>on the <em>$(document).ready</em> doesnt the site fully load before executing the code? and if so doesnt that mean the div should already contain the text? the code doesnt hit the code in the <em>if</em> statement as if the div was empty when in fact it does have text in it... Thanks in advance!</p>
jquery
[5]
3,104,646
3,104,647
check if wifi is connected every 5 minutes after screen is off
<p>I have found good tutorial to for Handling Screen OFF and Screen ON Intents: <a href="http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/" rel="nofollow">http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/</a></p> <p>but i want that after screen is off every 5 minutes wifi is checked if is connected</p> <pre><code>ConnectivityManager connManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); wifi.isConnected() </code></pre> <p>i want to use <code>alarm manager</code> <a href="http://developer.android.com/reference/android/app/AlarmManager.html" rel="nofollow">http://developer.android.com/reference/android/app/AlarmManager.html</a> but i don't know how to check every 5 minutes if is connected or not.</p>
android
[4]
3,369,395
3,369,396
How can I prevent DataGridView double click to open a form more than one time?
<p>How can I open a form one time when I double click a dataGridView cell ?</p> <pre><code>private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { //string queryString = "SELECT id, thename, address,fax,mobile,email,website,notes FROM movie"; int currentRow = int.Parse(e.RowIndex.ToString()); try { string movieIDString = dataGridView1[0, currentRow].Value.ToString(); movieIDInt = int.Parse(movieIDString); } catch (Exception ex) { } // edit button if (e.RowIndex != -1) { string id = dataGridView1[0, currentRow].Value.ToString(); string thename = dataGridView1[1, currentRow].Value.ToString(); string address = dataGridView1[2, currentRow].Value.ToString(); string fax = dataGridView1[3, currentRow].Value.ToString(); string mobile = dataGridView1[4, currentRow].Value.ToString(); string email = dataGridView1[5, currentRow].Value.ToString(); string website = dataGridView1[6, currentRow].Value.ToString(); string notes = dataGridView1[7, currentRow].Value.ToString(); Form4 f4 = new Form4(); f4.id = movieIDInt; f4.thename = thename; f4.address = address; f4.fax = fax; f4.mobile = mobile; f4.email = email; f4.website = website; f4.notes = notes; f4.Show(); } } </code></pre> <p>this code opens a form each time I click a dataGridView, I want if it is opened, doubleClick will not open it again </p>
c#
[0]
5,712,465
5,712,466
Union of two iterators
<p>Consider the iterators <code>count(3,3)</code> and <code>count(5,5)</code>. How can I create a iterator that outputs only the numbers that occur in either <code>count(3,3)</code> and <code>count(5,5)</code>?</p>
python
[7]
5,592,772
5,592,773
What's meant by result errors of SmsManager?
<p>When I send an SMS using <code>SmsManager</code>, the result intent broadcasted holds a value of 5</p> <pre><code>Activity.RESULT_OK SmsManager.RESULT_ERROR_GENERIC_FAILURE SmsManager.RESULT_ERROR_NO_SERVICE SmsManager.RESULT_ERROR_NULL_PDU SmsManager.RESULT_ERROR_RADIO_OFF </code></pre> <p>What's meant by every one of them? and please mention a test case that could generate each one. I know that RESULT_OK denotes a successfully sent SMS. GENERIC_FAILURE occurs for general erros (e.g. I've no credit).</p> <p>But I've activated Airplane mode and tried to send an SMS. I've thought it would trigger NO_SERVICE error, but a RADIO_OFF was triggered instead. Also the official documentation is not demonstrating them very well.</p>
android
[4]
4,272,225
4,272,226
How can i compare a string and a char array in java?
<p>In my program I'm trying to compare my char array <code>asterixA[]</code> to string (word) in an if loop like:</p> <pre><code>if (word.equals(asterixA)) </code></pre> <p>but its giving me an error. Is there any other way i can compare them?</p>
java
[1]
5,060,786
5,060,787
int? maxResults what does the ? means in this statement
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2699373/c-sharp-basic-question-what-is">C# - Basic question: What is ‘?’?</a> </p> </blockquote> <p>I have found this statement in a function arguments.</p> <pre><code>public static SyndicationFeed GetDataFeed(...... int? maxResults) </code></pre> <p>what does that means?</p>
c#
[0]
1,251,259
1,251,260
Should my business logic be in the fragment or the activity above?
<p>I'm trying to use fragments and a list view with an array adapter, and having trouble calling my method from the onClickListener in the array adapter.</p> <p>If I understand the pattern correctly, a fragment should be self-sufficient, so I want to put my business logic in there. But I can't manage to call it from the array adapter. I can call it if I put it in the main activity, but doesn't that preclude me from using the fragment in another activity and break the paradigm?</p> <p>Is my business logic in the wrong place, or am I not calling it correctly?</p> <p>Here is my ArrayAdapter;</p> <pre><code>public class RecipientsListAdapter extends ArrayAdapter&lt;Recipient&gt;{ Context context; int layoutResourceId; Recipient data[] = null; public RecipientsListAdapter(Context context, int layoutResourceId, Recipient[] data) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this.context = context; this.data = data; } @Override public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; RecipientHolder holder = null; final boolean isLastRow = (position == data.length-1); if(row == null) { LayoutInflater inflater = ((Activity)context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new RecipientHolder(); holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon); holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle); row.setTag(holder); } else { holder = (RecipientHolder)row.getTag(); } final Recipient recipient = data[position]; holder.txtTitle.setText(recipient.displayName); holder.imgIcon.setImageResource(recipient.icon); row.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((MainActivity)context).onChildItemSelected(position); if(isLastRow){ //((RecipientsFragment).getContext()).launchContactPicker(); ((MainActivity)context)).launchContactPicker(); } else{ Toast.makeText(getContext(), recipient.displayName, Toast.LENGTH_SHORT).show(); } } }); return row; } </code></pre>
android
[4]
5,932,399
5,932,400
Operator Functions as Member Functions and Nonmember Functions
<p>I am very confuse in getting the idea of operator overloading as a member and non member function.</p> <p>What do we actually mean, when we overload operator as a non-member function and similarly what do we mean when we overload operator as a member fuctions. Although I know that the non-member functions are the <em>friend</em> functions.</p>
c++
[6]
496,932
496,933
JavaScript: IF time >= 9:30 then
<p>I'm trying to write a statement that says "if time is this and less than that then". I can use get hours and get min. However, I'm having problems combining a time such as 9:30.</p> <p>Example,</p> <pre><code>var now = new Date(); var hour = now.getHours(); var day = now.getDay(); var mintues = now.getMinutes(); if (day == 0 &amp;&amp; hour &gt;= 9 &amp;&amp; &amp;&amp; mintues &gt;= 30 } &amp;&amp; hour &lt;= 11) { document.write(now); } </code></pre> <p>This only if the time is less between 9:30 10. As soon as the clock hits 10 the minutes are then &lt; 30 and the script breaks.</p> <p>Any thoughts on how to better incorporate the time function to make this theory work?</p> <p>Thanks,</p>
javascript
[3]
4,757,159
4,757,160
how to select next instance of a selector with possibly intervening classes
<p>I'd like to be able to select the next instance of a specific selector such as .ajax-loader in the following. I tried .next('.ajax-loader') but didn't seem to work and since there could be intervening classes, just simply next() wouldn't work. Here's my markup and a fiddle:</p> <pre><code>$(document).ready(function(){ $('.click-me').on('click',function(){ $(this).next().html('here i am'); }); });​ </code></pre> <p>html:</p> <pre><code>&lt;button class='click-me'&gt;JT&lt;/button&gt; &lt;div class='other-loader'&gt;other loader&lt;/div&gt;&lt;div class='ajax-loader'&gt;&lt;/div&gt;&lt;br /&gt; &lt;button class='click-me'&gt;JU&lt;/button&gt;&lt;div class='ajax-loader'&gt;&lt;/div&gt;&lt;br /&gt; </code></pre> <p>In the first example, how could I progamatically say the next instance of ajax-loader? Here is a fiddle: <a href="http://jsfiddle.net/HAJLP/2/" rel="nofollow">http://jsfiddle.net/HAJLP/2/</a></p> <p>thx in advance</p>
jquery
[5]
2,446,722
2,446,723
empty value of parameter - php
<p>I have this code:</p> <pre><code>foreach($summary as $machine) { $hostname = $machine['node']; $result = mysql_query("SELECT OS FROM machines WHERE ind='$hostname'"); while($row = mysql_fetch_array($result)) { if($row == 'solaris') { $partition_os = 'export/home'; } else { $partition_os = '/home'; } } } &lt;partition&lt;?php echo $i; ?&gt;&gt;&lt;?php echo $partition_os; ?&gt;&lt;/partition&lt;?php echo $i; ?&gt;&gt; </code></pre> <p>The output of the query is:(without the <code>where</code>)</p> <pre><code>mysql&gt; SELECT OS FROM machines; +---------+ | OS | +---------+ | NULL | | solaris | +---------+ </code></pre> <p>My problem is that in my xml (this is for ajax) i see only <code>/home/</code> instead of <code>export/home</code>. The <code>$hostname</code> supposed to be fine because i use it before.</p> <p>Thank you!</p>
php
[2]
581,861
581,862
How to use Accelerometer Values to Move an Image in Android
<p>Hiii all i want to move an image using accelerometer values,but m not able to do it.can anyone plz help me to do dis, i hav already gone through sample code in android developers site but couldnt understand properly. Thanks.</p>
android
[4]
4,443,933
4,443,934
how to highlight a div for a few seconds using jQuery
<p>I want to be add the following to a a page:</p> <p>When a div is clicked, I want to:</p> <ol> <li>change the background color of the clicked on div for a few seconds</li> <li>revert back to the original background color after a few seconds</li> </ol> <p>I want to do this by using only jQuery available functions - i.e. not using a plugin or anything else. I am relatively new to jQuery, but I think a possible solution involves the use of changing the class of the selected div and using a timer.</p> <p>I am not sure how to put it all together though. Can anyone provide a few lines that show how to do it?</p> <p>This is what I have so far:</p> <pre><code>$(function(){ $('div.highlightable').click(function(){ //change background color via CSS class $(this).addClass('highlighted); //set a timer to remove the highlighted class after N seconds .... how? }); }); </code></pre>
jquery
[5]
2,998,574
2,998,575
How to take the larger value and use in PHP query
<p>I have a field on a real estate search form asking for Min to Max number of bedrooms. The PHP query extract to return the search results is;</p> <pre><code>//check bedrooms if(!empty($_GET["room_no_min"]) &amp;&amp; is_numeric($_GET["room_no_min"])){ $query[] = "'No_Bedrooms' &gt;= '".$_GET["room_no_min"]."'"; $room_min_val = $_GET["room_no_min"]; } if(!empty($_GET["room_no_max"])){ $query[] = "'No_Bedrooms' &lt;= '".$_GET["room_no_max"]."'"; $room_max_val = $_GET["room_no_max"]; } </code></pre> <p>Which is fine, but I want it to take into account if someone enters the value 5 (min) to 2 (max) i.e. the other way round than they are suppose to. I don't want to use validation I'd rather the query could be something like <code>from =&gt;min(room_no_min,room_no_max)</code> and <code>&lt;= max(room_no_min,room_no_max)</code> but not sure how to re-write the query.</p>
php
[2]
4,283,213
4,283,214
inserting array elements into database
<p>I want to store Each element of each array into mysql database fields. how can i do that?</p> <pre><code>&lt;?php // primarily a method for storing data // arrays are counted from 0 $hosts = array( array("ronmexico.kainalopallo.com/", "beforename=$F_firstname%20$F_lastname&amp;gender=$F_gender", "Your Ron Mexico Name is ", "/the ultimate disguise, is ([^&lt;]+)&lt;\/b&gt;&lt;\/u&gt;/s"),&lt;u&gt;&lt;b&gt;([^&lt;]+)&lt;\/b&gt;&lt;\/u&gt;/s"), array("rumandmonkey.com/widgets/toys/mormon/index.php", "gender=$F_gender&amp;firstname=$F_firstname&amp;surname=$F_lastname", "Your Mormon Name is ","/ My &lt;p&gt;My Mormon name is &lt;b&gt;([^&lt;]+)&lt;\/b&gt;!&lt;br \/&gt;/s") ); return $hosts; ?&gt; </code></pre>
php
[2]
1,743,827
1,743,828
Count for datetime object
<p>I'm trying to iterate over DateTime properties on objects in a List collection... </p> <p>Ex. a tree view that lists the a Name with all its Courses underneath works fine:</p> <pre><code> // Sorting on name with the courses beneath it: // *list* is a List&lt;ClsStandholder&gt;; private void ShowNameWithCourses() { treeViewList.Nodes.Clear(); for (int i=0; i &lt; list.Count; i++) { treeViewList.Nodes.Add(list[i].name); for (int j=0; j &lt; list[i].courses.Count; j++) { treeViewList.Nodes[i].Nodes.Add(list[i].courses[j]); } treeviewList.ExpandAll(); } } </code></pre> <p>That works perfect... where I am having trouble is trying to sort on date and iterate through a count of the dates.</p> <pre><code>for (int j=0; j &lt; list[i].SubscriptionDate. // how do i put some sort of count for this? </code></pre> <p>There seems to be no property to loop over all the dates entered.</p>
c#
[0]
1,645,023
1,645,024
Generate combinations (in specific order) of all permutations of the dict of lists
<p>I have a dict of lists</p> <pre><code>d = {'A': [1,2,3], 'B': [4,5], 'C': [6]} </code></pre> <p>I need to produce all permutation of each list (A, B and C). This is OK.</p> <pre><code>p = {} for k in d.keys(): p[k] = [i for i in itertools.permutations(d[k])] </code></pre> <p>This results in <code>p</code></p> <pre><code>{'A': [(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)], 'B': [(4, 5), (5, 4)], 'C': [(6,)]} </code></pre> <p>Then I need to merge tuples from A, B and C lists but in the specific order (for example in order of <code>sorted(p.keys())</code> which actually gives <code>['A', 'B', 'C']</code>). So I should obtain list of tuples of integers:</p> <pre><code>[(1,2,3,4,5,6), (1,2,3,5,4,6), (1,3,2,4,5,6), (1,3,2,5,4,6), ... (3,2,1,5,4,6) ] </code></pre> <p>I know that <code>itertools.product</code> could be used in such cases, but the initial dictionary <code>d</code> can consist of arbitrary number of values with different keys and I don't know how to use it in this case. Or maybe you will be able to suggest totally different solution of the desribed problem. The faster the final solution will work the better.</p>
python
[7]
16,948
16,949
Rotating an ImageView within a Layout... how?
<p>I have a layout with an image on it (embedded in an ImageView). I need to rotate the image (let's say) 90 degrees CCW.</p> <p>I've written code to animate the image rotating...:</p> <pre><code>public class MainActivity extends Activity { private ImageView mImageView = null; private Animation mRotateAnimation = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mImageView = (ImageView) findViewById(R.id.my_image); mRotateAnimation = AnimationUtils.loadAnimation(this, R.anim.my_rotate_90); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { mImageView.startAnimation(mRotateAnimation); return true; } return super.onTouchEvent(event); } } </code></pre> <p>The image smoothly rotates 90 degrees, but then snaps back to its original state. This is what the Android documentation says will happen after an animation completes. Presumably, on the notification that the animation has ended, I'm supposed to transform the ImageView (or the underlying drawable), and possibly invalidate it to trigger a redraw.</p> <p>All well and good, except that <strong>I can't find a way to do it, and I can't find any examples of anyone else doing it</strong>.</p> <p>I tried using <code>getImageMatix</code>/<code>setImageMatrix</code> on <code>mImageView</code>, with no apparent effect. There are subclasses of Drawable that will rotate an image, but there is no setDrawable() method on ImageView, so I don't see how to use one.</p> <p>I searched the examples; though a few of them involve animation and rotation (notably LunarLander), none of them are animating an ImageView, and then leaving it in some transformed state.</p> <p>Surely I'm missing something simple here... aaaargh, how do you rotate an ImageView within a layout?</p> <p>Thanks.</p>
android
[4]
1,569,464
1,569,465
How to connect global server from local server in asp.net?
<p>Any one idea about how to connect the global server from local server? i mean entering data in local server also be placed into global server database.How to do this?</p>
asp.net
[9]
3,882,980
3,882,981
Slashes and backslashes uniformity on UNIX / Windows
<p>I'm writing a PHP class, and I want it to be cross-platform compatible. I need to explode a path to find a particular folder name. What do I choose for the delimiter? The path will contain '/' on UNIX and '\' on Windows.</p> <p>In this particular example, I want to get the name of the directory where an included file is stored. I use this :</p> <pre><code>private function find_lib_dir() { $array_path = explode('/', __DIR__); return $array_path[count($array_path)-1]; } </code></pre> <p>In this situation (and more generally), what can I do to make sure it will work on both Windows and UNIX?</p> <p>Thanks!</p>
php
[2]
3,248,496
3,248,497
Jquery find the text field by the text within it
<p>Is it possible to find a text field by the text entered inside. </p> <p>My exact situation is that,</p> <p>I have about 4-5 text fields, and i need to find those text fields which doesn't have any text entered, i.e whose value = "" .</p> <p>Any help would be of great use.</p>
jquery
[5]
1,657,142
1,657,143
custom bitmap icon to Statusbar notification icon
<p>my new question relate to my last <a href="http://stackoverflow.com/questions/8280179/write-text-on-image-and-show-it-to-a-imageview">question</a></p> <p>i want create a custom bitmap and write a string on it and use it for StatusBar notification icon .</p> <p>It's Possible, because <code>Battery Indicator Pro</code> exactly works with merging 2 image and show it on statusbar icon but how ?</p> <p>can any one help to me ?</p> <p>thanks</p>
android
[4]
193,848
193,849
Getting a value from a different class
<p>I have a main class named <code>main.java</code> and 3 classes in a package <code>f.java</code>, <code>graphics.java</code> and <code>image.java</code></p> <p>I have a private int R in f.java, with <code>setR()</code> and <code>getR()</code> there</p> <p>Now i need to get that value (from getR()) in <code>graphics.java</code></p> <p>I need to get an interface linking those 2, or is just a cast problem?</p> <p>Try to get me some code for graphics.java so i can get that value!</p>
java
[1]
2,888,228
2,888,229
AlertDialog Closing on Overlay Click
<p>Trying to debug a bit of code. I have a AlertDialog with a positive and negative listener set. On an Android 2.3.3 device everything works as expected. A user has to choose between two options in order to continue. However, on my 4.1.1 device a user can click anywhere on the screen to dismiss the dialog. Not sure what is getting called that is dismissing the dialog box. I've looked at <a href="http://developer.android.com/guide/topics/ui/dialogs.html#AlertDialog" rel="nofollow">Android AlertDialog</a> and <a href="http://developer.android.com/reference/android/app/AlertDialog.Builder.html" rel="nofollow">AlertDialog.Builder</a> but I can't find any helpful information. Any help on why this is occurring would be appreciated. The code for the dialog is below</p> <pre><code>AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.titleString)); builder.setPositiveButton(this.getResources().getString(R.string.option1), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Things Happen Here dialog.cancel(); } }); builder.setNegativeButton(this.getResources().getString(R.string.option2), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Things Happen Here dialog.cancel(); } }); AlertDialog demoAlert = builder.create(); demoAlert.show(); </code></pre>
android
[4]
5,292,867
5,292,868
How to reinstall the iPhone app in ad hoc distribution
<p>I am using ad hoc distribution for my iPhone app. It works very well. The only problem is when I update my app or create a new binary and want to install this new version on device, I need to delete the old version. Like although I drag and drop the new version in iTunes application, it does not over write the previous version even after I do sync. It might be becoz the app already exists in the device. So I need to delete it to reinstall it. How do I make sure the app gets updated to the new version and I dont loose the data from the previous app. Data I mean the database. Please note I am just formating the UI and not even touching the database.</p>
iphone
[8]
4,495,870
4,495,871
Gender Field in java
<p>Im creating an employee class containing three fields nem, age and gender. I need to create a gender field but the user can only choose male or female. I'm guessing I'm going to have to do this in boolean form but I don't know how I'm going to do that can anyone help me out please. </p> <p>So far i have </p> <pre><code>public class Employee { private String name; private int age; private boolean gender; private boolean male; private boolean female; public Employee(String name, int age, boolean gender) { this.name = name; this.age = age; boolean f = female; boolean m = male; if (gender = f) { System.out.print("female"); } else if (gender = m) { System.out.print("male"); } } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public boolean isGender() { return gender; } public void setGender(boolean gender) { if (gender = f) { System.out.print("female"); } else if (gender = m) { System.out.print("male"); } } } </code></pre>
java
[1]
2,962,174
2,962,175
read file matching lines using array using php
<p>I want to be able to read through a plain text file and match a number of lines without the need to iterate over the text file multiple times. I am passing in an array with a list of strings I would like to match, which ideally, I would like to put into an array.</p> <p>I can achieve the desired result using the code below, but it necessitates the reading of the text file multiple times.</p> <pre><code>function readFile($line){ $contents = file("test.txt"); if(preg_match("/$line*/i", $val)){ return($val); } } </code></pre> <p>Ideally, I would like to do the following:</p> <pre><code>// pass an array to the funciton which will parse the file once and match on the elements defined. $v = readFile(array("test_1", "test_2", "test_2", "test_3")); // return an array with the matched elements from the search. print_r($v); </code></pre> <p>Any help would be much appreciated.</p> <p>Thanks all!</p>
php
[2]
5,736,178
5,736,179
Calculating time by the C++ code
<p>I know this question has been asked few times over SO but none of them is really helping me out, so asking again.</p> <p>I am using windows xp and running visual studio c++ 2008.</p> <p>All the code which i am looking is using time.h but i think may be its not working correctly here, because results are making me suspicious.</p> <p>So this is what i want.</p> <pre><code>star time = get time some how (this is my question) my code end time = get time some how (this is my question) time passed = start time - end time </code></pre>
c++
[6]
5,166,458
5,166,459
scrollview scroll delegation
<p>Is there any delegate or some notification which tells that scroll view has been scrolled?</p>
iphone
[8]
3,012,109
3,012,110
printing negative value in C++ base 8 or 16
<p>How is C++ supposed to print negative values in base 8 or 16? I know I can try what my current compiler/library does (it prints the bit pattern, without a minus in front) but I want to know what is <em>should</em> do, preferrably with a reference.</p>
c++
[6]
5,743,232
5,743,233
if statement in loop not working
<p>For the life of me I can't figure out why my IF statement is not getting hit. There are plenty of cases where the remainder of n // the last number put in the results list is 0.</p> <pre><code>n = 100 numbers = range(2, n) results = [] results.append(numbers.pop(0)) print numbers for n in numbers: if n % results[-1] == 0: print "If statement", numbers numbers.remove(n) else: print "Else statement", numbers numbers.remove(n) </code></pre>
python
[7]
5,988,914
5,988,915
Java issue with object
<p>I have a class called</p> <pre><code>public class UserSettings { public static String sessionId; public static int vrefresh; public static int mrefresh; } </code></pre> <p>Then in another class I have this method </p> <pre><code>public static void parseBusinessObject(String input, Object output) </code></pre> <p>And this method writes into the output Object.</p> <p>But in this case there are still static variables, so I can pass the class without creating an object?</p>
java
[1]
71,955
71,956
c++ override operator and this
<p>I want to override the "="operator,but I have a problem,the class has a const member which I want to change when I use "=",I think deconstruct the object and construct a new object may be worked but "this" can not be change.so,would you help me?</p>
c++
[6]
4,108,649
4,108,650
how to set spinner item value according to the web service particular value in android
<p>I have some items on spinner adapter-{astro,pluto,sun}.I get a value from web service dynamically (ex)pluto.Then how can i set pluto value to spinner for user view. Please help me </p>
android
[4]
3,705,952
3,705,953
Run same exe twice
<p>I have the following code:</p> <pre><code>foreach(string fileName in chunkFiles) { p = GenerateProcessInstance(); p.StartInfo.Arguments = string.Format("{0} {1} false {2}", fileName, Id, logName); p.Start(); p.WaitForExit(); sent += p.ExitCode; } </code></pre> <p>What I want to do is if I have at least 2 chunks to run the EXE with 2 instances. My only problem is that I have WaitForExit. I am using this because I need a parameter returned from the EXE. How to solve this problem?</p>
c#
[0]
2,559,643
2,559,644
Is there a fiddler like app for IPhone to see what HTTP calls are being made?
<p>This is for troubleshooting my app on IPhone.</p>
iphone
[8]
5,363,774
5,363,775
jQuery - click on button shown on focusin
<p>I want to show a button on focusin, do some action when clicked or hide that button on focusout:</p> <pre><code>$(".editableDiv").live('focusin', function(){ // show button under the .editableDiv div $("#button").live('click', function(){ // do action }); $(".editableDiv").live('focusout', function(){ // hide button }); }); </code></pre> <p>It shows the button on focus but when the button is clicked, the action is ignored and the button is immediately hidden like if focusout had priority over click. When I try to remove that focusout part, the action gets done but button stays visible... but I need to hide that button on focusout.</p> <p>It seems so simple... but I cannot figure out why it's not working - any hint would be appreciated.</p>
jquery
[5]
5,201,646
5,201,647
converting numbers in to words C#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/554314/how-can-i-convert-an-integer-into-its-verbal-representation">How can I convert an integer into its verbal representation?</a> </p> </blockquote> <p>Can anybody give me a primer code I could work on in converting numbers into words? </p> <p>Converting numbers to words (ranging from -1000 to +1000) example: 1000 --> one thousand</p>
c#
[0]
2,270,543
2,270,544
Events Handling For CustomListView
<p>Hi i want to know how the handle events ,such as selected item in the Custom List,</p> <p>How To get the position ,name of selected item in customList</p> <p>Regards Rakesh shankar.P</p> <pre><code>public class Adapter extends BaseAdapter{ int count=0; Context ctx; List&lt;InfoObject&gt; obs; Adapter(Context ct,List&lt;InfoObject&gt; cols) { ctx=ct; obs=cols; } @Override public int getCount() { // TODO Auto-generated method stub return obs.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub count++; Log.v("Count", String.valueOf(count)); InfoObject obj=obs.get(position); return new ObjectAssigner(ctx,obj); } </code></pre> <p>}</p>
android
[4]
31,055
31,056
how to compress lines of code with jquery?
<p>I have the following lines of code that I am using. But it just seems redunent and I was curious if there is an optimized alternative to the following...</p> <pre><code>if(mkey[65]){ //this is left! (a) var nextpos = $("#item").x()-player.speed; if(nextpos &gt; 0){ $("#item").x(nextpos); } } if(mkey[68]){ //this is right! (d) var nextpos = $("#item").x()+player.speed; if(nextpos &lt; pg.width - 100){ $("#item").x(nextpos); } } if(mkey[87]){ //this is up! (w) var nextpos = $("#item").y()-player.speed; if(nextpos &gt; 0){ $("#item").y(nextpos); } } if(mkey[83]){ //this is down! (s) var nextpos = $("#item").y()+player.speed; if(nextpos &lt; pg.height - 30){ $("#item").y(nextpos); } } </code></pre> <p>I thought about using the jquery each method, but it only took me so far, because I don't know if you can store custom JavaScript functions into data objects...</p> <p>Thanks for any advice!</p> <p><strong>This is what I have tried...(no luck)</strong></p> <pre><code>$.each([ {keypress: mkey[65], item:$("#item").x()-player.speed}, {keypress: mkey[68], item:$("#item").x()+player.speed}, {keypress: mkey[87], item:$("#item").y()-player.speed}, {keypress: mkey[83], item:$("#item").y()+player.speed} ], function(i, obj) { if (obj.keypress) { if(obj.item &gt; 0) { $("#item").x(obj.item);} } }); </code></pre>
jquery
[5]
5,939,296
5,939,297
Would you recommend LearningTree for ASP.net training?
<p>I am a Windows app developer (drivers, fat client, etc) and did mostly C and C++ for the past 15 years. Now that I got laid off, everyone I applied to is asking about ASP.net. I looked through a few books and played around but I need some formal training. Hopefully something inexpensive b/c i am unemployed for 1 year now.</p> <p>Is $2K+ for Learning Tree worth it? Any other suggestions?</p>
asp.net
[9]
335,968
335,969
What does this type of Object mean?
<pre><code>HttpEntity&lt;?&gt; requestEntity = new HttpEntity&lt;Object&gt;(json, headers); </code></pre> <p>I have a couple of questions here?</p> <ol> <li>What does the <code>?</code> mean here. Why have they put <code>&lt;?&gt;</code> instead of <code>&lt;Object&gt;</code></li> <li>Why does the HTTPEntity Constructor take &lt;<code>Object</code>> as its type but the Class Reference taking &lt;<code>?</code>> as its type.</li> </ol>
java
[1]
5,829,859
5,829,860
Given a string describing a Javascript function, convert it to a Javascript function
<p>Say I've got a Javascript string like the following</p> <pre><code>var fnStr = "function(){blah1;blah2;blah3; }" ; </code></pre> <p>(This may be from an expression the user has typed in, duly sanitized, or it may be the result of some symbolic computation. It really doesn't matter).</p> <p>I want to define <code>fn</code> as if the following line was in my code:</p> <pre><code>var fn = function(){blah1;blah2;blah3; } ; </code></pre> <p>How do I do that?</p> <p>The best I've come up with is the following:</p> <pre><code>var fn = eval("var f = function(){ return "+fnStr+";}; f() ;") ; </code></pre> <p>This seems to do the trick, even though it uses the dreaded <code>eval()</code>, and uses a slightly convoluted argument. Can I do better? I.e. either not use <code>eval()</code>, or supply it with a simpler argument?</p>
javascript
[3]
2,239,022
2,239,023
Setting the value of a domain class defined in differen domain
<p>I have two domain classes (getter setter of two tables): <code>Contact Information</code> and <code>Address</code>. I have some fields in Contact Information and some fields in Address.</p> <p>I'm setting the values of the contact information in the controller class but I need to set the values of fields in Address class via Contact Information.</p> <p>Code:</p> <pre><code>class ContactInformation { String id; String name; Address address; //getter and setters } </code></pre> <p>And</p> <pre><code>Class Address{ String idAddress; ... ... //getter and setter } </code></pre> <p>In Controller class</p> <p>I am setting the values like</p> <pre><code>contactInformation.setId("some value"); </code></pre> <p>How do i set the value of idAddress via ContactInformation?</p>
java
[1]
802,443
802,444
Do I have to check LSRequiresIPhoneOS in Info.plist if my iPhone App may use the Cam but may work on iPod touch, too?
<p>In my XCode project under ressources there is a Info.plist file. It has an attribute like this:</p> <pre><code>LSRequiresIPhoneOS </code></pre> <p>so my question is: Do I have to check that? What I want is that my app finds out itself wheater there is a camera or not. If not, the feature is disabled, and if yes: Cool! It must work on both iPhone and iPod touch!</p> <p>I guess that if I disable this in Info.plist, I can still use iPhone features, and Apple will not refuse my code because of that, right?</p>
iphone
[8]
5,641,353
5,641,354
extracting substring by lines
<p>I am fairly new to programming so please bear with me. Say I have a large string such as this.</p> <blockquote> <p>String story = "This is the first line.\n" <br> + "This is the second line.\n" <br> + "This is the third line\n" <br> + "This is the fourth line.\n" <br> + "This is the fifth line."; <br></p> </blockquote> <p>How would I go about extracting the first, fourth, and so on lines?</p>
java
[1]
2,810,291
2,810,292
PHP: Timer for formular input
<p>I am coding a web based exam application in PHP.</p> <ul> <li>The examinee has to choose a set of modules with the according questions.</li> <li>A module is represented as one-single-formular.</li> <li>For each module he got for example 30 minutes.</li> </ul> <p>I will achive that if the 30 minutes are over, the state of the form (answered and unanswered questions will be stored in a database) and the form will be closed e.g. redirect to menu page. I tried something like that:</p> <pre><code>&lt;?php set_time_limit('30000'); function redirect(){ //... } $i = 1; while($i &lt;= 45){ sleep('60'); callthis(); flush(); $i++; } ?&gt; </code></pre> <p>At my hoster set_time_limit couldn't be used because of PHP's Safe Mode.</p> <p>What is the most reliable server-based solution (no Javascript) for a form timer in PHP?</p>
php
[2]
57,582
57,583
Last day of each month within a date range in php
<p>How to get last day of each month within a date range in PHP?</p> <p>Input:</p> <blockquote> <p>$startdate = '2013-01-15'<br> $enddate = '2013-03-15'</p> </blockquote> <p>The output that I want is:</p> <blockquote> <p><strong>2013-01-31</strong> <em>End date of January</em><br> <strong>2013-02-28</strong> <em>End date of February</em><br> <strong>2013-03-15</strong> *End date of March is '2013-03-31' but the end date is '2013-03-15' .</p> </blockquote> <p>So I want <code>2013-03-15</code>. </p> <p>How can I do that?</p>
php
[2]
5,237,499
5,237,500
error: passing xxx as 'this' argument of xxx discards qualifiers
<pre><code>#include &lt;iostream&gt; #include &lt;set&gt; using namespace std; class StudentT { public: int id; string name; public: StudentT(int _id, string _name) : id(_id), name(_name) { } int getId() { return id; } string getName() { return name; } }; inline bool operator&lt; (StudentT s1, StudentT s2) { return s1.getId() &lt; s2.getId(); } int main() { set&lt;StudentT&gt; st; StudentT s1(0, "Tom"); StudentT s2(1, "Tim"); st.insert(s1); st.insert(s2); set&lt;StudentT&gt; :: iterator itr; for (itr = st.begin(); itr != st.end(); itr++) { cout &lt;&lt; itr-&gt;getId() &lt;&lt; " " &lt;&lt; itr-&gt;getName() &lt;&lt; endl; } return 0; } </code></pre> <p>In line:</p> <pre><code>cout &lt;&lt; itr-&gt;getId() &lt;&lt; " " &lt;&lt; itr-&gt;getName() &lt;&lt; endl; </code></pre> <p>It give an error that:</p> <blockquote> <p>../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'int StudentT::getId()' discards qualifiers</p> <p>../main.cpp:35: error: passing 'const StudentT' as 'this' argument of 'std::string StudentT::getName()' discards qualifiers</p> </blockquote> <p>What's wrong with this code? Thank you!</p>
c++
[6]
1,205,582
1,205,583
int[] qualifies as IList<T>?
<p>In a different question on stackoverflow somebody suggested to write an extension method for an array, but used the <code>this IList&lt;T&gt;</code> interface in the extension method. I commented it should be an array but he declined. I tested it, and of course, he's right... :)</p> <p>Extension method:</p> <pre><code>public static void Fill&lt;T&gt;(this IList&lt;T&gt; array, T value) { for(var i = 0; i &lt; array.Count; i++) { array[i] = value; } } </code></pre> <p>Test code:</p> <pre><code>[Test] public void Stackoverflow() { int[] arr = new int[] { 1,2,3,4}; arr.Fill(2); Assert.AreEqual(2, arr[0]); Assert.AreEqual(2, arr[1]); Assert.AreEqual(2, arr[2]); Assert.AreEqual(2, arr[3]); } </code></pre> <p>An <code>array</code> is not an <code>IList&lt;T&gt;</code>. Why does this even compile? Let alone, pass?!</p>
c#
[0]
109,339
109,340
How many halfscreen images can I add to an animated UIImageView before performance would start to suck?
<p>Does anyone have experience with this? I didn't try because I have no appropriate imagery for this, right now. But I wonder if the iPod touch is capable of displaying a fluid, movie-like animation out of fullscreen images (300 x 270)? I fear performance would suck dramatically.</p>
iphone
[8]
3,026,746
3,026,747
Renaming files according to a set of rules
<p>I'm using (or attempting to use) a python script to (at the moment) to remove and alter file names</p> <p>I'm looking to have a bunch of renaming function all in one script.</p> <p><strong>Q1</strong></p> <p>I'd like to know how to do it so do file renames (like removing the '." without having to re-add it for the fileextention at the end.</p> <p><strong>Q2</strong></p> <p>I also would like to be able to make a list so I can rename multiple things into the same name without having to have a line for each: Right now it would be: </p> <pre><code>[os.rename(f, f.replace('B', 'A')) for f in os.listdir('.') if not f.startswith('.')] [os.rename(f, f.replace('C', 'A')) for f in os.listdir('.') if not f.startswith('.')] [os.rename(f, f.replace('D', 'A')) for f in os.listdir('.') if not f.startswith('.')] [os.rename(f, f.replace('E', 'A')) for f in os.listdir('.') if not f.startswith('.')] [os.rename(f, f.replace('F', 'A')) for f in os.listdir('.') if not f.startswith('.')] </code></pre> <p>I'd Like to be able to put that into some sort of complete "replace B, C, D, E, and/or F </p> <p><strong>Q3</strong></p> <p>My third question is how can I make it so I can have it remove all "-" from the filename unless part of the same is "Coca-Cola" (or something)</p> <p>At the moment I have a couple lame workarounds. But they aren't efficient</p>
python
[7]
2,631,332
2,631,333
Simple Java Question
<p>Can same class exist in multiple packages ? In other words, can I have <code>dummy.java</code> class in <code>com.test.package1</code> and <code>com.test.package2</code>?</p> <p><strong>Update</strong></p> <p>Now I copied class from package1 and placed in to package 2 and now I am creating an instance of that class, I want this instance to point to class present in package 1 but currently it points to package1 path, how can i modify it ?</p> <p>Oh so I cannot do something like:</p> <pre><code>Foo = new Foo() //pointing to 1 package Foo class Foo = new Foo() // pointing to 2 package Foo class </code></pre>
java
[1]
4,449,018
4,449,019
How to get Current window's "menubar" property using Javascript?
<p>Can we get the Window's "menubar" property value using javascript</p>
javascript
[3]
5,412,820
5,412,821
WAMP hash not generating
<p>The following code is not generating an output in WAMP on windows.</p> <p>Works fine on MAMP.</p> <p>Guessing it's a missing module or something.</p> <pre><code>$reportHash = str_replace( array('+','/','='), array('-','_',''), base64_encode(file_get_contents('/dev/urandom', null, null, -1, 16))); </code></pre>
php
[2]
3,246,658
3,246,659
Minimize browser window
<p>Thanks for your replies. First I am explaining my requirement :-</p> <p>I created my own minimize and maximize button in my Application. When I click on minimize button, my application should minimize like our application (If we minimize any application in our PC, that application is displaying in our taskbar) I want my application should display in taskbar after minimize.</p> <p>I know how to resize the application to its minimum size. But resize is not ful filling my requirement.</p>
javascript
[3]
5,676,615
5,676,616
android how to make native zip application
<p>I would like to create a zip file from files located on the sd card, I have managed to do that using java but I think that the result is too slow, so I thought of going native using the android NDK.</p> <p>My questions are: </p> <p>Does anyone know any C/C++ library to zip unzip files that will work on android?</p> <p>How to know if the library will work on android?</p> <p>will this make any difference on performance?</p> <p>reagrds maxsap</p>
android
[4]
3,744,022
3,744,023
Design and development of a meeting scheduler in java
<p>Hey I guys I a complete newbie in JAVA. I was ask to design a meeting scheduler with 10people and the choice of time is 9am to 4pm. Each person can choose two time to have the meeting for an hour. I so far have </p> <pre><code>public class Member { private String name; private VotingBox box; public Member(String newName){ name = newName; box = new VotingBox(); } public String getName(){ return name; } public VotingBox getVotingBox(){ return box; } public void setName(String newName){ name = newName; } public void setVotingBox(VotingBox newV){ box = newV; </code></pre> <p>does anyone have any what to possibly do next??</p>
java
[1]
5,559,877
5,559,878
how can i divide numerator by any similar to 0.0110932 in PHP?
<p>I'm getting error like PHP </p> <blockquote> <p>Warning: Division by zero error.</p> </blockquote> <p>I'm still and want to calculate some problems. If you can tell me, how can calculate antilog / log inverse with examples, I'll be more satisfied.</p> <pre><code>&lt;? if(isset($_POST['submit'])) { $P=$_POST['P']; // P=100000 $rate=$_POST['rate']; // rate = 10.5 $R=($rate/100); $N=$_POST['N']; // N = 78 echo $P ."&lt;br&gt;" ; echo $R ."&lt;br&gt;" ; echo $N ."&lt;br&gt;" ; $NEW=($R/12); // NEW = .00875 $aa = (1+($NEW)); // aa = 1.00875 $ab = bcpow('$aa', '$N',16); // ab = 1.9729529246182467 $ac = ($ab-1); // ac = 0.9729529246182467 $ad = bcdiv('$ab', '$ac', 3); // Div by Zero Error $M = ($P*$NEW) *($ad); echo "The Installment is : " . $M . "&lt;br&gt;"; } ?&gt; </code></pre>
php
[2]
2,896,709
2,896,710
defining UI component's height as percentage(or relative) to screen height
<p>Need some help with a UI problem in android. I am trying to create an activity where a text view is supposed to fill all the space above the two buttons on the bottom right and bottom left. <img src="http://i.stack.imgur.com/eAyKb.jpg" alt="layout"></p> <p>I don't want to hardcode any height/width parameters but want to define them as %. So I want button height to be 10% of the screen height and the textview to be 90% of the screenheight. </p> <p>Hence I keep button width as Wrap_text and the textview width as fill_parent.</p> <p>Below is the xml file as I have it as of now. The problem is in defining the height. How do i specify button height as 10% of screenheight and/or textview height as 90% of screen height?</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".Activityclass" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/button1" /&gt; &lt;Button android:id="@+id/button1" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:background="@android:drawable/btn_default" android:text="&lt;-prev" /&gt; &lt;Button android:id="@+id/button2" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:background="@android:drawable/btn_default" android:text="next-&gt;" /&gt; </code></pre> <p></p> <p>Any help will be most welcome.</p>
android
[4]