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,796,939
3,796,940
C# checkbox
<p>I have 3 check boxes in each row of 8 total rows. I want to have the third checkbox in each row to get checked only when the first two checkboxes are unchecked. I do not want to write a checkRow() method for each row.</p> <p>What is the best way to go about it?</p> <pre><code>private void checkRow() { for (int i = 0; i &lt; 8; i++) { var arraylist = new[] { checkbox1, checkbox2, checkbox3 }; if (checkbox1.Checked || checkbox2.Checked) { arraylist[2].Checked = false; } else arraylist[2].Checked = true; } } private void checbox1_CheckedChanged(object sender, EventArgs e) { checkRow(); } private void checbox2_CheckedChanged(object sender, EventArgs e) { checkRow(); } private void checbox3_CheckedChanged(object sender, EventArgs e) { checkRow(); } </code></pre> <p>In response.</p> <pre><code>private void checkRow() { var arraylist = new[] { checkEdit1, checkEdit2, checkEdit3 }; var arraylist1 = new[] { checkEdit4, checkEdit5, checkEdit6 }; var arraylist2 = new[] { checkEdit7, checkEdit8, checkEdit9 }; var array = new[] { arraylist, arraylist1, arraylist2 }; for (int i = 0; i &lt; 8; i++) { //if checkedit1 or checkedit2 is checked the checkedit3 should not be checked if (array[i]....Checked || array[i]....Checked) { arraylist[i]...Checked = false; } else arraylist[i]...Checked = true; } } </code></pre> <p>I was trying to do something like this so that I dont have to write the checkRow() for each row</p>
c#
[0]
3,046,631
3,046,632
How to hide a View programmatically?
<p>In my application, I have 2 <code>LinearLayout</code>'s right above each other. Via a menu option, I want to be able to make the bottom one disappear, and have the top one drop down over the disappeared <code>LinearLayout</code>...</p> <p>The problem is, I have no idea on how to do this in Java.</p> <p>It doesn't have to be animated, I want to hide the <code>Layout</code> on return of another activity (the menu), in <code>OnActivityResult</code>. The menu <code>activity</code> sets a <code>boolean</code> on which I check in <code>OnActivityResult</code>, and according to it's value I determine if I need to hide or show the bottom <code>Layout</code>:</p> <pre><code>// Only change value if it is different from what it was. if(mUseVolumeButtonAsPTT != resultData.getBoolean("UseVolumeButtonAsPTT")){ mUseVolumeButtonAsPTT = resultData.getBoolean("UseVolumeButtonAsPTT"); if(!mUseVolumeButtonAsPTT){ // Hide lower LinearLayout. } else { // Show lower LinearLayout. } } </code></pre> <p>Could anybody give me a hint or a link on how I should do this? Thanks in advance...</p>
android
[4]
2,133,793
2,133,794
Is it possible to create div throwing into another div
<p>Using jquery, can we create option like throwing one div to another div area(similar to drag and drop).</p> <p>Based on throwing direction, div need to shift to other div.</p> <p>Because, i need to keep 2 set of div group in the site's left and right side bars.</p> <p>if i use drag and drop, some time its taking difficulty to drop, in the wide screen monitor.</p> <p>Is it any option in the Jquery? Any tutorial links? i need something like drag and drop animation. </p>
jquery
[5]
5,579,630
5,579,631
accessing objects, static variables in PHP
<p>Here's my code:</p> <pre><code>class Photograph extends DatabaseObject { protected static $table_name="photographs"; protected static $db_fields=array('id', 'filename', 'type', 'size', 'caption','album_id'); public $id; public $filename; public $type; public $size; public $caption; //public $album_id; protected static $album_id; private $temp_path; protected $upload_dir="images"; </code></pre> <p>Now, when I use this function below on another page like '$photos = Photograph::find_by_album();' </p> <p>I get an sql error that says: 'Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=' at line 1'</p> <pre><code>public static function find_by_album($album_id='') { return self::find_by_sql("SELECT * FROM ".self::$table_name."WHERE album_id = ".self::$album_id.""); } </code></pre> <p>Basically, what I would to happen is to get all values saved in the database from the $table_name where $album_id entered by the user is equivalent to the album_id found in the database. You may find this problem simple, but unfortunately, I am not able to find a solution. Any ideas please? Thanks in advance. :) </p> <p>EDIT:</p> <p>Following Mr. Elias Ootegem,</p> <p>I have modified the code and it now looks like </p> <pre><code>public static function find_by_album($album_id='') { return self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE album_id = ".$album_id.""); } </code></pre> <p>However, I still get the same error. I tried using this code: </p> <pre><code>public static function find_by_album() { return self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE album_id = ".$album_id.""); } </code></pre> <p>Now another error comes up which says: Undefined variable: album_id </p> <p>Any other ideas?</p>
php
[2]
3,969,179
3,969,180
How to return to main activity after being three activities down?
<p>My app has four activities; MainActivity, ListActivity1 (L1) , ListActivity2 (L2), ListActivity3 (L3). From Main, the user goes down to L1 by clicking a button. After selecting an item in L1, user comes to L2 and then L3 after selecting an item in L2. In L3, when selecting an item a Yes/No-toast is launched. If user selects "No", user stays on L3. If user selects "Yes", user returns way back to Main.</p> <p>Here's the question: If the user selects "yes" taking him to Main and pressing Back button, he returns to L3. What I want is that if the user has walked down to L3, selected yes and returned to Main, pressing Back should take him to Home screen. I.e. I want to delete the "back trace" to L3.</p> <p>How do I accomplish this?</p> <p>(Main and the ListActivities starts the new activity with <code>startActivity(new Intent(foo, Bar.class))</code>)</p>
android
[4]
3,510,844
3,510,845
more space appears between spinner and EditTExt
<p><br> I am writing an android where I need to display Spinner and EditText . I am using LinearLayout with vertical orientation. I am getting lot of space between spinner and EditText. Can anyone help me in sorting out this issue. <br> Thanks in Advanvce</p>
android
[4]
3,469,480
3,469,481
What is the preferred syntax for initializing a dict?
<p>I'm putting in some effort to learn Python, and I am paying close attention to common coding standards. This may seem like a pointlessly nit-picky question, but I am trying to focus on best-practices as I learn, so I don't have to unlearn any 'bad' habits.</p> <p>I see two common methods for initializing a dict:</p> <pre><code>a = { 'a': 'value', 'another': 'value', } b = dict( a='value', another='value', ) </code></pre> <p>Which is considered to be "more pythonic"? Which do you use? Why?</p>
python
[7]
115,791
115,792
missing argument in php function?
<p>Ok no i am calling a few variables from mysql database and they are not static i not that good but if i call a function like</p> <pre><code>$var = 'hi'; function fun($var){ $var; } </code></pre> <p>now it will be correct and display the result but if i call multiple variables from mysql database then it will show missing argument or variable not defined why so? I have define the result in more separate variables like </p> <pre><code>$row_data['value'] = $var; function fun($var){ $var; } </code></pre> <p>now can anyone help me?</p>
php
[2]
5,458,814
5,458,815
DataTable Select
<p>How can I use Select method of a DataTable just to fetch UserNames starting with 'M'. Lets assume that UserNameTextBox has a string <strong>M</strong></p> <pre><code>oDataTable.Select("UserName = '" + UserNameTextBox.Text + "'"); DataView oDataView = oDataTable.DefaultView; oDataView.Sort = "UserName"; UserGridView.DataSource = oDataView; UserGridView.DataBind(); </code></pre> <p>and when I typed full name into textbox, which I am sure DataTable contains, it list everything not just what I typed. Can someone help me please?</p>
asp.net
[9]
1,487,773
1,487,774
How to make a function reference with the 'this' keyword
<p>I'm creating a small tooltip application and I'm having trouble. I'm trying to add an event to the document, but am having trouble referencing the function that needs to be executed. Here is the code:</p> <pre><code>var Note, note; (function () { 'use strict'; // Helper functions function addEvent(to, type, fn) { if (to.addEventListener) { to.addEventListener(type, fn, false); } else if (to.attachEvent) { to.attachEvent('on' + type, fn); } else { to['on' + type] = fn; } } // Temporary constructor function Temp() { this.dragging = false; return this; } Temp.prototype = { listen: function () { this.dragging = true; }, drag: function () { alert('hi 1'); if (!this.dragging) return; alert('hi 2'); }, create: function () { // unimportant code ... addEvent(document, 'mousedown', this.drag); // unimportant code ... } }; window.Note = Temp; }()); note = new Note(); note.create(); // the note is created as planned note.listen(); // alert(note.dragging) yields true </code></pre> <p>If there are small mistakes in the code I don't think those are the problem, the code on my system passes JSLint (I know that doesn't guarantee correctness). Neither of the alerts alert their arguments; I suspect, though, that the problem is assigning 'this.drag' as the function reference to the event handler. Are there any workarounds for this?</p> <p>Thank you all for your time!</p>
javascript
[3]
4,157,323
4,157,324
Word Counter in java
<p>The initial problem is to read a text file from a user, and print a histogram of its word Sizes. My initial Code is Below but its not working. Please Help!!</p> <pre><code>import java.util.Scanner; import java.io.*; public class wordCounter { public static final int Size = 15; public static void main(String args[])throws FileNotFoundException{ int counts[] = new int [Size]; int count = 0; Scanner scan = new Scanner(System.in); System.out.print("Enter the filename "); String filename = scan.next(); Scanner code = new Scanner(new File(filename)); code.useDelimiter("\\W+"); while (code.hasNext()) { count =0; int count1 = counts[Size-1]; String line = code.next(); while (count1&gt;=Size){ int i = Integer.parseInt(line); i = Size; count++; }//IF System.out.println("Length:" + line); }//while code.close(); System.out.println(" The amount of words in the text is" +" " + count); }//main }//CLASS </code></pre>
java
[1]
5,459,484
5,459,485
Allow only numbers to be typed in a textbox
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery">How to allow only numeric (0-9) in HTML inputbox using jQuery?</a> </p> </blockquote> <p>How to allow only numbers to be written in this textbox ?</p> <pre><code>&lt;input type="text" class="textfield" value="" id="extra7" name="extra7"&gt; </code></pre>
javascript
[3]
351,254
351,255
Using templates of the wizard control
<p>I learnt that Template allows us to customize the look of the control. I am practicing wizard control and trying to use template to control it's look. And it has following Templates available for customization:</p> <ul> <li>HeaderTemplate</li> <li>SideBarTemplate</li> <li>StartNavigationTemplate </li> <li>StepNavigationTemplate</li> <li>FinishNavigationTemplate</li> <li>LayoutTemplate</li> </ul> <p>But I don't know how to use it. Can somebody share an example to use it?</p>
asp.net
[9]
3,189,865
3,189,866
Can I link multiple .lib in C++
<p>If I have a library "a.lib" that I include in project B, then I generate B.lib. Then in a 3rd project if I want to use funtions from library a is it sufficient to include B.lib? or do I need to include a.lib also? </p> <p>So basically by addind a.lib to the LIBS path of project b does it link into b.lib automatically even if I don't use any of its function in project b?</p> <p>Thank you</p>
c++
[6]
5,585,473
5,585,474
C++ Converting Vector items to single String Error?
<p>So I have a function, where <code>KaylesPosition</code> is a class with a <code>vector&lt;int&gt;</code> called <code>piles</code>:</p> <pre><code>// Produces a key to compare itself to equivalent positions std::string KaylesPosition::makeKey(){ std::vector&lt;int&gt; temp(piles.size()); for (int i = 0;i&lt;piles.size();i++){ temp[i]=piles[i]; } std::sort (temp.begin(),temp.end()); std::string key = "" + temp.at(0); for (int i=1 ; i&lt;temp.size() ; i++){ key.push_back('.'); key.push_back(temp.at(i)); } return key; } </code></pre> <p>My expected output should be all of the elements in <code>piles</code> in order, separated by periods. However instead, I get <code>key</code> return as "_M_range_check". I have tried this using std::string.append() and I get either an empty string or a period. How do I get this function to return a string of all of the values in <code>piles</code> as expected?</p>
c++
[6]
4,543,975
4,543,976
Alarm manager triggered too many times
<p>I have a problem regarding Alarm manager in Android. I have the following code snippet to set an alarm that should be fired each week(once).</p> <pre><code> // Add the time and set when the notification will be triggered Calendar setCalendar = item.getDate(); calendar.set(Calendar.MINUTE,setCalendar.get(Calendar.MINUTE)+10080); //Create a new alarm intent Intent alarmIntent = new Intent(ApplicationUtils.getApplicationContext(), AlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(ApplicationUtils.getApplicationContext(), requestCode, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); // Get the AlarmManager service AlarmManager alarmManager = (AlarmManager) context.getSystemService(context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.ELAPSED_REALTIME, sender); </code></pre> <p>And I have to following problem. When the week is changed, the notifications are coming up and they never stop. Does anybody have any idea how can I set the calendar so the alarms are triggered once a week?</p> <p>Thanks, Arkde</p>
android
[4]
4,913,128
4,913,129
Why this HashMap.get return a null?
<p>I am inserting the values into <code>HashMap</code> like this</p> <pre><code>String group_name[]=group_names.split(","); String group_ids[]=new_groups.split(","); Hashtable&lt;Integer,String&gt; hm=new Hashtable&lt;Integer,String&gt;(10); for(int i=0;i&lt;group_ids.length;i++){ if (group_ids[i]!=null &amp;&amp; !group_ids.equals("")) { hm.put(Integer.parseInt(group_ids[i]), group_name[i]); } </code></pre> <p>in the below code list2 is <code>ArrayList</code> and it is having the keys of <code>HashMap</code> and i am retrieving the values like the following </p> <pre><code>for(String group_id1:list2) { int gid=Integer.parseInt(group_id1); String group_name=hm.get(Integer.parseInt(group_id1)); </code></pre> <p>here hm.get() method is returning null</p>
java
[1]
2,397,979
2,397,980
How to show validation control's Error messages in Alert box?
<p>I am using 4 required field validators,4 regular expression validators and 4 compare validators for 4 text boxes.Is it possible to show error messages</p> <p>in an alert or message box when validation fails?</p> <p>If possible please send code sample.</p> <p>Regards,</p> <p>NSJ</p>
asp.net
[9]
3,807,386
3,807,387
Disabling "Force Stop" Button in Android
<p>Okay, I'm pretty sure that this is not possible but a client had asked me to do so in one of our Android application we developed for her.</p> <p>What she had wanted is that if our application is running, and user navigate to:</p> <pre><code> Settings &gt; Manage Application &gt; [Our Application] </code></pre> <p>, the button for "Force Stop" is disabled.</p> <p>Is this possible? If it is possible, could someone point me out which way I should walk, or if it is not possible, how, using a valid argument based on facts, should I break the news to her.</p> <p><strong>Update:</strong> She just sent me a screenshot that, in her opinion, validates her request that there's an Android application that disables "Force Stop" button. How am I supposed to explain this to her?</p> <p><img src="http://i.stack.imgur.com/akS25.png" alt="Evernote Launcher - Force Stop disabled"></p>
android
[4]
760,295
760,296
How to work with $_SERVER['QUERY_STRING']
<p>How to work with $_SERVER['QUERY_STRING'] and pagination?</p> <p>When my table is sorted by this link:</p> <pre><code>&lt;a href="'.$_SERVER['PHP_SELF'].'?sort_name=name&amp;sort=asc" title="'.$lang['sorteer_asc'].'"&gt;&lt;/a&gt; </code></pre> <p>My url becomes: relation.php?sort_name=adres&amp;sort=asc</p> <p>The I use an pagination link:</p> <pre><code>echo '&lt;a href="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&amp;page='.$i.'"&gt;'.$i.'&lt;/a&gt; '; </code></pre> <p>And the url becomes: relation.php?sort_name=adres&amp;sort=asc&amp;page=2</p> <p>So far so good but when browsing to other pages it can be as long as: relation.php?sort_name=adres&amp;sort=asc&amp;page=2&amp;page=3&amp;page=14&amp;page=23&amp;page=27</p> <p>The age keeps appearing because of the $_SERVER['QUERY_STRING'], how can I clean up my url with only keeping the last page and ?sort_name=adres&amp;sort=asc.</p> <p>Or do you suggest an other solution of ordering and pagination?</p>
php
[2]
367,299
367,300
What is wrong with this usage of the new operator?
<p>Is this allowed?</p> <pre><code>Object::Object() { new (this) Object(0, NULL); } </code></pre>
c++
[6]
5,427,602
5,427,603
How to replace every char in a string value with the next char?
<p>If I have a string variable like this:</p> <pre><code>string f = "ABC"; </code></pre> <p>I want to make it like this:</p> <pre><code>f="CDE" </code></pre> <p>This means that I want to take every char in this string and increase it to the next 2 values, if I have 'a' I want to change it to 'c' and so on.</p>
c#
[0]
2,652,592
2,652,593
Java - how to clear message after display in view
<p>I want display error message in my view <code>home.jsp</code> using <code>&lt;c:out value="${message}" /&gt;</code>. But after displaying it, I want to clear it. any idea?</p>
java
[1]
1,702,706
1,702,707
Post some values to Php and store in database using HTTP, stores empty values only
<p>I have tried to send some values to Php file in server using Http post...It store only empty values in Fields of my mysql database....please help me...</p> <p><strong>My Android coding:</strong></p> <pre><code>private void sendValues() { List&lt;NameValuePair&gt; data= new ArrayList&lt;NameValuePair&gt;(2); data.add(new BasicNameValuePair("number", "123456789")); data.add(new BasicNameValuePair("msg", "haiRam")); try { HttpClient httpclient=new DefaultHttpClient(); HttpPost httppost=new HttpPost("http://www.mywebsite.com/fasttrack/HttpTest.php"); httppost.setEntity(new UrlEncodedFormEntity(data)); HttpResponse rs=httpclient.execute(httppost); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p><strong>my Php coding:</strong></p> <pre><code>&lt;?php // Gets data from URL parameters $mobile=$_GET['number']; $message = $_GET['msg']; echo $message; echo $mobile; $connection=mysql_connect ("mysql", "user", "pass"); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db("gps", $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Insert new row with user data $query = sprintf("INSERT INTO Http" . " (mobile,mess) " . " VALUES ('%s', '%s');", mysql_real_escape_string($mobile), mysql_real_escape_string($message)); $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } ?&gt; </code></pre>
android
[4]
4,716,319
4,716,320
Turn on/off gprs code
<p>Hi i am working on an application that need to turn on/off the gprs via code. I am using this methord to check if connection is On/Off. But i have no idea how to turn on gprs if it is off</p> <p>code</p> <pre><code>NetworkInfo i = conMgr.getActiveNetworkInfo(); if (i == null) return false; if (!i.isConnected()) return false; if (!i.isAvailable()) return false; return true; </code></pre>
android
[4]
1,602,674
1,602,675
User-Defined Form Creation
<p>We have a custom written on-line job application... application. HR is requesting a "skill sheet" added to the application. While we have yet to work with them to determine what all this could entail, I am starting to research if this is even feasible. </p> <p>At this point I am envisioning something similar to some of these poll sites where you can ask a multiple-choice questions, ask "essay" questions and possibly a couple other "defined standards". </p> <p>My initial questions come down to:</p> <ol> <li>How do you define and store these questions?</li> <li>How do you display these forms on the screen?</li> <li>How do you store these answers so it can be displayed on a report? We need to see the individual answers.</li> </ol> <p>We use C#.NET.</p> <p>UPDATE: Is there any sample code or articles that cover this topic a bit more?</p>
c#
[0]
571,822
571,823
How to know if a particular application is currently running?
<p>I am trying to build an application that can detect if the Messaging application is currently running so I can foreground one of my activity to prompt the user for a password. <br></p> <p>What I have done: <br> 1)Created a service that starts running after startup.<br></p> <p>Now, what is confusing me:<br></p> <p>1)Is the messaging application a process, a thread, a task, or something else?<br> 2)What is its package name that i should write to check if running?</p>
android
[4]
992,334
992,335
Search directory for a directory with certain files?
<p>I'd like to search a folder recursively for folders containing files names "x.txt" and "y.txt". For example, if it's given <code>/path/to/folder</code>, and <code>/path/to/folder/one/two/three/four/x.txt</code> and <code>/path/to/folder/one/two/three/four/y.txt</code> exist, it should return a list with the item <code>"/path/fo/folder/one/two/three/four"</code>. If multiple folders within the given folder satisfy the conditions, it should list them all. Could this be done with a simple loop, or is it more complex?</p>
python
[7]
786,864
786,865
Deleting a row from the database based on id from while loop
<p>I have a while loop that pops out all of my blog posts. Along with these blog posts it puts up a button beside each one with a red x that when I click it I want it to delete the post next to it. The problem? I haven't come up with an effective way for it decide which post to delete. It usually either deletes the post by largest Id or all of the posts. So I will give you an idea of what I have... (this isn't my actual code, just an idea of it). </p> <pre><code> $result = mysql_query("SELECT * FROM post"); while($row = mysql_fetch_array($result){ $someVariable = $row['Id']; $someVariable1 = $row['title']; $someVariable2 = $row['content']; ?&gt; //This form right below here is the delete button. It functions, just need how to pull the correct Id*** &lt;form action="" method="post"&gt; &lt;input type="submit" id ="&lt;?php echo $someVariable ?&gt;" value="" class="submit2" onClick="confirmation()"&gt; &lt;/form&gt; &lt;form action="" method="post"&gt; &lt;input type="submit" value="" class="submit3"&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; &lt;!-- function confirmation() { var answer = confirm("Delete Post?") if (answer){ &lt;?php mysql_query("DELETE FROM posts WHERE id=***"); ?&gt; } } //--&gt; &lt;/script&gt; &lt;?php }?&gt; </code></pre> <p>The function inside the Javascript is where the issue is. I can't seem to figure out how to get it to give back the right Id. I am fairly raw with php so be easy on me :p. </p>
php
[2]
2,372,154
2,372,155
Access to the elements of parent form from child in MDI
<p>The problem is that i need to access different forms elements from other forms, or for example access MdiContainer form menu from some child windows and do some operations with it. How to correctly implement such feature? I'm using Windows Forms now.</p> <p>Some sample code below to demonstrate how I tried to do it.</p> <p><strong>Form1 (is an Mdi container)</strong></p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void menu2ToolStripMenuItem_Click(object sender, EventArgs e) { Form2 chWin = new Form2(this); chWin.Show(); } public void disableMenu() { menuStrip1.Enabled = false; } } </code></pre> <p><strong>Form2 (is a child of Form1)</strong></p> <pre><code>public partial class Form2 : Form { private Form1 parent; public Form2(Form1 parent) { InitializeComponent(); MdiParent = parent; } private void button1_Click(object sender, EventArgs e) { parent.disableMenu(); } } </code></pre> <p>And the exception: Object reference not set to an instance of an object</p> <p>Tried to google on it, but actually nothing helpful for my occasion.</p> <p>Thanks in advance!</p>
c#
[0]
2,966,370
2,966,371
Element's position().top does not change after scroll - how to get the new position?
<p>I need to get an element's (a div) position (position().top) when the user scrolls the window. The problem is that when I call position().top to get the new position after scrolling, it's got the same value as before scrolling. Here's a bit of code:</p> <pre><code>$('document').ready(function() { alert($('#my-element').position().top); $(window).scroll(function() { alert($('#my-element').position().top); }); }); </code></pre> <p>How come it doesn't change? Is there a way to get the new fresh value?</p>
jquery
[5]
3,134,946
3,134,947
How to get authentication to access google services with android?
<p>In my application I am interfacing with google services such as calendar and documents. For testing I have just been providing a user name and password to access services as follows...</p> <pre><code>myService.setUserCredentials(username,password); </code></pre> <p>This method, at least how I'm implementing it, requires that I request the username and password for each session, which obviously is not practical. I would prefer not to save the username or password in long term storage. I know there is an account manager class in the SDK, but am unsure of proper implementation. My question is, what is the most secure and user friendly method for accessing google services from within the application? Thanks.</p>
android
[4]
2,727,833
2,727,834
Beginner Java question about instance variables
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/5747973/does-this-have-any-advantage">Does &ldquo;this&rdquo; have any advantage?</a><br> <a href="http://stackoverflow.com/questions/132777/do-you-prefix-your-instance-variable-with-this-in-java">Do you prefix your instance variable with &#39;this&#39; in java ?</a> </p> </blockquote> <p>When assigning/referring to an instance variable, what's the difference between <code>this.foo</code>, and simply <code>foo</code>? Does the former give a performance gain or something, or is it just convention?</p>
java
[1]
2,984,365
2,984,366
Android Font Recognition API
<p>I'm planning to develop an android font recognition app for my final year project. are there any free APIs that I can use for this process of image recognition. (looking for an API which will take the image as an input and output the name of the font or something similar) please suggest me a solution, I'm new to the android platform.</p>
android
[4]
692,807
692,808
Detect from browser if a specific application is installed in Android
<p>I'm looking for a way to find out if a specific application is installed from a client-side web browser. The platform is Android.</p>
android
[4]
4,921,726
4,921,727
Need help to understand a project in new domain
<p>I need to work on s&amp;op domain. As I am very new to this domain, and there was no documentation provided for the project. How can I proceed further to understand the domain and project. That project was built on very older technologies like ejb 2.x javascript, normal jsp pages. What can I do to get the most out of the project. I asked help from senior persons, they also don't know completely about the project. Please suggest me what to do? Any suggestions would be appreciated.</p>
java
[1]
3,537,494
3,537,495
Which for loop is faster in java and why
<p>From the following for loops, which one is faster in java</p> <pre><code> 1. for(int i = 100000; i &gt; 0; i--) {} 2. for(int i = 1; i &lt; 100001; i++) {} </code></pre> <p>Please provide the valuable reason for the speed. This really helps me in improving the performance of my application.</p>
java
[1]
3,877,449
3,877,450
noSuchMethod in globally defined functions
<p>I am aware of <code>__noSuchMethod__</code> but I'm not sure how to get this for functions that are called like this.</p> <pre><code>someThing(); </code></pre> <p>For example I am aware I can do this</p> <pre><code>var global = Function('return this')(); global.__noSuchMethod__ = function(id, args) { console.log('No Such Method'); } global.notDefined(); </code></pre> <p>But it does not work with this</p> <pre><code>var global = Function('return this')(); global.__noSuchMethod__ = function(id, args) { console.log('No Such Method'); } notDefined(); </code></pre> <p>As is quite obvious there is some Javascript fundamentals that I still need to learn.</p> <p>What I am trying to accomplish is to catch functions that are called outside of an object. If that makes sense. I apologize if my terminology is a bit off.</p>
javascript
[3]
1,605,095
1,605,096
java.lang.OutOfMemoryError how to fix this
<p>i found a code but sometimes have error :</p> <pre><code>StringBuilder strHeaders = new StringBuilder(); char c; while ((c = (char)stream.read()) != -1) { strHeaders.append(c); if (strHeaders.length() &gt; 5 &amp;&amp; (strHeaders.substring((strHeaders.length() - 4), strHeaders.length()).equals("\r\n\r\n"))) { // end of headers break; } } </code></pre> <p>logcat</p> <pre><code>java.lang.OutOfMemoryError at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95) at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:140) at java.lang.StringBuilder.append(StringBuilder.java:125) at myApp.activity.com.getFromPLS.retreiveMetadata(getFromPLS.java:98) at myApp.activity.com.getFromPLS.refreshMeta(getFromPLS.java:76) at myApp.activity.com.myApp$1.run(myApp.java:371) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>error on this line </p> <pre><code>strHeaders.append(c); </code></pre> <p>please any one can help me to fix this ?</p>
android
[4]
722,124
722,125
only load contents within body using ajax - jquery
<p>I want to load only the contents of the <strong>body</strong> of a page(sample.html) and append it to body of another page(index.html) .. how can this be done..sorry i'm a noob</p> <p>I used the below code .. but this doesn't seem to work properly</p> <pre><code>$.ajax({ url: "/site/pages/sample.html", success: function(data){ $('body').append(data); } }); </code></pre>
jquery
[5]
5,671,745
5,671,746
trying to make a Class
<p>I am trying to make this work myClass.student[x].books[z].<br> For each student I need to collect a name and a array of strings(books).</p> <pre><code>public class myClass { public student[] batch; } public class student { public books[] ; public string naam{ get; set; } } </code></pre>
c#
[0]
3,504,917
3,504,918
Java - System.currentTimeMillis(); Not Returning Difference
<p>For some reason I am getting a consistent 3600 returned by the function:</p> <pre><code>private static long getCountdownLeft() { long now = System.currentTimeMillis(); long elapsedMillis = now - initialTime; //difference of current 'current' time long millisLeft = secondsOfGame * 1000 - elapsedMillis; return millisLeft/1000; } public static void Main(String[] args ) { System.out.println("Time is " + getCountdownLeft()); } private static int secondsOfGame = 3600; private static long initialTime = System.currentTimeMillis(); </code></pre> <p>This is event driven. I expect to see a difference in time everytime I invoke the function. I just use main to show that I am invoking it.</p>
java
[1]
1,184,780
1,184,781
Need help with google voice on my motarola cliq
<p>I have a google voice number. I made a call from my computer. And from reading the instructions,I figure I have to have the app on my phone (motarola cliq). But I went to the m.google.com website,and it gives me a option to download it from the market. But there are no results for google voice in the market. I got the google voice number,I just want to know how to make a call from cell phone using the google number. How do I get the app on my phone ? Is it possible ? Please help !</p>
android
[4]
2,626,881
2,626,882
How to create a 2D Map to use in a Android Game?
<p>I'm looking for a program that make a 2D map to use in a Android Game, if there is, and how I can import this map (that can be in what format? .bin, .fmx?) to my game. I was reading about the Tiled Map Editor, that has files XML with extension .tmx(?) and I wanna to know - the las t question -, if I can use with the Android SDK without a game engine, like AndEngine.</p> <p>Thanks, Izaias.</p>
android
[4]
828,997
828,998
Android custom keyboard shift key
<p>How can i implement the shift key functionality for android custom keyboard, i want to change the keys from caps to small and small to caps while clicking the shift key, for me it is coming but while typing the messages texts are only in smalls, and also i need separate background for each key, for this purpose me implemented android:keyicon instead of android:keylabel attribute but while doing this the problem will arise when changing to small from caps by pressing he shift key , any idea please help , thanks very much for your efforts</p>
android
[4]
5,129,856
5,129,857
Problem with KeyPress Javascript function
<p>I call a javascript function from a textbox by using OnKeyPress="clickSearchButton()"</p> <p>Here is my function:</p> <pre><code>function clickSearchButton() { var code = e.keyCode || e.which; var btnSearch = document.getElementById("TopSubBanner1_SearchSite1_btnSearchSite"); if(code == 13); { btnSearch.click(); return false; } } </code></pre> <p>My problem is that this function fires when the user hits the enter button in any textbox, not just the one that calls the function. What am I missing?</p> <p>EDIT: Still not working correctly. So I'll throw my HTML out there if that helps.</p> <pre><code>&lt;input name="TopSubBanner1:SearchSite1:txtSearch" type="text" id="TopSubBanner1_SearchSite1_txtSearch" OnKeyPress="clickSearchButton(this)" /&gt;&lt;input type="submit" name="TopSubBanner1:SearchSite1:btnSearchSite" value="Search" id="TopSubBanner1_SearchSite1_btnSearchSite" /&gt; </code></pre> <p>Also, this is an ASP.NET page if that makes a difference.</p>
javascript
[3]
2,498,026
2,498,027
microsoft report viewer print button missing in mozilla
<p>I am developing a web application and using using rdlc reports. when i preview report in report viewer print button missing in mozilla, it is displayed in IE but prb with mozilla. can you please let me know any plugin or something for mozilla.</p>
asp.net
[9]
2,064,725
2,064,726
Disable mouse click when out of div
<p>Hi i have a div of a form. i want that disable click event when mouse is out of the div. So i tried this but it is not working ot of div is still clickable. Any idea??</p> <pre><code>var flag = false; $("#foo").live("mouseenter",function(){ flag = true; }).live("mouseleave",function(){ flag = false; }) $(document).click(function(){ if(!flag) return false; }); </code></pre>
jquery
[5]
5,051,299
5,051,300
Action bar sherlock error - Android
<p>I've created an Action Bar Sherlock library project, I've added that library to my project.</p> <p>I get the error:</p> <pre><code>R cannot be resolved to a variable </code></pre> <p>Im using min sdk 7, target sdk 15.</p> <p>I've cleaned the project and all of my projects in eclipse.</p> <p>I've restarted eclipse.</p> <p>Any ideas?</p>
android
[4]
3,621,188
3,621,189
100% cpu because of this thread java
<p>i have just attempted to add something to my game where if one player is hit by a bullet his health goes down. problem is when i am checking for this, CPU is at 100% and everything sooo laggy. This is a problem. here is the thread i am using:</p> <pre><code> package Graphics; import java.util.logging.Level; import java.util.logging.Logger; public class BulletCollision implements Runnable { Player1 player1 = new Player1(); Player2 player2 = new Player2(); public Thread checkBulletCollision = new Thread(this); public void checkPlayerBulletCollide() { if (player2.getBulletX() &gt; player1.getX() &amp;&amp; player2.getBulletX() &lt; player1.getX() - 50) { player2.decHealth(50); } } @Override public void run() { while(true) { checkPlayerBulletCollide(); try { checkBulletCollision.sleep(100); } catch (InterruptedException ex) { Logger.getLogger(BulletCollision.class.getName()).log( Level.SEVERE, null, ex); } } } } </code></pre> <p>i am pretty sure this is where the problem is. there are no errors when compiled or ran. if anyone could help that would be amazing! and i just make this class so the code is not perfect. i have tried a lot to fix this, the Threads start() method is being called in my Display class which only displays the JFrame. i previously had the start method in one of my player classed. </p>
java
[1]
4,005,438
4,005,439
Updating text node using jquery
<p>I have this html:</p> <pre><code>&lt;span class="msg-container"&gt; &lt;span class="msg"&gt;&lt;/span&gt; A message here &lt;/span&gt; </code></pre> <p>I'm wanting to use jQuery to find all the msg-container elements, take the "A message here" text and set the title attribute and remove the "A message here" text node.</p> <p>So, after executing, my DOM should look like this:</p> <pre><code>&lt;span class="msg-container" title="A message here"&gt; &lt;span class="msg"&gt;&lt;/span&gt; &lt;/span&gt; </code></pre> <p>How do I achieve this?</p>
jquery
[5]
2,125,596
2,125,597
Compile Error CS0305
<p>I'm new to C# programming and have hit a snag I cannot get past.</p> <p>I'm getting this compile error:</p> <blockquote> <p>CS0305: Using the generic type 'System.Collections.Generic.IEnumerable' reuires 1 type arguments</p> </blockquote> <p>with this code;</p> <pre><code>class Program { static void Main(string[] args) { Car c = new Car(); c.PetName = "Frank"; c.Speed = 55; c.colour = "Green"; Console.WriteLine("Name = : {0}", c.PetName); c.DisplayStats(); Garage carLot = new Garage(); // Hand over each car in the collection foreach (Car c in carLot) { Console.WriteLine("{0} is going {1} MPH", c.PetName, c.CurrentSpeed); } Console.ReadLine(); } class Car { //Automatic Properties public string PetName { get; set; } public int Speed { get; set; } public string colour { get; set; } public void DisplayStats() { Console.WriteLine("Car Name: {0}", PetName); Console.WriteLine("Speed: {0}", Speed); Console.WriteLine("Color: {0}", colour); } } public class Garage { private Car[] CarArray = new Car[4]; // Fill with some car objects on startup. public Garage() { carArray[0] = new Car("Rusty", 30); carArray[1] = new Car("Clunker", 55); carArray[2] = new Car("Zippy", 30); carArray[3] = new Car("Fred", 30); } } public IEnumerator GetEnumerator() { foreach (Car c in carArray) { yield return c; } } } </code></pre> <p>How can I resolve this?</p>
c#
[0]
439,356
439,357
why does the class_exists function return false?
<p>In the following script I check the <code>class_exists</code> function. What is the scope of this function ? It returns <code>false</code> for this script when I test for this class.</p> <pre><code>&lt;?php namespace my; class Tester { public function check() { $classname = 'Tester'; if(class_exists($classname)) { echo "class exists ! &lt;br /&gt;"; } else { echo "class doesn't exist ! &lt;br /&gt;"; } } } $obj = new Tester(); $obj-&gt;check(); </code></pre> <p><em>Output : class doesn't exist</em></p>
php
[2]
1,063,311
1,063,312
jQuery .live() issue
<p>I have an ordered list, and each item has a link with class "additem" to add another item to the list. In order to make the add item links in the newly added items work, I used .live(), like this:</p> <pre><code>function pageFunctions() { $('a.additem').click(function() { $('&lt;li&gt;'+trackli+'&lt;/li&gt;').insertAfter($(this).parent()); }); }); // there are other functions that warrant 'pageFunctions' being a separate function $(function() { pageFunctions(); $('a.additem').live('click', pageFunctions); }); </code></pre> <p>However, what happens is that the first time you click the add item link, it works fine. But after that, instead of adding an item once, it will double it. and the third time double it again. Any ideas how to fix this?</p>
jquery
[5]
5,117,455
5,117,456
Rolling or sliding window iterator in Python
<p>I need a rolling window (aka sliding window) iterable over a sequence/iterator/generator. Default Python iteration can be considered a special case, where the window length is 1. I'm currently using the following code. Does anyone have a more Pythonic, less verbose, or more efficient method for doing this?</p> <pre><code>def rolling_window(seq, window_size): it = iter(seq) win = [it.next() for cnt in xrange(window_size)] # First window yield win for e in it: # Subsequent windows win[:-1] = win[1:] win[-1] = e yield win if __name__=="__main__": for w in rolling_window(xrange(6), 3): print w """Example output: [0, 1, 2] [1, 2, 3] [2, 3, 4] [3, 4, 5] """ </code></pre>
python
[7]
4,353,584
4,353,585
NotImplementedException on android
<p>is there something similar to the NotImplementedException on the android platform?</p> <p>thanks!</p>
android
[4]
2,953,366
2,953,367
Calculate percentage wise stats using C sharp?
<p>i want to find the stats that will calculate percentage and give results in following format : WX GSA search % = GSA occurrences / GSA occurrences + Search occurrences + ADVSearch occurrences * 100 i.e. in this case it should give like : 3 / 3 + 2 + 2 * 100 = 42.8</p> <p>I have tried code that will give occurrences of every search :</p> <p>My code is here :</p> <pre><code> class Program { static void Main() { System.IO.StreamReader myFile = new System.IO.StreamReader(@"C:\Users\karansha\Desktop\sample log.txt"); string myString = myFile.ReadToEnd(); Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX Search")); // WX Rule Based Search. Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX GSA Search")); // WX GSA Search. Console.WriteLine(TextTool.CountStringOccurrences(myString, "WX ADVSearch")); //WX Form Based Search. // keep screen from going away // when run from VS.NET Console.ReadLine(); } } public static class TextTool { public static int CountStringOccurrences(string text, string pattern) { int count = 0; int i = 0; while ((i = text.IndexOf(pattern, i)) != -1) { i += pattern.Length; count++; } return count; } } </code></pre>
c#
[0]
3,228,487
3,228,488
Multiple classes in one .cpp file
<p>I was wondering if it is considered bad practice to have multiple classes in one .cpp file. I have a background in Objective-C, where this is rarely done.</p>
c++
[6]
2,668,736
2,668,737
jQuery: delegating clicks to elements that contain other elements
<p>So i get the gist of $.delegate and I know why it's doing what it's doing, but I'm wondering if there is a work around.</p> <p>I have link elements that contain spans like so:</p> <pre><code>&lt;a href='#'&gt; &lt;span&gt;Person Name&lt;/span&gt; &lt;span&gt;Person Info&lt;/span&gt; &lt;/a&gt; </code></pre> <p>I use the following code in jQuery for event delegation:</p> <pre><code>containerElement.delegate('click','a',function(){...}); </code></pre> <p>The trouble is that this only triggers when I click on white space not occupied by a span. I know it does this because delegate simply compares the event target to 'a' to check if it should fire the delegate, however I want to include the spans as well, pretty much anything inside the <code>&lt;a&gt;...&lt;/a&gt;</code></p> <p>what do?</p>
jquery
[5]
1,288,345
1,288,346
java.lang.UnsupportedClassVersionError:
<p>I have developed a small project in eclipse which makes use of Java6. But I want to run the same project in hpux system which has java1.5. When I try to run it is throwing the error : </p> <blockquote> <p>java.lang.UnsupportedClassVersionError:. </p> </blockquote> <p>Then I have changed the eclipse Java compiler to java1.5 and jre to 1.5.0_12 then recompiled my project. After that I have deployed once again in hpux system but still it is throwing the same error. I used ant to compile in hpux system. It compiled successfully and produced jar. But while running it is throwing the same error. </p> <p>Any help is highly appreciated. Many Thanks in Advance.</p>
java
[1]
4,243,835
4,243,836
Play sound when receiving a web chat message
<p>How can I add simple sound when a message arrives in a web chat session with jQuery?</p> <p>I noticed that they do it on the chat at <a href="http://chat.stackoverflow.com">http://chat.stackoverflow.com</a> and I want to emulate that in my own software.</p>
jquery
[5]
2,482,751
2,482,752
Macros to disallow class copy and assignment. Google -vs- Qt
<p>To disallow copying or assigning a class it's common practice to make the copy constructor and assignment operator private. Both Google and Qt have macros to make this easy and visible. These macros are:</p> <p>Google:</p> <pre><code>#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&amp;); \ void operator=(const TypeName&amp;) </code></pre> <p>Qt: </p> <pre><code>#define Q__DISABLE_COPY(Class) \ Class(const Class &amp;); \ Class &amp;operator=(const Class &amp;); </code></pre> <p>Questions: Why are the signatures of the two assignment operators different? It seems like the Qt version is correct. What is the practical difference between the two?</p>
c++
[6]
2,335,936
2,335,937
How to tell which control a contextmenustip is associated with?
<p>I have two labels one lblEmail1 and two lblEmal2 each has the same context menu strip associated with it. The contextmenustip has one menu item which is "Send Email" when I right click on either label and you select "Send Email" it goes to the same function to process the request which would be to take the value lblEmail1.Text or lblEmail2.Text and start an email. The problem is I can't figure out how to tell which label initiated the request. Any help would be appreciated.</p>
c#
[0]
3,748,872
3,748,873
Is there any way to refresh a tab in Android?
<p>I have two tabs. When I change a value in the first tab, another value in the second tab also should change depending on the change in the first tab. How to do it?. Please help at the earliest?. Or Is it possible to load the second tab once more.. any refreshment mechanism?</p>
android
[4]
1,784,727
1,784,728
jQuery load, can see the div in the source code but it is not being displayed
<p>I'm using jQuery's load function to load an error message if an ajax request fails into a div. I can see the div with the loaded contents in my source code but it's not showing up on the page. Any idea what's going on?</p> <pre><code>$(function() { $(".submit").click(function() { var element = $(this); var id = element.attr('id'); var note = $('#note-' + id).val(); $('#message').show(); $.ajax({ type: "POST", url: "/index.php/notes/new_note", data: "id=" + id + "&amp; note=" + note, success: function() { $('#notes-' + id).load('/index.php/ads #notes-' + id) $('#note-' + id).val('') } }); $('#message').load('/index.php/ads #message') return false; }); }); </code></pre>
jquery
[5]
847,381
847,382
Can someone explain this source code for balanced partitioning?
<p>Can someone please explain this code in detail? I've tried debugging it but i can't figure out how it produces the result. I've been searching for a solution for the problem and this is the code that I stumbled upon, it produces accurate solutions and I would like to know how it works. Many thanks.</p> <pre><code>#include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;math.h&gt; #include &lt;stdlib.h&gt; #include &lt;limits.h&gt; using namespace std; int BalancedPartition ( int a[] , int n ){ int sum = 0; for( int i = 0 ; i &lt; n ; i++) sum += a[i]; int *s = new int[sum+1]; s[0] = 1; for(int i = 1 ; i &lt; sum+1 ; i++) s[i] = 0; int diff = INT_MAX , ans; for(int i = 0 ; i &lt; n ; i++) { for(int j = sum ; j &gt;= a[i] ; j--) { s[j] = s[j] | s[j-a[i]]; if( s[j] == 1 ) { if( diff &gt; abs( sum/2 - j) ) { diff = abs( sum/2 - j ); ans = j; } } } } return sum-ans-ans; } int main() { int n,result, arr[300]; cin &gt;&gt;n; for(int i = 0; i &lt; n; i++) { cin&gt;&gt;arr[i]; } result = BalancedPartition(arr,n); cout &lt;&lt;abs(result); // The difference between the sums of the two subsets return 0; } </code></pre>
c++
[6]
2,383,145
2,383,146
Truncate array items to the first five characters with jQuery?
<p>A plugin I use on my site generates an array in this style:</p> <pre><code>&lt;script type="text/javascript"&gt; window.slideDetails = [ //Slide1 "C1BP7: user information", "FJAD7: user information", "FFAD7: user information", //Slide2 "C0AE7: user information", "C7AZ7: user information", "FJAE7: user information", //Slide3 "C1AW7: user information", "FJAP7: user information", "FFAD7: user information" ]; &lt;/script&gt; </code></pre> <p>I want to pass the first five characters to a cookie using the jQuery cookie plugin. Is it possible to truncate the array item to the first five characters?</p> <p>I'm trying to get my head around the slice() but the different codes I've tried don't work at all. </p> <p>EDIT:</p> <p>With thanks to andreas for his answer, I adapted it slightly to this:</p> <pre><code>window.slideCode = [], i; for(var i = 0; i &lt; window.slideDetails.length; i++) { window.slideCode.push(window.slideDetails[i].substr(0, 5)); } </code></pre>
jquery
[5]
5,174,794
5,174,795
How to resolve the error this bundle is invalid when i validated the app
<p>I got the error when I validate the app</p> <p>This bundle is invalid. The value of the CFBundleDocumentTypes key in the info.plist must be an array of dictionaries, with each dictionary containing at least the CFBundleTypeName key</p>
iphone
[8]
4,010,596
4,010,597
How to make javac squawk for incorrect package names in Java source files
<p>Today, I ran into a java source file that had a typo in the 'package' statement at the top. The name of the package did not match the name of the directory the file was sitting in (one extra 's' at the end).</p> <p>To my surprise, javac from 1.6, checkstyle, and pmd all passed the file as OK. The only tool that got around to complaining was javadoc, and only because it was the only file in the package, and a package with no classes in it is a fatal error to javadoc.</p> <p>Is there some option to javac, or some other command-line tool (preferably with a maven plugin maven) that will squeal about this sort of goof?</p>
java
[1]
5,658,365
5,658,366
C# Dice application, with die images
<p>The question: Create an application that simulates rolling a pair of dice. When the user clicks a button, the application should generate two random numbers, each in the range of 1 through 6, to represent the value of the dice. Use PictureBox controls to display the dice.</p> <p>I currently have 6 picture boxes with the picture boxes named "dice1PictureBox", "dice2PictureBox" etc, up to 6.</p> <p>Here is the code I have written so far. I am completely lost at this point. I am also very new at programming, any help is greatly appreciated. Thank you in advance.</p> <pre><code> private void rollButton_Click(object sender, EventArgs e) { int diceOne; int diceTwo; Random rand = new Random(); diceOne = rand.Next(3); if (diceOne == 0) { diceOne.Visible = true; } else (diceOne == 1) { diceOne.Visible = true; } else (diceOne == 2) { diceOne.Visible = true; } diceTwo = rand.Next(4) + 6; if (diceOne == 3) { diceOne.Visible = true; } else (diceOne == 4) { diceOne.Visible = true; } else (diceOne == 5) { diceOne.Visible = true; } } } </code></pre> <p>} </p>
c#
[0]
4,311,508
4,311,509
measuring latency time betwen two udp packets and then sending packets over udp based on that latency
<p>Measuring latency time between two packets of a pcap file and then sending over the UDP packet by packet using same latency .</p>
c++
[6]
751,037
751,038
Extension method for python built-in types!
<p>is it possible to add extension method to python built-in types? I know that I can add extension method to defined type by simply adding new method by . as following:</p> <pre><code>class myClass: pass myClass.myExtensionMethod = lambda self,x:x * 2 z = myClass() print z.myExtensionMethod(10) </code></pre> <p>But is any way to adding extension method to python built'in types like list, dict, ...</p> <pre><code>list.myExtension = lambda self,x:x * 2 list.myExtension(10) </code></pre>
python
[7]
2,950,471
2,950,472
regarding tab bar controller
<p>I want to show more tahn four tab bar item on tab bar controller by scrolling tab bar . is it possible in iphone if it is.. please give the exact solution.??</p> <p>Hoping your positive response </p>
iphone
[8]
4,689,142
4,689,143
From which library to include inline List creation?
<p>I find myself re-implementing List creation method. But I'm sure that it is already implemented in some widely used library (if not in java itself). So my question is: Which useful library to include, to get functionality of following code:</p> <pre><code>public static &lt;T&gt; List&lt;T&gt; buildList(T... args) { ArrayList&lt;T&gt; list = new ArrayList&lt;T&gt;(); for (T arg : args) { list.add(arg); } return list; } </code></pre> <p>EDIT: Already found what i was looking for: <a href="http://code.google.com/p/google-collections/" rel="nofollow">http://code.google.com/p/google-collections/</a> I just import statically:</p> <pre><code>import static com.google.common.collect.Lists.newArrayList; </code></pre> <p>and use:</p> <pre><code>methodThatTakesArray(newArrayList("fst", "snd", "lst)); </code></pre>
java
[1]
3,321,759
3,321,760
how to rewrite the following code so that i don't have to assign readonly variable in a method only called by constructor?
<p>e.g</p> <pre><code> Class A { readonly Bclass B; readonly Cclass C; public void Class() { Action1(); Action2(); Action3(); } void Action2() { Dosomething1(); B=Dosomething2(); //There goes the problem. C=Dosomething3(); Dosomething4(); } ... } </code></pre> <p>BTW, i know i can put all the Dosomthing() into the constructor, but the code hence becomes less readable.</p>
c#
[0]
5,020,507
5,020,508
Simple Array PHP
<p>Simple array but I am getting an error. Even when create it in its own PHP page I still get an error. I am not experienced at this so be kind.</p> <pre><code>&lt;?php $state = $array(Kentucky, New Mexico, New York, Alabama, Nebraska, Alaska, American Samoa, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, District of Columbia, Florida, Guam, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Louisiana, Maryland, Massachusetts, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, North Carolina, North Dakota, Northern Marianas Islands, Ohio, Oklahoma, Oregon, Pennsylvania, Puerto Rico, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, Virgin Islands, Washington, West Virginia, Wisconsin, Wyoming, Georgia, Maine, Michigan); ?&gt; </code></pre> <p>Any have any ideas as to the reason why?</p> <p>Regards, MIke</p>
php
[2]
830,020
830,021
How to add a class to list where there is unordered list child with jquery?
<p>I would like to add a class called "with_ul" to li tags where there is ul under in the following normal list with jquery.</p> <p>In the following case I need to add the class to list of Level 1-B, Level 2-B-1 and Level 1-C since they have an unordered list. </p> <pre><code> &lt;ul id="nav"&gt; &lt;li&gt;Level 1-A&lt;/li&gt; &lt;li&gt;Level 1-B &lt;ul&gt; &lt;li&gt;Level 2-B-1 &lt;ul&gt; &lt;li&gt;Level 3-B-1&lt;/li&gt; &lt;/li&gt; &lt;li&gt;Level 2-B-2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;Level 1-C &lt;ul&gt; &lt;li&gt;Level 2-C-1&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; ... ... &lt;/ul&gt; </code></pre> <p>Thanks in advance.</p>
jquery
[5]
3,420,600
3,420,601
[Infinite Loop]Try.. catch with exceptions
<p>So, I`m getting stuck with a method about Scanner, here is the code:</p> <pre><code>import java.util.InputMismatchException; import java.util.Scanner; public class ConsoleReader { Scanner reader; public ConsoleReader() { reader = new Scanner(System.in); //reader.useDelimiter(System.getProperty("line.separator")); } public int readInt(String msg) { int num = 0; boolean loop = true; while (loop) { try { System.out.println(msg); num = reader.nextInt(); loop = false; } catch (InputMismatchException e) { System.out.println("Invalid value!"); } } return num; } } </code></pre> <p>When I try to input a number(int), everything goes fine, but when I insert something that isnt an int, the exception goes to catch, do the while loop again, go to the try, read the first System.out but don't read the "num = reader.nextInt()" and throw again the exception, going to the catch and doing a INFINITE LOOP.</p> <p>if the "msg" is "Insert a integer number:", the output is:</p> <blockquote> <p>Insert a integer number:</p> <p>Invalid value!</p> <p>Insert a integer number:</p> <p>Invalid value!</p> <p>...</p> </blockquote>
java
[1]
5,966,453
5,966,454
Why is infinite loop needed when using threading and a queue in Python
<p>I'm trying to understand how to use threading and I came across this nice example at <a href="http://www.ibm.com/developerworks/aix/library/au-threadingpython/" rel="nofollow">http://www.ibm.com/developerworks/aix/library/au-threadingpython/</a></p> <pre><code> #!/usr/bin/env python import Queue import threading import urllib2 import time hosts = ["http://yahoo.com", "http://google.com", "http://amazon.com", "http://ibm.com", "http://apple.com"] queue = Queue.Queue() class ThreadUrl(threading.Thread): """Threaded Url Grab""" def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): while True: #grabs host from queue host = self.queue.get() #grabs urls of hosts and prints first 1024 bytes of page url = urllib2.urlopen(host) print url.read(1024) #signals to queue job is done self.queue.task_done() start = time.time() def main(): #spawn a pool of threads, and pass them queue instance for i in range(5): t = ThreadUrl(queue) t.setDaemon(True) t.start() #populate queue with data for host in hosts: queue.put(host) #wait on the queue until everything has been processed queue.join() main() print "Elapsed Time: %s" % (time.time() - start) </code></pre> <p>The part I don't understand is why the <code>run</code> method has an infinite loop:</p> <pre><code> def run(self): while True: ... etc ... </code></pre> <p>Just for laughs I ran the program without the loop and it looks like it runs fine! So can someone explain why this loop is needed? Also how is the loop exited as there is no break statement?</p>
python
[7]
3,703,099
3,703,100
I got errors when I use the MIRACL Cryptographic SDK
<p>In class ECn.h, has the definition:</p> <pre><code>friend BOOL operator==(const ECn&amp; a,const ECn&amp; b) { return epoint_comp(a.p,b.p); } </code></pre> <p>We have defined a ECn as a member of class G2,when defined this statement: </p> <pre><code>friend BOOL operator==(G2&amp; x,G2&amp; y) { if (x.g==y.g) return TRUE; else return FALSE; } </code></pre> <p>When I used VC6 to build my project,I got the error:</p> <blockquote> <p>error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'const class ECn' (or there is no acceptable conversion)</p> </blockquote> <p>Why? Pleas help me.</p>
c++
[6]
2,689,241
2,689,242
Where should i store "MemberID"?
<p>In my webpage i use FormsAuthentication</p> <pre><code>FormsAuthentication.RedirectFromLoginPage(VisitorEmail, False) </code></pre> <p>Every time the visitor gets authenticated via the login page, i set the </p> <p><code>Session("MemberID") = GetMemberIDByEmail(VisitorEmail)</code> for later processing.</p> <p>Since i need both <code>MemberID</code> and <code>VisitorEmail</code>.</p> <p>But something tells me that this is "out of the book" and not "by the book".</p> <p>So am i doing something WRONG or BAD here?</p>
asp.net
[9]
3,754,885
3,754,886
How to use jquery.index() when looking for class
<p>I have this simple use of <a href="http://api.jquery.com/index/" rel="nofollow">jquery.index()</a> meant to return the value of an element having a class:</p> <p>The HTML:</p> <pre><code>&lt;ul&gt; &lt;li&gt;foo&lt;/li&gt; &lt;li class='on'&gt;bar&lt;/li&gt; &lt;li&gt;roo&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>The JS:</p> <pre><code>var idx = $('li').index('.on'); </code></pre> <p>It returns <code>-1</code> if the class is on any element <strong>except the first one</strong>. What am I missing?</p> <p><a href="http://jsfiddle.net/R6mjG/" rel="nofollow">JSFIDDLE</a></p>
jquery
[5]
4,131,583
4,131,584
Uncaught TypeError: Object [object Object] has no method (using jQuery based Slider)
<p>On the following <a href="http://sh.betaforming.com/" rel="nofollow"><strong>site</strong></a>, the content slider is not working. I've used this <a href="http://slidesjs.com/" rel="nofollow"><strong>content slider</strong></a> on many other sites. This site is using Twitter Bootstrap (which I'm not familiar with).</p> <p>The Console error is:</p> <pre><code>Uncaught TypeError: Object [object Object] has no method 'slides' </code></pre> <p>I'm a JavaScript novice, so I'm not sure what to look for. I understand what the error is saying, but I don't understand why I'm getting it on this site and not others or where to start looking. What am I doing wrong?</p>
jquery
[5]
5,167,465
5,167,466
Python a fast way to count match in a list
<pre><code>print sum(1 for x in alist if x[1] == 8) </code></pre> <p>This code runs fine, but it is so slow. Is there a way better than this. Because, my list is very large and the computation takes a lot of time. Do you know a better and faster way to do it?</p>
python
[7]
4,784,415
4,784,416
Am I taking a risk if I give a distributor an unsigned apk?
<p>A distributor is asking for an unsigned version of my app's apk. Is there some security risk I am taking if I give it to him? I'm not really sure of the purpose of the signature.</p>
android
[4]
6,019,801
6,019,802
How do we modify the source of original Java classes?
<p>Hi all I was wondering if I could modify and recompile a Java base class?</p> <p>I would like to add functions to existing classes and be able to call these functions.</p> <p>For example, I would like to add a function to <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html" rel="nofollow">java.lang.String</a>, recompile it and use it for my project:</p> <pre><code>public char[] getInternalValue(){ return value; } </code></pre> <p>I was wondering how do we go about doing that?</p>
java
[1]
2,961,409
2,961,410
Sett scope on javascript function call
<p>I want to call a javascript function within a protected scope and i can do it this way </p> <pre><code>var a = "Global a"; ( function() { var a = "Local a"; var alertA = function() { alert(a); } alertA(); })(); </code></pre> <p>This alerts "Local a" butt what i realy would like to do is to get the same result with an already declared function. </p> <pre><code>var a = "Global a"; var alertA = function() { alert(a); } ( function() { var a = "Local a"; alertA(); })(); </code></pre> <p>So my question is how can a call alertA with a different scope so the result would be "Local a"</p> <p>The reason i would like to do this i want to call globally defined functions on different iframes and have global variabels like document and window point to the appropriate documents and windows for every specific iframe.</p>
javascript
[3]
3,324,013
3,324,014
jQuery current element index if has class
<p>so my code generates like this (when click a it adds active class to current):</p> <pre><code>&lt;div&gt; &lt;a href="#"&gt;&lt;/a&gt; &lt;a href="#"&gt;&lt;/a&gt; &lt;a href="#" class="active"&gt;&lt;/a&gt; &lt;a href="#"&gt;&lt;/a&gt; ... &lt;/div&gt; </code></pre> <p>how can I grab active a tags index?</p>
jquery
[5]
416,971
416,972
android youtube upload using intent
<pre><code>Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("video/3gpp"); intent.putExtra(Intent.EXTRA_STREAM, videoURI); startActivity(Intent.createChooser(intent,"Upload video via:")); </code></pre> <p>I used above code to upload 3gp video to youtube by firing intent</p> <p>but it throws following exception.</p> <p>I dont understand what is the relationship between the date exception and media uploading</p> <pre><code>05-04 13:04:59.315: ERROR/AndroidRuntime(10671): FATAL EXCEPTION: Thread-12 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): java.lang.NullPointerException 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at java.util.Calendar.setTime(Calendar.java:1325) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at java.text.SimpleDateFormat.formatImpl(SimpleDateFormat.java:536) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at java.text.SimpleDateFormat.format(SimpleDateFormat.java:818) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at java.text.DateFormat.format(DateFormat.java:376) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at com.google.android.apps.uploader.clients.youtube.YouTubeSettingsActivity.a(SourceFile:183) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at com.google.android.apps.uploader.clients.SettingsActivity.b(SourceFile:43) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at com.google.android.apps.uploader.clients.j.run(SourceFile:348) 05-04 13:04:59.315: ERROR/AndroidRuntime(10671): at java.lang.Thread.run(Thread.java:1019) </code></pre>
android
[4]
3,307,318
3,307,319
Conditional compilation in python
<p>Hi I am trying to implement conditional compilation in python similar to <a href="http://ideone.com/ttndK" rel="nofollow">this in C</a>,I have seen <a href="http://stackoverflow.com/questions/560040/conditional-compilation-in-python">this thread</a> and <a href="http://stackoverflow.com/questions/3496592/conditional-import-of-modules-in-python">this thread</a>.</p> <p>But <a href="http://ideone.com/u7BO8" rel="nofollow">this</a> is not working. I am relatively new to python,how can we fix this ?</p>
python
[7]
2,224,525
2,224,526
Split url with javascript
<p>I'm trying to split following url:</p> <p><a href="http://www.store.com/products.aspx/Books/The-happy-donkey" rel="nofollow">http://www.store.com/products.aspx/Books/The-happy-donkey</a></p> <p>in order to get only <a href="http://www.store.com/products.aspx" rel="nofollow">http://www.store.com/products.aspx</a></p> <p>I'm using javascript window.location.href and split but not success so far. How can this be done? thanks</p>
javascript
[3]
765,243
765,244
How to Capture and Set a Webpage as Live WallPapaer within Wallpaper Service And Engine
<p>I want to capture a web page from any website like "www.google.com" and then i want to convert that web page in a bitmap image and then set that bitmap image like "google.jpeg" as live wallpaper.. please help me..</p> <p>i have tried to get input stream of a web page and then i want to convert it in bitmap and save in sdcard or if it will directly convert in bitmap then it is the best..</p> <p>my code is</p> <pre><code>public Bitmap getRemoteDataMain(URL aURL) { try { URLConnection connection = aURL.openConnection(); connection.connect(); BufferedInputStream bis = new BufferedInputStream(connection.getInputStream()); Bitmap bm = Bitmap.createBitmap( 200,200, Bitmap.Config.ARGB_8888); ByteArrayBuffer baf = new ByteArrayBuffer(bis.available()); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); Log.v("3 BAF " + baf ,"BAF"); } FileOutputStream fos = new FileOutputStream("/sdcard/image.jpeg"); fos.write(baf.toByteArray()); bm.compress(Bitmap.CompressFormat.JPEG, 90, fos ); bm = BitmapFactory.decodeStream(bis); bis.close(); return bm; } catch (IOException e) { return null; } } </code></pre>
android
[4]
1,926,693
1,926,694
Small need help for Jquery image gallery modification
<p>I am using this image gallery in my project. need the effect of hover. But there is an issue when user clicks on that image it opens the image in a new window. How can i prevent that.</p> <p>Here is the <a href="http://www.catswhocode.com/blog/how-to-create-a-fancy-image-gallery-with-jquery" rel="nofollow">code sample</a> and here is the <a href="http://www.webinventif.fr/wp-content/uploads/projets/tooltip/02/" rel="nofollow">demo</a>.</p>
jquery
[5]
2,135,788
2,135,789
js slider - how to set up handle to negative margin?
<p>Take a look here: <a href="http://jsfiddle.net/ELKHq/" rel="nofollow">http://jsfiddle.net/ELKHq/</a>, now I would like to set up minimum to for example <code>-50px</code> and also I would like get opportunity to move handler a little next to parent div (<code>#szyna</code>) from the right side... I <strong>must</strong> use that script <a href="http://madrobby.github.com/scriptaculous/slider/" rel="nofollow">http://madrobby.github.com/scriptaculous/slider/</a> . Thanks in advice.</p> <p>EDIT: Here is both example what I would like to do with my slider: (remove spaces in below links)</p> <p>http:// i.stack.imgur.com/jP5Zm.png</p> <p>http:// i.stack.imgur.com/Hcrb6.png</p>
javascript
[3]
5,079,989
5,079,990
How to do this on one line?
<p>I am looking at tidying up this a bit but I'm kind of new to C#</p> <pre><code>ResponseList responsesList = new ResponseList(); PagedResponseList pagedResponsesList = new PagedResponseList(); responsesList = responseService.ListSurveyResponses(1000); pagedResponsesList = responsesList.ResultData; </code></pre> <p>This is probably an easy one, but the syntax needed to one-line this one escapes me.</p>
c#
[0]
1,834,360
1,834,361
Merge DataTables in C#
<p>I have two DataTables in an ASP.NET application written in C# (dtA and dtB). The both get filled from textboxes from user input. Each of them will only have one datarow at a time. For example, dtA can have the following values [ABC, DEF] where the column names are first name and last name, and dtB can having the following values [50, 100, 95] where the column names are grades. I need to know how to combine the two of these tables into a new datatable called dtC this way I can return dtC.</p>
c#
[0]
2,478,268
2,478,269
.trigger('blur') on collection of inputs?
<p>im trying to <code>trigger('blur');</code> on a collection of inputs but i does not seem to get this right.</p> <p>example is avaible here <a href="http://jsfiddle.net/VUUme/1/" rel="nofollow">http://jsfiddle.net/VUUme/1/</a></p> <p>im getting the collection and i got the blur method done but im not sure about the trigger part tho.</p> <pre><code>var $inputs = $('#form').find('input'); alert('load'); $inputs.each(function(){ $(this).trigger('blur'); }); //i tried this to but with no success //$inputs.trigger('blur'); alert('after the blur'); $inputs.blur(function(){ var $this = $(this); if ($this.val() == ''){ alert('it works'); } }); </code></pre>
jquery
[5]
2,739,207
2,739,208
abstract method not being picked up
<p>I'm getting the following error: <code>The type new MyWebViewClient(){} must implement the inherited abstract method MyWebViewClient.launchExternalBrowser()</code></p> <pre><code> DCWebView.setWebViewClient(new MyWebViewClient() { public void launchExternalBrowser(String url) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); } }); </code></pre> <p>I don't understand because according to my code I am defining the method. </p> <pre><code>public abstract class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (Uri.parse(url).getHost().equals("www.url.com")) { // This is my web site, so do not override; let my WebView load the page return false; } // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs launchExternalBrowser(); return true; } public abstract void launchExternalBrowser(); } </code></pre>
java
[1]
1,934,843
1,934,844
How to bold specific elements from a Database using a SimpleCursorAdapter
<p>I have a main activity that takes elements from a database and displays them in a clickable listview. I use this method to accomplish the task:</p> <pre><code>private void fillData() { // Get all of the notes from the database and create the item list Cursor c = RequestManager.getRequests(getApplicationContext()); startManagingCursor(c); String[] from = new String[] { DataBase.KEY_TITLE, DataBase.KEY_BODY }; int[] to = new int[] { R.id.text1, R.id.text2 }; // Now create an array adapter and set it to display using our row SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); setListAdapter(notes); } </code></pre> <p>I am wondering, is it possible to access a boolean field inside the database, and bold the specific element is the field is marked as unread? The elements are each in a textview, and are then placed in a listview. Thanks</p> <p>Edit: Used the suggestion to extend the CursorAdapter Class, but when any element in the list is bolded, the first element is also bolded. Once all the elements are marked as read, the first element goes back to unbolded. Any ideas?</p> <pre><code> public void bindView(View view, Context context, Cursor cursor) { TextView textRequestNo = (TextView) view.findViewById(R.id.text1); TextView textMessage = (TextView) view.findViewById(R.id.text2); StringBuilder requestNo = new StringBuilder(cursor.getString(cursor .getColumnIndex("requestNo"))); StringBuilder message = new StringBuilder(cursor.getString(cursor .getColumnIndex("Message"))); textRequestNo.setText(requestNo); textMessage.setText(message); if (cursor.getString(cursor.getColumnIndex("Read")).equals("false")) { textRequestNo.setTypeface(null, Typeface.BOLD); textMessage.setTypeface(null, Typeface.BOLD); } } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { final View view = mInflater.inflate(R.layout.notes_row, parent, false); bindView(view, context, cursor); return view; } </code></pre>
android
[4]
1,639,324
1,639,325
Regex to isolate id
<p>I would like to have a php function that will strip any input and keep only a numeric ID, 36816268 in the example below. </p> <p>The input can be something like this:</p> <pre><code>&lt;iframe src="http://player.vimeo.com/video/36816268" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt; </code></pre> <p>or like this</p> <pre><code>&lt;iframe src="http://player.vimeo.com/video/36816268" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/36816268"&gt;ABCinema&lt;/a&gt; from &lt;a href="http://vimeo.com/eeseitz"&gt;Evan Seitz&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt; </code></pre> <p>I can strip the first part as</p> <pre><code>preg_match('%.*http://player.vimeo.com/video/%im', $subject) </code></pre>
php
[2]