Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
5,807,203
5,807,204
ListActivity with selectable Items
<p>To improve usability for blind users, I need a ListActivity with an OnItemSelected method to add stuff like vibration or sounds when a specific listitem is selected. Therefore I have extended the ListActivity class and added the following methods:</p> <pre><code>protected void onListItemSelected(ListView parent, View v, int position, long id) { } private AdapterView.OnItemSelectedListener mOnSelectedListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position, long id) { onListItemSelected((ListView)parent, v, position, id); } public void onNothingSelected(AdapterView&lt;?&gt; parent) { // TODO Auto-generated method stub } }; </code></pre> <p>Now, when I create an instance of my new Class SelectableListActivity and override the onListItemSelected method, still nothing happens. Any Ideas? Many thanks in advance! </p>
android
[4]
3,841,229
3,841,230
Get a value of returned array
<p>How can I write this code in one php operator?</p> <pre><code>$menu = theme('nice_menu', 1, 10, 'down'); print $menu['content']; </code></pre> <p>Something like this:</p> <pre><code>print theme('nice_menu', 1, 10, 'down')['content']; </code></pre>
php
[2]
386,396
386,397
How to recursively display folders and sub folders with specific file types only using PHP5 RecursiveDirectoryIterator class
<p>Hi I am trying to get RecursiveDirectoryIterator class using a extension on the FilterIterator to work but for some reason it is iterating on the root directory only.</p> <p>my code is this.</p> <pre><code> class fileTypeFilter extends FilterIterator { public function __construct($path) { parent::__construct(new RecursiveDirectoryIterator($path)); } public function accept() { $file = $this-&gt;getInnerIterator()-&gt;current(); return preg_match('/\.php/i', $file-&gt;getFilename()); } } $it = new RecursiveDirectoryIterator('./'); $it = new fileTypeFilter($it); foreach ($it as $file) { echo $file; } </code></pre> <p>my directory structure is something like this.</p> <pre><code>-Dir1 --file1.php --file2.php -Dir2 --file1.php </code></pre> <p>etc etc</p> <p>But as I said before the class is not recursively iterating over the entire directory structure and is only looking at the root. </p> <p>Question is, how do use a basic RescursiveDirectoryIterator to display folders and then run the FilterIterator to only show the php files in those directorys?</p> <p>Cheers</p>
php
[2]
525,522
525,523
Finding out which version PHP a remote server is running
<p>I can't imagine this is possible but maybe there's some novel way. I'm developing an app which will require a few php files to be deployed and run on the clients' webservers. I'm not particularly interested in targeting clients who are still running pre version 5 versions of PHP.</p> <p>So is there any way one can tell which version of PHP a remote webserver has running?</p>
php
[2]
3,967,384
3,967,385
Alternatives to deleteOnExit
<p>I want to delete some files after a certain a time say once every day.Is using deleteOnExit() for this a good option ? Any other suggestions ?</p> <p>I have some flash content which render its state by reading from some xml files stored inside web server root.These xmls are created on the fly.Now I want to delete these files.It would be better if I can manage this using java</p>
java
[1]
3,668,459
3,668,460
How can i get my last clicked row of Jtable in java
<p>I have a problem that i cann't get my last clicked row of Jtable in java.</p>
java
[1]
4,775,442
4,775,443
How can I determine the "correct" number of steps in a questionnaire where branching is used?
<p>I have a potential maths / formula / algorithm question which I would like help on.</p> <p>I've written a questionnaire application in ASP.Net that takes people through a series of pages. I've introduced conditional processing, or branching, so that some pages can be skipped dependent on an answer, e.g. if you're over a certain age, you will skip the page that has Teen Music Choice and go straight to the Golden Oldies page.</p> <p>I wish to display how far along the questionnaire someone is (as a percentage). Let's say I have 10 pages to go through and my first answer takes me straight to page 9. Technically, I'm now 90% of the way through the questionnaire, but the user can think of themselves as being on page 2 of 3: the start page (with the branching question), page 9, then the end page (page 10).</p> <p>How can I show that I'm on 66% and not 90% when I'm on page 9 of 10?</p> <p>For further information, each Page can have a number of questions on that can have one or more conditions on them that will send the user to another page. By default, the next page will be the next one in the collection, but that can be over-ridden (e.g. entire sets of pages can be skipped).</p> <p>Any thoughts? :-s</p>
asp.net
[9]
3,545,778
3,545,779
How to search and return string values in C# using input text file
<p>I have a log file in following format :</p> <pre><code>[BugServices] WX Edit Bug: 4027909 Server: nomos-scanner.corp.adobe.com User:karansha appGUID: wx Elapsed Time: 1204ms method:bug.updateBug Date: Mon Jan 14 09:42:05 IST 2013 [BugServices] WX Edit Bug: 4027909 Server: nomos-scanner.corp.adobe.com User:karansha appGUID: wx Elapsed Time: 1204ms method:bug.updateBug Date: Mon Jan 14 09:42:05 IST 2013 [BugServices] WX Edit Bug: 4027909 Server: nomos-scanner.corp.adobe.com user:vader appGUID: wx Elapsed Time: 1204ms method:bug.updateBug Date: Mon Jan 14 09:42:05 IST 2013 [BugServices] WX Edit Bug: 4027912 Server: nomos-scanner.corp.adobe.com User:gulanand appGUID: wx Elapsed Time: 1204ms method:bug.updateBug Date: Mon Jan 14 09:42:05 IST 2013 </code></pre> <p>How can i manage to get all the string values say e.g. User: value, using C# ?</p>
c#
[0]
503,251
503,252
How do I append a section containing multiple elements using jQuery?
<p>Let's say I have some</p> <pre><code>&lt;section id="something"&gt;&lt;/section&gt; </code></pre> <p>with a ton of content in between. </p> <p>And I want to create a click event so when you click "+" it appends that entire section beneath, but gives it the id "something2" so that they can be manipulated separately.</p> <p>I've uploaded it so it is clear what I am talking about. Navigate to education and look at the section that contains a form for your college info. Clicking the "+" should create another section like that. There won't be an "x" next to the first one as appears currently, but it will be next to each of the added sections. </p> <p><em>EDIT</em> Forgot the link. <a href="http://ravvel.com/markup/createResume.htm" rel="nofollow">http://ravvel.com/markup/createResume.htm</a></p>
jquery
[5]
5,316,906
5,316,907
Display selected flashcard in a separate window
<p>I need to find a way to call string selected flashcard to a new form but I have no idea how to pass it through because what i'm trying to do is display that individual flashcard in a separate window into a label in a form, the code is below Thanks.</p> <pre><code>public void FlashcardDisplaylistbox_DoubleClick(object sender, MouseEventArgs e) { int index = this.FlashcardDisplaylistbox.IndexFromPoint(e.Location); if (index != System.Windows.Forms.ListBox.NoMatches) { // when an item in listbox is double clicked it will execute this bit of code below String selectedflashcard = FlashcardDisplaylistbox.SelectedItem.ToString(); MessageBox.Show(selectedflashcard); MessageBox.Show(FlashcardDisplaylistbox.SelectedIndex.ToString()); int FlashcardID = (int)Flashcards.Rows[FlashcardDisplaylistbox.SelectedIndex][0]; // this section identifies the position of category the user clicks and converts it to a an integer // the flashcardID will possibly be a way to remove the desired flashcard from the database } } </code></pre>
c#
[0]
1,314,905
1,314,906
Thread safe random numbers
<p>I tried to implement "Monte Carlo" algorithm in parallel manner, so I need to use a thread safe version of a random number generator.<br> I searched a lot and finally found <code>int qrand ()</code> which is a Thread-safe version of the standard C++ <code>rand()</code> function, (defined in <code>&lt;cstdlib&gt;</code> and <code>&lt;stdlib.h&gt;</code>). When I use it, VS fired "identifier not found" error. </p> <p>I use MS visual studio'10 and wrote my code in C++ using OMP.</p> <p>Any help?</p>
c++
[6]
1,505,698
1,505,699
What does it mean: The serializable class does not declare a static final serialversionUID field
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2288937/what-does-it-mean-the-serializable-class-does-not-declare-a-static-final-serial">What does it mean: The serializable class does not declare a static final serialVersionUID field?</a> </p> </blockquote> <p>I know this warning will go away if I just follow the instruction to create the field but I wonder about the background, why and when was this added, what is the advantage of doing it this way now?</p> <p><code>The serializable class does not declare a static final serialversionUID field...</code></p>
java
[1]
2,463,556
2,463,557
Simple python code about double loop
<p>I tested the following python code on Spyder IDE. Thinking it would output 2d array <code>q</code> as increasing number as 0..31 from <code>q[0][0]</code> to <code>q[3][7]</code>. But it actually returns q as:</p> <pre><code>[[24, 25, 26, 27, 28, 29, 30, 31], [24, 25, 26, 27, 28, 29, 30, 31], [24, 25, 26, 27, 28, 29, 30, 31], [24, 25, 26, 27, 28, 29, 30, 31]]. </code></pre> <p>The code: </p> <pre><code>q=[[0]*8]*4 for i in range(4): for j in range(8): q[i][j] = 8*i+j print q </code></pre> <p>Any idea of what's happening here? I debugged step by step. It shows the updates of every row will sync with all other rows, quite different from my experience of other programing languages.</p>
python
[7]
1,333,801
1,333,802
why does sudo work on Linux but not Android?
<p>I have not had the chance to read enough about <a href="http://en.wikipedia.org/wiki/Android_%28operating_system%29">Android</a>, Linux, or UNIX to answer this myself. <code>sudo</code> works on a Linux machine but doesn't work on Android unless you root the mobile device (e.g. Samsung GT-N8013). Why does the mobile device require to be rooted, but not the typical Linux install?</p> <hr> <p>The context of my question is related to <a href="http://stackoverflow.com/questions/14019698/adb-shell-sudo-on-windows-7/14019726#14019726">http://stackoverflow.com/questions/14019698/adb-shell-sudo-on-windows-7/14019726#14019726</a></p> <p>(Also, is there any way for a program to ask to run as <code>root</code> on Android, the same way you have escalation of privileges to "run as administrator" on Windows? If you think this question should be on its own thread, I can create one)</p>
android
[4]
4,392,487
4,392,488
how to store values in a structure array
<p>I'm having a problem storing certain processed values in my program into a structure array. These values contain 3 long integers, and I'm trying to store these values as arrays in my structure.</p> <p>This is a simplified, relevant version of my whole code. Please help me make it work. </p> <pre><code>#include&lt;iostream&gt; #define MAX 20 using namespace std; struct DATA { int id, number; float height; } stuarray [MAX]; int main () { long int1 =0; //contains integer values obtained from a file long int2 =0; //contains integer values obtained from a file long int3 =0 ; //contains integer values obtained from a file cout&lt;&lt; stuarray[MAX].id &lt;&lt; endl; cout&lt;&lt; stuarray[MAX].number &lt;&lt; endl; cout&lt;&lt; stuarray[MAX].height &lt;&lt; endl; return 0; } </code></pre> <p>okay, i'll explain my program. im reading values from a file as a string. after this im supposed to split them into 3 parts and store them in an array. this arrays should refer to the member variables in the structure. i have managed to read the values, split them, and convert all 3 of them into long ints. now i have to store these three values in the structure array. thank you all for ur help.</p>
c++
[6]
3,955,826
3,955,827
Javascript for "how many seconds have passed since this timestamp"
<p>Is there a Javascript equivalent for this PHP code?</p> <pre><code>function secondsAgo($unixtime){ return time() - $unixtime; } </code></pre> <p>Example usage:</p> <pre><code>echo secondsAgo(time()-10); // 10 </code></pre> <p>I have a unixtimestamp in Javascript and need to find out how many seconds have passed from today until that timestamp.</p>
javascript
[3]
168,100
168,101
PHP Sort by using drop-down box
<p>I am basically creating a website and it is a site that sells mobile phones. I need to find a way using PHP to create a drop-down box that can sort the phones by model, brand, screen size etc. (Fields already in my SQL database). What is the simplest way of going about this? I am quite new to PHP and not too sure how to go about it.</p>
php
[2]
275,138
275,139
Understanding directory linkage in php
<p>I need some help in understanding how directory paths and file linking works. I am testing this on a local server.</p> <p>If I have the following files in the <strong>ROOT Directory</strong>:<br /> - <strong>includes [folder]</strong><br /> -- <strong>index.php [php file inside includes folder]</strong><br /> - <strong>adm [folder]</strong><br /> -- <strong>constant.php [php file inside adm folder]</strong> </p> <p>I want to require "constant.php" inside the "index.php", how can I do that?</p> <p><em>Another confusion is that what is the difference between real path and relative path in PHP?</em></p>
php
[2]
3,878,024
3,878,025
Android - Using int in different classes
<p>i have this int MASK.. </p> <pre><code>public class Canvastutorial extends Activity { /** Called when the activity is first created. */ public int MASK=R.drawable.face00; public void setMask(int value) { MASK=value; } </code></pre> <p>its value is changed in the same class Canvastutorial as </p> <pre><code>public void onClick(DialogInterface dialog, int item) { if(items[item]=="Mask 1") { setMask(R.drawable.face00); } else if(items[item]=="Mask 2") { setMask(R.drawable.face01); } else if(items[item]=="Mask 3") { setMask(R.drawable.face02); } else if(items[item]=="Mask 4") { setMask(R.drawable.face03); } else if(items[item]=="Mask 5") { setMask(R.drawable.face04); } </code></pre> <p>i want to use this int MASK in other class</p> <pre><code>public class Panel extends SurfaceView implements SurfaceHolder.Callback{ </code></pre> <p>i am unable to do so.. so far i tried to call MASK as Canvastutorial.ct = new Canvastutorial(); and then using ct.MASK;</p> <p>but this forced closed the application..</p> <p>Any ideas how to do so?</p>
android
[4]
1,484,573
1,484,574
Unexplained error from MediaPlayer
<p>My code tries to play an MP3 file from res/raw.</p> <p>Code:</p> <pre><code>FileDescriptor fd = appContext.getResources().openRawResourceFd(R.raw.ringtone) .getFileDescriptor(); player = new MediaPlayer(); try { player.setAudioStreamType(AudioManager.STREAM_RING); player.setDataSource(fd); player.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); player = null; return; } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); player = null; return; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); player = null; return; } player.setLooping(true); player.start(); </code></pre> <p>The log shows:</p> <p>02-21 15:18:18.360: ERROR/PlayerDriver(51): Command PLAYER_SET_DATA_SOURCE completed with an error or info PVMFErrNotSupported 02-21 15:18:18.380: ERROR/MediaPlayer(693): error (1, -4) 02-21 15:18:18.390: WARN/PlayerDriver(51): PVMFInfoErrorHandlingComplete</p> <p>After player.prepare() is called.</p> <p>I really don't have a hint. I won't use MediaPlayer.create() because I need player.setAudioStreamType(AudioManager.STREAM_RING );</p> <p>Would appreciate any help on this...</p>
android
[4]
1,751,911
1,751,912
Javascript replace a character with a space
<p>I need to get the name of the page from a url. I did this way:</p> <pre><code>var filename = window.location.href.substr(window.location.href.lastIndexOf('/')+1) // -&gt; 'state.aspx' var statelookup = filename.substr(0, filename.lastIndexOf('.')) // -&gt; 'state' </code></pre> <p>Now for e.g, my statelookup has a value like New-York or North-Carolina, how do I replace hyphen with a space in between?</p>
javascript
[3]
2,319,456
2,319,457
Refreshing previous activity
<p>I know some people asked the question, but no answers helped me, and i'm new on android :)</p> <p><a href="http://stackoverflow.com/questions/6850683/using-onresume-to-refresh-activity">This answer</a> could help me. But I cannot figure it out.</p> <ol> <li>I have two Activities : Activity1 and Activity2</li> <li>I go to Activity2 by using the button01</li> </ol> <p>I want automatic refresh When I back to Activity1 using even physical back button.</p> <p>Code of Activity1</p> <pre><code>public class Activity1 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button next = (Button) findViewById(R.id.Button01); next.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent myIntent = new Intent(view.getContext(), Activity2.class); startActivityForResult(myIntent, 0); } }); } } </code></pre> <p>Code of Activity2</p> <pre><code>public class Activity2 extends Activity { /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main2); } } </code></pre> <p>Kind request for elaborate suggestions... Thanks in Advance.</p>
android
[4]
1,627,988
1,627,989
Textbox Change Event
<p>What two things need to happen for a text box's change event to fire?</p>
python
[7]
2,077,361
2,077,362
Custom Alert Box
<p>I want an alert box which is fully customized in short i want my background image on that, my custom buttons and my custom message on it, currently i m using a default alert box having my message only but i want it to be fully custom alert box as i said earlier</p> <p>please help me, and please share a sample code snippet if its possible thnks :)</p> <p>currently the code is like that :-</p> <pre><code>AlertDialog.Builder alertDialogBuilder3 = new AlertDialog.Builder(context); alertDialogBuilder3.setTitle("Location Check"); alertDialogBuilder3 .setMessage("Do you want to cancel loading?") .setCancelable(false) .setPositiveButton("Ok",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { LAtestTab.this.finish(); } }) .setNegativeButton("No",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { // if this button is clicked, just close // the dialog box and do nothing dialog.cancel(); } }); ; AlertDialog alertDialog3 = alertDialogBuilder3.create(); alertDialog3.show(); </code></pre>
android
[4]
777,842
777,843
jquery - how to determine if an Items of now viewable/in the window / below the fold
<p>with jquery, what's the best way to determine if an element is below the fold meaning it's also not in the window and not visible to the user?</p> <p>Thanks</p>
jquery
[5]
1,791,110
1,791,111
Sorting the alphabets
<p>I designed a program in Java for retrieving small letters from the given string. Now I want the in sorted order. How can i get a output in sorted order?</p> <p>This is my code:</p> <pre><code>public class Smallalpha{ public static void main(String []args){ String s= "Hi aM hErE"; int len =s.length(); System.out.println("The lenth is "+len); for(int i=0;i&lt;=len-1;i++){ if(Character.isLowerCase(s.charAt(i))) { char alpha = s.charAt(i); System.out.print(alpha+" "); } } } } </code></pre>
java
[1]
932,276
932,277
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\html\Login\checklogin.php on line 23
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a> </p> </blockquote> <p>Hello im trying to get my login system going and i keep getting this error here is my code:</p> <pre><code>&lt;?php $host="localhost"; $username="root"; $password="power1"; $db_name="members"; $tbl_name="users"; $link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $Email=$_POST['Email']; $Password=$_POST['Password']; $Email = stripslashes($Email); $Password = stripslashes($Password); $Email = mysql_real_escape_string($Email); $Password = mysql_real_escape_string($Password); $sql="SELECT * FROM $tbl_name WHERE Email='$Email' AND password ='$Password'"; $result=mysql_query($sql, $link) or die ('Unable to run query:'.mysql_error()); $count=mysql_num_rows($result); if($count==1){ session_register("Email"); session_register("Password"); header("location:login_success.php"); } else { echo "Wrong Email or Password"; } ?&gt; </code></pre> <p>Its working now</p>
php
[2]
4,472,265
4,472,266
.Net Changes the element IDs
<p>.Net is kindly changing the element ids on my pages by appending a ct100_ to them. As much as I appreciate microsoft trying to help me keep from duplicating ids on my site, I think I can manage it on my own. Can anyone tell me how to prevent this? Thanks in advance.</p>
asp.net
[9]
4,499,604
4,499,605
Using the groupby method in Python, example included
<p>Trying to work with groupby so that I can group together files that were created on the same day. When I say same day in this case, I mean the dd part in mm/dd/yyyy. So if a file was created on March 1 and April 1, they should be grouped together because the "1" matches. Here's the code I have so far:</p> <pre><code>#!/usr/bin/python import os import datetime from itertools import groupby def created_ymd(fn): ts = os.stat(fn).st_ctime dt = datetime.date.fromtimestamp(ts) return dt.year, dt.month, dt.day def get_files(): files = [] for f in os.listdir(os.getcwd()): if not os.path.isfile(f): continue y,m,d = created_ymd(f) files.append((f, d)) return files files = get_files() for key, group in groupby(files, lambda x: x[1]): for file in group: print "file: %s, date: %s" % (file[0], key) print " " </code></pre> <p>The problem is, I get lots of files that get grouped together based on the day. But then I'll see multiple groups with the same day. Meaning I might have 4 files grouped that were created on the 17th. Later on I'll see another unique set of 2 files that are also created on the 17th. Where am I going wrong?</p>
python
[7]
2,922,225
2,922,226
whats the different between nibNameOrNil and ViewDidLoad methods?
<p>whats os the difference between initWithNibName and ViewDidLoad methods ? can i use them both?</p>
iphone
[8]
5,826,965
5,826,966
Instantiating Objects Shorthand
<p>I'm wondering if this is a stupid question but whatever...</p> <p>Consider:</p> <pre><code>this.dataSourceFacade = new DataSourceFacade(); this.SomeGrid.DataSource = this.dataSourceFacade.GetData(); </code></pre> <p>And compare to:</p> <pre><code>this.SomeGrid.DataSource = new DataSourceFacade().GetData(); </code></pre> <p>Anything wrong with the second approach assuming that's the only place it gets used?</p> <p>Richard</p>
c#
[0]
6,028,555
6,028,556
Open Crystal Report Viewer form C#
<p>I'm Puthyrath,</p> <p>I have a windows forms application with two windows form (form1 and form2) in C# 2010. My form2 contains crystal report viewer and I created a button on form1 to open form2:</p> <pre><code>Form2 frm = new Form2(); frm.QueryString = SQLstring(); frm.Show(); this.Hide(); </code></pre> <p>It's OK to run form2 to show report, but when I try to export the report by clicking button 'Export report' on the left top corner, I got an error:</p> <pre><code> static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1());//Error occurred. } </code></pre> <p>the error message is:</p> <blockquote> <p>"External component has thrown an exception."</p> </blockquote> <p>please help. </p>
c#
[0]
5,629,238
5,629,239
Upgrading to PHP 5.3 - solutions for legacy sites
<p>I am about to upgrade a couple of servers from PHP 5.1.6 to PHP 5.3.x, however, we host a number of old websites that would be time-consuming to fix in application code.</p> <p>As I see it there are 2 solutions: </p> <ul> <li>stick the old sites on a separate, compatible server</li> <li>make minimal (backwards-incompatible) fixes and turn off error reporting</li> <li>fix all backwards-incompatible and deprecated features in application code</li> </ul> <p>The latter 2 options are not preferable given this would be very time-consuming -- bear in mind that there are no unit tests and such. The former will be at additional expense given we'd have to pay for and manage an additional box.</p> <p>Are there any other options you might suggest trying, or <strong>what in your experience has been the best solution to managing legacy sites?</strong></p> <p>Cheers </p>
php
[2]
2,883,449
2,883,450
Maximum size of objects that can be stored in NSUserDefaults
<p>Can anyone please tell me the maximum size of NSUserDefaults. Means objects or primitives we can store in userdefaults. for example 10 MB etc.</p> <p>Thanks </p>
iphone
[8]
4,323,577
4,323,578
Why is it called android:id, android:textAppearance, etc.?
<p>Why does most of the XML attributes start with android:? It seems like a great waste of typing...</p>
android
[4]
1,047,466
1,047,467
Map::using size() and looping
<pre><code>//employee is class with public members salary and nname int main() { map&lt;int,employee&gt; employees; employee e1; strcpy(e1.nname,"aaa"); e1.salary=25000; employee e2; strcpy(e2.nname,"ccc"); e2.salary=26000; employees[1]=e1; employees[2]=e2; employee e3; strcpy(e3.nname,"bbb"); e3.salary=26000; employees[5]=e3; employee ee; cout&lt;&lt;employees.size()&lt;&lt;endl; for(int i=0;i&lt;employees.size();i++) { ee=employees[i]; cout&lt;&lt;ee.nname&lt;&lt;endl; } o/p: 3 - //so i=3 displays employees[0],1,2,3 aaa - //i= ccc - - //2 blank lines - // &lt;---why blank line cming ,ok cause no data but why it bbb - //executed 4th and 5th time and we got // employees[5] ----- bbb????? //when i printed value of"i" i got from 0 to 5!!! -------------- can any1 explain thanx in advance </code></pre>
c++
[6]
955,884
955,885
how to run Applets on Safari(web browser)
<p>hii every one good morning I have created one project on JApplet it runs successfully on Applet window but i want to run it on web browsers(Internet explorer , Mozilla firefox, Safari, etc.) I m using Mac os x and i want to run it on Safari.</p>
java
[1]
4,971,527
4,971,528
How can I find the length of a specific index in an array
<p>have tried various things</p> <pre><code>split[6].length String.split[6].length </code></pre> <p>along these lines without success get this error message for the last one ...</p> <p>ReferenceError: "string" is not defined.</p> <p>Hi Thanks for all the replies, in the end I created an array based on the index of the original array and then queried the length of that. As you can see I am having trouble removing single and double quotes from the input strings. New to javascript and its making me a little crazy lol.</p> <pre><code>// Loop through all the input messages for (var i = 0; i &lt; input.length; i++) { var next = output.append(input[i]); // Get the body of the current input message var body = input[i].text; // Set the body next.text = body ; next.text.replace(/\'/g, "&amp;#39;"); next.text.replace(/\"/g, "&amp;#34;"); //replace(/['"]/g,''); // Set a property var split = next.text.split(","); var array1 = split[5]; var array2 = split[2]; next.setProperty("aaaLength", split.length); next.setProperty("aaaSplitValue", split.length); next.setProperty("aaaArray1Value", split.length); next.setProperty("aaaArray2Value", split.length); if (next.getProperty("BaseFilename")=="name"){ next.text.replace(/\'/g, "&amp;#39;"); next.text.replace(/\"/g, "&amp;#34;"); //replace(/['"]/g,''); if(split.length&gt;10){ next.setProperty("FullFilename","nameError"+i); next.setProperty("BaseFilename","nameError"+i); next.setProperty("Suffix",".err"); } if(array1.length&gt;10){ next.setProperty("FullFilename","nameSnameSuffixError"+i); next.setProperty("BaseFilename","nameSnameSuffixError"+i); next.setProperty("Suffix",".err"); } } </code></pre>
javascript
[3]
3,614,040
3,614,041
Can I close statements in a transaction before committing it in Derby (JDBC)?
<p>Basically I have (ignoring exception handling, etc.):</p> <pre><code>connection.setAutoCommit(false); Statement statement1 = connection.createStatement(); statement1.executeUpdate("..."); statement1.close(); Statement statement2 = connection.createStatement(); statement2.executeUpdate("..."); statement2.close(); connection.commit(); </code></pre> <p>If I understand correctly it shouldn't have any impact because all it really does is free the resources for the GC. <a href="http://db.apache.org/derby/manuals/develop/develop63.html" rel="nofollow">Especially with Derby</a>: You should explicitly close Statements, ResultSets, and Connections when you no longer need them. Connections to Derby are resources external to an application, and the garbage collector will not close them automatically.</p> <p>However will it cause any issues with the transaction? I don't believe the transaction relies on the Statement. Can anyone please confirm this?</p>
java
[1]
2,531,841
2,531,842
Python: Passing a function name as an argument in a function
<p>I am trying to pass the name of a function into another function as an argument but I get an error: "TypeError: 'str' object is not callable". Here is a simplified example of the problem:</p> <pre><code>def doIt(a, func, y, z): result = z result = func(a, y, result) return result def dork1(arg1, arg2, arg3): thing = (arg1 + arg2) / arg3 return thing def dork2(arg1, arg2, arg3): thing = arg1 + (arg2 / arg3) return thing </code></pre> <p>When I call doIt like so:</p> <pre><code>var = 'dork1' ned = doIt(3, var, 4, 9) print (ned) </code></pre> <p>I get:</p> <pre><code>Traceback (most recent call last): File "&lt;pyshell#9&gt;", line 1, in &lt;module&gt; ned = doIt(3, var, 4, 9) File "&lt;pyshell#2&gt;", line 3, in doIt result = func(a, y, result) TypeError: 'str' object is not callable </code></pre>
python
[7]
3,506,734
3,506,735
Cant Start App Due to Errors
<p>I keep getting these two errors which stop me from running my app</p> <pre><code>Description error: Error parsing XML: not well-formed (invalid token) AndroidManifest.xml /SMSLookup line 6 Android AAPT Problem Description The element type "manifest" must be terminated by the matching end-tag "&lt;/manifest&gt;". AndroidManifest.xml /SMSLookup line 14 Android XML Format Problem </code></pre> <p>Here is my AndroidManifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.xenom.sms" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name" /&gt; &lt;activity android:name=".SMSLookupActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt; &lt;/manifest&gt; </code></pre> <p>Can anyone help me identify the problem?</p>
android
[4]
4,563,604
4,563,605
jquery - remove specific element from cloned node
<p>Im trying to clone tree, remove one element from it and then append result to new place. But the problem is that element is not deleted, it always append original tree.</p> <pre><code>$(".js-parent-trigger").click(function() { var commentForm = $("#js-add-comment-wrapper").clone(true).css("margin", "10px").remove(".js-add-comment-title"); $(this).parents(".js-comment-wrapper").append(commentForm); return false; }); </code></pre>
jquery
[5]
4,327,530
4,327,531
Accessing the web WITHOUT a webview
<p>I'd like to know if there's any way to access a web page from an Android phone without using a WebView component. I've been following up some tutorials on how to program for Android and the ones that mention web access always use this component to load a URL, and then it shows the resulting page on the screen. However, I'm developing an application that will need to pass some data to a website (id, name, points, etc.) and I don't want to show the response on the screen - I'll still want to record the response on a log file, I just don't want to show the page onscreen. Is there a class or method that allows this to be done? If not, is there a way to hide this component from the screen somehow? I tried to tag it as 'invisible' in main.xml but with no success.</p> <p>Thanks in advance for your help!</p>
android
[4]
5,490,141
5,490,142
Update DataSet, How?
<p>I have DataSet that I fill like this:</p> <pre><code> dsView = new DataSet(); adp = new OleDbDataAdapter("select * from Worki", Conn); adp.Fill(dsView, "Worki"); this.dataGridView1.DataSource = dsView.Tables["Worki"].DefaultView; </code></pre> <p>If I change any cell in the Datagrid, How I can update the DataBase too ?</p> <p>thank's in advance</p>
c#
[0]
5,260,586
5,260,587
32 or 64 bit class file
<p>I have a Java <code>.class file</code>. Now I want to check it was compiled on a 32 bit machine or 64 bit machine ? I tried <code>file</code> command but it just says it is a compiled java class. Is there any way to find it?</p>
java
[1]
3,650,001
3,650,002
Refer to class variable in another class variable definition
<pre><code>class SomeClass: SOME_CONST = "hello" SOME_OTHER_CONST = SomeClass.SOME_CONST + " world" </code></pre> <p>This doesn't work.</p> <blockquote> <p>NameError: name 'SomeClass' is not defined</p> </blockquote> <p>Is there any way to refer to the class within the class?</p>
python
[7]
2,577,183
2,577,184
Best way to go about file properties
<p>Whats the best way to read/write file properties (like author, description, etc) in C#? I can use dsofile.dll to accomplish this but I wonder if this is the right way to go. (being unmanaged code?)</p> <p>Any ideas?</p>
c#
[0]
5,371,314
5,371,315
all builtin function of empty list
<p>Can anybody explain why in python builtin buinction <code>all</code> return <code>True</code> in this case <code>all([])</code>?</p> <pre><code>In [33]: all([]) Out[33]: True In [34]: all([0]) Out[34]: False In [35]: __builtins__.all([]) Out[35]: True </code></pre>
python
[7]
4,277,718
4,277,719
Accessing users itunes library
<p>Is there another way to access the users itunes library than MPMediaPickerController ?</p> <p>Can the tableview which is used to present the MPMediaPickerController be customized?</p>
iphone
[8]
2,765,509
2,765,510
What is wrong with saving image into sqlite database?
<p>I want to write an image into database as blob type. But when i load this image from database, it's different from source image. I write source image into database as follow:</p> <pre><code> ByteArrayOutputStream bs = new ByteArrayOutputStream(); Bitmap medBmp = BitmapFactory.decodeStream(this.getResources().openRawResource(R.drawable.source_image)); medBmp.compress(Bitmap.CompressFormat.JPEG, 100, bs); initialValues.put(IMAGE_COL,bs.toByteArray()); </code></pre> <p>And here are images</p> <p>source image: <img src="http://i.stack.imgur.com/5CiyV.png" alt="enter image description here"></p> <p>Image is loaded from database <img src="http://i.stack.imgur.com/tLtRZ.jpg" alt="enter image description here"></p> <p>The background of source image is transparent, but the image is loaded from db has background in black.why are they different?What is wrong with my code?</p> <p>Please help me out, thanks you so much.</p>
android
[4]
36,147
36,148
Fetch email of configured account in android phone?
<p>I want to fetch the emails of the account configured on my phone.</p> <p>How can I do that? Are the emails stored in a database or they are fetched at runtime?</p>
android
[4]
801,055
801,056
Convert png or jpg image to Base64 string in android
<p>Hello In my application i need to convert Image to Base64 format. Could any one please let me know how i can do that?</p> <p>Please forward your valuable suggestions.</p> <p>Thanks in advance :)</p>
android
[4]
4,781,241
4,781,242
count numbers in the list are between 1 and 10 in python
<p>Im looking to create a program in python that asks the user to enter a list of numbers in [] format.</p> <p>It then must count and display how many of those numbers in the list are between 1 and 10, 10 and 20, 20 and 30 ect.</p> <p>Here is what i have so far.</p> <pre><code>my_num = [int(i) for i in raw_input("Enter numbers... ").split(",")] the_list = eval(my_num) number = 0 if 1&lt;= my_num and my_num &lt;=10: number = number + 1 </code></pre>
python
[7]
2,322,861
2,322,862
Assign object to "this"
<p>Say I have a class and some static helper methods like this:</p> <pre><code>function MyClass (myVar) { this.myVar = myVar; this.replaceMe = function (value) { // this will fail this = MyClass.staticHelper( value ); return this; } this.revealVar = function () { alert( this.myVar ); } } MyClass.staticHelper = function (instance, value) { return new MyClass( instance.myVar + value ); } </code></pre> <p>What I want to do is something like this:</p> <pre><code>var instance = new MyClass( 2 ); instance.revealVar(); // alerts 2 instance.replaceMe( 40 ).revealVar(); // alerts 42 </code></pre> <p>The reason is that my class has a slightly more complicated structure and I don't want to assign all internal variables manually everytime, but rather replace the entire object. Is there a simple way to do so?</p>
javascript
[3]
111,957
111,958
how to check if a passcode or screenlock is set in Android?
<p>Hi friend's i am new in Android</p> <blockquote> <p>how to check if a passcode or screenlock is set in Android.</p> </blockquote> <p>Is there any public API to figure this out. MY current application stores some secure data so it's important to know from the business logic of the application.please suggest me something. Thanks in Advance.</p>
android
[4]
2,147,737
2,147,738
Where to go from here
<p>I have a basic understanding of C++ (and cicual basic, but I dont like it). I know the syntax, classes inheritance, pointers,m stuff like that. I can answer most basic exercises I come across and make simple programs like imperial/metric conversions and things like that. Best program I wrote (and I was chuffed with myself!) was a program that accepted football player names and goals and sorted them how you wanted (alphabetically, goials scored, games:goal ratio) and saved them to a file.</p> <p>Now I am stuck. It's just a hobby (I am 26, work with computers but only excel and some sql) but I am really enjoying myself and would like to start writting better code, and more usefull stuff. Any ideas?</p>
c++
[6]
1,753,588
1,753,589
How can I change the circle picture of a radio button in both cases checked and unchecked?
<p>I want to customize the radio buttons so instead of being like this "empty circle in case unchecked and green on in case checked" <img src="http://i.stack.imgur.com/wM1eT.jpg" alt="enter image description here"></p> <p>I want to make the picture in case it's unchecked like this <img src="http://i.stack.imgur.com/DtS3G.png" alt="enter image description here"></p> <p>and in case it's checked like this <img src="http://i.stack.imgur.com/9ivXt.png" alt="enter image description here"></p> <p>How can I achieve that by xml or java??</p>
android
[4]
6,030,439
6,030,440
diff between two days, in hours
<p>I do not uderstand why the result of:</p> <pre><code>(DateTime.Now.Subtract(user.created_time.Value.Date)).Hours </code></pre> <p>is 23.</p> <p>where:</p> <blockquote> <p>DateTime.Now is:{3/30/2010 12:00:00 AM}</p> </blockquote> <p>and</p> <blockquote> <p>user.created_time.Value.Date is : {3/24/2010 12:00:00 AM}</p> </blockquote> <p>Does it make sense for anybody?</p> <p>ps: I want to select all users created in last 72 hours so i suppose that is the way i should do...</p>
c#
[0]
7,860
7,861
What is this enum for in the destructor?
<pre><code>// Destructor. If there is a C object, delete it. // We don't need to test ptr_ == NULL because C++ does that for us ~scoped_ptr() { enum { type_must_be_complete = sizeof(C) }; delete ptr_; } </code></pre> <p>Note: C is a template parameter</p> <p>I know we cant delete a null pointer, an exception will be raised. So in this case, the enum definition must be doing something to prevent that. In production, sometimes we dont want to end a program simple because we have a null pointer, we may want to look at alternative scenario, when the pointer is null. And this code is used in production, almost everywhere?</p> <p>Thanks guys.</p>
c++
[6]
3,956,333
3,956,334
A numeric string as array key in PHP
<p>Is it possible to use a numeric string like <code>"123"</code> as a key in a PHP array, without it being converted to an integer?</p> <pre><code>$blah = array('123' =&gt; 1); var_dump($blah); </code></pre> <p>prints</p> <pre><code>array(1) { [123]=&gt; int(1) } </code></pre> <p>I want</p> <pre><code>array(1) { ["123"]=&gt; int(1) } </code></pre>
php
[2]
5,136,036
5,136,037
How to load a properties file in java without calling laod method separately
<p>How to load a properties file in java without calling laod method separately i want to load the file while instantiation of the properties object itself. like i have pasted below but i am not able to succeed in it.</p> <pre><code>class test{ Properties configFile = new Properties(load(new FileInputStream("config.properties")); } </code></pre>
java
[1]
3,792,229
3,792,230
using customadapter of listview with viewpagerextension?
<p>any reference/example would be greatly appreciated? trying to use library <a href="https://github.com/astuetz/ViewPagerExtensions" rel="nofollow">https://github.com/astuetz/ViewPagerExtensions</a></p>
android
[4]
2,631,998
2,631,999
Python Programmer Development path
<p>I have been learning Python for a while, but the problem is that I am not sure where I need to go from here, could you recommend me a "Curriculum" or development path for python programming from novice to advanced programmer? </p>
python
[7]
6,025,055
6,025,056
Not able to see list of available packages in Android SDK version 21
<p>I installed the latest android sdk from <a href="http://developer.android.com/sdk/index.html" rel="nofollow">http://developer.android.com/sdk/index.html</a>. When I ran SDK manager.exe I found that some of the packages are missing like Google API. I mean to say that Android 4.0 (API 14) is completely missing.</p> <p>I tried to update sdk by executing the command "android.bat update sdk" but it didn't work Can someone tell me where can I find it?</p>
java
[1]
4,852,522
4,852,523
Export data from php to excel
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4005814/export-from-php-to-excel">Export from PHP to Excel</a> </p> </blockquote> <p>I need to export data retrieved from mysql database to excel. I need to do some changes to my data before exporting to excel. I really can't understand how I should begin. </p> <p>Should i go for PEAR? or any other class library? or any simple way to do this?</p>
php
[2]
1,373,932
1,373,933
Security for ASP.NET application
<p>I am developing a .net based application which is for a financial institution and it has multiple roles so I am not using built in ROLE PROVIDER.</p> <p>Now what i want is that when create user i just assign role and when user logs in with the assigned role he/she cannot open any form on which he/she has no rights.</p> <p>How to come up with a role based security system for my application ? I would appreciate if someone can help me and guide me to come up with a strong and secure application.</p> <p>Thanks</p>
asp.net
[9]
4,758,043
4,758,044
How to send SMS to iphone users if any update is available in my application
<p>I am creating a one deal application in iphone and I want to send an sms from my application if a coupon is available for it. How can we send an sms from our application to a user ? If any free module is available then please let me know. Thanks for your Help.</p>
iphone
[8]
2,553,347
2,553,348
tracking down Unknown on line 0 errors
<p>From the Apache error logs:</p> <blockquote> <p>[Mon Dec 03 14:58:01 2012] [error] [client x.x.x.x] PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 884830 bytes) in Unknown on line 0, referer: <a href="https://www.domain.tld/referer" rel="nofollow">https://www.domain.tld/referer</a></p> </blockquote> <p>Why is it saying "Unknown on line 0"? Why not "Filename.php on line xx"?</p>
php
[2]
1,144,024
1,144,025
How to change the selectedIndex of a select element using getElementById
<p>I want to do something similar to this but I am unable to change the selectedIndex value this way:</p> <pre><code>var selected = document.getElementById("state-select"); switch (state) { case 'VA': selected.options[selected.selectedIndex] = 0; break; case 'NC': selected.options[selected.selectedIndex] = 1; break; case 'SC': selected.options[selected.selectedIndex] = 2; break; } </code></pre>
javascript
[3]
3,626,591
3,626,592
How to attach the source in eclipse using java program?
<p>How can i attach the source in eclipse using java program? Can anyone help me??? Thanks in advance..</p>
java
[1]
5,728,406
5,728,407
Action_INSERT always returns result code 0 (ZERO) on Droid-X
<p>My code is as following </p> <p>Permission </p> <pre><code>&lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt; </code></pre> <p>And caller Activity code is </p> <pre><code>Intent addNewContact = new Intent(Intent.ACTION_INSERT); addNewContact.setType(ContactsContract.Contacts.CONTENT_TYPE); startActivityForResult(addNewContact, ADD_NEW_CONTACT); // ADD_NEW_CONTACT = 2 for my specific purpose </code></pre> <p>And onActivityResult of caller Activity as </p> <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i("OnActivityResult Test ", "Request code : " + requestCode + " " + " ResultCode : " + resultCode); switch(requestCode) { case 2: if (resultCode == Activity.RESULT_OK) { // code to Update my list view } } } </code></pre> <p>My list view gets update on emulator and device (I checked with samsung galuxy) also other than Droid-X, so result doesn't reflect on list if I am using Droid-X. </p> <p>When I read Log cat msg of Droid-X I saw resultCode is always 0 (ZERO), even if I am adding new contact.</p>
android
[4]
878,063
878,064
Taking the Response from the Printer by using Xon and Xoff
<pre><code>how to retrieve the printer response from the Bluetooth printer in android by using X-On and X-Off. I have tried but It is not working. I have tried with the following code but it is not working: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("COM"); SerialPort sPort = (SerialPort)portId .open(this.getClass().getName(), 30000); sPort.setSerialPortParams(9600, SerialPort.DATABITS_8,SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); sPort.setFlowControlMode(SerialPort.FLOWCONTROL_XONXOFF_IN | SerialPort.FLOWCONTROL_XONXOFF_OUT); OutputStream os = sPort.getOutputStream(); os= sPort.getOutputStream(); InputStream is = sPort.getInputStream(); os.write(baos.toByteArray(), 0, baos.toByteArray().length); StringBuffer inputBuffer = new StringBuffer(); do{ for(int newData = is.read();newData != -1; newData = is.read()) { inputBuffer.append((char)newData); } try { Thread.sleep(300); } catch { } }while(inputBuffer.length() &lt;= 0); String sDataIn = inputBuffer.toString(); </code></pre> <p>In the above program when the flow comes in the following line it give an error: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier("COM");</p> <p>Error is::java.lang.ExceptionInInitializerError</p>
android
[4]
46,830
46,831
Way of overloading operator without changing original values?
<p>I'm wondering if you can overload an operator and use it without changing the object's original values.</p> <p>Edited code example: </p> <pre><code>class Rational{ public: Rational(double n, double d):numerator_(n), denominator_(d){}; Rational(){}; // default constructor double numerator() const { return numerator_; } // accessor double denominator() const { return denominator_; } // accessor private: double numerator_; double denominator_; }; const Rational operator+(const Rational&amp; a, const Rational&amp; b) { Rational tmp; tmp.denominator_ = (a.denominator() * b.denominator()); tmp.numerator_ = (a.numerator() * b.denominator()); tmp.numerator_ += (b.numerator() * a.denominator()); return tmp; } </code></pre> <p>I made the accessors const methods, but I'm still getting a privacy error for every tmp.denominator_ / numerator_.</p>
c++
[6]
5,107,802
5,107,803
Inner classes defined inside a block like a method in Java can not have any modifiers not even public. Why?
<p>In Java, a class can <strong>never</strong> be qualified to be either private or protected. It can simply be <strong>public</strong> all the times. It's quite obvious, there is no question about it. </p> <hr> <p>Inner classes in Java however, can be designated with any of these modifiers private, protected or public. An inner class can also be defined within an individual block like a method. In such a case, an inner class can not be designated with any of these modifiers, private, public or protected.</p> <hr> <p>The following simple program is compiled with no errors and works just fine.</p> <pre><code>package amazingjava; final class Demo { public class Really { public class Quite { public class Surprising { @Override public String toString() { return( "it really works !" ); } } } } } final public class Main { public static void main(String[] args) { System.out.println( "It may be hard to believe, but " + new Demo().new Really().new Quite().new Surprising().toString()); class Really { class Quite { class Surprising { @Override public String toString() { return( "it really works !" ); } } } } System.out.println( "It may be hard to believe, but " + new Really().new Quite().new Surprising().toString()); } } </code></pre> <p>It produces the following output.</p> <p><em>It may be hard to believe, but it really works !</em></p> <p><em>It may be hard to believe, but it really works !</em></p> <hr> <p>Now, my question is only that the inner classes declared inside the main() method in the above example can not have any modifiers. An attempt to qualify those classes with any of modifiers private, protected or <strong>even public</strong> issues a compile time error! Why? Which default modifier is used by the compiler in such cases?</p>
java
[1]
5,803,327
5,803,328
Storing time in database
<p>I'm wondering which is the best way to store a time into a database. Is it better to store the time in millis as a LONG value or use the sql DATE type. </p> <p>I want to store a time into the SQLite database of the android device and send it later to a server. Which is the best way in consideration of performance.</p>
android
[4]
5,901,459
5,901,460
Magic trick to get the correct url?
<p>I am about to make a system that automaticly puts <code>&amp;pni=something</code> behind an URL. It would be easy if the url just was <em><a href="http://t.co/something.php">http://t.co/something.php</a></em> with "?pni=...." but users can also have <em><a href="http://t.co/something.php?myown=paramater">http://t.co/something.php?myown=paramater</a></em> and then the system should add <code>&amp;</code> instead of <code>?</code></p> <p>How can I put the <code>pni</code> parameter behind the URL and to be valid every time? I've tried this without luck.</p> <pre><code>&lt;?php function nice($in){ $out = parse_url($in); return $out['scheme'] . "://" . $out['host'] . $out['path'] . "?" . $out['query']; } $urls = array( "http://t.co/something.php?w=23&amp;", "http://t.co/something.php?w=23&amp;dfdf=", "http://t.co/something.php?", "http://t.co/something.php", "http://t.co/something", "http://t.co/something.php?w=23&amp;dfdf=34&amp;hvem", ); foreach ( $urls as $url): echo print_r(nice($url)) . "&lt;br/&gt;"; endforeach; ?&gt; </code></pre>
php
[2]
2,154,227
2,154,228
How to use bit-addressable in java?
<p>How to use bit-addresable(assembly) in java?</p> <p>e.g.</p> <pre><code>int a = 13; int b = 99; //How can i write 13 &amp; 99 (but &amp; only last bit of 13,99 = 1 &amp; 1)? //In assembly you can use Acc.0 or anything.x to manipulate bit. //How to use this feature in java? </code></pre>
java
[1]
2,754,598
2,754,599
Android Custom Calendar for bookings
<p>I am busy writing an android app that needs to have a booking system. It needs to have a Calendar that users can view or navigate (Day | Month | Year) and click on to book events on certain days. Thus in the day view, you will see the booked events. These events will then be saved in the database under that users id.</p> <p>The problem is to get a calendar view to do this without reinventing the calendar or programming a calendar from scratch. As far as I know, android does not have support for this or at least not for API 10. The app needs support from API 10 and upwards.</p> <p>Also, I don't want to use the built in Google calender that comes with the phone or any calendar application running on the phone, because that places some restrictions such as, the device needs to have that app installed etc.</p> <p>The screenshot shows more or less the view I am looking for. If I can get that type of view working with day , month and year views working, that will be great. Any help,resources, libraries etc. will be useful. </p> <p>Please see the screenshot to see what I am more or less trying to do.</p> <p><a href="http://i50.tinypic.com/1q0u49.png" rel="nofollow">http://i50.tinypic.com/1q0u49.png</a></p>
android
[4]
986,366
986,367
Regex to allow single hyphen and underscore but not at beginning or end of string
<p>I have this Regex I modified to allow underscores, hyphen, letters and numbers. I am trying to modify it further so that it has the following properties:</p> <ol> <li>Allow only Numbers, Letters</li> <li>Allow Underscore or Hyphen anywhere between the first and last character </li> <li><p><strong>Cannot</strong> start with <strong><em>underscore</em></strong> or <strong><em>hyphen</em></strong> <em>(only between first and last character).</em></p> <p>"^[a-zA-Z0-9_-]*$"</p></li> </ol> <p>Thank for your help.</p>
c#
[0]
2,895,438
2,895,439
Comparing two arraylist in c# windows application
<p>I have the arraylist which has some process names like "Notepad", "mspaint"</p> <p>I want to check the values of above arraylist against the following :</p> <p>Process[] Procs = Process.GetProcesses();</p> <p>If the process "Notepad" is not there in Procs, then i want to use that value for further requirement.</p> <p>How do i find the value of my arraylist which is missing in Procs ??</p>
c#
[0]
1,525,779
1,525,780
Remove punctuation mark after the preg split
<p>I am using this code to split my content after the first punctuation mark, retrieving the fist sentence.</p> <pre><code>$content = preg_split('/(?&lt;=[!?.])./', $content); </code></pre> <p>How can I remove that remaining punctuation mark at the end of the splitted sentence?</p>
php
[2]
5,304,670
5,304,671
split file sentences into words
<p>can anyone help me please?</p> <p>I'm trying to split the <code>sentences[]</code> into <code>words[]</code>. But it shows <code>Syntax error on token "j", delete this token</code>... </p> <p>My code is:</p> <pre><code>try { int j; String paragraph = sample.readFileString(f); String[] sentences = paragraph.split("[\\.\\!\\?]"); for (int i=0;i&lt;sentences.length;i++) { System.out.println(i); System.out.println(sentences[i]); for( j=0;j&lt;=i;j++) { String word[j]=sentences[i].split(" "); } } } </code></pre> <p>What can I do?</p>
java
[1]
1,385,780
1,385,781
JS load order with jQuery on load inside a function that executes immediately
<p>Can you do this?</p> <pre><code>var myFunction = function(){ $(function(){ // jQuery code here $("#myField").hide(); }) }(); </code></pre> <p>I had some code like this which worked fine almost everywhere but then I discovered it only worked about 80% of the time in FF 9.0.1. The fix was to do this:</p> <pre><code>var myFunction = function(){ $(function(){ // jQuery code here $("#myField").hide(); }) }; myFunction(); </code></pre> <p>Now I'm a bit puzzled why this was necessary</p> <p>EDIT: I can see this is a bit confusing. Maybe what I should have done would have been this instead:</p> <pre><code>var myFunction = function(){ // jQuery code here $("#myField").hide(); }; $(function(){ myFunction(); }); </code></pre>
jquery
[5]
1,909,155
1,909,156
setting up Project structure in PHP
<p>I am trying to setup a basic project structure. That is creating a new folder for my project and setting up other folders in a logical way that will provide separation between the PHP files that produce HTML and ones that don’t.</p> <p>Any ideas or thoughts of how to do this?</p>
php
[2]
4,782,557
4,782,558
Setting the limit on the while function
<p>Kindly let me know how can I put the limit on the record in the below function. I want to fetch all the record but one first page I want to show 5 only. Like pagination.</p> <pre><code>while (($row = mysqli_fetch_array($rd)) ){ } </code></pre>
php
[2]
707,084
707,085
Can an iphone app developed using html5 be sold through Apple store?
<p>Can an iphone app developed using html5, CSS and Javascript be sold through Apple store ?</p>
iphone
[8]
1,931,458
1,931,459
How to break an ASP.NET website down into modules that can be enabled/disabled?
<p>I have an ASP.NET website with some independent sections. I need a way to turn on/off the different sections (each section is in it's own directory) based on the user selection. How can I prevent the users from accessing sections that are turned off?</p>
asp.net
[9]
5,461,527
5,461,528
Managing C# snippets
<p>In Visual Studio, when I right-click I've the option to Insert Snippet. Are those snippets static or I can add my own snippets? How can this be done?</p>
c#
[0]
485,569
485,570
What does "->" mean in php?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php">Reference - What does this symbol mean in PHP?</a> </p> </blockquote> <p>What exactly does -> do in php? </p> <p>I have a good understanding of the basics of php but never understood this. I tend to see in apps that use Codeignitor. </p>
php
[2]
234,964
234,965
Reading parts of a line (getline())
<p>Basically this program searches a .txt file for a word and if it finds it, it prints the line and the line number. Here is what I have so far.</p> <p>Code:</p> <pre><code>#include "std_lib_facilities.h" int main() { string findword; cout &lt;&lt; "Enter word to search for.\n"; cin &gt;&gt; findword; char filename[20]; cout &lt;&lt; "Enter file to search in.\n"; cin &gt;&gt; filename; ifstream ist(filename); string line; string word; int linecounter = 1; while(getline(ist, line)) { if(line.find(findword) != string::npos){ cout &lt;&lt; line &lt;&lt; " " &lt;&lt; linecounter &lt;&lt; endl;} ++linecounter; } keep_window_open(); } </code></pre> <p>Solved. </p>
c++
[6]
551,418
551,419
deleting letters from strings without string methods or imports?
<p>This is a homework question. I need to define a function that takes a word and letter and deletes all occurrences of that letter in the word. I can't use stuff like regex or the string library. I've tried...</p> <pre><code>def delete(word,letter): word = [] char = "" if char != letter: word+=char return word </code></pre> <p>and</p> <pre><code>def delete(word,letter): word = [] char = "" if char != letter: #I also tried "if char not letter" for both word = word.append(char) return word </code></pre> <p>Both don't give any output. What am I doing wrong?</p>
python
[7]
3,676,395
3,676,396
Cycle backwards through NSArray
<p>I'm trying to cycle backwards through an array by clicking a button. </p> <p>My current code is close, but doesn't quite work.</p> <pre><code>- (void)viewDidLoad { self.imageNames = [NSArray arrayWithObjects:@"MyFirstImage", @"AnotherImage", nil]; currentImageIndex = 0; [super viewDidLoad]; } </code></pre> <p>...what works:</p> <pre><code>- (IBAction)change { UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[imageNames objectAtIndex:currentImageIndex] ofType:@"png"]; currentImageIndex++; if (currentImageIndex &gt;= imageNames.count) { currentImageIndex = 0; } } </code></pre> <p>...and what isn't working:</p> <pre><code>- (IBAction)changeBack { UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[imageNames objectAtIndex:currentImageIndex] ofType:@"png"]; currentImageIndex--; if (currentImageIndex &gt;= imageNames.count) { currentImageIndex = 0; } } </code></pre> <p>Any help is gladly appreciated! </p> <p>Thanks!</p>
iphone
[8]
1,026,254
1,026,255
how to ping a server using different ip addresses in php
<p>I want to ping a server using different ip addresses.</p> <p>below is the sample code:</p> <pre><code>&lt;?php $ip = '76.76.21.246'; $port = '9000'; $server = 'blogsearch.google.com'; $fp = fsockopen($ip, $port, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)&lt;br /&gt;\n"; } else { $out = "POST /ping/RPC2/ HTTP/1.1\r\n"; $out .= "Host: {$server}\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); } ?&gt; </code></pre> <p>I am getting "requested url could not be retrieved" error</p> <p>Can anyone let me know what is wrong in my code? Thanks in advance</p>
php
[2]
469,537
469,538
Interfaces and casting lists
<p>Why doesnt this work, and how to fix?</p> <pre><code>public interface ITheInterface { string a{get;set;} string b{get;set;} } public class SomeObject: ITheInterface { string a{get;set;} string b{get;set;} ... } public class SomeGroup { ITheInterface Result; ... } var results= from y in dc.Groups where y.id==1 select new SomeGroup { Result= (from x in dc.Objects select new SomeObject{... } ).SingleOrDefault(), } return results.ToList(); </code></pre> <p>Could not convert from type <code>System.Collections.Generic.List</code> to Interface</p>
c#
[0]
688,764
688,765
jQuery wait for event to complete
<p>How can I realize that when I have a function</p> <pre><code>$('.anyclass').slideToggle(1000); </code></pre> <p>that the program exetutes the function test() after the slideToggle completed?</p> <p>If I write like this:</p> <pre><code>$('.anyclass').slideToggle(1000); test(); </code></pre> <p>...test() gets executed before slideToggle completed.</p> <p>How can I realize? I don't know jQuery very well ...</p> <p>Thank you for your help! Regards, Florian</p> <p>EDIT: Results u can see here: <a href="http://virtual-swiss-hornets.ch" rel="nofollow">www.virtual-swiss-hornets.ch</a></p>
jquery
[5]
3,972,002
3,972,003
Selecting multiline-text on focus using jQuery
<p>This istructions does not work with multiline text-box:</p> <pre><code>$("input:text").mouseup(function () { $(this).select(); }); </code></pre> <p>I have to simlpy select all text inside texbox on my page. </p> <p>Is there anything wrong?</p>
jquery
[5]
53,836
53,837
php sessions create and destroy on submit?
<p>Given a php form that submits to it’self, via <code>&lt;?php echo $_SERVER[‘PHP_SELF’];?&gt;</code></p> <p>And the same form with some html and one submit button</p> <pre><code>&lt;label for="submit"&gt;Submit&lt;/label&gt; &lt;input id="submit" type="submit" value="Submit Info:" /&gt;&lt;br /&gt; </code></pre> <p>How do I set it up, such that when the user has finished inputting all the relevant information on the form(one, form.php), without any errors, the session is destroyed, after pressing the submit button.</p> <p>I know this starts a session:</p> <pre><code>&lt;?php session_start() ?&gt; </code></pre> <p>At the top of form.</p> <p>And this destroys the session variables </p> <pre><code>session_destroy(); </code></pre> <p>Would I have to do something like this:</p> <pre><code>$_SESSION[‘submit’] = ‘submit’; </code></pre> <p>I am trying to avoid creating sessions for each variable on my form, for example, </p> <p>name</p> <p>age</p> <p>sex</p> <p>It sounds like it would be a lot of work to create sessions for each and every variable on a given form, that’s why I am here seeking answers, in the meantime I will read more on sessions, thank you for not flaming the newb.</p>
php
[2]
1,792,619
1,792,620
Paper View effect iPhone
<p>I would like to create a turn up page view with button under the view like the first image of this app: <a href="http://itunes.apple.com/us/app/ihandy-translator-pro/id402422247?mt=8" rel="nofollow">http://itunes.apple.com/us/app/ihandy-translator-pro/id402422247?mt=8</a></p> <p>How can I do this "page peek" view, it works so if I press in the bottom right of the yellow pad is raised and the button are displayed. How can I do that? And how is this method of view called?</p>
iphone
[8]
4,033,171
4,033,172
Printing the absolute value without using cmath
<p>I am a beginner in C++ and I need help printing the absolute difference of 2 integers. How can I go about doing that without using cmath? </p> <p>This is what I have so far :</p> <pre><code> #include&lt;iostream&gt; #include&lt;cstdlib&gt; using namespace std; abs(double num1, double num2); int main() { double n1, n2, num1, num2, results; cout&lt;&lt;" Enter two numbers : "; cin&gt;&gt;n1 &gt;&gt; n2 ; results= abs(num1, num2); cout&lt;&lt;" Absoulte value of your two numbers is " &lt;&lt; results &lt;&lt;endl; return 0; } abs(double num1, double num2) { return abs(num1, num2); } </code></pre>
c++
[6]
3,944,018
3,944,019
Check for invalid characters in a php string
<p>How can i check to see if a php string contains only 0-9 , and |? so it would accept <code>158,147|157,541|145,157</code> but not <code>125 ,148|126,4</code></p>
php
[2]