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
2,785,525
2,785,526
Enable and disable the system searching option
<p>how to enable/disable the system searching option thru c# program</p> <p>yes i want enable/disable (Start->Search) option. already i have disable it thru program i don't know how to enable it..</p>
c#
[0]
1,569,461
1,569,462
startActivityForResult is undefined for class CustomizeDialog extends Dialog
<p>I am working in android. i want to make a custom dialog in which i want to add a paypal button. </p> <p>this is the code for my program:-</p> <pre><code>public class CustomizeDialog extends Dialog implements OnClickListener { Button close; String TAG="CustomizeDialog"; Context customize_dialog; CheckoutButton launchSimplePayment; public CustomizeDialog(Context context,String title_of_song,String artist_of_song,float price_of_song) { super(context); customize_dialog=context; setContentView(R.layout.paypal_custom_dialog); close = (Button) findViewById(R.id.paypal_close); PayPal pp = PayPal.getInstance(); if (pp == null) { try { pp = PayPal.initWithAppID(context, "", PayPal.ENV_NONE); } catch (IllegalStateException e) { throw new RuntimeException(e); } pp.setShippingEnabled(false); } launchSimplePayment = pp.getCheckoutButton(context, PayPal.BUTTON_118x24, CheckoutButton.TEXT_PAY); LinearLayout lnr = (LinearLayout) findViewById(R.id.Paypal_Custom_Dialog_View); launchSimplePayment.setOnClickListener( this); lnr.addView(launchSimplePayment); close.setOnClickListener(this); } @Override public void onClick(View v) { if (v == close) dismiss(); if(v==launchSimplePayment) { PayPalPayment payment = new PayPalPayment(); payment.setSubtotal(new BigDecimal("2.25")); payment.setCurrencyType("USD"); payment.setRecipient("kuntal_1316186174_biz@gmail.com"); payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS); Intent checkoutIntent = PayPal.getInstance().checkout(payment,customize_dialog); startActivityForResult(checkoutIntent, 1); **//this line is creating error that startActivityForResult() is undefined for type CustomizeDialog** } } </code></pre> <p>are we not apply CustomizeDialog() for a activity which is extending Dialog ? (as i done in my this program) please suggest me what should i do for this ? Thank you in advance...</p>
android
[4]
3,804,716
3,804,717
Help with PHP Session Start
<p>my program gives me this error, - Warning-PHP Function_start(); C:/PHp\tmp no such file or directory.</p> <p>What do i do?</p> <p>the session save thingy is pointing to windows temp.</p> <p>Thank You</p>
php
[2]
5,447,188
5,447,189
How to process sound in Java for Android?
<p>Folks,</p> <p>As a start, I would like to develop a Java application that will act as a guitar tuner. The application should listen to what I play on the guitar and tell me the notes I played. I am wondering what level of support is provided by Android SDK. Do I need any other open source library? Any pointers would be appreciated.</p> <p>Thank you in advance for your help. </p> <p>Regards,</p> <p>Peter</p>
android
[4]
3,554,265
3,554,266
Pass entire $_POST variable to popup
<p>I have a PHP webpage that takes which accepts a rather large POST array. I have a button on the page that opens a PHP popup window. Is there a convenient way to pass the entire $_POST array to the popup?</p> <p>Edit: It is an entirely different page. I open it with JavaScript: window.open</p>
php
[2]
2,833,962
2,833,963
Reading stream twice?
<p>When I have uploaded an image from my website I need to do 2 things: </p> <ol> <li>read the image dimensions</li> <li>save the image to the database</li> </ol> <p>the first thing I do is reading the image stream into an Image object, like so:</p> <pre><code>var file = Request.Files["logo"]; Image FullsizeImage = Image.FromStream(file.InputStream); </code></pre> <p>the next thing I do is to save the "file" object to the database (LINQ to SQL). BUT, when I try to save the image to database, the stream from the file has it's postion at the end of the stream, and it seems no data is present.</p> <p>I know I should somwhow reset the stream and put it back into position 0, but how do I do that the most effiecent and correct way ?</p>
c#
[0]
2,700,766
2,700,767
Why the result of bool(true) && string is string in javascript?
<p>test code is:</p> <pre><code>console.log(true &amp;&amp; "abc");//abc </code></pre> <p>who can tell me why the result is <code>abc</code>?</p>
javascript
[3]
955,358
955,359
Empty folder in Assets tree on Android
<p>I'm using the AssetManager to list the contents of my assets folder on Android. Everything is working as expected except for if I have an empty subfolder. It is not included in the list. If I put a file in the folder, the folder and the file show up no problem.</p> <p>Is this the expected behavior? I imagine that under normal circumstances an empty folder is pretty useless as an asset and can probably be ignored, but I am intending to copy the folder hierarchy out of the assets folder to the SD card, so including everything, even empty folders, would be best.</p> <p>I haven't found any documentation that covers this particular issue.</p> <p>Thanks!</p>
android
[4]
2,920,602
2,920,603
multiple choice questionaire in php
<p>condition is </p> <ul> <li>IF D is more than or equal to 3 Answer No1</li> <li>IF I is more than or equal to 3 Answer No2</li> <li>IF S is more than or equal to 3 Answer No3</li> <li>IF C is more than or equal to 3 Answer No 4</li> <li>IF D&amp;I are more than or equal to 3 Answer no5</li> <li>IF D&amp;S are more than or equal to 3 Answer no 6</li> <li>IF D&amp; C are more than or equal to 3 Answer no7</li> <li>IF I&amp; S are More than or equal to 3 Answer no 8</li> <li>IF C&amp; I are More than or equal to 3 Answer no9</li> <li>If C&amp; S are More than or equal to 3 Answer No 10</li> <li>these d,c etc are values. please help me out.</li> </ul> <p>the query is we have multiple choice questionnaire with two options for each questionnaire.totally 10 questionnaire. but here the values assigned for the choices may repeat. that's the reason why i want to write the script in php which echos the answers when the above listed condition satisfies. </p> <p>i know very little about php, if guided will improve. suggestions are welcome. if you have the solution please write an example code for me, which is very helpful to me.</p>
php
[2]
5,668,088
5,668,089
apk installation via my application
<p>i get parse error once i use my function below</p> <pre><code>public void installFile() { String path = "/data/data/com.utsc.smartdictate/"; String filename = "smartdictate.apk"; File file = new File(path + filename); if(file.exists()) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); startActivity(intent); } } </code></pre> <p>i tried pulling the apk file from the emulator and tried installing it, to test if the file was corrupted or not, however it installed! so i dont know why it is failing.</p> <p>EDIT: i have "android.permission.INSTALL_PACKAGES" permission added in the manifest</p>
android
[4]
4,918,254
4,918,255
How to Edit custom UITableViewCell's Frame size?
<p>I am using custom UITableViewCell class to make table view cell. I am changing row height dynamically:</p> <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60; } </code></pre> <p>Its working for row height perfectly.</p> <p>But this only changing the row height, not the Cell's Frame height. The Cell frame height is still 44 (default). So how can I make it effective for both row height as well as cell frame?</p> <p>Thanks in advance..</p>
iphone
[8]
3,100,934
3,100,935
Intializing classes in module for namespace
<p>There is a module <code>car.py</code>.</p> <p>There are engine and tires, and I want them (theirs methods and properties) to be accessible as </p> <pre><code>car.engine.data # and car.tires.data </code></pre> <p>So file <code>parts.py</code> looks like </p> <pre><code>class engineClass(object): def __init__(self): self.data = 'foo data 1' class tiresClass(object): def __init__(self): self.data = 'foo data 2' engine = engineClass() tires = tiresClass() </code></pre> <p>And now after <code>import car</code> I can access them as I want - <code>car.engine.data</code> </p> <p>Is it a right thing to do for this task?</p>
python
[7]
5,281,478
5,281,479
How to get the onResume of Application?
<p>My application has 3 activities-Main menu, sub menu, detail. Every time the <strong>APPLICATION</strong> resumes, I want to get some intimation so that I can start downloading some files. </p> <p>Right now what i am doing is- on each activity <code>onResume</code>, i check if downloading is already going on or not. If it isn't then i start downloading. This way, whenever i start next/previous activity, if the downloading is not going on, it starts downloading. Meaning, once downloading was completed, user navigates to next page, downloading started again. </p> <p>I want to prevent this behaviour otherwise there will be unnecessary internet usage.</p> <p>If i maintain a global (application level) variable which keeps a track of download state, even after i resume the application, the value is not re-set.</p> <p>Any suggestion as to how to get the <code>onResume</code> of application.</p>
android
[4]
3,898,529
3,898,530
How do you sanitize your data?
<p>This is the function i currently use(from a php book i bought):</p> <pre><code>function escape($data) { return mysql_real_escape_string(trim($data), $this-&gt;linkid); } </code></pre> <p>But I feel like it could be safer. for example, maybe use htmlspecialchars. It always makes me paranoid. I've read that mysql_real_escape_string is bad and never to use it, but then i've also read it's the best way. Lots of confusion regarding data sanitizing when inserting them to the database. </p> <p>So how do you do it? and what are the pros and cons of the way you do it.</p>
php
[2]
95,413
95,414
What's wrong w this code: file_get_contents from remote zipped file and extract to local directory
<p>The purpose of this code is to pull upgrade.zip from a central server, extract it and place it in a folder on the resident server. I get no errors, it just results in the die("!There was a problem. Please try again!"); </p> <pre><code>require('../../../wp-blog-header.php'); function openZip($file_to_open) { global $target; $zip = new ZipArchive(); $x = $zip-&gt;open($file_to_open); if($x === true) { $zip-&gt;extractTo($target); $zip-&gt;close(); unlink($file_to_open); } else { die("!There was a problem. Please try again!"); } } $payload = file_get_contents('http://myserver.com/upgrade.zip'); if(isset($payload)) { $filename = 'upgrade.zip'; $source = file_get_contents('http://myserver.com/upgrade.zip'); $target = ABSPATH.'wp-content/themes/mytheme/'; // permission settings for newly created folders $chmod = 0755; $saved_file_location = $target . $filename; openZip($saved_file_location); } </code></pre>
php
[2]
2,397,231
2,397,232
Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
<p>I need to work on a project that was written in msvcpp6.0sp6</p> <p><strong>I DIDN'T write the project. I know very little about its inner works. I DO know it WAS POSSIBLE to build it in the past.</strong></p> <p>while trying to build this project that was built successfuly in the past(not by me)</p> <p>I get the error:</p> <pre><code> Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast) </code></pre> <p>for example: error C2664: 'strncpy' : cannot convert parameter 2 from 'const unsigned short *' to 'const char *'</p> <p>error C2664: 'void __cdecl CString::Format(const unsigned short *,...)' : cannot convert parameter 1</p> <p>for a few dozen implicit conversions. I mustn't change the code. how can I force the complier to accept the implicit convertions?</p>
c++
[6]
4,464,901
4,464,902
const char* initialization
<p>This is one usage I found in a open source software.And I don't understant how it works. when I ouput it to the stdout,it was "version 0.8.0".</p> <pre><code>const char version[] = " version " "0" "." "8" "." "0"; </code></pre>
c++
[6]
4,286,248
4,286,249
Extraxt values and distribute with jquery
<p>This question is the <strong>opposite</strong> of <a href="http://stackoverflow.com/questions/9135079/collect-several-input-fields-and-insert-into-a-single-field-with-jquery/9135129#9135129">Collect several input fields and insert into a single field with jquery</a></p> <p>I have 4 input textfields, and a single textfield that should extract its value and distribute them into each separate input using index. I am expecting a reverse process (from the previous question) to get default value from <strong>distributor</strong> to be distributed/ populated into <strong>distributed</strong> textfield. Each value is pipe delimited.</p> <pre><code>&lt;input type="text" value="Data 1 | Null | Data 3 | Data 4" class="distributor"&gt; &lt;input type="text" class="distributed"&gt; &lt;input type="text" class="distributed"&gt; &lt;input type="text" class="distributed"&gt; &lt;input type="text" class="distributed"&gt; </code></pre> <p>The distributor has an array-like value string: Data 1 | Null | Data 3 | Data 4</p> <p>Null is accepted from original process, simply to maintain the process of explode and implode by PHP.</p> <p>So input#1 will recieve Data 1, etc in an indexed manner, hopefully, because the order is fixed and using <strong>name</strong> attributes seems redundant.</p> <p>Any hint is very much appreciated. Thanks</p>
jquery
[5]
37,948
37,949
how to access the id of textarea in javascript
<p>i have to acces the id of textarea in javasript.Please tell me how we can access the id of the textarea in javascript.</p>
javascript
[3]
3,406,601
3,406,602
Is it possible to control the keyboard type by code ? (android)
<p>Is it possible to control the keyboard type by java android code ? </p> <p>for example: if flag=1 and the focus on TextView the keyboard will be numeric</p> <p>and if the flag=0 the keyboard will be alpha numeric</p>
android
[4]
1,162,590
1,162,591
Javascript access parent properties
<p>How can I get parent options?</p> <p>I would like to access a global myObject options</p> <pre><code>var myObject = { method: function(){ this.options = {}; }, property: { propertyMethod: function(){ alert(this.options); } } } myObject.method(); myObject.property.propertyMethod(); </code></pre>
javascript
[3]
3,791,165
3,791,166
When to use Parasitic Constructor Pattern
<p>Why should Parasitic constructor pattern be used with caution and when it would be appropriate to use that pattern?</p>
javascript
[3]
3,046,366
3,046,367
Why does 1.__add__(1) yield a syntax error?
<p>Why does </p> <pre><code>1.__add__(1) </code></pre> <p>yield <code>SyntaxError: invalid syntax</code>? What do the extra brackets add?</p> <pre><code>(1).__add__(1) </code></pre>
python
[7]
2,831,776
2,831,777
PHP - aiContactSafe change field order
<p>i created form using aiContactSafe. But the field order is different. How to change the field order? i dont know how to change the field order. please help me. Please tell the procedure step by step.</p> <p><img src="http://i.stack.imgur.com/18xsG.png" alt="enter image description here"></p>
php
[2]
5,661,364
5,661,365
Create a function to a function that runs a for loop?
<p>I have made some code that creates a red border around an image when the user click on to highlite thats the choosen one. But I want to erase previous or all border with a white border around all images before a new click is made on another image. My question is how do I activate a call to a function when a click is made and how would a function look in jQuery? I just whant to use the <code>.css</code> to change the border in perhaps a loop and change the id of the images? Can I mix common javascript with jQuery, or should it only be pure jQuery code in a script?</p> <p>This is a simplified part of the code, it contains <code>"minibild_1"</code> to <code>"minibild_5"</code></p> <pre><code>$(document).ready(function(){ $("#minibild_1").click(function(){ $("#minibild_1").css({"border":"2px solid #D00C33"}); $("#storbild").attr("src","../bilder/bilder_stora/{$row1-&gt;bild_1}.jpg"); }); $("#minibild_2").click(function(){ $("#minibild_2").css({"border":"2px solid #D00C33"}); $("#storbild").attr("src","../bilder/bilder_stora/{$row1-&gt;bild_2}.jpg"); }); }); </code></pre>
jquery
[5]
5,525,907
5,525,908
How can I link the command pattern to the button selected and the last checkbox selected?
<pre><code>Public Interface command{ public void execute(); { } //this is the command interface public class UndoCheckbox implements command{ Undo undo; Public UndoCheckbox(Undo undo){ this.undo=undo; } public void execute(); //to execute } } </code></pre>
java
[1]
2,362,931
2,362,932
A cool python script to get teen learning python excited about programming?
<p>So I'm teaching a friends son some python programming, just going through control of flow, basic data types/structures.</p> <p>I want to go through a tutorial with him, and hopefully build something simple yet cool to get him excited about the power of python.</p> <p>Any ideas?</p>
python
[7]
1,915,186
1,915,187
how to set SplitPane setOneTouchExpandable expand in only one direction
<p>I set setOneTouchExpandable(true) and setEnabled(false) in my JSplitPane allowing the users only to expand left or right . But what I actually want is to have the the left panel either collapse to the left or stay at the default position. (that's why i set setEnabled(false)).</p> <p>is there a simple way to achieve this? Any help or snippet of code is welcome!</p>
java
[1]
2,528,676
2,528,677
Re-Sizing Images With PHP
<p>I have a website where users can upload images. Most of these images are far too big. I know I can limit the size of the file before the user even uploads it, but that is impractical. Most smart phone image sizes range from 2MB- 4MB, and that is what I expect my users to upload. But when they do, even after the page loads, the page lags when I try and scroll. I am assuming this is due to so many large photos being displayed (even though I re-size them with CSS).</p> <p>Now, I would like to simply:</p> <p>1) If the image has a width bigger than 960px resize the image to width: 960px and height proportionally.</p> <p>2) Cut the quality in half</p> <p>What is the most simple, detailed, way to do this.</p> <p>Thanks</p>
php
[2]
5,554,508
5,554,509
Downloading a large list of files in the background on Android
<p>I have an app that allows the user to cache data for offline use. The data I need to download is mostly images, but includes other things like videos, text files &amp; mp3s. There may be as little as 20 files to download or upwards of 300 or more. The files range from a few kilobytes to several megs in the case of videos.</p> <p>I've tried using a service with a looper, and a service with a plain old thread, but even if I use startForeground on the service it inevitably gets killed with a "timeout executing service" and an ANR after about 10 files or so on both my Droid and my Incredible.</p> <p>When I get the ANR it seems that the user system is around 45-50% cpu usage. The service restarts after a while and continues, but I need the downloads to take precedence in most cases.</p> <p>Here's the code to actually download a file, which is run in a thread:</p> <pre><code>try { URL request = new URL(entry.remotePath); InputStream is = (InputStream) request.getContent(); FileOutputStream fos = new FileOutputStream(entry.localPath); try { byte[] buffer = new byte[4096]; int l; while ((l = is.read(buffer)) != -1) { fos.write(buffer, 0, l); } } catch (IOException e) { e.printStackTrace(); } finally { is.close(); fos.flush(); fos.close(); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } </code></pre> <p>My question is, is there a standard way to do this (podcast apps like ACast seem to download a lot of data through a service with no issue), or do I have the right approach but am doing something incorrectly causing an overload to the system. Should my service thread be sleeping between downloads, or anything special I can do to meter it to keep cpu low or let the system know it's still working?</p> <p>I'm targeting System 8 and above, if that matters.</p>
android
[4]
2,155,528
2,155,529
Creating a processing queue in python
<p>I have an email account set up that triggers a python script whenever it receives an email. The script goes through several functions which can take about 30 seconds and writes an entry into a MYSQL database.</p> <p>Everything runs smoothly until a second email is sent in less than 30 seconds after the first. The second email is processed correctly, but the first email creates a corrupted entry into the database.</p> <p>I'm looking to hold the email data,</p> <pre><code>msg=email.message_from_file(sys.stdin) </code></pre> <p>in a queue if the script has not finished processing the prior email.</p> <p>I'm using python 2.5. Can anyone recommend a package/script that would accomplish this?</p>
python
[7]
3,926,318
3,926,319
asp.net - best way to display 5 records at a time using two pages
<ol> <li><p>I have to create a asp.net page that shows 5 records, stays for 10 seconds, shows the next 5 for another 10 seconds and return to the first 5 record when reaching last record.</p></li> <li><p>I need to retrieve data from database every 5 min only to do refresh for the displayed record. I want to do this in 2 different pages - for example one page does all the work and the second page only displays data without doing anything with the database. So whenever there is any problem with the database the first page will keep on showing the last records.</p></li> </ol> <p>I figured out the first part by using a grid view and timer but I struggled with the second.</p> <p>It is a notice page like flight information board idea at airports.</p> <p>I hope you can help me with it or tell me what is the best way to do it.</p>
asp.net
[9]
5,160,260
5,160,261
javascript alert problem
<p>Work on ASP.net C# vs 05.</p> <p>To Preventing Duplicate Record Insertion on Page Refresh. Under the button event i wrote below code</p> <pre><code>Response.Redirect(Request.Url.ToString(), false); </code></pre> <p>i also used a javascript alert under this event ,after use the above code alert message is not showing,display message boxes from server-side code?</p> <pre><code>string message = "Data saved successfully."; string s = "&lt;script type=\"text/javascript\"&gt;alert('" + message + "');&lt;/script&gt;"; ClientScript.RegisterStartupScript(GetType(), "Alert", s); </code></pre>
javascript
[3]
2,705,703
2,705,704
Does the SDK provide a way to group Annotations, like on Photos (places)
<p>I would like to implement a similar effect where the pins are grouped together then separate with an animation as you get closer to the points. This effect is seen in the Photos app when you select Places with geotagged apps</p>
iphone
[8]
2,073,629
2,073,630
I cannot use IF-THEN-ELSE and $_SERVER variables in PHP class definition
<pre><code>class MY_CONFIG { if ( $_SERVER["SERVER_ADDR"] == "127.0.0.1" ) { var $default = array( 'foo' =&gt; 1, 'bar' =&gt; 2 ); } else { var $default = array( 'foo' =&gt; 3, 'bar' =&gt; 4 ); } } </code></pre> <p>I am new to PHP. What's wrong with my code above?</p> <p>The system keeps saying:</p> <p>Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in C:\wamp\www\test\class.php on line 4</p> <p>Thanks.</p> <p>-- Hin</p>
php
[2]
159,653
159,654
Merge two DataColumns of type DateTime
<p>i have a datatable which contains two Datacolumns (date_start,date_sent) and i wanted to merge them into one single column (date_order) to then apply a sort like this:</p> <pre><code>DataRow[] dtSorted = dt.Select(null, "date_order DESC",DataViewRowState.CurrentRows); </code></pre> <p>Since whenever date_start is null, date_sent is not and vice versa, i tried the following expression to the datacolumn:</p> <pre><code>dt.Columns.Add("date_order", typeof(String), "IIF(date_start=NULL,date_sent,date_start)"); </code></pre> <p>but its not working.Tried something like "ISNULL(date_start,date_sent),date_start" and "date_start + date_sent" but they didn't work either.</p> <p>Can someone please tell me what expression i should use? Thank you.</p>
c#
[0]
408,256
408,257
Console.ReadLine().ToString() generates error
<p>I never did Console programming so got stuck in this silly thing:</p> <pre><code>Console.Write("Enter customer's salary: "); string sal = Console.Write("{0}! ", Console.ReadLine().ToString()); </code></pre> <p>It generates error: Cannot implicitly convert type 'void' to 'string'</p>
c#
[0]
3,215,560
3,215,561
C++ :: Boost :: posix_time (elapsed seconds. elapsed fractional seconds)
<p>I'm trying to come up with an answer to two questions that didn't seem hard at first. Q1 : How do I obtain the number of elapsed seconds between UTC.Now() and a given date? A1 : Just like in the code below! Q2 : How do I determine how many fractional seconds have elapsed since the last "full" second ? I'd like to print the "total_elapsed_seconds.fractional_seconds" -> "1234124.45". How do I do that? A2 : ???</p> <pre><code>#include &lt;iostream&gt; #include &lt;boost/date_time/gregorian/gregorian.hpp&gt; #include &lt;boost/date_time/posix_time/posix_time.hpp&gt; using namespace std; using namespace boost::gregorian; using namespace boost::posix_time; void main() { ptime Jan1st1970(date(1970, 1, 1)); for(int i = 0; i &lt; 10; i++) { ptime Now = second_clock::universal_time(); time_duration diff = Now - Jan1st1970; cout &lt;&lt; Now &lt;&lt; " : " &lt;&lt; diff.total_seconds() &lt;&lt; "." &lt;&lt; diff.fractional_seconds() &lt;&lt; endl; } } </code></pre>
c++
[6]
710,300
710,301
How to Create a class dynamically with its variables and methods in Java?
<p>How to Create a class dynamically with its variables and methods in Java without using Reflections.</p> <p>I want that the class should be created at runtime with variables like age, name and method like display(String age,String name). </p>
java
[1]
5,591,217
5,591,218
Accessing "pseudo-globals" by their name as a string
<p>I am now in the process of removing most globals from my code by enclosing everything in a function, turning the globals into "pseudo globals," that are all accessible from anywhere inside that function block.</p> <pre><code>(function(){ var g = 1; var func f1 = function () { alert (g); } var func f2= function () { f1(); } })(); </code></pre> <p>(technically this is only for my "release version", where I append all my files together into a single file and surround them with the above....my dev version still has typically one global per js file)</p> <p>This all works great except for one thing...there is one important place where I need to access some of these "globals" by string name. Previously, I could have done this:</p> <pre><code> var name = "g"; alert (window[name]); </code></pre> <p>and it did the same as</p> <pre><code> alert(g); </code></pre> <p>Now -- from inside the block -- I would like to do the same, on my pseudo-globals. But I can't, since they are no longer members of any parent object ("window"), even though are in scope.</p> <p>Any way to access them by string?</p> <p>Thanks...</p>
javascript
[3]
3,255,006
3,255,007
Android soft keyboard showing problem
<p>I'm trying to control soft keyboard using this:</p> <pre><code>((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromInputMethod(filterText.getWindowToken(), 0); ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .showSoftInput(filterText, InputMethodManager.SHOW_IMPLICIT); </code></pre> <p>But nothing happens on the device when i call this code. What can cause such behavior?</p>
android
[4]
3,870,308
3,870,309
Python and PAMIE
<p>I am having trouble navigaing a website with PAMIE. I want to invidually use it to open IE, then put in my username and password on a website. First I am trying o just navigate a site. This is what I have so Far....</p> <pre><code>from PAM30 import PAMIE ie = PAMIE.PAMIE() website = "http://www.python.org" ie.navigate(website) ie.textBoxSet('q', 'pamie') ie.buttonClick('submit') </code></pre> <p>So this "should" open python.org and in search put Pame and submit. The error I am getting is....</p> <pre><code>AttributeError: type object 'PAMIE' has no attribute 'PAMIE' </code></pre> <p>I know this is probably something stupid, but I can't figure it out?</p>
python
[7]
1,143,612
1,143,613
reading excel error on configuring IIS of running asp.net application
<p>I am running my asp.net application on Window Server 2008.</p> <p>IF I enable x86 application on ISS, it is running fine with excel 2003 files: xls</p> <p>But then I got a problem of running excel 2007: (Microsoft.ACE.OLEDB.12.0). If I switch it back to x64 mode, then it is running fine with excel 2007. </p> <p>So, how I config it or install something on my server in order to run both?</p> <p>Thanks in advance. </p>
asp.net
[9]
2,899,842
2,899,843
function that finds how many times n can be divided in half
<p>Basically, I need a function that will divide n by 2 and return the number of times it can be done.</p> <p>Coding so far:</p> <pre><code>def div(n): while n &gt;= 0: n / 2 return n </code></pre> <p>I know for a fact that I have to use the while loop but I'm not confident in my third line of coding. Can someone tell me what I'm doing wrong?</p> <p>examples:</p> <pre><code>&gt;&gt;&gt; div(4) 2 &gt;&gt;&gt; div(7) 2 </code></pre>
python
[7]
4,508,065
4,508,066
How to use presentModalViewController to create a transparent view
<p>I am displaying a modal view with</p> <pre><code>[self presentModalViewController:controller animated:YES]; </code></pre> <p>When the view moves up the screen it is transparent as per the setting in the xib file it is created from, but once it fills the screen it goes opaque.</p> <p>Is there anyway of keeping the view transparent? </p> <p>I suspect that the view it is being placed over is not being rendered rather then that the modal view is becoming opaque.</p>
iphone
[8]
5,312,070
5,312,071
Why does my ListView stack views on top of each other instead of vertically cascading downwards?
<p>I am returning a Custom View that extends RelativeLayout.</p> <p>How can I fix this? Thanks.</p> <p>This is the listview:</p> <pre><code>&lt;ListView android:id="@+id/view_container" android:layout_below="@+id/optionBarContainer" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="-8px" android:paddingBottom="5dp" &gt; &lt;/ListView&gt; </code></pre> <p>This is the adapter:</p> <pre><code>public class OptionBarListViewArrayAdapter extends ArrayAdapter&lt;UserCheckpointBean&gt; { public OptionBarListViewArrayAdapter(Context context, UserCheckpointBean[] beans) { super(context, R.layout.checkpoint_tab, beans); } @Override public View getView(int position, View convertView, ViewGroup parent) { UserCheckpointBean userCheckpointBean = getItem(position); CheckpointTabView view = new CheckpointTabView(getContext()); view.setData(userCheckpointBean); return view; } } </code></pre>
android
[4]
3,842,012
3,842,013
I am a new programmer and I can not get my fields to be stored in the database from a registration form
<p>If I declare a global variable such as a database connection of $mysqli how do I use that in a class. i am trying to use it in my user class. Do i store it as a public variable in the class or as a global in the function itself. I also think there is something wrong with my following code but I may be wrong.</p> <pre><code>class USER { function __constructor() { } /* * adds a new user * returns FALSE on error * returns user id on success */ function add_member($name, $email, $password) { global $mysqli; $query = "INSERT INTO members SET user_name = {'$name'}, user_email = {'$email'}, password = ['$password'}"; $success = $mysqli -&gt; query ($query); if (!$success || $mysqli -&gt; affected_rows == 0) { echo "&lt;p&gt; An error occurred: you just are not tough enough!!!&lt;/p&gt;"; return FALSE; } $uid = $mysqli -&gt; insert_id; return $uid; } } // end class $uc = new USER(); ?&gt; &lt;?php require_once ('includes/classes/database.php'); require_once('includes/classes/user.php'); require_once('includes/header.php'); // if user submits a new registration if (isset($_POST['name'],$_POST['email'],$_POST['pwd'],$_POST['pwd2'])) { // validate input fields $name = $_POST['name']; $email = $_POST['email']; $password = $_POST['pwd']; $password2 = $_POST['pwd2']; // if error fall through and redisplay page with errors // if no errors update database and redirect to homepage if ($uc-&gt;add_member($name, $email, $password) === FALSE) { echo "System Error. damn if I know what to do"; } else { header("location: homepage.php"); } } </code></pre>
php
[2]
4,326,401
4,326,402
Declaring class properties as a decimal
<pre><code> public class Invoice { public decimal Amount { get; set; } } </code></pre> <p>I know that <strong>M</strong> is the suffix for decimal values</p> <pre><code> public class Invoices { public void IdentityTest() { Invoice firstInvoice = new Invoice(); firstInvoice.Amount = 0.0M; } } </code></pre> <p>What is the point of declaring class properties as decimal when you have to use M with a value which you expect to be decimal?</p>
c#
[0]
1,958,720
1,958,721
How to convert German plural nouns to singular in Python?
<p>I'm searching for an algorithm, which converts German plural nouns to singular. Any idea is welcome.</p>
python
[7]
395,771
395,772
Multiple return statements vs Multiple goto statements : which one would be preferable?
<p>I read that both multiple returns and multiple goto statements are bad programming practice. I have a function which can detect some 8 types of errors. In case of error, should i return error code or should i use goto statment to go to end of function and return from there. Whenever memory freeing is required before returning from function, i thought it would be better to have a goto end and free the memory at the end of the function(so that only one free is enough in function)</p> <p>However, In my function, memory is not allocated. In this case which one is preferable ? Multiple returns or multiple goto statements ? Or can we avoid both ?</p> <p>EDIT: Some way to avoid both is, pass parameter to function which can store errorType. Samething can be checked inside function before proceeding further. But this too makes the code ugly.</p>
c++
[6]
4,914,995
4,914,996
Threads, Queue and a serious headache
<p>I am making a program for days but nothing seems to be working. I want to run (n threads=user sepecified threads ie 1-100) on a listview which has 1st field as email (the list is of 10000 records). Now I want to verify each email and add on the 2nd column the thread id and on the third column the result whether the email is valid or not can anybody help me? With some code and explanation. thanx</p>
c#
[0]
1,605,690
1,605,691
ListPreference: how to display without popup?
<p>In my app's preferences there are some voices that are managed with ListPreference. For example:</p> <pre><code>&lt;ListPreference android:title="@string/pref_clear_buttons" android:summary="@string/pref_clear_buttons_summary" android:key="clear_buttons" android:defaultValue="right" android:entries="@array/buttons_entries" android:entryValues="@array/buttons_values" /&gt; </code></pre> <p>With entryValues taking the values of "hide", "left", "right".</p> <p>When I run the preferences activity the ListPreference takes one single row, and when I click it opens a popup where I can choose among the three preferences, as if it was a sort of submenu.</p> <p><img src="http://i.stack.imgur.com/CAJpd.png" alt="enter image description here"></p> <p>I want all the three radio buttons to display indented, directly below the "Clear Buttons" line, without asking the user one extra click to open the popup.</p> <p>Any easy idea? Thank you.</p>
android
[4]
859,696
859,697
Use regular expression to split up a decimal number
<p>Using VS 2012, Windows Forms, C#</p> <p>If I have a <code>decimal</code> variable called <code>productPrice</code> and I want to split it up into two numbers, the number to the left of the decimal, and the decimal and the number to the right, what is the <code>regex</code> pattern I need to use?</p> <p>For example: if <code>productPrice = 3.75</code> how can i split it up so i have one variable that is <code>3</code>, and one variable that is <code>.75</code></p> <p>Thanks!</p>
c#
[0]
3,624,238
3,624,239
How to get count(*) on PHP?
<p>I have a following outputs from MySQL.</p> <pre><code>Array ( [0] =&gt; stdClass Object ( [id] =&gt; 19 [date] =&gt; 2010-10-04 11:00:00 [course] =&gt; Yoga [course_id] =&gt; 19 [count(*)] =&gt; 2 [capacity] =&gt; 20 ) [1] =&gt; stdClass Object ( [id] =&gt; 20 [date] =&gt; 2010-10-04 13:00:00 [course] =&gt; Spin [course_id] =&gt; 20 [count(*)] =&gt; 1 [capacity] =&gt; 24 ) ... ... </code></pre> <p>I can get date, course etc, but I am not sure how to get count(*) with PHP.</p> <pre><code>foreach ($bookingnum as $key =&gt; $list){ echo "&lt;tr valign='top'&gt;\n"; echo "&lt;td align='center'&gt;".$list-&gt;date."&lt;/td&gt;\n"; echo "&lt;td align='center'&gt;".$list-&gt;course."&lt;/td&gt;\n"; // echo "&lt;td align='center'&gt;".$list-&gt;count(*)."&lt;/td&gt;\n"; // this is wrong. how to get count(*)?? .... ... </code></pre>
php
[2]
1,738,280
1,738,281
Comparing Textbox values in JQUERY
<p>Am comparing 2 values in text box </p> <p>say <code>$('#Low'.val()) &gt; $('#High'.val()) //Where low and high are textbox id</code></p> <p>But it is fails in few scenarios as it is comparing string. </p> <p>i have 2 questions here</p> <p>1.how to convert to integer or float and check it in correct way </p> <p>2.When i compare the string as per my above code "99" > "1000" is returning true. Why it succeeds ?</p> <p>Thanks </p>
jquery
[5]
2,258,022
2,258,023
Releasing of the associative arrays
<p>How to rightly release the associative arrays from memory? Or memory will be released automatically and manually release isn't necessary?</p>
javascript
[3]
2,947,402
2,947,403
Handle multiple Clients
<p>I'm writing an application that deals with a server and a client. I don't necessarily know how to get the server to handle multiple clients, this is where I'm having problems with. Right now the server side only handles one client. So how can I handle multiple clients. </p>
c#
[0]
254,225
254,226
How to resrtrict resolution in Android Manifest
<p><a href="http://developer.android.com/guide/topics/manifest/supports-screens-element.html" rel="nofollow">http://developer.android.com/guide/topics/manifest/supports-screens-element.html</a> <a href="http://developer.android.com/guide/topics/manifest/supports-screens-element.html" rel="nofollow">http://developer.android.com/guide/topics/manifest/supports-screens-element.html</a> Can anyone simply explain how restrict small resolution for my app. For example, I want that my app will be appropriate for QVGA , WVGA and devices with more resolutions?</p> <p>Thanks in advance.</p>
android
[4]
303,096
303,097
Multiple Selection in Dropdown and update query string
<p>I generate a report according to selection of company and their customer. I use one dropdown for company and according to company the customer is displayed. However, I want to make it possible to select multiple customers, and when the user clicks on the button to the view report, I want to update the query string with that selection. If the selection of customer is three, I want to pass their customer code using query string. In sort querystring is send according to the selection of customer.</p> <p>Please help me.</p> <p>Thanks and regards.</p> <p>Mitesh</p>
c#
[0]
3,993,849
3,993,850
apending a row in php
<p>how a row can be appended to a table using php?</p>
php
[2]
3,679,820
3,679,821
Navigating through
<p>I am new to android and, of course, I have some problems. Your help will be appreciated. </p> <p>I am trying to create two activity classes: one of them is ListActivity class. </p> <p>Normal activity class pass a data(string) to ListActivity class(using bundle) to display in the list. </p> <p>Once we click on the particular item in the list, I again want to go back to the normal activity class to do some further operation. I don't know if it is possible or not. </p> <p>Waiting for your reply, Thanks in advance!! </p>
android
[4]
4,010,941
4,010,942
JavaScript shells - what is the difference
<p><a href="https://developer.mozilla.org/en/JavaScript%5Fshells" rel="nofollow">https://developer.mozilla.org/en/JavaScript_shells</a> lists quite a few shells. What is there to choose between them.</p>
javascript
[3]
680,284
680,285
How to save contact number in android device?
<p>I want to save contact number in my Apps, if I am using android 1.6 so this my apps is not work in android2.2 and same if T use android2.2 so my apps does not work with Adroid 1.6 supportable device.</p> <p>Please help me.</p> <p>Thanks in advance.</p>
android
[4]
3,431,367
3,431,368
Cache selector in object (jquery)
<p>i've a problem... What am I doing wrong?</p> <p>I want to use a selector previously saved in a variable. The idea is to use it within a function in an object.</p> <pre><code>var escribir = { obj:$('#cont'), algo: function(i) { escribir.obj.html(i++); setTimeout('escribir.algo('+i+')',1000); } } $(document).ready( function(){ escribir.algo(0); } ); .... &lt;div id="cont"&gt;&lt;/div&gt; </code></pre>
jquery
[5]
4,744,367
4,744,368
JavaScript: What is the equivalent of PHP's "$this->$somefunc()"?
<p>Is it possible to store the name of a function as string in JS, and invoke it from an object, pretty much like the PHP code below?</p> <pre><code>$this-&gt;$someFunc(); </code></pre>
javascript
[3]
2,263,253
2,263,254
Is there a way I can generate a class with all the properties obtained from a List<string>?
<p>I have a List object. In the code, I want to declare a new class , and its attributes, which are dynamically generated, are all obtained from the List object. Is there a way I can do this?</p> <p>For example: I have a <code>List&lt;string&gt; lstStr= "apple, pear, banana";</code> and I want to generate a new class in the code:</p> <pre><code>Class Foo{ string apple; string pear; string banana; } </code></pre>
c#
[0]
3,826,923
3,826,924
Show content between two dates with PHP?
<p>I want to be able to show some content or echo some text between and on two dates.</p> <p>Its for a promotion of a product, between the dates given the price will be lower and after the promotion the price will return to the original cost.</p> <p>Is this possible?</p> <p>Cheers</p> <p>Matt</p>
php
[2]
3,317,866
3,317,867
Colour Animation in Javascipt
<p>I would like my text to fade from white to black and the background colour to change from black to white simultaneously any ideas?</p>
javascript
[3]
4,599,586
4,599,587
Display date and time something like blog
<p>I have a blog. Regularly I post some fun thing. I maintain the timestamps for response times. How do I display the time like the following?</p> <ul> <li><p>2010-02-09 1 hour before, if the reply is just 1 hour old</p></li> <li><p>2010-02-09 20 hour before, if the reply is just 20 hour old</p></li> <li><p>2010-02-08 yesterday, if the reply is just 1 day old</p></li> <li><p>2010-02-04 17:20, if the reply is a couple of days before</p></li> </ul> <p>I am maintaining the timestamp in a database as a <a href="http://en.wikipedia.org/wiki/Unix_time" rel="nofollow">Unix time</a>. For example my timestamp is 1265709142.</p> <p>How can this be implemented with PHP?</p>
php
[2]
4,151,588
4,151,589
How to get the current user's home directory in Windows
<p>How can I get the path to the current User's home directory?</p> <p>Ex: In Windows, if the current user is "guest" I need "C:\Users\guest"</p> <p>My application will run on most of the Windows versions (XP, Vista, Win 7).</p>
c++
[6]
1,268,383
1,268,384
How to start developing applications for Android?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/144254/getting-started-with-android">Getting started with Android</a> </p> </blockquote> <p>I'm interested about learning how to develop applications for Android. I downloaded the Android SDK but I don't see where to begin. Any suggestion? Any literature? Thanks in advance for your answers.</p>
android
[4]
2,839,044
2,839,045
online php developer tools for my server?
<p>I'm searching for a tool, which i can upload to my server and then edit/create new php files so that i can create a new php project with any computer that have a internet browser</p>
php
[2]
3,670,582
3,670,583
Adding activity re-sizing feature
<p>I have a activity which I want to resize based on user event.I tried <code>getWindow.setLayout()</code> inside <code>onTouchListener</code> but the resizing is not smooth at all.Please provide some suggestions.</p>
android
[4]
2,075,898
2,075,899
Is it possible to obfuscate raw C# source code?
<p>I have seen many C# obfuscators, and they all need an assembly (.exe, .dll, etc.) Why isn't it possible to just obfuscate the source code? Like you can do with javascript for example: <a href="http://www.javascriptobfuscator.com" rel="nofollow">http://www.javascriptobfuscator.com</a></p>
c#
[0]
555,014
555,015
Get attribute values as array from selection of elements using jQuery
<p>I have the following using jQuery:</p> <pre><code>var x = $('.boxes &gt; input:checked'); </code></pre> <p>From x I am trying to retrieve an array of id values and have been unable to work out how to do this.</p> <p>Something like:</p> <pre><code>var y = x[id]; // y becomes an array like ['1', '2', '3'] assuming // that x had 3 checkboxes with id's of 1, 2, 3 etc. </code></pre>
jquery
[5]
4,175,195
4,175,196
Android : Using GPS
<p>Is there any way by which i can get the last GPS location my application itself ???? </p> <p>Is there any API available which can show me the Lat and Long. of the place from where i have connected GPS last time.</p> <p>Any help, much appriciated </p> <p>Thank you</p>
android
[4]
5,815,690
5,815,691
calling jquery ajax function from javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4982983/jquery-ajax-return-value">jQuery ajax return value</a><br> <a href="http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call-from-a-function">How to return the response from an AJAX call from a function?</a> </p> </blockquote> <p>I have javascript. It loads data from database. I want to return true or false with respect to loading data. But I could not return it. My code has given bellow:</p> <pre><code>function CheckISRC() { var url = "/TrackEdit/CheckISRC/" + $('#isrcid').val(); var isrc = $('#isrcid').val(); var result = false; $.get(url, { isrc: isrc }, function (data) { if (data == "true") { result = true; } else { result = false; } }); return result; } </code></pre> <p>It always gives false result. Anyone has faced this kind of problem? 'Thanks advance'</p>
javascript
[3]
422,863
422,864
jquery 'invalid expression' using selector on a tablecell
<p>Hi can someone tell me what i'm doing wrong in this jquery statement. I have a 'row' object which contains any number of tablecells, and i'm looking only for the cells that contain a textbox or text area.</p> <p>This statement works fine:</p> <pre><code>var $textCells = jQuery('td:has(textarea)', row); </code></pre> <p>but i need to include 'text', inputs, and this is where is blows up:</p> <pre><code>var $textCells = jQuery('td:has(textarea,input[@type=text])', row); </code></pre> <p>I get an 'Unrecognized expression error'. Can someone set me straight? Thanks</p>
jquery
[5]
3,140,902
3,140,903
How do I match words in different languages
<p>How can I write a regular expression to efficiently match both Swedish and English words?</p> <p>I must be able to match the likes of Å, é and '. I think 123 is also a word. I even think 1:e and 1st are words... </p> <p>How would I proceed if I wish to match words from Russian and Japanese also. </p> <p>Thanks,</p> <p>Barry</p> <p>P.S. The following are not words and should not be matched:</p> <p><br>, =HELLO=, @NEW_LINE_MARKER, can"t, hel*o, /new/</p> <p>Also, </p> <p>This string "Hey! What? Yes, I'm coming." should be split into:</p> <p>(Hey, What, Yes I'm coming)</p>
python
[7]
560,393
560,394
How to load images loading.gif before load iframe in jquery?
<p>I have a Jquery code:</p> <pre><code>&lt;script type='text/javascript'&gt; jQuery(function ($) { $('.basic').click(function (e) { var loading = '&lt;img src="loading.gif"/&gt;'; $('&lt;div&gt;&lt;/div&gt;').load(loading); var src = 'test.php'; var html = '&lt;iframe src="'+src+'&amp;output=embed" style="border:0"&gt;&lt;/iframe&gt;'; $.modal(html); return false; }); }); &lt;/script&gt; </code></pre> <p>How to load a image loading.gif before load a iframe ?</p>
jquery
[5]
5,434,585
5,434,586
How do I hide a menu item in the actionbar?
<p>I have an action bar with a menuitem. How can I hide/show that menu item?</p> <p>This is what I'm trying to do:</p> <pre><code>MenuItem item = (MenuItem) findViewById(R.id.addAction); item.setVisible(false); this.invalidateOptionsMenu(); </code></pre>
android
[4]
5,941,842
5,941,843
How to create an sqlconnection in a class with c# to use in all form?
<ol> <li>Create sqlserver connection in class</li> <li>call connection class to use all form.</li> </ol> <p>I want to create SQLServer connection in class with C# to use all forms.</p> <p>Hereabout code of connection in class file </p> <pre><code>public System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection(); public System.Data.SqlClient.SqlCommand Com = new System.Data.SqlClient.SqlCommand(); public string conStr; public SQL2(string conStr) { try { Con.ConnectionString = conStr; Con.Open(); Com.Connection = Con; Com.CommandTimeout = 3600; } catch (Exception ex) { MessageBox.Show(ex.Message); } } public bool IsConnection() { Boolean st; if (Con.State==ConnectionState.Open) { st=true; } else { st = false; } return st; } </code></pre> <p>Can give me full example code?</p>
c#
[0]
2,407,896
2,407,897
PHP - Source (hostname) of a GET request
<p>I have a Javascript widget that people can embed on their site. </p> <p>I want to use a simple cross domain get request to pull in a hash. </p> <p>However I need my PHP script to only allow this cross domain request from a series of domains I have stored in an array. </p> <p>What can I do in my PHP script (not in .htaccess or iptables) to find out the source (hostname) of the get request?</p> <p>Thank you very much,</p> <p>Cei </p>
php
[2]
1,854,223
1,854,224
Halt closing the div; if hover over it
<p>as shown below, if the user hover over the div then how to halt the fade out div? and if the is not hover the div then fadeout whatever the time is set to.?</p> <p>below is the code i am using....for fadein and fadeout:</p> <pre><code> $("#success").fadeOut('slow'); $("#success").fadeIn('slow'); $("#success").fadeTo(5000, 1).fadeOut(2000); </code></pre> <p>my div:</p> <pre><code>&lt;div class="success"&gt;&lt;a href="#" class="close"&gt;&amp;times;&lt;/a&gt;status message here...&lt;/div&gt; </code></pre> <p>i tried this:</p> <pre><code>if ($('#success').is(':hover')) { //dont close me and reset the time ...} </code></pre> <p>result: <img src="http://i.stack.imgur.com/FkebT.png" alt="enter image description here"></p>
jquery
[5]
1,468,053
1,468,054
Memory management on the array initialized for UITabBarController
<p>I am still learning the ropes of Objective C and iPhone development. My weak point is memory management - any help will be much appreciated.</p> <p>In the code below, where can I release the <code>NSMutableArray listOfViewControllers</code>? Keep in mind the function <code>createTab</code>s can be called within the app multiple times and the tabs are recreated dynamically based on user input. This function is within a ViewController.</p> <ol> <li><p>If i do <code>[listofViewControllers release]</code> just before exiting the function, the app crashes when I have to call createTabs again</p></li> <li><p>If I use a convenience method like below:</p></li> </ol> <p><code>NSMutableArray *listOfViewControllers = [NSMutableArray arrayWithCapacity:1]</code></p> <p>instead of:</p> <pre><code>NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init] </code></pre> <p>it still crashes when createTabs is called again</p> <pre><code>-(void) createTabs { //TODO - memory management - where do you release this? NSMutableArray *listOfViewControllers = [[NSMutableArray alloc] init]; if ([briefingsArray count] &gt; 0) { //add briefing(s) tab(s) for (Briefing *briefing in briefingsArray) { WebViewController *briefingViewController = [[WebViewController alloc] initWithBriefing: briefing]; [listOfViewControllers addObject:briefingViewController]; [briefingViewController release]; } [listOfViewControllers addObject:alertViewController]; //add archives tab NSString *archiveURL = [NSString stringWithFormat: ARCHIVEURL, DeviceID()]; UIViewController *archiveViewController = [[WebViewController alloc] initWithURL:ARCHIVEURL andTitle:@"Archives" andImage:@"archive_icon.png"]; [listOfViewControllers addObject:archiveViewController]; [archiveViewController release]; } NSArray *oldlistOfViewControllers = [self.tabBarController viewControllers]; UIViewController *vcOld = [oldlistOfViewControllers objectAtIndex:[oldlistOfViewControllers count] -1]; [listOfViewControllers addObject:vcOld]; [self.tabBarController setViewControllers:listOfViewControllers animated:YES]; } </code></pre>
iphone
[8]
4,463,437
4,463,438
A simple HTML Anchor Link does not show-up as a link when sending a mail from Samsung galaxy S III
<p>I have developed an android application in which I am sending a mail whose body text contains a link for downloading my application from Google play store.</p> <p>This works fine for all other android devices except Samsung Galaxy S III. The issue that I am facing is when I am <strong>sending a mail from Samsung Galaxy S III</strong>, the <strong>link in email</strong> appears to be <strong>normal text</strong> instead. </p> <p>It seems like it is a device specific problem. I have worked around for a solution, but I am unable to find it.</p> <p>Why this happening only in case of Samsung galaxy S III?</p>
android
[4]
1,012,842
1,012,843
Creating anonymous dynamic runtime instances
<p>How can I create implementations of an interface dynamically at runtime in java?</p> <p>I have a factory that will read the annotations on class Foo and create an instance of class Bar. For this factory to be type safe, I'd like my client factories to be interfaces with a factory method that takes type Foo and returns type Bar. I then want my factory to implement this factory method at runtime.</p> <p>All of this is because the factory code would be redundant and hard to maintain. If generated at runtime, it would always be current.</p> <p>Example:</p> <pre><code>public class Foo{ private String name; public String getName(){ return name; } public void setName(String name){ this.name = name; } } public class Bar{ private String personName; public String getPersonName(){ return personName; } public void setPersonName(String personName){ this.personName= personName; } } public interface BarFactory{ Bar create(Foo foo); } </code></pre> <p>Is there a way to do this?</p>
java
[1]
1,615,256
1,615,257
Order Unordered Group of Div's by ID or Class with jQuery
<p>Is it possible to order a group of Div's by id or class using jQuery? Here's my code:</p> <pre><code>&lt;div id="product_categories"&gt; &lt;div class="wpsc_categorisation_group" id="categorisation_group_49"&gt; &lt;a href="http://africa.local/store/african-dolls/"&gt;African Dolls&lt;/a&gt; &lt;/div&gt; &lt;div class="wpsc_categorisation_group" id="categorisation_group_47"&gt; &lt;a href="http://africa.local/store/anklets/"&gt;Anklets&lt;/a&gt; &lt;/div&gt; &lt;div class="wpsc_categorisation_group" id="categorisation_group_5"&gt; &lt;a href="http://africa.local/store/bracelets/"&gt;Bracelets&lt;/a&gt; &lt;/div&gt; &lt;div class="wpsc_categorisation_group" id="categorisation_group_11"&gt; &lt;a href="http://africa.local/store/childrens-jewelry/"&gt;Children's Jewelry&lt;/a&gt; &lt;/div&gt; &lt;div class="wpsc_categorisation_group" id="categorisation_group_13"&gt; &lt;a href="http://africa.local/store/clearance/"&gt;Clearance&lt;/a&gt; &lt;/div&gt; &lt;div class="wpsc_categorisation_group" id="categorisation_group_8"&gt; &lt;a href="http://africa.local/store/cross-necklaces/"&gt;Cross Necklaces&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I know the code is kind messed up but WP E-Commerce is generating it and won't allow me to order it the way I want. Any thoughts? </p> <p>Thanks.</p>
jquery
[5]
2,241,263
2,241,264
comparing against undefined
<p>Is it unsafe to compare a variable against undefined?</p> <pre><code>if(foo == undefined) </code></pre> <p>vs</p> <pre><code>if(foo == 'undefined') </code></pre> <p>Is the first example sufficient? Or should it be something like</p> <pre><code>if('undefined' in window){ //compare against undefined } else { //compare against 'undefined' } </code></pre> <p>since <code>undefined</code> exists on the <code>window</code> object? Will it exist in all browsers? Or should I simply compare to <code>== 'undefined'</code>? I've found some similar questions on SO, but no answers regarding the existance of the undefined property on the window object.</p>
javascript
[3]
3,979,069
3,979,070
C# replace part of string but only exact matches possible?
<p>I have a <code>string beginString = "apple|fruitsapple|turnip";</code></p> <p>What I want to do is replace just apple with mango, not fruitsapple.</p> <p><code>string fixedString = beginString.Replace("apple","mango");</code> This doesn't work because it replaces both apple and fruitsapple.</p> <p>Any ideas?</p>
c#
[0]
487,788
487,789
Uncaught ReferenceError: jquery is not defined (anonymous function)
<p>I am trying to learn jquery and seem to be struggling to get it to work how i would expect, can someone please help.</p> <p>So far I have gone to Jquery and copied and pasted the source code into a .js file which I have named jquery. I have referenced the file in the body of my practice page.</p> <p>I then added</p> <pre><code>&lt;script&gt; var lis = jquery('ul li').css('color', 'green'); &lt;/script&gt; </code></pre> <p>and in the browser using the developer tools I got the following message "Uncaught ReferenceError: jquery is not defined(anonymous function) "</p> <p>I tested jquery by adding</p> <pre><code> $('document').ready(function(){ alert("ready and working!"); }) </code></pre> <p>so i am confident that it is working but cant get it to change the css color, which I am trying to do as part of an excercise.</p>
jquery
[5]
2,442,194
2,442,195
Eclipse: Android not adding id class to R.java
<p>I am currently writing a program for an android app and I keep running into a problem where I get an error <code>"id cannot be resolved or is not a field"</code>. For example I have a line of code: </p> <pre><code>mBodyText = (EditText) findViewById(R.id.body); </code></pre> <p>After viewing the <code>R.java</code> class there is no id class. I previously copied and pasted an example online and it also implemented a line of code that was similar and it added the id class to <code>R.java</code>. </p> <p>I'm just wondering how to correct this problem. I have researched it and some people suggested to others to <code>import android.R</code> and this corrects some errors but then creates new ones saying that the part after is not in that category. </p>
android
[4]
5,736,267
5,736,268
Virtual functions cannot be friends
<p>I wish to create an interface for a class C which has this function:</p> <pre><code>friend bool operator==(const C&amp; a, const C&amp; b);* </code></pre> <p>I wish to the create a mock for C for test driven purposes.</p> <p>I tried doing it like this:</p> <pre><code>class IC { virtual friend bool operator==(const IC&amp; a, const IC&amp; b) = 0; }; </code></pre> <p>What should I do?</p>
c++
[6]
768,733
768,734
Why string method on a string object doesn't modify the object in Python?
<p>I found it odd that a string method operation on a string object doesn't modify the string object. Why is it? I wasted quite a bit of time yesterday trying to understand why my code wasn't working when I finally discovered this.</p>
python
[7]
3,673,726
3,673,727
Extending an Applications Browse for Files Dialogue
<p>I need to extend the Browse for File Dialogue box in an application, however the problem is I did not create the original application so I do not have the code that brings up the dialogue. What i'm hoping to do is something similar to Direct Folders or FileBox eXtender (sorry I can't post more then 2 links as I am new) however I don't need it as complex as that and a folder list that I need to make display is already created. I believe what I need to do is create a system tray application watching for a Browse for File Handle and when it is detected add some sort of extender to the window, its this I am not sure on however, I've researched a fair bit and it looks like either SetWindowsHookEx <a href="http://www.pinvoke.net/default.aspx/user32.setwindowshookex" rel="nofollow">http://www.pinvoke.net/default.aspx/user32.setwindowshookex</a> or EnumDesktopWindows <a href="http://pinvoke.net/default.aspx/user32/EnumWindows.html" rel="nofollow">http://pinvoke.net/default.aspx/user32/EnumWindows.html</a> will do what i'm after but i'm not sure how to proceed. Any assistance in pointing me in the right direction would be welcome, Thank you.</p>
c#
[0]
2,045,979
2,045,980
How to access the +/- dialog to modify a number (like when setting the time)
<p>If you pop open the clock application and set the alarm you get a nifty pop-up with the time that you can modify using + and - buttons. I'm wondering if there's that's a standard and, if so, if there's an easy way to access it so that it pops up when clicking on an element in a ListView?</p> <p><img src="http://i.stack.imgur.com/H7xYB.png" alt="plus/minus dialog"></p>
android
[4]
4,607,624
4,607,625
Android: java.lang.NoSuchFieldError: android.os.Build.SERIAL
<p>In android, I have the following error thrown:</p> <pre><code>java.lang.NoSuchFieldError: android.os.Build.SERIAL </code></pre> <p>It happens only on certain devices, for instance: "sec_smdk6410" or "sdkDemo".</p> <p>I have tried to catch the exception but it ignores the try/catch block.</p> <pre><code> try { return android.os.Build.SERIAL; } catch (Exception e) { return null; } </code></pre> <p>Is there anyway I can detect if this error will be thrown in order to adapt my code ?</p> <p>Thanks.</p>
android
[4]
919,879
919,880
Deleting empty (0-lenght) files in a directory
<p>the php script below select and elaborate one by one all .txt files contained in a specific directory. First of all, a file is copied in a subdirectory named "copy", after the script calls read.php so that the file is analyzed and elaborated. Finally the same file can be deleted from the main directory. This is done to all files in the folder, until they end.</p> <p>THE ISSUE: unfortunately the script stops when a 0 KB file (empty) is found. Probabily the problem is read.php but i can't modify this. So I'd like to delete automatically these unwanted empty files so that the process go on regularly.</p> <p>Any suggestion? TNX</p> <pre><code> &lt;?php $files = glob( '*.txt' ); array_multisort( array_map( 'filemtime', $files ), SORT_NUMERIC, SORT_ASC, $files ); $filename="$files[0]"; foreach($files as $filename) { copy($filename,"./copy/$filename"); echo "&lt;b&gt; $filename &lt;/b&gt;File copied&lt;br&gt;"; include ("read.php"); sleep(4); unlink($filename); echo "$filename elaborated and deleted from the main folder.&lt;br&gt;"; } ?&gt; </code></pre>
php
[2]
5,164,247
5,164,248
Differences in these Javascript function declarations
<p>Today I saw two different types of Javascript function declarations and I'd like to have a deeper understanding of the two:</p> <pre><code>function Car( model, year, miles ){ this.model = model; this.year = year; this.miles = miles; } /* Note here that we are using Object.prototype.newMethod rather than Object.prototype so as to avoid redefining the prototype object */ Car.prototype.toString = function(){ return this.model + " has done " + this.miles + " miles"; }; var civic = new Car( "Honda Civic", 2009, 20000); var mondeo = new Car( "Ford Mondeo", 2010, 5000); console.log(civic.toString()); </code></pre> <p>and type 2:</p> <pre><code>function Car( model, year, miles ){ this.model = model; this.year = year; this.miles = miles; this.toString = function(){ return this.model + " has done " + this.miles + " miles"; }; } var civic = new Car( "Honda Civic", 2009, 20000); var mondeo = new Car( "Ford Mondeo", 2010, 5000); console.log(civic.toString()); </code></pre> <p>Specifically the 'prototype' and the 'this.toString'.</p> <p>Can anyone impart some pearls of JS wisdom?</p>
javascript
[3]
4,766,245
4,766,246
Excel Sheet in asp.net?
<p>In web application [asp.net], i am upload the Excel file from admin end. now i want to display that excel sheet in my asp.net at the user end whe he click on button "Show", is it possible to show the uploaded excel sheet in asp.net pages. Tahnk you.</p>
asp.net
[9]