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,239,954
5,239,955
PHP: Remove image from server
<p>as I you can upload profile avatar to your profile, I wish to remove the previous one the user had. </p> <p>So before the query, where it changes the column "avatar" with the newfile.jpg, i wish to grab the newfile.jpg, and remove it from the server.</p> <p>How can I remove an image from the server? A secure way</p>
php
[2]
4,409,130
4,409,131
Remove object from list by identity
<p>In the following example a std::list stores objects of type Resource (by value, not pointing to). The Resource class does not provide a less than comparison nor equality operator. What is a good way to remove an object by identity (aka memory address). Can i avoid O(n) somehow? Is std::list the right container?</p> <pre><code>// Definition of the container std::list&lt;Resource&gt; resources; // Code Resource *closedResource = resourceFromList(); for (std::list&lt;Resource&gt;::iterator it = resources.begin(); it != resources.end(); ++it) { if (closedResource == &amp;*it) { resources.erase(it); break; } } </code></pre> <p><strong>Edit:</strong> Assume that the Resource class implements move semantic. Furthermore the Resource reregisters itself for any "movement" by a kind of Selector (cp. epoll or java.nio.Selector) for event notifications.</p>
c++
[6]
3,318,396
3,318,397
EditText focus lost
<p>In a custom ListView, there are two cols, one having TextView and other having EditText. For entering some preference, as the user clicks on the EditText, the software keyboard comes in focus and focus from the EditText is lost. How i can do this?</p>
android
[4]
4,583,146
4,583,147
How to add more options in Javascript dependent options?
<p>I want to add more dropdown options in this file:</p> <p><a href="http://parseven.com/java_ex.html" rel="nofollow">http://parseven.com/java_ex.html</a></p> <p>Now it has two and I want to make three more. Third option must be dependent on second option and so on. Please advise me. Thanks in advance.</p>
javascript
[3]
2,738,283
2,738,284
Java - Is there a way to call a variable using a variable as part of its name?
<p>This is what I'm doing,</p> <pre><code>for (i=0; i&lt;4; i++){ for (j=0; j&lt;7; j++){ someArray[1][i][j] = value1[i][j]; } } for (i=0; i&lt;4; i++){ for (j=0; j=0; j&lt;7; j++){ someArray[2][i][j] = value2[i][j]; } } </code></pre> <p>This is what I'd like to do</p> <pre><code>for (j=0; j&lt;14; j++){ for (i=0; i&lt;4; i++){ for (j=0; j=0; j&lt;7; j++){ someArray[j][i][j] = value%j%; } } } </code></pre> <p>Is there a way to do something like this? </p> <p>The reason I am doing this is because I need to set the value of an array and I don't know how to declare values for multidimensional string arrays.</p> <p>I know how to do this</p> <pre><code>public static String value1[] = { "somevalue", "morevalue", "blahvalue" }; </code></pre> <p>but I don't know how to do that if I'm declaring...</p> <pre><code>public static String value[][] = ... </code></pre>
java
[1]
3,204,157
3,204,158
How to show No record found in GridView if binded datasource is List Collection
<p><br> I have a gridview in which dtasource binded is a List which returns class type. If no records in list, I want to display 'No records found' in GridView.</p> <pre><code>List&lt;Ticket&gt; ticketList = new List&lt;Ticket&gt;(); ticketList = _tktBusiness.ReadAll(_tkt); if (ticketList.Count &gt; 0) { gridTicketList.DataSource = ticketList; gridTicketList.DataBind(); } else { } </code></pre> <p>In else part, what code i have to write to get desired output?Can anybody help?</p>
asp.net
[9]
481,426
481,427
From Bluetooth headset I am getting unclear voice when it is audio call in Android
<p>In my Activity class I wrote the following code for start the <code>bluetoothsco</code> in android. After connected Bluetooth to my tablet I make a sip audio call once call is established voice is <code>In-voice/Out-voice</code> is working, but voice is really unusable to hearing from Bluetooth.</p> <pre><code>AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.startBluetoothSco(); audioManager.setBluetoothScoOn(true); </code></pre> <p>Please anybody help me, how to get clear voice using android code.</p>
android
[4]
5,832,320
5,832,321
C#: New line and tab characters in strings
<pre><code>StringBuilder sb = new StringBuilder(); sb.Append("Line 1"); //insert new line character //insert tab character sb.Append("Line 2"); using (StreamWriter sw = new StreamWriter("example.txt")) { sq.Write(sb.ToString()); } </code></pre> <p>How can insert a new line and tab character in this example? </p>
c#
[0]
4,514,376
4,514,377
DownloadFile throws Internal Server Error
<p>This code throws exception. How to fix it?</p> <pre><code>string uriString = "http://www.fileserve.com/login.php"; NameValueCollection postvals = new NameValueCollection(); postvals.Add("loginUserName", "aaaa"); postvals.Add("loginUserPassword", "xxxx"); postvals.Add("autoLogin", "on"); postvals.Add("loginFormSubmit", "Login"); WebClient myWebClient = new WebClient(); myWebClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.36 Safari/535.7"); myWebClient.UploadValues(uriString, "POST", postvals); string cookiestr = myWebClient.ResponseHeaders.Get("Set-Cookie"); myWebClient.Headers.Add("Cookie", cookiestr); myWebClient.DownloadFile(new Uri("http://fileserve.com/file/2jkYtZS"), "C:\\temp\\" + Path.GetFileName("http://www.fileserve.com/file/2jkYtZS/some.avi")); </code></pre> <p>Exception is thrown by myWebClient.DownloadFile() method.:</p> <pre><code> The remote server returned an error: (500) Internal Server Error. at System.Net.WebClient.DownloadFile(Uri address, String fileName) at SimonDownloader2.Program.Main(String[] args) in C:\Users\Simon\Workspace\C#\Projects\SerialDownloader2\SerialDownloader2\Program.cs:line 32 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() </code></pre>
c#
[0]
1,422,073
1,422,074
Using conditions in different triggers
<p>I am having a lot of difficulties trying to find out more about how to type out a set of codes and reference it at other parts of the CS file.</p> <p>For example, I have a simple "switch statement" with a label. Instead of typing it out 2 or 3 times, I would like to just be able to call it. Below is a quick illustration of what I am tyring to do.</p> <pre><code>//Begin Reuseable Codes string title; switch (Request.QueryString["parameter"]){ case "first": title = "123"; break; case "two": title = "ABC"; break; } lblDDSubject.Text = "My message" + title //End Reuseable Codes protected void Page_Load(object sender, EventArgs e) { call the above reusable codes; } protected void something_SelectedIndexChanged(object sender, EventArgs e) { call the above reusable codes here also; ] </code></pre> <p>Since I am a super-noob, may the assistor(s) respond in less abstract way? </p>
c#
[0]
1,415,605
1,415,606
How do I set EOF on an istream without reading formatted input?
<p>I'm doing a read in on a file character by character using istream::get(). How do I end this function with something to check if there's nothing left to read in formatted in the file (eg. only whitespace) and set the corresponding flags (EOF, bad, etc)?</p>
c++
[6]
3,466,178
3,466,179
How to remain on the same page if error occured?
<p>The following code is simplified to illustrate my question. This is a page to capture data and it will will post the captured info and pass to another php page for processing. I'm trying to ensure the required fields are entered but it always go to the calling page regardless there is error. Can anyone help?</p> <pre><code>&lt;?php if (empty($_POST) === false) { $required_field = array('first_name','last_name'); foreach ($_POST as $key=&gt;$value) { if (empty($value) &amp;&amp; in_array($key, $required_field) === true) { $errors[] = 'Fields marked with asterisk are required'; break 1; } } } ?&gt; &lt;h1&gt;Input Form&lt;/h1&gt; &lt;?php if (empty($errors) === false) { echo output_errors($errors); } ?&gt; &lt;form method="POST" action="UpdateDB.php" name="UpdateForm"&gt; &lt;input type=text size="19" maxlength="19" name="firstname"&gt; &lt;input type=text size="19" maxlength="19" name="lastname"&gt; &lt;input type="submit" value="Submit" &gt; &lt;/form&gt; </code></pre>
php
[2]
4,784,595
4,784,596
path problem in java
<p>I am using net beans for developing my application in windows environment .. I have a xml file in XML folder (under web pages folder) . I am using the following code to read the xml file: </p> <pre><code>String path=new File("XML/TableNamesAndColumnNames.xml").getAbsolutePath(); </code></pre> <p>but it is giving no file found .. because I am getting the path like - </p> <pre><code>"C:\Documents and Settings\rajesh\My Documents\NetBeansProjects\ReportOfReuls\XML\TableNamesAndColumnNames.xml" </code></pre> <p>but if I use reverse slash i.e: </p> <pre><code>"C:/Documents and Settings/rajesh/MyDocuments/NetBeansProjects/ReportOfReuls/web/XML/TableNamesAndColumnNames.xml" </code></pre> <p>I am getting the file.. Is the problem of Net Beans or windows ..</p> <p>please any one suggest how to resolve this problem </p> <p>Thanks in Advance. Raj</p>
java
[1]
5,871,746
5,871,747
how does this php form work without defining variable?
<p>how does this php form work without defining $SCRIPT_NAME variable ?</p> <pre><code>&lt;form action="&lt;?php echo $SCRIPT_NAME ?&gt;" method="post"&gt; </code></pre>
php
[2]
3,015,380
3,015,381
Method taking two default parameters
<p>I have a method with the following definition:</p> <pre><code>void foo(int i = 0, bool flag = false) {} </code></pre> <p>I want to call foo() by passing only the second argument:</p> <pre><code>foo(true); </code></pre> <p>But like this it will always pass it to the first parameter (i).<br> Is there any other solution I can pass my argument to the second parameter ? Or the only way is to pass the first one also.</p> <pre><code>foo(0, true); </code></pre>
c++
[6]
3,112,287
3,112,288
iphone - stuff inside alertview
<p>I have a part on my app that I show the users, the files they have created and have stored inside the app's directory. I want to allow the users to rename the files. </p> <p>I am wondering of doing this:</p> <ol> <li>The user selects a file</li> <li>The user taps on the RENAME button.</li> <li>An alertview pops showing the old name and having a textview where the user can type the new name.</li> </ol> <p>My question is: is this blessed by Apple? This sounds like a hack to the alertview.</p> <p>Will the app be approved?</p> <p>I googled around and I saw mixed opinions about that.</p> <p>thanks</p>
iphone
[8]
659,422
659,423
Calling OnPaintBackground
<p>I'm working on making the form's background to be transparent, so i tested the following code in some random project and it worked perfectly, but now when i applied it to a new project it hasn't been read during the load process as i tried to break point!! what am i doing wrong?</p> <pre><code>protected override void OnPaintBackground(PaintEventArgs e) { Bitmap bmp = new Bitmap(AFK_AIESEC.Properties.Resources.splash); this.locked.BackgroundImage = bmp; } </code></pre>
c#
[0]
3,300,956
3,300,957
How to drag images around the screen
<p>Can anyone help me on how to code program for an image that can be drag around the screen? Can you give me a sample code for it. thanks a lot. And how can i make a game score for it. i will appreciate your response.</p>
android
[4]
4,030,626
4,030,627
Using Named Parameters in java Class
<p>I have a use case to use named and optional parameter.I tried to use named parameter as in a tutorial but it doesn't work</p> <p>My code is</p> <pre><code>public static void Main(String[] args) { System.out.println((CalculateBMI(weight= 123, height: 64)); } public static int CalculateBMI(int weight, int height) { return (weight * 703) / (height * height); } </code></pre> <p>getting Error " weight cannot be resolved to a variable" Please help</p>
java
[1]
3,239,015
3,239,016
Is the bitmap recycling process asynchronous?
<p>I have method that returns <code>Drawable</code>, and if its <code>Bitmap</code> object is recycled then it reloads.</p> <pre><code>public Drawable getLogo() { if(logo == null || Util.isRecycled(logo)) //Util.isRecycled checks - is Drawable's bitmap recycled, if it had so logo = CacheController.getInstance().getLogo(this); return logo; } </code></pre> <p>But looks like right after calling <code>bitmap.recycle()</code> it's <code>bitmap.isRecycled()</code> still returns <code>false</code>. Am I right, that bitmap recycle process goes asynchonously, or it's just bug in my code? If so, how can I make sure, that <code>Bitmap</code> is not recycled right now?</p>
android
[4]
1,744,078
1,744,079
new object in c++
<p>i'm new to c++ programming and i will be happy if you can help me. i tried to write this code:</p> <pre><code>bool RailwayLineList:: AddInTail(const RailwayLine&amp; data) { //there is no linked list to add the element if(this==NULL) return false; RailwayLineLink *newLink = new RailwayLineLink(data); } </code></pre> <p>when i tried to debug it i saw that the copy constructor had been called and the data had been initialized with some garbage (the class is using a default constructor).</p> <p>why is the copy constructor being called?</p>
c++
[6]
4,351,620
4,351,621
PHP PDO error successful no matter what
<p>I have a problem with my database! Here is my code:</p> <pre><code>&lt;?php $host = "/homes/49/jc192699/public_html/dbase"; $database = "EduPro.db"; $dbhandle = new PDO("sqlite:".$host.$database); if (!$dbhandle){ echo "Error connecting to database.\n"; } else{ echo "&lt;br&gt;"; echo "&lt;br&gt;"; echo "Database connection successful!"; } mysql_select_db($database); ?&gt; </code></pre> <p>The problem is that it's saying "Database connection successful!" No matter what I do, if I type the address in wrong, it still says successful, when I renamed the database to a database that doesn't exist, it still says successful. I can't see what the problem is here?</p> <p>If anybody could help me out it would be GREATLY appreciated!</p> <p>Thank you!</p>
php
[2]
3,906,556
3,906,557
hide everything on site
<p>Is it possible to hide everything on site using jquery before it starts to be rendered ? I check query string and if something is as I expected I do postback and then want to render correct site content.</p>
jquery
[5]
4,625,208
4,625,209
java adding two int arrays with different lengths. why giving a result that is smaller than correct result?
<pre><code>public void add(int[]a1,int[]a2){ int atotal[] = new int[20]; int capacity3 = Math.max(a1.length, a2.length); for (int i = 0; i &lt; capacity3; i++) { int a3 = a1[i] + a2[i]; if (a3 &gt; 9) { atotal[i] = a3 % 10; atotal[i+1] += a3 /10; } else { atotal[i] = a3; } } for(int i = capacity3 - 1; i &gt;= 0; i--) { System.out.print(atotal[i] + " "); } } </code></pre> <p>In the addition of each elements in two arrays in my program, the carry of each single bit addition is not added to the next-insignificance bit . so if array1[0] = 9, array2[0] = 2.. my result[0] = 1 and my result[1] doesn't have the added one from [0]. for example if i put 9999 and 1234 as the two arrays ,the result is 0123 instead of 11233.</p>
java
[1]
2,811,228
2,811,229
c# finding indexof and remove character atsign
<p>there is a String which contains some @ characters, i want to find " @ " in my string and remove them, but it also finds and removes these ones: "@"</p> <pre><code>int atsignPlace = str.IndexOf(" @ "); while (atsignPlace &gt;= 0) { str = str.Remove(atsignPlace,3); atsignPlace = str.IndexOf(" @ "); } </code></pre> <p>i tried this code, but it removes nothing, so it always finds first '@' ,which makes it an infinite loop.</p> <pre><code>int atsignPlace = str.IndexOf(" @"); while (atsignPlace &gt;= 0) { if( atsignPlace+1 &lt; str.Length &amp;&amp; str[atsignPlace+1] == ' ' ) str = str.Remove(atsignPlace,3); atsignPlace = str.IndexOf(" @ "); } </code></pre> <p>Replace method also doesn't work correct. </p> <pre><code>str = str.Replace(" @ ", String.Empty); </code></pre> <p>maybe there is a problem with '@' character.</p> <p>the input string is a sql query, i am trying to remove some parameters from it.</p> <p>[ i have used try-catch for exceptions ]</p>
c#
[0]
4,397,924
4,397,925
Create a Dialog from AlarmManager?
<p>I have scheduled an alarm using the AlarmManager and it fires off a BroadcastReceiver. Inside the broadcast receiver I want to call an Activity and create a popup dialog. </p> <p>The important thing here is I want to see the background of wherever the user is and NOT bring my application to the front first. Take a look at the following code:</p> <pre><code>Intent intent = new Intent(context, AlarmActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(intent); </code></pre> <p>Now here is what happens, which I do not want: 1. User is looking at my application 2. User presses home and is now in some other application 3. My application is still running in the background 4. Alarm triggers->BroadcastReceiver->The above intent is started 5. The user is now looking at the last page of MY application and my popup dialog</p> <p>What I want instead is: 5. The user is still looking at whatever application they were in, but they now have my popup dialog.</p> <p>How can I call the activity without bringing my application to the front?</p>
android
[4]
5,310,497
5,310,498
what is serialization, can't i do it for methods or varibales in a class
<p>Could some body explain me why we do serialization an what is profit of this ?</p> <p>can we put serialize word on method or not, like in the following program on complete class the serialization is done can i do it on a method or a variable</p> <pre><code>Serializable] public class StudentInfo { //Default Constructor public StudentInfo() { } /// &lt;summary&gt; /// Create object of student Class /// &lt;/summary&gt; /// &lt;param name="intRoll"&gt;Int RollNumber&lt;/param&gt; /// &lt;param name="strName"&gt;String Name&lt;/param&gt; public StudentInfo(int intRoll, string strName) { this.Roll = intRoll; this.Name = strName; } private int intRoll; private string strName; public int Roll { get { return intRoll; } set { intRoll = value; } } public string Name { get { return strName; } set { strName = value; } } } </code></pre>
asp.net
[9]
431,719
431,720
Incrementally updating a asp.net web site?
<p>Is there a good way to make incremental changes to an asp.net website without re-publishing the whole site?</p> <p>I'm moving an old website from classic asp to asp.net, and one of the things that used to happen on the site was individual pages being changed in isolation. The site is only on a single server, and has a lot of files so doing a re-publish would take the whole site down for a while. I'd like to avoid that, or at least make that time as short as possible.</p> <p>Each page does have a code behind file, and there's some stuff used by each page in App_Code (just in case that changes the answer).</p>
asp.net
[9]
2,718,914
2,718,915
Set a layoutmargin on a dynamically created checkbox
<p>I'm writing a task manager app that downloads a list of tasks and subtasks from a server and creates a new checkbox for each item and adds it to a linear layout (called ll below). The problem I'm having is that I cannot set the "layout margin left" using java like I can with XML (this is for the subtasks to indent them a bit on the screen). I can set most other xml properties, but cb.setMargins() doesn't work (says undefined for type checkbox). Setting the padding of course does not achieve the desired result.</p> <pre><code>for(int i=0;i&lt;tasks.size();i++) { CheckBox cb = new CheckBox(this); cb.setText(tasks.get(i).subtask_desc); cb.setButtonDrawable(R.drawable.checkbox_xml); ll.addView(cb); } </code></pre> <p>Any ideas or how I would work through this?</p>
android
[4]
1,766,901
1,766,902
VideoView audio only, no video?
<p>I have a Video view in my activity used to display a video stored in my res.raw folder like this:</p> <pre><code>MediaController controller=new MediaController(this); video.setMediaController(controller); String filePath="android.resource://" + getPackageName() + "/" + R.raw.video3; video.setVideoURI(Uri.parse(filePath)); video.requestFocus(); video.start(); </code></pre> <p>The problem is that I can hear the audio only, but the video is not shown.</p> <p>What can be the reason for this?</p> <p><strong>Edit:</strong> here's my layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/btnPlayAudio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Play Audio" &gt; &lt;/Button&gt; &lt;Button android:id="@+id/btnPlayVideo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Play Video" &gt; &lt;/Button&gt; &lt;VideoView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/videoView" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
1,689,084
1,689,085
How to call a web service on page load
<p>I am trying to call a web service on page load. Currently I call it on a button click and it works fine. But when I try to do the same on viewDidAppear, it doesn't happen. What i want to achieve is if username and password are saved then it should automatically load the next page. It is filling in the text boxes but not loading the next page.</p> <p>Here is my code for submit button and ViewDidAppear:</p> <pre><code>-(IBAction)submitButton{ [apd showCoverView:YES WithActivityIndicator:YES]; PlaceWebService *handler = [[PlaceWebService alloc]init]; [handler setRequestType:Loginparser]; NSString *url = [NSString stringWithFormat:@"http://www.mywebsite.com/api.php?command=auth&amp;cardno=%@&amp;password=%@",username.text,password.text]; [handler sendingLoginRequest:url Respond:self At:@selector(showParsed:)]; } </code></pre> <p>and for viewDidAppear</p> <pre><code>-(void)viewDidAppear:(BOOL)animated { NSLog(@"Appeared"); [self loginArea]; apd=[[UIApplication sharedApplication]delegate]; NSString *filepath=[self pathOfFile]; if([[NSFileManager defaultManager]fileExistsAtPath:filepath]) { NSArray *array=[[NSArray alloc]initWithContentsOfFile:filepath]; username.text=[array objectAtIndex:0]; password.text=[array objectAtIndex:1]; [self submitButton]; } } </code></pre> <p>What should I do? Please help...</p>
iphone
[8]
4,353,222
4,353,223
How can I download and display first 200 or 250 characters from a web-page?
<p>I have a list of urls for which I want to display first 200 or 250 characters. Can I do it using jquery or should I download them on the server side [using PHP] and store them in database?</p> <p>I guess I will have to use fopen with limit of characters. **</p> <h1>Edit</h1> <p>First 200 characters of "body" excluding tags. Like summary</p>
php
[2]
5,367,836
5,367,837
AttributeError: StringIO instance has no attribute 'fileno'
<pre><code>def captureOutput(self, func, *args, **kwargs): pass sys.stdout.flush() sys.stderr.flush() (outfd, fn) = tempfile.mkstemp() fout = os.fdopen(outfd, 'r') os.unlink(fn) (errfd, fn) = tempfile.mkstemp() ferr = os.fdopen(errfd, 'r') os.unlink(fn) try: oldstdout = os.dup(sys.stdout.fileno()) oldstderr = os.dup(sys.stderr.fileno()) os.dup2(outfd, sys.stdout.fileno()) os.dup2(errfd, sys.stderr.fileno()) try: ret = func(*args, **kwargs) finally: sys.stderr.flush() sys.stdout.flush() os.dup2(oldstdout, sys.stdout.fileno()) os.close(oldstdout) os.dup2(oldstderr, sys.stderr.fileno()) os.close(oldstderr) os.lseek(outfd, 0, 0) out = fout.read() os.lseek(errfd, 0, 0) err = ferr.read() finally: fout.close() ferr.close() return ret, out, err </code></pre> <p>When running this code, I get an error:</p> <pre> AttributeError: StringIO instance has no attribute 'fileno' </pre> <p>Why am I getting this error and how can I correct it?</p>
python
[7]
302,342
302,343
jQuery & Enabled/Disabled Controls
<p>I took from somewhere the following <em>script</em> which clears all input controls in the 'mainFrm' form:</p> <pre><code>$(':text , textarea , #mainFrm').val(''); $('select option:nth-child(1) , #mainFrm').attr('selected', 'selected'); $(':checkbox , :radio , #mainFrm').removeAttr('checked'); </code></pre> <p>It works really nice, but the problem is that is clears all controls regardless of the fact that some of them may be disabled. I would like to clear only the enabled ones, leaving the disables ones alone. How can I accomplish this? I tried changing the first line to</p> <pre><code>$(':text , textarea , enabled , #mainFrm').val(''); $(':text:enabled , textarea , #mainFrm').val(''); $(':enabled, text , textarea , #mainFrm').val(''); </code></pre> <p>but none of them worked. Can anyone please help me out with this?</p>
jquery
[5]
5,209,089
5,209,090
representation of a number as multiplication of its factors
<p>I want to represent a number as the product of its factors.The number of factors that are used to represent the number should be from 2 to number of prime factors of the same number(this i s the maximum possible number of factors for a number).</p> <p>for example taking the number 24:</p> <p>representation of the number as two factors multiplication are <code>2*12</code>, <code>8*3</code>, <code>6*4</code> and so on...,</p> <p>representation of the number as three factors multiplication are <code>2*2*6</code>, <code>2*3*4</code> and so on...,</p> <p>representation of the number as four factors multiplication(prime factors alone) are <code>2*2*2*3</code>.</p> <p>please help me get some simple and generic algorithm for this </p>
python
[7]
537,209
537,210
page Preinit, Init, load
<p>I am having a doubt in page_init, page preinit, load. I need to know when we use this also where we need to call our objects in different stages of our life cycle.</p> <p>Please let me know how they will process for each events raised</p>
asp.net
[9]
2,752,599
2,752,600
How do i get started with Android?
<p>How should i get started with Android? From where do i get help and sample source code? Can a JSF application run on Android phones? I saw primefaces site and it has TouchFaces which are meant for Android phones. But i really don't know how should i get started with Android. Is it too tough? Does it take too much time creating even a simple application?</p> <p>Thanks in advance :)</p>
android
[4]
334,185
334,186
calculation of work time and lunch time of individual days - php/mysql
<p>example: </p> <p>if a user come office in morning, go to lunch, come office after lunch, and then go to home then how we can calculate work time and lunch time</p> <p>[ currently i have 'start time', 'end time' and total time including lunch time ]</p> <p>I need 'total time' excluding 'lunch time' order by individual dates</p> <p>Please help me! </p>
php
[2]
5,766,084
5,766,085
iphone private API
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3546046/check-for-private-api-usage-yourself">Check for private API “usage” yourself?</a> </p> </blockquote> <p>How to find that my iphone project having private API..?</p> <p>Thanks....</p>
iphone
[8]
581,393
581,394
Custom control with Multiple Controls with same ID issue?
<p>I have a very simple custom control ive defined below:</p> <pre><code>public class TestCtrl : WebControl { protected override void OnInit(EventArgs e) { var btn = new Button() { ID = "test", Text = "text"}; this.Controls.Add(btn); } } </code></pre> <p>However, when I wish to place multiple instances of them on the same page, I get... </p> <blockquote> <p>'Multiple controls with the same ID 'test' were found.</p> </blockquote> <p>...when <code>btn</code> is clicked.</p> <pre><code> protected void Page_Init(object sender, EventArgs e) { var ctrl1 = new TestCtrl() { ID = "ctrl1" }; plc.Controls.Add(ctrl1); var ctrl2 = new TestCtrl() { ID = "ctrl2" }; plc.Controls.Add(ctrl2); } </code></pre> <p>Is there a clean way to stop this from happening? Ive tried setting ClientIDMode to 'Auto' without any success, as the <code>name</code> property of the rendered markup is <code>"test"</code> on both buttons.</p> <p>EDIT: Solved by adding 'INamingContainer' to the control <code>public class TestCtrl : WebControl, INamingContainer{...}</code></p>
asp.net
[9]
815,291
815,292
jQuery-How to improve this code
<p>I have one jQuery code and need some help from u guys to improve performance. HTML:</p> <pre><code> &lt;div class="mydiv"&gt; &lt;div class="indiv"&gt; &lt;span&gt; myspan &lt;/span&gt; &lt;a href="#"&gt; a1 &lt;/a&gt; &lt;a href="#"&gt; a2 &lt;/a&gt; &lt;/div&gt; &lt;table &gt; .................. &lt;/table&gt; &lt;/div&gt; </code></pre> <p>Now I wantto know the following. 1.Now for working with a particular range of tr, I am coding like</p> <pre><code> var $myrows = $(".mydiv table tr").slice(index); $($myrows , this).jQueryFunction() </code></pre> <p>The code is working fine, but I think $(".mydiv table tr") will make the browser traverse total DOM, so should I go for $(".mydiv table tr",this).jQueryfunction() //I think this will improve performance,instead of using var$myrows.</p> <p>I think 2 nd one is good.</p> <p>2.$(".mydiv .indiv a",this).click(function(event) this click is not working , if I remove this it will start working.why?</p> <p>3.I have to select one specific tr, for that I am using </p> <p>$(".mydiv table tr:nth-child(that specific child)") Any better way of doing this?Also in this case it will traverse the DOM. Thanks.</p>
jquery
[5]
4,846,008
4,846,009
Why Debugger is not working Properly in Microsoft visual web developer 2005 express edition
<p>Debugger is not working Properly in Microsoft visual web developer 2005 express edition. </p>
asp.net
[9]
3,874,589
3,874,590
How is this if statement interpreted?
<p>I saw the code below, which shocked everyone.</p> <p>How is this code executed?</p> <pre><code>if (!Test.IsXyz == true) { } </code></pre> <p>If IsXyz resolves to true but then to false with the ! operator, how is this code interpreted? Because the RHS states true. Would this be:</p> <p>1) False for LHS | True for RHS == False (From my truth table days)</p> <p>Assuming the bool resolves to true, I can imagine several wierd ways this code would be understood. What is the official way to the compiler?</p>
c#
[0]
5,100,284
5,100,285
Check if a string is all numbers and 10 chars long
<p>Just looking for a quick way using PHP to check if a string is all numbers and 10 numbers long.</p> <p>eg: </p> <p>4343434345 - this would be accepted (10 chars all digits)</p> <p>343434344 - this wouldn't (9 chars)</p> <p>sdfefsefsdf - this wouldn't.</p> <p>thanks</p>
php
[2]
4,453,966
4,453,967
identifiers in java with different versions?
<p>as we "No keyword should be used as an Identifier in java". But there will be some words like asser or enum or any other which have been added as keyword in version 1.4, 1.5 resp. So if any older version code is used to compile with new javac, what happens if that code contains these words as an identifier?</p>
java
[1]
3,881,248
3,881,249
Unify 2 bytes to Int
<p>I have a function that allows me to separate a INT value in 2 Bytes (e.g: INT "123123" results in E0F3; <code>highByte= 0xF3</code> and <code>lowByte=0xE0</code>)</p> <p>using this:</p> <pre><code>void int2bytes(unsigned char dest[2],int val){ int hByte=0; int lByte=0; hByte=val&amp;0XFF; lByte=val&gt;&gt;8; dest[0]= (char)hByte; dest[1]= (char)lByte; } </code></pre> <p>my question is:</p> <p>How do I convert(unify) those 2 bytes to one INT equals to "123123"?</p>
c++
[6]
4,228,369
4,228,370
Send bacup on dropbox
<p>I'm able to get files,zip,accountinfo from dropbox via api of dropbox,but i"m not put a file on dropbox. All code running on server. i'm using code : accontinfo code is: $accountInfo = $dropbox->accountInfo();</p> <p>getFile code is: $dropbox->getFile($path, $outFile);</p> <p>putFile code is : $dropbox->putFile('/home/funnybun/public_html/wp-content/nalin_dbbackupfile/database-.sql1336974851.zip', 'database-.sql1336974851.zip');</p> <p>i have a problem in putFile , not got a response. does anyone know about this problem. Thanks!</p>
php
[2]
3,224,728
3,224,729
How to show current time in textbox in android
<p>In my application I need to show current date and time in a texview. The text view should be set with updated for every minute. I dont want to display seconds. Can any one please help me.</p>
android
[4]
917,469
917,470
Setters not working
<pre><code>public class Shape{ public int xPos = 10; public int yPos = 20; Shape(){ } public int getXpos(){ return xPos; } public void setXpos(int x){ this.xPos = x; } public int getYpos(){ return yPos; } public void setYpos(int y){ this.yPos = y; } } public class Shape1 extends Shape{ Shape1(){ xPos = 100; yPos = 200; } } public class Test{ public static void main(String[] args) { Shape1 shape1 = new Shape1(); System.out.println(shape1.getXpos()); } } </code></pre> <p>Now my question is: Why am I getting 10 as a result instead 100?</p>
java
[1]
3,835,233
3,835,234
How to display a welcome screen in android?
<p>Hi i want a screen which should appear for 2-3 screen with my logo and then should proceed to main program. how to implement this.</p>
android
[4]
987,539
987,540
JavaScript - Replace two characters with each other?
<p>I have a string and I want to replace every capital 'I' with small 'i', and every small 'i' with a capital 'I'. As you can see if I do this in two stages it just converts it, then converts it back to how it was before. So how would I do it all at once?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function init() { text = document.getElementById('test'); newtext = text.innerHTML.replace(/I/g, "i"); newtext = newtext.replace(/i/g, "I"); text.innerHTML = newtext; } &lt;/script&gt; &lt;/head&gt; &lt;body onload="init()"&gt; &lt;div id="test"&gt; THIS IS SOME TEST &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
163,242
163,243
Access the Apps available in iphone
<p>Hi i would like to access the apps which are available in iphone means downloaded apps and inbuild apps.But here issue is if i access any app which is available in iphone using [[UIapplication sharedapplication]openurl:[NSURl url urlwithstring:@"http://www.skype.com"]] like this i can able to access that iphone app succesfully but if i want to come back to my app i did not find any way only i have to hit homebutton. So is there anyway to come back to my app at any point of time. if anyone know please let me know. Thanking you.</p>
iphone
[8]
4,700,759
4,700,760
Android save and load firstrun state
<p>In my app when user clicks a button, a male or a female sound is played. I want this: if at first run a male sound was played then also at the other clicks/runs a male sound is played. So no female voice ever. If at first run a female sound was played then also at the other clicks/runs a female sound is played. I do not mean just clicking the button, i mean everytime the user opens the app.</p> <p>Here is my code for randomize and playing:</p> <pre><code> randNem = new Random(); nem = randNem.nextInt(2)+0; NameButton = (Button)findViewById(R.id.Button01); NameButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (nem == 0) { mp = MediaPlayer.create(Main.this, R.raw.hellomyfriend_amy); mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.release(); NameButton.setEnabled(true); } }); } else if (nem == 1) { mp = MediaPlayer.create(Main.this, R.raw.hellomyfriend_joey); mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { mp.release(); NameButton.setEnabled(true); } }); } } }); </code></pre>
android
[4]
2,959,924
2,959,925
How to prevent a user from using "view source" to look at my php code and copy it?
<p>How can I prevent a user from using "view source" to look at my php code and copy it?</p> <p>thanks</p>
php
[2]
6,005,389
6,005,390
ClassFormatError: Unknown constant tag in class XY
<p>I have a piece of code in which I try to load a class during runtime. The code is not all selfwritten so I have some problems understanding the error which always appers after compiling.</p> <p>Here the code:</p> <pre><code>private Class findClass(String s) throws ClassNotFoundException { URL url = getResource("AP.class"); if(url == null) { throw new ClassNotFoundException(s); } inputstream = null; Class classToRead; try { inputstream = url.openStream(); byte abyte0[] = readClass(inputstream); classToRead= defineClass(s, abyte0, 0, abyte0.length); } catch(IOException ioexception) { throw new ClassNotFoundException(s); } if(inputstream != null) { try { inputstream.close(); } catch(Exception exception1) { } } return classToRead; } </code></pre> <p>The error appears at the defineClass method.</p> <p>Error stacktrace:</p> <pre><code>Exception in thread "main" java.lang.ClassFormatError: Unknown constant tag 63 in class file AP at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.lang.ClassLoader.defineClass(Unknown Source) at c.findClass(c.java:100) at c.loadClass(c.java:56) at java.lang.ClassLoader.loadClass(Unknown Source) at c.a(c.java:20) at mainOpenClass.main(lol.java:13) </code></pre> <p>My questions now are: Is maybe anything wrong with the code? Is it possible that the AP.class is damaged? What does the error really mean?</p> <p>I hope anybody can help me with my problem because searching the internet didn't really help in that case.</p>
java
[1]
2,251,392
2,251,393
Increment an index that uses numbers and characters
<p>I have a string based code that can be either two or three characters in length and I am looking for some help in creating a function that will increment it.</p> <p>Each 'digit' of the code has a value of 0 to 9 and A to Z.</p> <p>some examples:</p> <p>the first code in the sequence is 000 </p> <p>009 - next code is - 00A<br> 00D - next code is - 00E<br> AAZ - next code is - AB0 </p> <p>the last code is ZZZ.</p> <p>Hope this makes some sense.</p>
c#
[0]
2,381,193
2,381,194
how can I play a sound using a phone call in android?
<p>I am making calls using my app , but now i need to something very funny with call means i need to play recording sounds so that other person on call can hear it . Is it possible in android ? Please help</p>
android
[4]
5,228,209
5,228,210
I want to split an activity into several classes. is it possible?
<p>I'm finishing an application, the thing is that I have a couple of layouts and all the code concentrated in an Activity. I have 5000 lines of codes and when I have to fix something is a pain in the ass to find what im looking for.</p> <p>as im really new in Android development, I can't find a way to split the code into several classes. is there a simply way of split one layout with one activity? its really annoying to declare each layout with his corresponding activity in the manifest.</p> <p>thanks for any suggestion.</p>
android
[4]
3,242,520
3,242,521
Javascript datestring constructor changes timezone
<p>I have a string Date in this format: </p> <blockquote> <p>"2012-07-22T08:00:00Z" </p> </blockquote> <p>But when i try to create a date from that string: </p> <pre><code>new Date("2012-07-22T08:00:00Z"); </code></pre> <p>I get: </p> <blockquote> <p>Date {Sun Jul 22 2012 01:00:00 GMT-0700} </p> </blockquote> <p>Looks like it's changing the timezone of the date to local timezone. Because it's reducing the time in 7 hours (<strong>GMT-0700</strong>)</p> <p>How can i keep the date object with utc and in the right time (<strong>08:00:00</strong>)? </p> <p>Thanks in advance!!! </p>
javascript
[3]
497,608
497,609
Python Datatype for a fixed-length FIFO
<p>I would like to know if there is a native datatype in Python that acts like a fixed-length FIFO buffer. For example, I want do create a length-5 FIFO buffer that is initialized with all zeros. Then, it might look like this:</p> <p>[0,0,0,0,0]</p> <p>Then, when I call the put function on the object, it will shift off the last zero and put the new value, say 1, into the left side:</p> <p>[1,0,0,0,0]</p> <p>If I put a 2, it would then shift and put to look like this:</p> <p>[2,1,0,0,0]</p> <p>...and so on. The new value goes at the front and the oldest one is shifted off. I understand that this would be very easy to implement myself, but I would like to use native python datatypes if at all possible. Does anyone know which datatype would be best for this?</p>
python
[7]
200,185
200,186
how to close an application in android
<p>Is there any proper way as suggested by google or android official documentation to close an application in android with out using any task killer tools .... </p> <p>I ask this question as a android use not as developer..... </p>
android
[4]
5,335,134
5,335,135
java constructor in super classes
<p>The following code is a testing program. Why i can't use A(int a), in this program?</p> <pre><code>public class A { int a; void meth(int b) { a+=b; } A(int a) { this.a=a; } } class B extends A { int a; void meh2(int b) { a+=b; } } </code></pre> <p>why can't pass parameter to constructor? What the reasons? Netbeans error message:</p> <p>constructor A in class tma1.A cannot be applied to given types; required: int found: no arguments reason: actual and formal argument lists differ in length</p>
java
[1]
1,883,151
1,883,152
How to make an Android application work only for some trial period
<p>I have an application which should work only for 30 days or few days.</p> <p>It's just a simple application which has some audio files playing to corresponding to images displayed with some text displayed.</p>
android
[4]
1,157,215
1,157,216
Setting attribute using data from a for loop
<p>I have the following code</p> <pre><code>for(var i = 0; i &lt; data.length; i++) { var item = data[i]; $('.client-content').append("&lt;li&gt;"+"&lt;b&gt;"+i +"&lt;/b&gt;" + " : " +item[0] + " : " + item[1]+"&lt;a href='#' class='link-right'&gt;Edit&lt;/a&gt;" + "&lt;a href='#' class='link-right'&gt;Delete&lt;/a&gt;"+"&lt;/li&gt;" + "&lt;br/&gt;"); </code></pre> <p><code>item[0]</code> is the record id that i want to have as my id attribute.I want my <code>&lt;li&gt;</code> to have the id <code>item[0]</code>.How do i do that?.</p>
jquery
[5]
5,098,829
5,098,830
Website Development Problem CakePHP, WordPress or Start From Scratch?
<p>I'm in the process of starting a new web site that is something like stackoverflow but a little bit more different along with making the members profiles highly more customizable I was thinking of building it from scratch using PHP, but was thinking of using CakePHP, but then I thought WordPress sounded better but I remember working with wordpress and it was a little bit slow at times when you tried to browse the web site. </p> <p>So what I guess I'm trying to ask is that should I design the site from scratch? And I heard techcrunch.com and 9rules.com are completely done in WordPress, is this true?</p>
php
[2]
5,042,972
5,042,973
Code check - Function to verify integers with optional return value
<p>I'm hoping someone could give me some input on how to improve this function. Its purpose is to evaluate whether a form input is a valid integer, and if not, either return a zero by default, or -1 if the second argument = true.</p> <p>EDIT: Here is an updated version of the function I'm using. It seems the two most challenging parts are to ensure that an empty string doesn't evaluate as 0 when expecting -1 for empty strings ($neg=true), and evaluating inputs with left padded zeros as integers and not octals.</p> <pre><code>function clean_integer($value, $neg=false) { if (!is_numeric($value)) { if (!$neg) { return 0; else { return -1; } } $value = ltrim(trim($value), '0'); if (!$neg) { if ($value !== true &amp;&amp; ((string)(int) $value) === ((string) $value)) { return (int) $value; } else { return 0; } } else { if (!is_numeric($value)) { return 0; } if ($value !== true &amp;&amp; ((string)(int) $value) === ((string) $value)) { return (int) $value; } else { return -1; } } } </code></pre> <p>I've been staring at this for too long and am convinced I'm making it terribly overcomplicated. </p>
php
[2]
3,485,415
3,485,416
View PDF in a web page without Flash
<p>I am working on a website that need to embed weekly PDF file on a page.<br> We don't want to use Flash since website need to support cross browsers(like Android).<br> I have reviewed following topic but it doesn't meet my target since some browsers don't support HTML5.<br> <a href="http://stackoverflow.com/questions/10380963/browsing-pdf-in-a-web-page-without-flash">Browsing PDF in a web page without Flash</a><br> I now have three options and wonder which is better.</p> <p>1.Use Google Doc Viewer - the problem of google doc viewer is that PDF resolution can't be too high.<br> As result our PDF content become unclear.<br> 2.<a href="http://www.OpenLayers.org/" rel="nofollow">OpenLayers</a> - we have to convert our PDF file to image.<br> 3.<a href="http://www.dimviewer.com/" rel="nofollow">DimViewer</a> - this is not open source tool.</p> <p>If anyone has similar experience welcome to share.</p>
javascript
[3]
1,329,211
1,329,212
How to test ajax post w\ jQuery
<p>I have the following function that opens jQuery UI's dialog warning about the delete of an entry. Everything works fine, except the POST with AJAX. I get response on "success" but I don't believe I am hitting the .php page that is supposed to execute the query. Am I missing anything here?</p> <pre><code>var $dialog = $("#dialog").dialog({ autoOpen: false, resizable: false, modal: true }); $(".delProj").click(function(){ var delURL = $(this).attr("href").split("#"); var projID = delURL[1]; $dialog.dialog("open"); $("#dialog").dialog({ buttons: { "Yes, delete this test": function() { $.ajax({ type: "POST", url: "http://www.mydomain.com/inc/db_actions.php", data: "op=DeleteProject&amp;delete="+projID, success: function(){ // alert( "Test Project deleted successfully." ); $("#"+projID).remove(); } }); $(this).dialog("close"); }, "No, keep it.": function() { $(this).dialog("close"); } } }); }); </code></pre>
jquery
[5]
5,196,064
5,196,065
C++ - Where do i start?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/525726/the-best-place-to-start-learning-c">The Best Place to Start Learning C++</a> </p> </blockquote> <p>Hi All, As a bit of a side project while I'm on my summer break from uni, I've decided to have a look at C++, and get the hang of the basics.</p> <p>I'm by no means a programming novice, I've done web development before with PHP and Ruby, and I've done a fair bit of work with compiled languages (Java / C#). However, C++ seems to be a more significant undertaking. Basically I'm wanting pointers to the best resources for learning C++, as well as some idea as to areas I could do with reading up on (That I might not have come across before).</p> <p>Any help would be hugely appreciated.</p> <p>Thanks</p>
c++
[6]
541,092
541,093
How to throw new Exception gracefully
<p>How can I throw exception gracefully?</p> <pre><code>public void Test() { if (error != 0) { string msg = "Error"; throw new Exception(msg); } // Other function ... } </code></pre> <p>I have also change the <code>throw new Exception(msg);</code> with logger</p> <pre><code>public void Test() { if (error != 0) { string msg = "Error"; //throw new Exception(msg); logger.Error(msg); } // Other function ... } </code></pre> <p>Should I use Exit function to exit the function when error hit?</p> <p>Thnak you.</p>
c#
[0]
1,988,095
1,988,096
Display as two Decimal
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8779659/convert-a-number-to-2-decimal-places-in-java">Convert a number to 2 decimal places in Java</a> </p> </blockquote> <p>I need to display a decimal number up to two digits in Java.</p> <p>For example:</p> <pre><code>Case1. 2.333 - 2.33 Case2. 3.4 - 3.40 </code></pre> <p>I am able to do the first case. Can anybody help me how to do for the second case.</p>
java
[1]
2,650,407
2,650,408
Python Tkinter program for Status Bar
<pre><code>from Tkinter import * class StatusBar(Frame): def __init__(self, master): Frame.__init__(self, master) self.label = Label(self, bd=1, relief=SUNKEN, anchor=W) self.label.pack(fill=X) def set(self, format, *args): self.label.config(text=format % args) self.label.update_idletasks() def clear(self): self.label.config(text="") self.label.update_idletasks() root = Tk() root.update() d =StatusBar(root) d.pack() mainloop() </code></pre> <p>Hi Friend.This is my code for Status bar.Even though i didn't get any error or warning. I had failed to obtain the status bar. But my Widget is getting opened with empty in it.Can any one please help me in this aspect.</p> <p>Thank you</p>
python
[7]
3,772,486
3,772,487
Launching a project downloaded from the android open source project in eclipse
<p>I'm just starting to developing for the android platform. I'm still in "reading lots of code" phase. I downloaded the source code from android's music player into eclipse, now I want to run it on the emulator but eclipse tells me that the "selection cannot be launched". Is there something missing? I used this tutorial to get the code: <a href="http://www.vogella.de/articles/EGit/article.html" rel="nofollow">http://www.vogella.de/articles/EGit/article.html</a> and the git repository is: <a href="http://android.git.kernel.org/?p=platform/packages/apps/Music.git;a=summary" rel="nofollow">http://android.git.kernel.org/?p=platform/packages/apps/Music.git;a=summary</a></p> <p>Appreciate in advance.</p>
android
[4]
4,519,764
4,519,765
How to make UpdateProgress render as span not div or make this div display:inline?
<p>How to make UpdateProgress render as span not div or make this div display:inline ?</p>
asp.net
[9]
3,564,476
3,564,477
Check a string regardless of case structure
<p>I have this code that checks if a string is blue. I want it to approve it regardless of whether it's lower or upper case in any of the letters.</p> <pre><code>if( ($subcol !== 'blue') || ($subcol !== 'Blue') || ($subcol !== 'BLUE') ) { $form-&gt;setError($field, "* Colour not correct, use the hint"); } </code></pre> <p>This doesn't seem to work? Have I structured something wrong?</p> <p>Also, is there a PHP function that can be used that will just check it once for all these scenarios?</p> <p>Thanks</p>
php
[2]
3,431,084
3,431,085
import content from csv to mysql database
<p>There is a mysql database named: <code>example</code> which has a table named: <code>products</code> it have fields: <code>products_model</code> and <code>products_image</code>. the model field is unique.</p> <p>now i have a csv file named <code>data.csv</code>. which have two column products_model and <code>products_image</code>.i use the following code. but it doesn't import the data into the database.what's wrong with my code?</p> <pre><code> $fp = fopen("data.csv","r"); $length = 4096; //have to be optional length $fildDelineate = ',' ;//or "|" declare what you need $dbhost="localhost"; $dbname="zencartone"; $dbuser="root"; $dbpass=""; $link = mysql_connect($dbhost,$dbuser,$dbpass); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db($dbname); $databasetable = 'products'; $counter = 1;//to omission first row if it is table headers while($line = fgetcsv($fp,$length,$fildDelineate)){ foreach($line as $key=&gt;$value){ //for example insert in 3 column $importSQL = "insert into $databasetable (products_model, products_image) values('$line[0]','$line[1]')"; mysql_query($importSQL) or die(mysql_error()); } $counter++; } fclose($fp); </code></pre> <p>data.csv:</p> <p>have two column:</p> <pre><code>products_model products_image MG200MMS dress/201247561673.jpg MG400-32MB dress/2012471141673.jpg MSIMPRO dress/201247741673.jpg DVD-RPMK dress/2012471831673.jpg DVD-BLDRNDC dress/2012474221673.jpg DVD-MATR dress/201112132056773.jpg </code></pre>
php
[2]
4,676,208
4,676,209
Android Gridview drag and drop example
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7146639/android-gridview-reorder-elements-via-drag-and-drop">Android GridView reorder elements via Drag and Drop</a> </p> </blockquote> <p>Can anyone give me some link from where I can learn Drag and Drop inside Android GridView.</p>
android
[4]
752,550
752,551
jQuery: how to apply same predefined behavior for new appended element?
<p>I have a click method for a class of div tags <code></p> <pre><code>&lt;div id="wrapper"&gt; &lt;div class="detail"&gt;abc&lt;/div&gt; &lt;div class="click"&gt;click here&lt;/div&gt; &lt;div ckass="click"&gt;click here&lt;/div&gt; &lt;/div&gt; &lt;script&gt; ${.click}.click(function(){ $(#wrapper).append("&lt;div class="click"&gt;added&lt;/div&gt;"); }); &lt;/script&gt; </code></pre> <p></code></p> <p>When I click on "click here" the script added new div. But when I tried to click on the new added div, nothing happened. Please show me how to make the new added also clickable. Thank you very much. </p>
jquery
[5]
1,107,314
1,107,315
Errors in C# Namespace, expected class, and end-of file expected
<p>I'm getting 4 errors with the following code, can you tell me how to fix this?</p> <p>1- A namespace cannot directly contain members such as fields or methods 2- Expected class, delegate, enum, interface, or struct. 3- Type or namespace definition, or end-of-file expected</p> <p>The code is:</p> <pre><code>License Seal; public void Mainform() {} public MainForm() {} public enum auth{} } {{ Seal = new License(); Seal.ID = ""; Seal.Catch = true; Seal.Protection = License.Guard.FullScan; Seal.Initialize(); } public MainForm.cs(); }} auth(); InitializeComponent();{ } </code></pre>
c#
[0]
4,358,625
4,358,626
Return type from db methods
<p>What return type should one return from a method that is getting rows from the database. Should you keep the data in a dataset / datatable, should you create a collection of objects representing the data, or should you return an interface such as IList or IEnumerable, etc?</p> <p>I know the real answer is "it depends", but I am just curious as to best practices that others observe. Dataset / datatable seems the simplest, but returning an interface seems to be the way it should be done. How are you all doing it?</p>
c#
[0]
2,660,942
2,660,943
php - regexp match string and digit
<p>I want to match this </p> <pre><code>{format i=34 ds=11 k=a /} $patern = "/\{format[a-z0-9=\s]?\/\}/i"; </code></pre> <p>but result is null</p> <p>In additional question:</p> <pre><code>string string {format mat=34/} string string string string string string string string string string {format mat=34/} string string string string string string string string </code></pre> <ol> <li><p>$pattern = "/{format[a-z0-9=\s]*\/}/i";</p> <p>str_replace($pattern, 'test', $strings);</p> <p>it will replace all formats in string, i want to replace only first "format", and remove all another "format". How ? </p></li> <li><p>when get match result is "{format mat=34/}". i want to find string begin with "mat=".</p></li> </ol> <p>So i have this </p> <pre><code>$string = "{format mat=34/}"; $pattern = "/^mat=[0-9]*/"; // result is null $pattern = "/mat=[0-9]*/"; // ok, but also effect with "{format wrongformat=34/}" </code></pre> <p>How to match string that begin with "mat="</p>
php
[2]
4,380,251
4,380,252
Why Android application is not visible in running application?
<p>I am facing quite different issue.I had developed Android application it works fine.But the problem is I am not able to see that application in Running application (i.e. Setting > Application > Manage Application > Running). It is visible in rest of all the tab's (i.e. Downloaded,All). I am facing this issue in HTC Nexus 2.3.6 and in IceCreamSandwich. Application is running fine without any issue.But the only problem is ></p> <p>Why it is not visible.Any suggestion.......</p>
android
[4]
2,521,166
2,521,167
how can i start a song when app is in background mode
<p>I want to stop all playbacks by playing a empty audio file when my app is in background I tried following code but I was not played.</p> <pre><code> -(void)stop{ [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; if(_viewController.checkIpod==0){ AVAudioPlayer *playerA = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:@"2sec" ofType:@"mp3"]] error:nil]; [playerA play]; //[player close]; _viewController.onceClosed=1; NSLog(@"Oneclosed=1"); } else{ //[self.musicPlayer play]; [_viewController.musicPlayer pause]; [_viewController.playerA play]; NSLog(@"closing and playing the sound"); } </code></pre> <p>}</p> <p>I placed this code in beginBackgroundTaskWithExpirationHandler Please help</p>
iphone
[8]
977,251
977,252
Disclosure button for displaying more text in a table view
<p>So i have created a custom cell with IB and source files associated which is put in my table view. The cell in my table view display text which doesn't fit entirely. What i want is to add a disclosure button in my cells which when is touch up display the rest of the text of the cell in for example two lines or by adjusting the text in the cell. But i really do not know how to do. </p> <p>So if you have any clue, link or code it would be really nice thanks to all. </p>
iphone
[8]
2,416,744
2,416,745
When to use getparent()
<p>In my custom view I need to use the getParent method and set the visibility on some of it's child views depending on my custom view's state. The problem is that I want to instantiate the child views just once. Where is the best place to do this?</p> <p>Thanks a lot,</p> <p>Gratzi</p>
android
[4]
5,654,869
5,654,870
How to check the occurence of the SelectedIndexChange event of a dropdownlist
<p>How can we check whether the selectedIndexChange event of a dropdownlist is fired or not? Can we use a boolean varible or is there any predefined method to do that?</p>
asp.net
[9]
3,127,069
3,127,070
Opposite to jQuery .remove
<p>I have an input form I am trying to remove/add on a click function. </p> <p>Here is my code:</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $("#1").click(function () { $("#1").hide(""); }); $("#1").click(function () { $("#twitter").remove(); }); $("#1").click(function () { $("#2").show(""); }); $("#2").click(function () { $("#2").hide(""); }); $("#2").click(function () { $("#1").show(""); }); }); &lt;/script&gt; &lt;span id="1"&gt; &lt;img align="left" src="../images/twitter_blue.png" width="30px;" style="margin:5px;"/&gt; &lt;div&gt;Share as @&lt;?php echo $_SESSION['username'] ?&gt;&lt;/div&gt; &lt;/span&gt; &lt;img align="left" id="2" src="../images/twitter_white.png" width="30px;" style="margin:5px;display:none;"/&gt; &lt;input id="twitter" type="hidden" name="twitter" value="yes"/&gt; </code></pre> <p>You can see that on click of the span id="1" it removes the image and the input form. And when you click on the img id="2" it hides that one and bring backs the original image. How can I bring back or add the input form that I originally remove on the click of the img id="2". Is there a function that is opposite of .remove?</p> <p>Thanks!</p>
jquery
[5]
1,495,280
1,495,281
mouseenter / mouseover events not working on newly created elements
<p>I have a search bar and I want to list results as user types the query. The list results Div is a dynamically created Div. So, I couldn't use the mouseenter and mouseover and even the hover events on the div's contents.</p> <pre><code>$("ul#list_results li").mouseover(function(){ console.log("hh"); }); </code></pre>
jquery
[5]
523,452
523,453
What is the fastest way to learn Android and quickly start developing apps?
<p>I am a recent computer science student and have intermediate knowledge of java. However I am good at PHP.</p> <p>Please suggest me a fastest way to learn Android and start developing apps immediately.</p>
android
[4]
2,331,137
2,331,138
Java Pass by value, Advantage or Disadvantage?
<p>Java is pass by value. What if I need a pass by reference. For example in the following code I need a pass by reference mechanism.</p> <pre><code>public class BinaryTree { public TreeNode root; public BinaryTree(){ root = null; } public TreeNode insert(TreeNode temp,int x){ if(temp == null){ temp = new TreeNode(); temp.key = x; temp.left = temp.right = null; return temp; } if(temp.key &gt; x) temp.left = insert(temp.left,x); else if(temp.key &lt; x) temp.right = insert(temp.right,x); return null; } } </code></pre> <p>When <code>insert</code> is called with <code>root</code>, I need <code>root</code> to be passed as a reference so as to change its value. But this does not happen in Java, since it's pass by value. In C/C++ the above could be easily achieved. Don't you think that this is a drawback of Java? How could such problems be solved in Java?</p>
java
[1]
5,054,344
5,054,345
How to bring a jQuery object into a function?
<p>I have this jQuery object which I need to pull into a function, is this possible? Please see the code snippet:</p> <pre><code> var input; jQuery('.upload').live('click', function() { input = jQuery(this).find(".image-path"); tb_show(title, 'media-upload.php?type=image&amp;amp;TB_iframe=true'); return false; }); window.send_to_editor = function( html ) { if (input) { console.log(input); // works and defined at this point... var data { action: "doFunction" }; jQuery.post( ajaxurl, data, function( response ) { console.log(input); // does not work, not defined...why?? input.val(response); // this gives me input.val(response) is not a function }); } } </code></pre>
jquery
[5]
1,523,763
1,523,764
How could this line possibly lead to a crash?
<p>Trouble code:</p> <pre><code>NSDictionary *contactNameDictionary = [[NSDictionary alloc] initWithObjectsAndKeys:item, @"contact", sortName, @"contactSortName", compositeName, @"compositeName", nil]; </code></pre> <p>Error:</p> <pre><code>Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000 Crashed Thread: 0 Thread 0 Crashed: 0 libobjc.A.dylib 0x00004420 objc_msgSend + 24 1 CoreFoundation 0x000042a6 CFRetain + 54 2 CoreFoundation 0x0000a9f0 __CFBasicHashStandardRetainValue + 8 3 CoreFoundation 0x000054c0 __CFBasicHashAddValue + 100 4 CoreFoundation 0x00006184 CFBasicHashAddValue + 276 5 CoreFoundation 0x00006cfe CFDictionaryCreate + 58 6 CoreFoundation 0x00033d7c -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 1456 7 CoreFoundation 0x000361bc -[NSDictionary initWithObjectsAndKeys:] + 776 8 iota 0x0000cb04 -[CorpDirViewController reloadDisplayList] (CorpDirViewController.m:833) </code></pre>
iphone
[8]
432,226
432,227
checking text field value length
<p>I am trying to see if the text field length is at least a certain length. here is my code:</p> <pre><code>&lt;form name="form2" id="form2" onsubmit="return validate()"&gt; length 4: &lt;input type="text" name = "t" id="t" /&gt; &lt;input type="button" name="submit" value="submit" /&gt; &lt;/form&gt; &lt;script&gt; function validate() { document.write("good"); submitFlag = true; if(document.form2.t.value.length!=4){ submitFlag=false; alert("ivalid length - 4 characters needed!"); } return submitFlag; } &lt;/script&gt; </code></pre> <p>when I click submit, nothing happens.</p>
javascript
[3]
1,740,979
1,740,980
Why overloaded operators that are members of classes can only have one parameter
<p>why cant i used an overloaded operator with 2 arguments as a member of a class like this:</p> <pre><code>myclass&amp; operator+(const otherclass&amp; cl, int value); </code></pre>
c++
[6]
2,162,109
2,162,110
C++ assignment operator associativity
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points">Undefined Behavior and Sequence Points</a> </p> </blockquote> <p>after the following c++ code, the array a contains: 0, 1, 2, 3, 4</p> <pre><code>int a[5] = {0,1,2,3,4}; int i = 2; a[i++] = a[i++]; </code></pre> <p>i expected it to be: 0, 1, 3, 3, 4</p> <p>could anyone explain me why?</p>
c++
[6]
5,563,279
5,563,280
Getting the ID of the most recent DIV with Jquery
<p>I have a webpage that dynamically prepends new divs about once per minute.</p> <p>Here is what the HTML code basically looks like:</p> <pre><code>&lt;div id="container"&gt;&lt;/div&gt; &lt;div id="freshcontent"&gt; &lt;div id="501"&gt;Stuff 2:18pm&lt;/div&gt; &lt;div id="500"&gt;Stuff 2:12pm&lt;/div&gt; &lt;div id="499"&gt;Stuff 2:09pm&lt;/div&gt; &lt;div id="498"&gt;Stuff 2:05pm&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want to retrieve the id of the most recent div that is inside the "freshcontent" div, which would be "501" in the example above.</p> <p>Then I want to take the id number and insert it into some Jquery code, which I have here:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $.ajaxSetup({ cache: false }); setInterval(function() { $("#container").load("/webpage/?id="+THE_ID_NUMBER_GOES_HERE); }, 10000); }); &lt;/script&gt; </code></pre> <p>So I have 2 questions:</p> <ol> <li>How do I get the id of the most recent div (which is constantly changing)?</li> <li>How do I insert it into my Jquery code?</li> </ol> <p>I'm new to Javascript/Jquery, so I'm not sure how to do this. I've tried using .first() and .closest(), but I can't get it to work.</p>
jquery
[5]
4,587,675
4,587,676
Python unix timestamp conversion and timezone
<p>Hey all! Ive got timezone troubles.</p> <p>I have a time stamp of 2010-07-26 23:35:03 </p> <p>What I really want to do is subtract 15 minutes from that time.</p> <p>My method was going to be a simple conversion to unix time, subtract the seconds and convert back. Simple right?</p> <p>My problem is that python adjusts the returned unix time using my local timezone, currently eastern daylight savings time which I believe is GMT -4. </p> <p>So when I do this:</p> <pre><code> # packet[20] holds the time stamp unix_time_value = (mktime(packet[20].timetuple())) </code></pre> <p>I get 1280201703 which is Tue, 27 Jul 2010 03:35:03. I can do this:</p> <pre><code> unix_time_value = (mktime(packet[20].timetuple())) - (4 * 3600) </code></pre> <p>but now I have to check for eastern standard time which is -5 GMT and adjust the (4 * 3600) to (5 * 3600). Is there any way to tell python to not use my local timezone and just convert the darn timestamp OR is there an easy way to take packet[20] and subtract 15 minutes?</p>
python
[7]
4,944,871
4,944,872
Find nearest airport using iOS
<p>I am writing an App that needs to find the closest international airports using the iPads GPS. Is there anyway of doing this easily?</p>
iphone
[8]
3,336,720
3,336,721
handling integer having large number of digits
<p>how to handle integers having say 25 digits in c++ solve the problems..</p>
c++
[6]
228,451
228,452
Compare dictionary values and key in python
<p>I have a dictionary <code>item</code>. It has strings as keys and the values are lists e.g.:</p> <pre><code>item['title'] = [u'python'] item['image'] = [u'/link/to/image'] item['link'] = [u'link to article'] </code></pre> <p>I want to check if any value is 0 in length, but link or image may be empty, so I did the following:</p> <pre><code> for key, value in item.iteritems(): if len(value) == 0: if key != 'image' or key != 'link': raise DropItem("Item is empty: %s" %item) return item </code></pre> <p>So an item should be dropped only if the value is 0 and it is not an image or a key. My problem is now that this condition does not work. The item is still dropped when the image or link is empty.</p> <p>Any idea whats wrong? (I am new to python^^)</p>
python
[7]