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
4,749,992
4,749,993
How can I count the instances of an object?
<p>If i have Javascript object defined as: </p> <pre><code>function MyObj(){}; MyObj.prototype.showAlert = function(){ alert("This is an alert"); return; }; </code></pre> <p>Now one can call it as:</p> <pre><code>var a = new MyObj(); a.showAlert(); </code></pre> <p>So for so good, and one can also in the same code run another instance of this:</p> <pre><code>var b = new MyObj(); b.showAlert(); </code></pre> <p>Now i want to know, how can i get a hold of number of instances of this MyObj? is there some built in function?</p> <p>One way i have in my mind is to increment a global variable when MyObj is initialized and that will be the only way to keep track of this counter, but is there anything better then this idea?</p> <p><strong>EDIT:</strong></p> <p>Have a look at this as suggestion here:</p> <p><img src="http://i.stack.imgur.com/98LEs.png" alt="enter image description here"></p> <p>I mean how can i make it get back to 2 instead of 3</p>
javascript
[3]
2,331,534
2,331,535
Creating a Simple IsNullOrFalse method for both a method and its caller
<p>I find myself doing this a lot.</p> <pre><code>if( obj == null || !obj.SomeMethodThatReturnsABoolean() ) { // then do this } </code></pre> <p>I mean, I just see it cluttering up code in a lot of places. It isn't really a bad thing, but what's the fun of syntactical sugar if you can't sprinkle it around here and there where it makes things slimmer? </p> <p>So I tried to just make a very humble little method, <code>IsNullOrFalse</code>. The idea is that it will test for what was passed in, see if it is null, and if not, it will run the method, and return the boolean result.</p> <p>This has actually proven a lot harder than I imagined. I don't really need this to continue on in any project, but at this point I have gone from curious to intrigued. </p> <p>Has anyone else done something like this? The problem I am getting is that I cannot pass in something that does not exist that contains a method.</p>
c#
[0]
2,821,144
2,821,145
Add scroll view for particular row in runtime in android?
<p>In my tableview i need to add the scroll view for the particular rows . Is there any way to create like this in android? </p>
android
[4]
5,506,105
5,506,106
jQuery function needs clicking twice
<p>if you visit one of our sites; <a href="http://skateboardingphoto.co.uk" rel="nofollow">http://skateboardingphoto.co.uk</a>, you will see that there is a navigation bar at the top which can be hidden or expanded. </p> <p>When being expanded (expanded by default, so have to minimise first), it needs to be clicked twice, but it would seem only the first time...</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function() { jQuery(".open-close").click( function() { if (jQuery("#openClose").is(":hidden")) { jQuery("#navigation-wrap").removeClass("closed").addClass("open") .animate({ marginLeft: "0px" }, 500 ); jQuery.cookie('navbar', 'open', { expires: 1, path: '/' }); jQuery("#openClose").show(); } else { jQuery("#navigation-wrap").removeClass("open").addClass("closed") .animate({ marginLeft: "-330px" }, 500 ); jQuery.cookie('navbar', 'closed', { expires: 1, path: '/' }); jQuery("#openClose").hide(); } }); }); &lt;/script&gt; </code></pre> <p>Thanks for your help</p>
jquery
[5]
2,186,800
2,186,801
Deleting part of href using JQuery
<p>Hi I have few bookmarks in the CMS:</p> <pre><code> &lt;li&gt;&lt;a href="#online"&gt;Chat Online&lt;/a&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#termsOfService"&gt;Terms of Service&lt;/a&gt; &lt;/li&gt; </code></pre> <p>But CMS is adding some url before # in the link which breaks my functionality. Is there any way to delete everything before # in a link using <strong>Jquery</strong>. Thanks for the help</p>
jquery
[5]
5,403,000
5,403,001
Launch App from iTunes
<p>I am launching an iTunes from my App, from where when I buy or install an app it is redirecting me to the device menu where I can see the app downloading, but my requirement is when I buy/install an app. from iTunes it should redirect to the app again from where the app is terminated instead of menu. Please help me out on this.... Thanks in advance.</p> <p>Thanks </p>
iphone
[8]
2,084,751
2,084,752
full implementation of b+ tree
<p>I am looking for an implementation of b+ tree in java. Does anyone know where I can find the proper and full implementation? When I say proper - I mean that each inner node must have at least N/2 to N children and each leaf must have between M/2 to M records. I have the following link <a href="http://en.wikibooks.org/wiki/Transwi...tation_In_Java" rel="nofollow">http://en.wikibooks.org/wiki/Transwi...tation_In_Java</a> but it is not enough. I dont think the code takes into account that the tree has to be constantly balanced and that each inner node must have more than N/2 children. I dont know how to add that to the code. Any suggestions???</p> <p>Thank you</p>
java
[1]
361,502
361,503
Writing Data from an Array of Classes to a Binary File C++
<p>In my code I have an Array of class User as a private variable in class UserManager. When UserManager::Shutdown() is called it save the Array of Users to a file. Yet I get an access violation error. The Access violation error occurs in fwrite.c</p> <p>I am compiling on Visual Studio 2010 running Windows 7.</p> <p><strong>User Class</strong></p> <pre><code>class User { public: User() { memset(username, 0, 255); memset(password, 0, 255); } int userId; char username[255]; char password[255]; }; </code></pre> <p><strong>MAX_USERS Definition</strong></p> <pre><code>#define MAX_USERS 2048 </code></pre> <p><strong>User Manager Constructor</strong></p> <pre><code>UserManager::UserManager() { memset( users, 0, MAX_USERS); } </code></pre> <p><strong>Shutdown Function</strong></p> <pre><code>void UserManager::Shutdown( void) { FILE *userDB = fopen( "users.bin", "wb"); int k=1; for(k=1;k&lt;MAX_USERS-1;k++){ if (users[k]!=NULL) { fwrite((const void*)&amp;users[k]-&gt;userId, sizeof(int), 1, userDB); fwrite((const void*)users[k]-&gt;username, 255, 1, userDB); fwrite((const void*)users[k]-&gt;password, 255, 1, userDB); } else { fpos_t skip = 255 + 255 + sizeof(int); fsetpos( userDB, &amp;skip); } } fclose( userDB); } </code></pre> <p>The array 'users' is memset to zero at the constructor.</p>
c++
[6]
1,059,079
1,059,080
C# drop downlist values not insert
<p>i have written a code to load the data to drop down list, as i written it was loaded, but while trying to insert the value of drop down list, (i mean selectedItem.text) it will not insert, instead if thtat selectedIndex=0 alone has been inserted. please correct me.</p> <pre><code>//Load the name to Drop down list public void name() { DropDownList1.Items.Clear(); ListItem i = new ListItem(); i.Text = "-Select-"; DropDownList1.Items.Add(i); DropDownList1.SelectedIndex = 0; Conhr.Open(); string s; s = "select EmployeeName from tbl_EmploeeDetails where SiteName='" + Label5.Text + "' "; SqlCommand cd = new SqlCommand(s, Conhr); SqlDataReader dr; dr = cd.ExecuteReader(); while (dr.Read()) { ListItem m= new ListItem(); m.Text = dr["EmployeeName"].ToString().Trim(); DropDownList1.Items.Add(m); } dr.Close(); Conhr.Close(); } //trying to insert the data for drop down list protected void Button1_Click(object sender, EventArgs e) { con.Open(); string a; a = "insert into tbl_KKSUser(EName,Uname,Password)values(@en,@un,@pas)"; SqlCommand cm = new SqlCommand(a, con); SqlParameter paramName; paramName = new SqlParameter("@en", SqlDbType.VarChar, 25); paramName.Value = DropDownList1.SelectedItem.Text; cm.Parameters.Add(paramName); cm.ExecuteNonQuery(); con.close } </code></pre> <p>answer will be like this in data base</p> <p>1 -Select- dsad AGEAcwBkAGY=</p> <p>2 -Select- da AGEAZA==</p>
c#
[0]
1,030,280
1,030,281
Any disadvantage to using braces on same line or new line for C#
<p>I have been using the default of new line for methods and code blocks but it's using up a lot of space. Should I use the curly brace on the same line as the start of the method? Is there any disadvantage to doing this?</p>
c#
[0]
999,614
999,615
How Can I Set Text Field Properties Dynamically or Statically in Android
<p>How can I set the following two properties for a text field in Android: </p> <p>(<b>Property 1</b>) How can I set a text field that contains some text like "Enter a number" but when it is clicked the text field automatically becomes empty?</p> <p>(<b>Property: 2</b>) Suppose I have two text fields in my application. My <em>first</em> text field only accepts integers and the <em>second</em> text field accepts text like "name, address" etcetera. But by mistakenly I enter some text like "apple" or "ball" in my first text field that only accepts numbers. </p> <p>How can I set my <em>first</em> text field so that when I click on the <em>second</em> text field my <em>first</em> text field should show a toast message or change the color of inputed data to indicate invalid input?</p>
android
[4]
905,421
905,422
How to use the "is" operator in System.Type variables?
<p>here is what a I'm doing: </p> <pre><code>object ReturnMatch(System.Type type) { foreach(object obj in myObjects) { if (obj == type) { return obj; } } } </code></pre> <p>However, if obj is a subclass of <code>type</code>, it will not match. But I would like the function to return the same way as if I was using the operator <code>is</code>.</p> <p>I tried the following, but it won't compile:</p> <pre><code>if (obj is type) // won't compile in C# 2.0 </code></pre> <p>The best solution I came up with was:</p> <pre><code>if (obj.GetType().Equals(type) || obj.GetType().IsSubclassOf(type)) </code></pre> <p>Isn't there a way to use operator <code>is</code> to make the code cleaner?</p>
c#
[0]
5,235,079
5,235,080
Window open and close effect with c# in windows application
<p>please give me idea about effect. in android or windows vista a effect is used when any application window is open or closed. effect is like grow and shrink. very similar like jquery transfer effect. i can generate that effect like window size increment or decrement with in time but it flicker and not smooth like professional. so please guide how to generate that effect in windows application which look very professional. also tell me is there any free open source library to generate that kind of effect. please me with sample code.</p> <p>thanks</p>
c#
[0]
2,228,513
2,228,514
Highlighting Menu Using jQuery - Does Not Work on POST
<p>I'm having an issue regarding some jQuery I am using to highlight a menu item that has been selected by a user.</p> <p>Here is my code (within the Site.Master):</p> <pre><code>&lt;script type="text/javascript"&gt; $(function () { $('#horizontalmenu ul li a').live('click', function () { $('#horizontalmenu ul li').removeClass('current'); $(this).closest('li').addClass('current'); }); }); &lt;/script&gt; </code></pre> <p>This works when I trace through with Firebug, but the class is changed and then the page reloads and I lose the class change. What am I doing wrong here?</p>
jquery
[5]
5,383,570
5,383,571
Adjusting 1 space between two strings using python
<p>I have two strings:</p> <pre><code>&gt;&gt;&gt; a = "abcd" &gt;&gt;&gt; b = "xyz" &gt;&gt;&gt; c = a + b &gt;&gt;&gt; c abcdxyz </code></pre> <p>How can I get <code>abcd xyz</code> as a result instead when adding <code>a</code> and <code>b</code>?</p>
python
[7]
1,358,731
1,358,732
Select All Checkboxes By ID/Class
<p>I'm really bad at Javascript and I'm struggling to get my head round it.</p> <p>What I'm trying to do is get something to select all checkboxes. However everything I have found tries to do it by name, I want to do it by ID or class. Select all by name is just inpractical isn't it?</p>
javascript
[3]
1,833,832
1,833,833
Given 2 16-bit ints, can I interleave those bits to form a single 32 bit int?
<p>Whats the proper way about going about this? Lets say I have ABCD and abcd and the output bits should be something like AaBbCcDd.</p> <pre><code>unsigned int JoinBits(unsigned short a, unsigned short b) { } </code></pre>
c++
[6]
766,708
766,709
jQuery display image issue
<p>I have PHP page where users can upload photos (using Ajax &amp; PHP script). Those uploaded photos (thumbs) are shown after upload in DIV below upload field.</p> <p>Then, after hitting send button I want to clone that DIV at that same page at message board, bellow other messages with or without uploaded photos.</p> <p>When I try to do that with:</p> <pre><code>var pht = $("#photos").clone().addClass('p_pht'); </code></pre> <p>and try to display sent photos bellow sent message like this:</p> <pre><code>$("div#wall").append('&lt;div class=msg&gt;'+ message +'&lt;/div&gt;&lt;div class=n_pht&gt;'+ pht +'&lt;/div&gt;'); </code></pre> <p>I get jQuery error message "[object Object]" in place where the photos should be displaying.</p> <p>What am I doing wrong?</p>
jquery
[5]
2,121,068
2,121,069
How to make variable with a variable?
<p>I would make a varibale with a variable.</p> <p>My varaible should look like this <code>$_test</code> and the php-Code that I think it is right but doesn't work is: <code>$alias='test';</code></p> <p><code>$_$alias</code> or <code>$_.{$alias}</code> or <code>{$_}.{$alias}</code></p>
php
[2]
5,360,866
5,360,867
window.onunload event
<p>i am using confirm dialogue box on the window.onunload event.but when i click the cancel button it will navigate me to another page but i want to stay on that page. is this a problem of window.onunload event. please give me solution for this problem. also tell me another window event instead of it.But i do not want to use onbeforeunload event</p>
javascript
[3]
3,163,749
3,163,750
text to image conversion
<p>i just succeeded in calling a line of text from a text file in th sdcard and got it to display the text out on the application via textview,</p> <p>is there anyway where i could read the characters from the text and then get it to display a image below the character</p> <p>like an text to image conversion right below each line of text</p> <p>the text are short and simple words</p> <p>thanks in advance</p>
android
[4]
5,687,488
5,687,489
custom javascript objects as properties of other custom javascript objects
<p>I want to create some custom javascript objects some of which have properties which are other objects. I'm not sure what the syntax would be to do this. My pseudo code is below with the idea that I have a person object and an order object. The order object has a property that I want to be of the person object type. Is this possible in javascript and if so, can someone give me a basic example? Thanks.</p> <pre><code>var person { name: "John", gender: "M", age: 3 } var order { customer: person, /*the property name is customer but of type person - is this possible?*/ total: 100 } </code></pre>
javascript
[3]
3,979,906
3,979,907
Read/Write Parent Application Config using C#
<p>I am trying to read my parent application config inside my class library but getting error. My application hierarchic is like this</p> <p>Executable Application(MS Test Project) > Service(Class Library) > DataAccess(Class Library)</p> <p>Now my App.config is inside my Executable Application(MS Test Project) and i am tying to read inside DataAccess(Class Library) using following command.</p> <pre><code> System.Configuration.Configuration _config1 = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); </code></pre> <blockquote> <p>Error:- An error occurred loading a configuration file: Type is not resolved for member 'Castle.DynamicProxy.Serialization.ProxyObjectReference,Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920'.</p> </blockquote> <p>Please suggest me is there any other way?</p> <p><strong>Modified....</strong></p> <p>Now to fix this Problem, i did like this</p> <pre><code> var path = System.AppDomain.CurrentDomain.GetAssemblies().Where(p =&gt; !p.GlobalAssemblyCache &amp;&amp; p.ImageRuntimeVersion.Contains("v" + System.Environment.Version.ToString().Substring(0, System.Environment.Version.ToString().LastIndexOf(".")))).FirstOrDefault().Location; _config = ConfigurationManager.OpenExeConfiguration(path); </code></pre> <p>It is working for me, but still is there any other way???</p>
c#
[0]
3,897,128
3,897,129
how disable/block USB
<p>Programmaticslly I want disable USB data read. There is no meaning or purpose.I just want to learn whether it is possible or not. In order to clarify, how can I disable USB connection? ( sort of unpluggin)</p>
android
[4]
1,410,457
1,410,458
.load(function) firing twice
<p>I have a click event that loads an iframe, which is followed by a .load(function() for the iframe. The problem is the load function gets fired twice for each click event. Can someone explain me the reason why this is happening? And how can it be prevented?</p> <pre><code>$(document).ready(function() { $('.Popup').click(function() { $('#myiframe').attr('src', $(this).attr('href')).load(function() { alert('done loading') }) return false; }); });​ </code></pre>
jquery
[5]
1,607,478
1,607,479
Nullpointer exception to a dialog object
<p>I received an error from an app on the market to a TextView in a dialog. The error is</p> <pre><code>java.lang.NullPointerException at com.b2creativedesigns.eyetest.ColorBlindTest1$2.onClick(ColorBlindTest1.java:324) </code></pre> <p>Partial code is:</p> <pre><code>btnNext1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GlobalVars.setPoints(points); dialog = new Dialog(ColorBlindTest1.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.cbtdialog); TextView dialogtext = (TextView) dialog.findViewById (R.id.tvCBTresult); TextView dialogtext2 = (TextView) dialog.findViewById (R.id.tvCBTresult2); Button btnQuit = (Button) dialog.findViewById (R.id.btnCTBback); Button btnFB = (Button) dialog.findViewById (R.id.btnCBTFB); Button btnMarket = (Button) dialog.findViewById (R.id.btnCBTMarket); if (points &gt;= 14) { dialogtext.setText("Your result is " + points + "/15!"); dialogtext.setTextColor(Color.rgb(19, 20, 111)); dialogtext2.setText("Something"); //error line } ... </code></pre> <p>My questions are</p> <ol> <li><p>Is it okay to the declare the objects (in case the TextView) here, locally, and not globally outside <code>TextView dialogtext2;</code> and write here only <code>dialogtext2 = (TextView) dialog.findViewById (R.id.tvCBTresult2);</code> <code>?</code></p></li> <li><p>I have 4 folders for 4 density: layout-ldpi, layout-mdpi, layout-hdpi, layout-xhdpi. The xml in the layout-xhdpi folder did not include the dialogtext2 TextView. Could this cause the error? Doesn't android apply an xml from another density folder when an object is missing from the same xml in another density folder?</p></li> </ol> <p>What else can be the root of error?</p>
android
[4]
4,674,192
4,674,193
Function to search associative array keys
<p>I am writing a shopping cart session handler class and I find myself repeating this certain chunk of code which searches a multidimensional associative array for a value match.</p> <pre><code>foreach($_SESSION['cart'] as $k =&gt; $v){ if($v['productID'] == $productID){ $key = $k; $this-&gt;found = true; } } </code></pre> <p>I am repeating this when trying to match different values in the array. Would there be an easy to to create a method whereby I pass the key to search and the value. (Sounds simple now I read that back but for some reason have had no luck)</p>
php
[2]
1,249,331
1,249,332
Retiving facebook friendlist and showing it in Tableview
<p>Hi I am using facebook graph api, to retrive, facebook's friend list.</p> <p>i m using this </p> <pre><code>-(IBAction)getMeFriendsButtonPressed:(id)sender { FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:@"me/friends" withGetVars:nil]; NSLog(@"getMeFriendsButtonPressed: %@", fb_graph_response.htmlResponse); } </code></pre> <p>And in return i am getting this at console.</p> <blockquote> <p>getMeFriendsButtonPressed: {"data":[{"name":"name1","id":"504181912"},{"name":"name2","id":"505621879"},{"name":"name3","id":"520845156"},{"name":"name4","id":"537539375"}}</p> </blockquote> <p>something like this.</p> <p>I want to get names, like name1 ,name2, name3 and show it in table view.</p> <p>How can i create an array of these name? Suggestion please Thanks</p>
iphone
[8]
2,278,818
2,278,819
modify method argument or return in java
<p>I have seen this method in android source code.</p> <pre><code> protected LocaleConfiguration doInBackground(Void... unused) { LocaleConfiguration localeConfiguration = new LocaleConfiguration(); readConfiguration(Launcher.this, localeConfiguration); return localeConfiguration; } private static void readConfiguration(Context context, LocaleConfiguration configuration) { DataInputStream in = null; try { in = new DataInputStream(context.openFileInput(PREFERENCES)); configuration.locale = in.readUTF(); configuration.mcc = in.readInt(); configuration.mnc = in.readInt(); } catch (FileNotFoundException e) { // Ignore } catch (IOException e) { // Ignore } finally { if (in != null) { try { in.close(); } catch (IOException e) { // Ignore } } } } </code></pre> <p>why not something like this</p> <pre><code> private static LocaleConfiguration readConfiguration(Context context) { LocaleConfiguration configuration = new LocaleConfiguration(); DataInputStream in = null; try { in = new DataInputStream(context.openFileInput(PREFERENCES)); configuration.locale = in.readUTF(); configuration.mcc = in.readInt(); configuration.mnc = in.readInt(); } catch (FileNotFoundException e) { // Ignore } catch (IOException e) { // Ignore } finally { if (in != null) { try { in.close(); } catch (IOException e) { // Ignore } } } return configuration; } </code></pre> <p>what is the advantage of modifying argument instead of returning new value</p>
java
[1]
3,174,369
3,174,370
record voice when phone incoming call or outgoing call
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3370278/record-phone-calls-on-android-phone">Record phone calls on android phone ??</a> </p> </blockquote> <p>Hi, is this possible record voice call if yes please tell me how?</p>
android
[4]
3,200,138
3,200,139
Adding function to Object prototype causes function to show up in all 'for X in OBJ' loops
<p>So, here's some sample javascript code:</p> <pre><code>Object.prototype.simpleFunction = function () { return true; } var tempObject = {}; for (var temp in tempObject) { console.log(temp); } </code></pre> <p>Note that if you execute this, you'll get 'simpleFunction' output from the <code>console.log</code> commands in Google Chrome. (I'm using 19.0.1084.46m .)</p> <p>However, the wide variety of related Object functions are <em>not</em> passed to the <code>console.log</code>. </p> <p>How can I add functions onto the <code>Object</code> prototype without them showing up in my '<code>for property in</code> object' loops?</p> <p><strong>Edit</strong>: I should have mentioned that the last thing I wanted was to throw another 'if' statement in there, as it'd mean I'd need to add it to ALL <code>for</code> loops. :(</p>
javascript
[3]
2,374,857
2,374,858
Android dx generates bad checksum dex files
<p>I'm working on a project which generates Java code on-the-fly, and compiles it for Android. Funny thing is that sometimes <strong>dx.bat</strong> generates a broken DEX file while finishing successfully.</p> <p>When I try to dexdump the DEX, I get: <strong>ERROR: bad checksum (deadbeef vs deadc0de)</strong></p> <p>Manually playing around with <em>--no-optimize</em> or <em>--no-locals</em> will solve the issue for this specific compilation. But you can never know what will happen with the next one and this is a process that should be reliable.</p> <p>BTW, manually fixing the checksum doesn't fix the problem (dexdump will crash after dumping some data) so I figure it isn't a dx checksum calculation bug.</p> <p>Is there a known issue? How can I further debug?</p> <p>Thanks!</p>
android
[4]
1,999,627
1,999,628
how to use codebeside in ASP.NET Web Application
<p>I'm using VS2008 and want to create a web application (not a web site) with Code-Beside but, the default mode of aspx is Code-Behind. I have tried to change the CodeBehind=ClassFile.cs to CodeFile=ClassFile.cs in the header of aspx's &lt;%@Page%> part, and deleted the aspx.designer.cs file,but if I added a server control to the page, the compiler is also send me an error of no member defined.the cs file is the orinal file of codebehind, it is partial class.</p>
asp.net
[9]
1,983,961
1,983,962
Largest and smallest number in an array
<p>This works perfectly...but when I use <code>foreach</code> instead of <code>for</code> this doesn't works. I can't understand <code>for</code> and <code>foreach</code> are same.</p> <pre><code>namespace ConsoleApplication2 { class Program { static void Main(string[] args) { int[] array = new int[10]; Console.WriteLine("enter the array elements to b sorted"); for(int i=0;i&lt;10;i++) { array[i] = Convert.ToInt32(Console.ReadLine()); } int smallest = array[0]; for(int i=0;i&lt;10;i++) { if(array[i]&lt;smallest) { smallest=array[i]; } } int largest = array[9]; for(int i=0;i&lt;10;i++) { if (array[i] &gt; largest) { largest = array[i]; } } Console.WriteLine("the smallest no is {0}", smallest); Console.WriteLine("the largest no is {0}", largest); Console.Read(); } } } </code></pre>
c#
[0]
685,357
685,358
how to nest PHP code blocks
<p>This code is broken because I am nesting php code blocks. What is the proper way to do this?</p> <pre><code>&lt;?php if ($prev_ID &gt; $totalRows_totalBoogerRows) { echo ""; } else { echo &lt;&lt;&lt;_END &lt;div class='paging_button_left paging_button_left_episode'&gt; &lt;a href='episode.php?post_ID=&lt;?php echo $prev_ID; ?&gt;'&gt; &lt;h4 style='text-align: right;'&gt;Ep. &lt;?php echo $prev_ID; ?&gt; &lt;/h4&gt; &lt;/a&gt; &lt;/div&gt;" _END; } ?&gt; </code></pre> <p>I breaks on line 11 because my closing PHP tag closes the first PHP opening tag on line one (I want it to only close the opening PHP tag on line 11). Also, I may be using &lt;&lt;&lt;_END wrong.</p>
php
[2]
1,022,576
1,022,577
Javascript getElementByID().innerHTML() not working
<p>I'm new to Javascript and for some reason I can't get the following code to work and it's driving me crazy!</p> <p>It's</p> <pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;title&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;meta name="description" content="test" /&gt; &lt;meta name="keywords" content="test" /&gt; &lt;meta name="robots" content="index,follow" /&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;test&lt;/h1&gt; &lt;p id="demo"&gt;something&lt;/p&gt; &lt;button type="button" onclick="myFunction();"&gt;Try it&lt;/button&gt; &lt;script type="text/javascript"&gt; function myFunction() { document.getElementByID("demo").innerHTML = "testttt"; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Anyone know the problem?</p>
javascript
[3]
900,981
900,982
Enabling a disabled child window form's maximize button from another process
<p>I currently do not know how could I get all forms window handle that is created by a single process.</p> <p>For ex:</p> <p>Internet explorer creates forms but runs in single process. For some reason one of the child form's maximize button is disabled. How could I Enable it?</p>
c#
[0]
6,024,705
6,024,706
String Holding Array of objects?? Is it possible?
<p>Can a String hold Array Object? May be this question could be silly? Just wanted to know... </p>
javascript
[3]
4,717,167
4,717,168
Does python's httplib.HTTPConnection block?
<p>I am unsure whether or not the following code is a blocking operation in python:</p> <pre><code>import httplib import urllib def do_request(server, port, timeout, remote_url): conn = httplib.HTTPConnection(server, port, timeout=timeout) conn.request("POST", remote_url, urllib.urlencode(query_dictionary, True)) conn.close() return True do_request("http://www.example.org", 80, 30, "foo/bar") print "hi!" </code></pre> <p>And if it is, how would one go about creating a non-blocking asynchronous http request in python?</p> <p>Thanks from a python noob.</p>
python
[7]
304,853
304,854
pushback data from vector to vector of map
<p>i have created a map called select_p and vector of this map is called pts. i have stored data in a array and i want to pushbcak these data into my vector of map. i tried this by inserting value of array into new vector and then pushback into my map.but it is not working please help me to correct these codes? thanks </p> <pre><code>#include&lt;iostream&gt; #include&lt;cstdlib&gt; #include &lt;map&gt; #include &lt;vector&gt; using namespace std; int main() { int M=7; int N=6; int i=0; int * temp; map&lt;int,vector&lt;int&gt; &gt; select_p; vector&lt;int&gt;pts; for (int m=0; m&lt;M; m++) { for (int n=0; n&lt;N; n++) { vector&lt;int&gt;id; if (n==0 &amp;&amp; m==5) { temp = new int[3,i+N,i+N+1,i+1]; unsigned ArraySize = sizeof(temp) / sizeof(int); id.insert(id.begin(),temp[0], temp[ArraySize]); select_p[i].push_back(id); } i++; } } delete[] temp; system("PAUSE"); return 0; } </code></pre>
c++
[6]
5,166,490
5,166,491
jQuery show / hide logic required
<p>I have 4 optgroup select menus that appear dependent on the value of the first select option. What I'd like to do is get the Value and load in the relevant matching select group. But obviously if a group has already been select hide the group and put the new select group in its place.</p> <p>My jQuery code is :</p> <pre><code>$('#subcategory1, #subcategory2, #subcategory3, #subcategory4').hide(); // Hide Orientation Dropdown $('#orientation').hide(); $('#category').change(function() { $('#orientation').show(); var CatValue = $("#category").val(); if (CatValue == '1') { $("#subcategory1").show(); } if (CatValue == '2') { $("#subcategory2").show(); } if (CatValue == '3') { $("#subcategory3").show(); } if(CatValue == '4') { $("#subcategory4").show(); } }); </code></pre> <p>I am looking at a more logical way of writing this out. i.e hide previous subcategory selections etc.</p> <p>Thanks in advance.</p>
jquery
[5]
2,497,768
2,497,769
Is there control(view) for android that I can use to take user signature?
<p>I would like to allow user to sign on a screen with stylus like UPS or Credit Card terminal in store.</p> <p>Is there control/api I can use in my program to convert this to image?</p>
android
[4]
4,316,173
4,316,174
How can I create a JavaScript object constructor in a module?
<p>I am trying to create a reusable javascript object (I want to use new). When I attempt to new up one of my custom objects I get an error:</p> <blockquote> <p>"org.myorg.sadp.section.sadpSection is not a constructor"</p> </blockquote> <p>I am modularizing my JS for namespace reasons. I wonder if that is the problem:</p> <pre><code>if (!window.org) var org = { myorg: {} }; if (!org.myorg) org["myorg"] = { sadp: {} }; if (!org.myorg.sadp) org.myorg["sadp"] = {}; org.myorg.sadp.section = (function(ns) { if (ns.section) { return ns; } else { ns.section = {}; } ns.section.sadpSection = function(name) { this.name = name; this.isCompleted = false; this.booleanQuestions = new Array(); this.multipleChoiceQuestions = new Array(); this.sliders = new Array(); return true; } return ns; } (org.myorg.sadp)) </code></pre> <p>This results in the error:</p> <pre><code>var myObj = new org.myorg.sadp.section.sadpSection("test"); </code></pre> <p>What am I doing wrong here?</p> <p>Thanks!</p>
javascript
[3]
2,509,748
2,509,749
Sample twitter App
<p>I am now running my code on a web hosting service <a href="http://xtreemhost.com/" rel="nofollow">http://xtreemhost.com/</a></p> <pre><code>&lt;?php function updateTwitter($status) { $username = 'xxxxxx'; $password = 'xxxx'; $url = 'http://api.twitter.com/1/statuses/update.xml'; $postargs = 'status='.urlencode($status); $responseInfo=array(); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_POST, true); // Give CURL the arguments in the POST curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs); // Set the username and password in the CURL call curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password); // Set some cur flags (not too important) $response = curl_exec($ch); if($response === false) { echo 'Curl error: ' . curl_error($ch); } else { echo 'Operation completed without any errors&lt;br/&gt;'; } // Get information about the response $responseInfo=curl_getinfo($ch); // Close the CURL connection curl_close($ch); // Make sure we received a response from Twitter if(intval($responseInfo['http_code'])==200){ // Display the response from Twitter echo $response; }else{ // Something went wrong echo "Error: " . $responseInfo['http_code']; } curl_close($ch); } updateTwitter("Just finished a sweet tutorial on http://brandontreb.com"); ?&gt; </code></pre> <p>I get the following error now</p> <pre><code>Curl error: Couldn't resolve host 'api.twitter.com' Error: 0 </code></pre> <p>Please somebody solve my problem</p>
php
[2]
2,175,001
2,175,002
How can I read data from a URL?
<p>I have a function in javascript which I hard-coded as of now:</p> <pre><code>function getCarData() { return [ {car: "Nissan", year: 2009, chassis: "black", bumper: "black"}, {car: "Nissan", year: 2006, chassis: "blue", bumper: "blue"}, {car: "Chrysler", year: 2004, chassis: "yellow", bumper: "black"}, {car: "Volvo", year: 2012, chassis: "white", bumper: "gray"} ]; } </code></pre> <p>Now.. this was just to unit test whether the code will work or not.. But now it is working..</p> <p>I am generating this data on backend and am mapping it to the directory on server (which is localhost at the moment)</p> <p>So if I go to localhost:5000/cardata I have exact same data i.e</p> <pre><code>[ {car: "Nissan", year: 2009, chassis: "black", bumper: "black"}, {car: "Nissan", year: 2006, chassis: "blue", bumper: "blue"}, {car: "Chrysler", year: 2004, chassis: "yellow", bumper: "black"}, {car: "Volvo", year: 2012, chassis: "white", bumper: "gray"} ]; </code></pre> <p>What changes I should made on my javascript file in order to make this work?</p>
javascript
[3]
2,300,713
2,300,714
How to set onclick with javascript?
<p>I am trying to set the onclick event using javascript. The following code works:</p> <pre><code>var link = document.createElement('a'); link.setAttribute('href', "#"); link.setAttribute('onclick', "alert('click')"); </code></pre> <p>I then use appendChild to add link to the rest of the document.</p> <p>But I obviously would like a more complicated callback than alert, so I tried this:</p> <pre><code>link.onclick = function() {alert('clicked');}; </code></pre> <p>and this:</p> <pre><code>link.onclick = (function() {alert('clicked');}); </code></pre> <p>But that does nothing. When I click the link, nothing happens. I have testing using chrome and browsing the DOM object shows me for that element that the onclick attribute is NULL.</p> <p>Why am I not able to pass a function into onclick?</p> <p>EDIT:</p> <p>I tried using addEventListener as suggested below with the same results. The DOM for the link shows onclick as null.</p> <p>My problem may be that the DOM for this element might not have been fully built yet. At this point the page has been loaded and the user clicks a button. The button executes javascript that builds up a new div that it appends to the page by calling document.body.appendChild. This link is a member of the new div. If this is my problem, how do I work around it?</p>
javascript
[3]
3,818,933
3,818,934
How to Stay on same page even I do refresh
<p>I'm developing one asp.net website. I have page which contains menu items like Home,Aboutsus,Help.. like I have 5 tabs. in single page. If I click on second tab and If I do refresh agian its going to home page. How to stay on the same page even I refreshed the page. Hope u understand my problem. Pleas help me. Thanks in advance.</p>
asp.net
[9]
2,794,973
2,794,974
jquery fadeout text and image opacity changes
<p>I have something like this</p> <pre><code>&lt;div id="dis_image"&gt;&lt;/div&gt; &lt;div id="images"&gt; &lt;img src="1/1.jpg" class="image" style="opacity:0.3" /&gt; &lt;img src="1/2.jpg" class="image" style="opacity:0.3" /&gt; &lt;/div&gt; &lt;ul style="display:none" id="images_list"&gt; &lt;li&gt;testing 1&lt;/li&gt; &lt;li&gt;testing 2&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>What i am planning to do is every 5 seconds, i want the first text from <code>id:images_list</code> to display on <code>id:dis_images</code> and <code>id:images</code> first image changes opacity from 0.3 to 1 then, proceed to second one, first text and first image is replaced by second text and second image and so with opacity. The first image should return to its normal opacity 0.3</p> <p>I have tried this but its not working correctly as it is stopped at last.</p> <p>jquery:</p> <pre><code>setInterval(function() { $("#dis_image").html(""); $('#images_list :nth-child(1)').next().show().fadeOut(1200).appendTo('#dis_image'); $('#images :nth-child(1)').next().css({ opacity: 1 }); } , 5000); </code></pre>
jquery
[5]
2,665,599
2,665,600
parameter passing to split function from if condition
<pre><code>string= "im fine.gds how are you" if '.gds' or '.cdl' in string : a=string.split("????????") </code></pre> <p>the above string may contain <code>.gds</code> or <code>.cdl</code> extension. i want to split the string based on the extension. </p> <p>here how the parameters can be passed to split funtion.(<strong>EX</strong> if <code>.gds</code> is present in string then it should take as <code>split(".gds")</code> if <code>.cdl</code> is there in string then it should get <code>split(".cdl")</code>)</p>
python
[7]
2,634,837
2,634,838
Error: can't declare a virtual/ abstract member private
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3082310/why-are-private-virtual-methods-illegal-in-c">Why are private virtual methods illegal in C#?</a> </p> </blockquote> <p>I have the following code in C#, and Visual Studio is complaining in the Derived class that i cant declare a virtual/ abstract member private.. but i am not .. so does anyone have some ideas? Thanks</p> <pre><code>public class Base { private const string Name= "Name1"; protected virtual string Member1 { get{ return Name; } } } public class Derived: Base { private const string Name= "Name2"; protected override string Member1 { get{ return Name; } } } </code></pre>
c#
[0]
1,539,265
1,539,266
Android Antena Data?
<p>How do I acces how strong my signal is for an android phone? I am new to android programming but have experience in java, and C#. I would like to be able to tell how strong my antena signal is with a numerical value if at all possible. </p>
android
[4]
879,557
879,558
Read UTF-8 Lines of Text and Write them to File
<p>I fetch lines of UTF-8 text from a page then dump into a file. The text in the original page appears fine. However, the text in the output file appears scrambled!</p> <p><strong>My attempt:</strong></p> <pre><code>$myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $pageContent = file_get_contents("page.html"); //Here: use regex to grab the title ... $stringData = $title."\n"; fwrite($fh, utf8_encode($stringData)); fclose($fh); </code></pre> <p>Before writing anything to the file. I saved the file as UTF-8 and i also saved it as Unicode, i still get scrambled text as:</p> <blockquote> <p>ÊãäíÇÊí ááÌãíÚ</p> </blockquote> <p>I'm not using PHP5</p> <p><strong>Any help will be appreciated...</strong></p>
php
[2]
3,066,775
3,066,776
importing required module
<p>The following code is working as expected. But I have 2 questions.</p> <pre><code># import datetime # does not work from datetime import datetime row = ('2002-01-02 00:00:00.3453', 'a') x = datetime.strptime(row[0], "%Y-%m-%d %H:%M:%S.%f") </code></pre> <p>1) Why does only import datetime does not work?</p> <p>2) How do I know to which module does the 'strptime' method belogs to?</p> <pre><code>&gt;&gt;&gt; help('modules strptime') </code></pre> <p>does not provide the info I am looking for.</p>
python
[7]
4,163,718
4,163,719
map operations(find most occurence element)
<p>here is code</p> <pre><code>#include &lt;iostream&gt; #include &lt;map&gt; using namespace std; int main(){ map&lt;int ,int&gt;a; map&lt;int,int&gt;::iterator it; int b[]={2,4,3,5,2,6,6,3,6,4}; for (int i=0;i&lt;(sizeof(b)/sizeof(b[0]));i++){ ++a[b[i]]; } // for (it=a.begin();it!=a.end();it++){ // cout&lt;&lt;(*it).first&lt;&lt;" =&gt;"&lt;&lt;(*it).second&lt;&lt;"\n"; //} int max=a.begin()-&gt;second; for (it=a.begin();it!=a.end();it++){ if ((*it).second&gt;max){ max=(*it).second; } } for (it!=a.begin();it!=a.end();it++){ if ((*it).second==max){ cout&lt;&lt;(*it).first&lt;&lt;"\n"; } } return 0; } </code></pre> <p>what i am trying is following according to number of occurence of each keys i want it print element which occurs most often in this case 6 but it does not show me result what is mistake?</p>
c++
[6]
5,282,822
5,282,823
Why is Javascript's "in" operator consistently slower than strict member comparison to undefined?
<p>See <a href="http://jsperf.com/in-vs-member-object-access" rel="nofollow">http://jsperf.com/in-vs-member-object-access</a></p> <p>Essentially, why is checking <code>if ('bar' in foo) {}</code> significantly slower than <code>if (foo.bar !== undefined) {}</code>?</p>
javascript
[3]
3,696,016
3,696,017
query table columns for specific data values in sqlite android
<p>i am trying to query my database so that it returns only rows with a specific value in a certain column.but when i run it, it still returns all the rows. please take a look at the code and see if i have done it incorrectly. I am trying to query for the string in the PRIORITY column. i want to display those specific rows in a listview. Thank you.</p> <pre><code> private static final String DATABASE_NAME = "MemoData.db"; private static final int DATABASE_VERSION = 1; public static final String DATABASE_TABLE = "Places"; public static final String KEY_ID = "_id"; public static final String NAME = "Title"; public static final String CATEGORY = "category"; public static final String PRIORITY = "priority"; private static final String TAG = "DBAdapter"; private static final String DATABASE_CREATE = "create table Places (_id integer primary key autoincrement, Title text, category text, priority text);"; public Cursor priorityData(){ String[] resultColumns = new String[] {KEY_ID,NAME,CATEGORY,PRIORITY }; String[] condition = {"High"}; Cursor cursor = db.query(DATABASE_TABLE, resultColumns, KEY_ID + "=" + "?", condition, null, null, null); if(cursor.moveToNext()){ return cursor; } return cursor; } </code></pre> <p>The values for priority columns can be "Low", "Medium" or "High". i am trying to query the database to return rows whose values are set as "High" in the PRIORITY column.</p>
android
[4]
4,388,757
4,388,758
How do I develop an online survey application?
<p>I want to develop application that contain number of question with independent radiobuttonlist which contain three option Yes, No, Unsure. </p> <p>Daily visitors comes on the site &amp; reply to the question. Also to show addition of the Yes, NO &amp; Unsure in front of each question.</p> <p>Please give me idea how to do such functionalty.</p> <p>Regards, Girish </p>
asp.net
[9]
3,162,062
3,162,063
call class from jar
<p>How to call method from callapi.jar file?Callapi.jar file contains callapi package with callapi.class inside.</p> <p>And another problem how to call it from another jar. I mean staticapi.jar contains staticapi package with file staticapi.class and callapi.jar. Callapi.jar is called by staticapi.</p>
java
[1]
5,319,434
5,319,435
Process function for dynamically added DOM element
<p>I would like to process certain initialization steps whenever an item with a certain class is added anywhere in the DOM. This includes applying some style attributes to its parent (this is why I cannot use CSS), and also binding to the click event.</p> <p>The following code works when element is static (was already on the page after <code>document.ready</code>):</p> <pre><code>$(function(){ //... global initialization code $('.myclass').each(function(){ var parent = $(this).parent(); parent.css({cursor:'pointer'}); //apply CSS style to the parent parent.click(function(event){ //... event handler }); }); }); </code></pre> <p>Is it possible to convert it to handle dynamically added elements and how?</p>
jquery
[5]
2,743,132
2,743,133
prevent writing in a textbox if table length exceeded
<p>so I'm using jquery tags input in my project i want to check if the user has entered more than the max allowed tags i should prevent him from writing how can i do that . PS: i don't want to disable the input</p> <p>that's my code so far : </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $('#tag1').tagsInput({ 'width':'300px', 'height':'50px', 'minChars' : 1, 'maxChars' : 12, 'onAddTag':tagsCountExceeded }); function tagsCountExceeded(){ var TagsCount=2; var TagsTable=$('#tag1').val().split(","); $('#tag1').keypress(function(e){ if(TagsTable.length==TagsCount) e.preventDefault(); }); } }); &lt;/script&gt; </code></pre> <p>but the keyPress function isn't working </p>
jquery
[5]
864,313
864,314
Jquery to fade in .after()?
<p>Simple really but cannot get it to work, here is my script...</p> <pre><code>$('body').after('&lt;div id="lightBox" style="height: ' + htmlHeight + 'px;"&gt;&lt;/div&gt;'); </code></pre> <p>How can I get it to fade in rather than just pop up? putting fadeIn after or before .after() doesn't work?</p>
jquery
[5]
3,005,097
3,005,098
UITableView does not go into "swipe to delete" mode
<p>My UITableView is linked with my UIViewController instance. The UIViewController instance is the table's UITableViewDelegate and UITableViewDataSource.</p> <p>Whenever a cell is swiped in the simulator, it does not trigger the "swipe to delete" mode. I tried to provide implementations for the methods to support "swipe to delete" and table cell editing. None of them get called (none of the NSLogs are logging).</p> <pre><code>- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"tableView editingStyleForRowAtIndexPath"); return UITableViewCellEditingStyleDelete; } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"tableView canEditRowAt..."); return YES; } - (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"tableView willBeginEditingRowAtIndexPath: %@", indexPath); } - (void)tableView:(UITableView *)tableView willEndEditingRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"tableView willEndEditingRowAtIndexPath: %@", indexPath); } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle { NSLog(@"tableView commitEditingStyle"); } - (void)tableView:(UITableView*)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"tableView didEndEditingRowAtIndexPath"); } </code></pre> <p>There must be a simple thing I'm forgetting, but cannot figure out what. Any ideas?</p>
iphone
[8]
39,745
39,746
How to record voice with out noise in AVAudio Recorder iPhone SDK
<p>I am new to iPhone Developing,Here i have developed like a Tomcat Application.I have changed the Voice Pitch,but while i am playing the recorded voice there is a lot of noise in that audio file. I have recorded sound by using AVAudio Recorder So how can i remove the noise in recording.?</p> <pre><code>NSMutableDictionary *settings = [[NSMutableDictionary alloc] init]; </code></pre> <p>[settings setValue:[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; </p> <pre><code>[settings setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [settings setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; [settings setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; [settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey]; [settings setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey]; recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL fileURLWithPath:self.audioPath] settings:settings error:nil]; recorder = [self.recorder retain]; [recorder prepareToRecord]; recorder.meteringEnabled = YES; [recorder record]; </code></pre> <p>Please Help me , Thanking you in Advance.</p>
iphone
[8]
4,527,126
4,527,127
How to capture screen touch event when screen is off in Android?
<p>I write a program to capture screen touch event. But when the screen is off, I can't get any <code>MotionEvent ev</code>. </p> <pre><code>private PowerManager pm = null; private PowerManager.WakeLock wl = null; this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE); this.wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "test"); wl.acquire(); @Override public boolean dispatchTouchEvent (MotionEvent ev) { if(ev.getAction() == MotionEvent.ACTION_DOWN) Log.i("test", "!!!"); return true; } </code></pre>
android
[4]
4,564,326
4,564,327
Error occuring in that line no. which doesn't present in code
<p>When i am running the javascript code that is reading excel of 237 rows so it runs well but when i am reading the excel of 999 rows with the same code so it gives error "Number expected" in line 272 although my code ends at line 268.Can anyone plz tell me how to fix it </p>
javascript
[3]
1,436,164
1,436,165
Macintosh Python: 64-bit vs 32-bit problems
<p>I'm trying to sort through a whole host of problems arising from upgrading my macintosh to 10.6. Most of the tools I need work, but a couple (scipy, wxpython) do not, and give error messages that are highly suggestive of my messing up something with 64-bit and 32-bit binaries.</p> <p>I'm currently running Python 2.7. I don't know whether it is a 32-bit or a 64-bit version. How do I tell?</p> <p>What I'm most concerned about is that I have some bizarre mixture of 32-bit and 64-bit, and that I should scrap everything and reinstall. If I do this, and I want to avoid as many build problems as possible, do I (1) install the 32-bit version, (2) install the 64-bit version and make sure everything I build is 64-bit enabled, or (3) something else.</p> <p>I've tried without luck to find web pages regarding this, since other people must have stumbled over these issue, but I apologize if I'm rehashing old issues here. I've also tried very hard not to type the offensive statement "I don't care about 32-bit vs 64-bit, I just want Python to <em>work</em>", but, in effect, that's what I'm asking here.</p> <p>Heaps of gratitude to whomever can help me sort through this, and apologies if I'm just being dense.</p>
python
[7]
3,025,856
3,025,857
Catchable fatal error: Object of class __PHP_Incomplete_Class
<p>i get this error</p> <p>Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in user.php on line 248 this is the line</p> <pre><code> function loadUser($userID) { global $db; $res = $db-&gt;getrow("SELECT * FROM `{$this-&gt;dbTable}` WHERE `{$this-&gt;tbFields['userID']}` = '".$this-&gt;escape($userID)."' LIMIT 1"); if ( !$res ) return false; $this-&gt;userData = $res; $this-&gt;userID = $userID; $_SESSION[$this-&gt;sessionVariable] = $this-&gt;userID; return true; } </code></pre> <p>see</p> <pre><code>var_dump($_SESSION); array(1) { ["user"]=&gt; &amp;object(__PHP_Incomplete_Class)#1 (12) { ["__PHP_Incomplete_Class_Name"]=&gt; string(11) "jooria_user" ["dbTable"]=&gt; string(5) "users" ["sessionVariable"]=&gt; string(4) "user" } } </code></pre>
php
[2]
1,009,141
1,009,142
Netbeans IDE Project Deployment
<p>I am unable to deploy an existing project into Netbeans IDE. Could someone guide me? Thanks in advance</p>
java
[1]
3,637,512
3,637,513
Passing variables to another webserver
<p>Is it possible to pass variables from one webserver to another using php? I need to be able to pass variables from a webhost to a local server for processing and I dont know if it can be done.</p>
php
[2]
4,036,607
4,036,608
iPhone UIPickerView issue
<p>Friends I have problem in horizontal UIPickerView. Can some one help me to short this problem out? Actually I got the horizontal picker view but I have problem with data array inside picker view is not clear,its visibility is not good I show you picture what exactly i want sorry i cant add so please help me out. </p> <p><img src="http://i.stack.imgur.com/dSqrs.png" alt="enter image description here"> This is my code:</p> <pre><code>- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ CGRect rect = CGRectMake(0, 0, 180, 30); UILabel *label = [[UILabel alloc]initWithFrame:rect]; CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14/2); rotate = CGAffineTransformScale(rotate, 2.0, 2.0); [label setTransform:rotate]; label.text = [pickerArray objectAtIndex:row]; label.textAlignment = UITextAlignmentCenter; label.numberOfLines = 2; label.font = [UIFont fontWithName:@"Verdana-Bold" size:22]; label.lineBreakMode = UILineBreakModeWordWrap; label.backgroundColor = [UIColor clearColor]; label.clipsToBounds = YES; return label ; } </code></pre>
iphone
[8]
5,665,610
5,665,611
the javascript object model: strange constructor property
<p>I find the behaviour of this piece of code puzzling, why is the constructor of <code>child</code> not <code>Child</code>? Can someone please explain this to me?</p> <pre><code>function Parent() { this.prop1 = "value1"; this.prop2 = "value2"; } function Child() { this.prop1 = "value1b"; this.prop3 = "value3"; } Child.prototype = new Parent(); var child = new Child(); // this is expected console.log(child instanceof Child); //true console.log(child instanceof Parent); //true // what?? console.log(child.constructor == Child); //false console.log(child.constructor == Parent); //true </code></pre>
javascript
[3]
5,980,317
5,980,318
how to pass "this" in c++
<p>I'm confused with the keyword "this" in C++, i'm not sure that if i'm doing the right thing by passing "this". Here is the piece of code that I'm struggling with:</p> <pre><code>ClassA::ClassA( ClassB &amp;b) { b.doSth(this); // trying to call b's routine by passing a pointer to itself, should i use "this"? } ClassB::doSth(ClassA * a) { //do sth } </code></pre>
c++
[6]
3,167,781
3,167,782
Android problem
<p>Hi iam working on android getting the following problem for my login but i didn't got my mistake... The error notice is the application has been terminated unexpectedly</p> <p>my code is</p> <pre><code> package layout.program; import android.app.Activity; import android.os.Bundle; public class Tablelayout extends Activity{ public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.tablelayout); } } </code></pre> <p><strong>tablelayout.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:layout_height="wrap_content" android:text="TextView" android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="wrap_content"&gt;&lt;/TextView&gt; &lt;EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="fill_parent"&gt; &lt;requestFocus&gt;&lt;/requestFocus&gt; &lt;/EditText&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <p><img src="http://i.stack.imgur.com/AQHpE.jpg" alt="snapshot of logcat and emulator"></p>
android
[4]
5,773,716
5,773,717
Two date stamps, echo something for every day in between
<p>Okay say I have two timestamps saved in database in the format yyyymmdd, a start date and end date.</p> <p>say these are my start and end dates: 20110618-20110630</p> <p>How could i make it echo 20110618, 20110619, 20110620 etc all the way to 20110630?</p>
php
[2]
2,007,233
2,007,234
Edit option in Android tableLayout like in iphone UITableView
<p>I need to have an edit option in <strong>tableLayout</strong> just like in iphone <strong>UITableView</strong>. When edit button is clicked a <strong>Delete</strong> button should appear in each row of tableLayout. What I just did was I created a <strong>Delete</strong> button in each row at runtime and made it hide. And when <strong>Edit</strong> button is clicked, <strong>Delete button</strong> gets visible. But I don't think it seems to be a good practice.<br> Is there an inbuilt functionality for this? What is the best practice I should follow? </p> <p>Thanks and regards</p>
android
[4]
4,218,458
4,218,459
Removing fadeOut in jQuery search suggestions
<p>I have a search suggestion script written in jQuery which uses the jQuery framework file to work. The fadeOut function on line 3 is used for hiding the content when there is no text in the search box. However, I do not like the fade function. My question is; How can I removed the fade effect but still make the contents disappear?</p> <p>I have posted a copy of my code here:</p> <pre><code>function lookup(inputString){ if (inputString.length==0){ $('#suggestions').fadeOut(); } else{ $.post("suggestions.php",{ queryString: "" + inputString + "" }, function(data){ $('#suggestions').html(data); }); } } </code></pre> <p>Thanks in advance, Callum</p>
jquery
[5]
4,296,934
4,296,935
new String() in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/390703/what-is-the-purpose-of-the-expression-new-string-in-java">What is the purpose of the expression &ldquo;new String(&hellip;)&rdquo; in Java?</a> </p> </blockquote> <p>I've found some old code that has new String("somestring") in it. Has there ever been a time when this was a good idea?</p>
java
[1]
2,924,978
2,924,979
How to reference an external jar in an Android Library project in Eclipse
<p>Oh Android. How I love your verbiage.</p> <p>I have a workspace with a few projects in it. App1 and App2 are Android applications. Common is an Android library project. App1 and App2 depend upon Common (linked via the Android tab). </p> <p>Common has some external dependencies, namely httpmime &amp; apache-mime4j, which exist as jar files.</p> <p>For some reason, it appears that I need to add my mime jars to the build path of App1 and App2 for compilation to succeed. This seems really dumb. In normal Java, I would add Common to the build path of App1 and App2 and things would work. Is this expected that I have to add my jars to every Android application?</p> <p>-Andy</p> <p>Note: If I don't configure the build path as described above, I get "The type org.apache.james.mime4j.message.SingleBody cannot be resolved. It is indirectly referenced from required .class files | DataCallUtil.java | /App1/Common/util | line 364"</p>
android
[4]
5,814,842
5,814,843
android Audio Recording
<p>I want to Record audio but with some background images in out put file.</p> <p>i tried normal recording function of android but,there out put file in only blank with audio. but i want to add some images to that audio file,how can i do this one.</p> <p>pls help me</p>
android
[4]
4,865,710
4,865,711
how to insert a movie clip into my game?
<p>im making an android game and i want to insert a movie clip (.flv) of exlosion into the game, how do i do that?</p>
android
[4]
1,948,542
1,948,543
Get IP of Visitor, then name a .txt file after the visitor?
<p>I'm trying to create a system that will get the visitors IP, include some information, and then save that information in a .txt file with the file name of like... 10.0.0.1.txt.</p> <p>I'm having some issues with it.</p> <p>Here's some of the code:</p> <pre><code>$logfile = fopen($client_IP, 'a+'); fwrite($logfile, "\n".$_GET['c']); fclose($logfile); </code></pre> <p>$client_IP is basically : </p> <pre><code> $client_IP = $_Server['REMOTE_ADDR']; </code></pre> <p>Can anyone help me out?</p> <p>The output file always either ends up empty, and causes an error stating that the file name cannot be empty, or it just outputs .txt.</p> <p>I've tried multiple variations, but no success so far.</p>
php
[2]
854,631
854,632
Ajax dropdown not working in mobile device
<p>In my Java spring application I have a form with Region drop down. On selection of particular region city list is populated using ajax. This functionality working fine in web browsers. But does not work from an iPhone or Android phone. The second dropdown is not populate. Is any solution for such problem ? Please help.</p>
java
[1]
3,050,688
3,050,689
adding a confirmation box in jquery
<p>I'm trying to make code which will continuously show the confirmation box whenever a mouse movement occurs. I tried many but none are working for me. </p> <p>In my code, I need a confirmation box just having OK and Cancel.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;script type="text/javascript" src="jquery-1.3.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function(){ $("#onediv").mousemove(function(evt){ alert("hai"); }); }); &lt;/script&gt; &lt;style type="text/css"&gt; div{ background-color:orange; border:5px solid black; height:400px; margin:10px } &lt;/style&gt; &lt;/head&gt; &lt;div id="onediv"&gt; sdfas &lt;/div&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
477,578
477,579
JAVA:method and using one class
<p>I want to use different methods in a class. But I know that only the <code>main</code> method will be read by the compiler. So how can I use other methods, objects and data in the <code>main</code> method? Can you give me a simple example?</p>
java
[1]
5,847,074
5,847,075
changing panel color
<p>i have a string which stores the name of a color. Through the help of this variable i need to change the panel background. how can it be done???</p>
java
[1]
3,599,509
3,599,510
array of objects of a class
<pre><code>#include&lt;iostream.h&gt; class test{ int a; char b; public: test() { cout&lt;&lt;"\n\nDefault constructor being called"; } test(int i,char j) { a=i; b=j; cout&lt;&lt;"\n\nConstructor with arguments called"; } }; int main() { test tarray[5]; test newobj(31,'z'); }; </code></pre> <p>In the above code snippet can we initialize values to <code>tarray[5]</code>?</p>
c++
[6]
2,398,162
2,398,163
Best matches for a partially specified word in Python
<p>I have a file dict.txt that has all words in the English language.</p> <p>The user will input their word:</p> <p><code>x = raw_input("Enter partial word: ")</code></p> <p>Example inputs would be: r-n, --n, -u-, he--o, h-llo and so on, unknown characters would be specified by a underscore preferably instead of (-).</p> <p>I want the program to come up with a list, of all the best matches that are found in the dictionary.</p> <p>Example: If partial word was r--, the list would contain run, ran, rat, rob and so on.</p> <p>Is there any way to do this using for loops?</p>
python
[7]
1,267,378
1,267,379
Does JMF have support with Xuggler
<p>i am working on a project consisting of sending and receiving streaming multimedia.So,i have installed JMF, but i have seen that JMF has 32 bit library as mine is 64 bit so i wanted to use Xuggler for streaming videos.</p> <p>Can anyone clarify me about the support of Java Media FrameWork with Xuggler.. </p>
java
[1]
2,489,076
2,489,077
How can I include files using paths relative to where the file resides?
<p>Imagine I have two directories, <strong>foo</strong> and <strong>bar</strong> in a parent directory, and these directories contain some PHP files:</p> <pre><code>/ /index.php /foo /foo/functions.php /foo/stuff.php /bar /bar/doodie.php </code></pre> <p>Let's say:</p> <ol> <li><code>functions.php</code> includes <code>stuff.php</code></li> <li><code>index.php</code> includes <code>functions.php</code></li> <li><code>doodie.php</code> includes <code>functions.php</code></li> </ol> <p>Based upon this structure, when <code>index.php</code> is run, it will look for <code>/foo/functions.php</code>in the <code>/foo</code> directory. <strong>However</strong>, <code>stuff.php</code> must be included using the relative path according to the location of <code>index.php</code>. This works, in the case of when <code>index.php</code> is run. <strong>It doesn't work</strong> when <code>doodie.php</code> is called because <code>functions.php</code> looks for <code>stuff.php</code> in the <code>/foo</code> directory, which doesn't exist when the location is <code>/bar</code>.</p> <p>Is it possible to include files according to where they reside instead of where they are called from, without using absolute paths (and <a href="http://stackoverflow.com/a/3243015/613857">session variables</a>)?</p> <p>I apologize if this wasn't clear, it was really tough to describe this...</p>
php
[2]
207,101
207,102
jQueryUI buttonset style issue
<p>I'm working on a buttonset, here's the normal one, <a href="http://s11.postimage.org/sieamntpv/buttonset2.png" rel="nofollow">photo</a></p> <p>So, after applying some UI style, I get the buttons styled, but please check the next <a href="http://s13.postimage.org/lx8rmiw3b/buttonset1.png" rel="nofollow">image</a>... A weird button-dot appears on the left side. (if I click on it, the buttonset activates button #3)</p> <p>I have to say that this weird little button only appears using Chrome, if I browse it using IE, it's 100% fine. </p> <p>The code for the buttonset is pretty simple, </p> <p><strong>//JS</strong></p> <pre><code>$(document).ready(function () { $("#radio").buttonset(); }); </code></pre> <p><strong>//HTML</strong></p> <pre><code>&lt;div id="radio" align="center"&gt; &lt;input type="radio" id="radio1" runat="server" value="BtnNextCaseClick" name="radio" checked="true"/&gt;&lt;label for="radio1" style="width: 109px; margin-right:-.9em"&gt;Siguiente Caso&lt;/label&gt; &lt;input type="radio" id="radio2" runat="server" value="CloseCaseAndBandeja" name="radio" /&gt;&lt;label for="radio2" style="margin-right:-.9em"&gt;Terminar Caso y Cerrar Bandeja&lt;/label&gt; &lt;input type="radio" id="radio3" runat="server" value="CloseBandeja" name="radio"/&gt;&lt;label for="radio3" style="width: 109px"&gt;Cerrar Bandeja&lt;/label&gt; &lt;/div&gt; </code></pre> <p>Any idea on how to remove that style error?</p>
jquery
[5]
4,409,077
4,409,078
preg_match_all() how to display results? array to string conversion error
<p>I've tried learning this but for whatever reason it just does not work.</p> <p>I have the following:</p> <p><li><b> text here: </b> 5.3 x 6.0 x 40 metres </li></p> <p>which in code is:</p> <pre><code>&lt;li&gt;&lt;b&gt; text here: &lt;/b&gt; 5.3 x 6.0 x 40 metres &lt;/li&gt; </code></pre> <p>This HTML is in a variable let's call it $dimensions I'm trying to extract the <code>5.3 x 6.0 x 40 metres</code> with a preg_match_all, ideally extracting the dimensions and also the measurement but I'm having trouble echoing the results. It says array conversion to string error each time despite the size of matches being 5. Any Ideas what's going on? </p> <pre><code>preg_match_all('/\&lt;li\&gt;([0-9]*\.*[0-9]*)x([0-9]*\.*[0-9]*)x([0-9]*\.*[0-9]*) \s*([a-zA-Z]*)\&lt;\/li\&gt;/',$dimensions,$matches,PREG_PATTERN_ORDER); echo sizeof($matches); echo($matches[0]); </code></pre> <p>EDIT:</p> <p>As suggested by an answer below: someone said use var_dump($matches) to see what the array contains... Turns out I have 4 empty arrays, which brings up the next question. what is wrong with my preg_match_all?</p> <pre><code>array (size=5) 0 =&gt; array (size=0) empty 1 =&gt; array (size=0) empty 2 =&gt; array (size=0) empty 3 =&gt; array (size=0) empty 4 =&gt; array (size=0) empty </code></pre>
php
[2]
2,588,925
2,588,926
Printing Script Codes
<p>I wanna print out script's codes after the output.</p> <p>The script goes on different ways on the way it calls. So i wanna see it when script runs. is there any function that prints all script codes as the way it writed.</p> <p>Example:</p> <pre><code>$foo = "bar"; $foo .= " is my bar"; function foobar() { // do some stuff here } </code></pre> <p>i wanna see the codes just like this. is there a way to do this? without file_get_contents(), file(), readfile() functions?</p>
php
[2]
584,131
584,132
Microsoft Expression SDK
<p>I'm converting mp3 to wma with expression encoder sdk 4 with the code below</p> <p>A wma file is produced but it is missing the thumbnail / image / cover from the mp3 file.</p> <pre><code>using (var job = new Job()) { var mediaItem = new MediaItem(input.FullName) { OutputFileName = outputFileName, OutputFormat = { AudioProfile = { Codec = AudioCodec.Wma, Bitrate = BitRate ?? BitRate, Channels = 1 } } }; job.MediaItems.Add(mediaItem); job.OutputDirectory = OutputDirectory; job.CreateSubfolder = false; job.Encode(); } </code></pre> <p>I have tried the following:</p> <p>1)</p> <pre><code>mediaItem.MarkerThumbnailCodec = ImageFormat.Jpeg; mediaItem.MarkerThumbnailJpegCompression = 0; mediaItem.MarkerThumbnailSize = new Size(50, 50); </code></pre> <p>2)</p> <pre><code>mediaItem.ThumbnailCodec = ImageFormat.Jpeg; mediaItem.ThumbnailEmbed = true; mediaItem.ThumbnailJpegCompression = 50; mediaItem.ThumbnailMode = ThumbnailMode.BestFrame; mediaItem.ThumbnailSize = new Size(50, 50); mediaItem.ThumbnailTime = TimeSpan.FromSeconds(0); </code></pre> <p>3)</p> <pre><code>mediaItem.OverlayFileName = @"c:\Chrysanthemum.jpg"; mediaItem.OverlayStartTime = TimeSpan.FromSeconds(0); </code></pre> <p>..but it doesn't help.</p> <p>Please help me :)</p>
c#
[0]
5,027,990
5,027,991
how to apply watermark property on string value?
<p>i am using following line for printing <code>DB value</code> if true or <code>Not Applicable</code> if false using ternary operator. </p> <pre><code>dReader = cmd_last.ExecuteReader(); if (dReader.HasRows == true) { while (dReader.Read()) { jms_final = ((dReader["jms"].ToString().Equals("") || dReader["jms"].ToString().Equals(string.Empty) || dReader["jms"].ToString().Equals(null)) ? (SetWatermark("Not Applicable")) : (dReader["jms"].ToString())); } } </code></pre> <p>but here i want to print the Not Applicable word in faded color like watermark property. so how can i apply directly on string? please help me out.</p>
c#
[0]
3,933,725
3,933,726
Implementing IDisposable in File.Delete method?
<p>I want to delete a file on my computer but the app throws an exception that The directory is busy. My first thought is to implement a dispose method in my class which does a file delete. Knows anybody how to do this? </p> <p>It's actually a Picturebox which displays a image and if you click on a button beside the image you can remove it, thus deleting it. It's propably that which blocks my filepath.</p> <pre><code>picobx.Image = Image.FromFile(//path) </code></pre> <p>Is there any solution to this? </p> <p>PS. I want to dispose the resource so that I can delete... </p> <p>do like this: </p> <pre><code>File.Delete(// path ) </code></pre>
c#
[0]
1,063,900
1,063,901
How do I convert a decimal to a string without replacing decimals?
<p>I have an object, <code>CellData</code>, that is equal to <code>-0.000009482102880653542</code>.</p> <p>I want to display as is when exporting it as a <code>.csv</code> file. To do that I have to convert the object to a string.</p> <pre><code>output = CellData.ToString(); output = string.Format("{0}", CellData); </code></pre> <p>The above two cases result in <code>output</code> being <code>-9.48210288065354E-06</code>. I would like it to return <code>output</code> as <code>-0.0000094821028806535423</code> (with decimals).</p> <p>Is there anyway I can get this working?</p>
c#
[0]
3,664,269
3,664,270
Simple way to render tuples to a table in ASP.NET 2.0?
<p>Say I have a data structure like a <code>Dictionary&lt;string, Dictionary&lt;string, int&gt;&gt;</code> or similar, and I want to render this as an HTML table with row-headers as the first string key, and column headers as the second string key. Is there a built-in or other Control for this?</p>
asp.net
[9]
1,543,466
1,543,467
Popup window content refreshes once the window is maximized
<p>When I open a popup window with large content in IE, the popup window comes with a scrollbar to fit the content. But when I maximize the page in that case it also remains the same. It is a page with frameset and frames. So is it possible the resize the frame?</p>
javascript
[3]
2,579,050
2,579,051
how to block or engage lines completely on android programmatically?
<p>In my present application which i am developing i need to engage phone lines completely till my application is running(i.e. i should not receive any call or sms and i myself shouldn't be able to call or send sms) and as soon as my application exits the service should be returned suggest me a way to do this thanks in advance!</p>
android
[4]
1,047,605
1,047,606
Except the input check box i need to disable all other input using jquery
<pre><code>$('fieldset').not('#Pchk input[type=checkbox]').find("input,select,textarea").attr('disabled','disabled'); </code></pre> <p>Pchk is the id of my input checkbox </p> <p>and even i did this code to its not working out for me..</p> <pre><code>$('fieldset').not(':checkbox').find("input,select,textarea").attr('disabled','disabled'); </code></pre> <p>if I use this code its disabling even my checkbox from fieldset? this code is right?</p> <p>thanks</p>
jquery
[5]