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,069,291
4,069,292
Code not getting hot swapped in emulator
<p>everything was working fine, suddenly hot swap of code is not working. after i change anything in the code and rebuild and launch, console flashes this error:</p> <blockquote> <p>Installation error: INSTALL_FAILED_CONTAINER_ERROR Please check logcat output for more details. Launch canceled!</p> </blockquote> <p>here is the logcat: <img src="http://i.stack.imgur.com/EOPrb.png" alt="enter image description here"></p> <p>I have to again and again resstart emulator to see my changes! I have tried restarting adb, wipe user data but :(</p>
android
[4]
1,020,427
1,020,428
changing the background color of custom cell
<p>It looks simple thing but i dont know why i am not able to change the background color of a custom tag on which i am working. Please check my code below for the custom cell.</p> <pre><code>- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { self.textLabel.backgroundColor = [UIColor clearColor]; self.textLabel.textColor = [UIColor orangeColor]; self.textLabel.text = @"lklklk"; self.accessoryType = UITableViewCellAccessoryDisclosureIndicator; self.contentView.backgroundColor = [UIColor blackColor]; self.accessoryView.backgroundColor = [UIColor blackColor]; } return self; } </code></pre> <p>The cell is only displaying the above text with white backgroud</p> <p>Thanks in advance</p>
iphone
[8]
5,803,632
5,803,633
Selecting all children and decendants with jQuery
<p>I have some HTML that is being produced by a WordPress plugin that is designed to allow for expandable/collapsible text, with up to three levels of depth. I would like it so that if you were to collapse the first or second levels and the children below it were also expanded those too would get collapsed but nothing I use seems to allow the selection of <em>all</em> children. This is what I'm using so far:</p> <pre><code>$(".hidden-text-toggle").click(function () { if ($(".hidden-text:animated").length) return false; $(this).next().slideToggle(); if ($(this).hasClass('expanded') ){ $(this).removeClass('expanded'); $(this).animate({ backgroundColor: "black" , color: "red"}); } else { $(this).addClass('expanded'); $(this).animate({backgroundColor: "red" , color: "black"}); } return false; }); &lt;div class="wrapper"&gt; &lt;h2 class="title"&gt;Level One&lt;/h2&gt; &lt;div class="text" href="#"&gt; This is level one text. &lt;div class="wrapper"&gt; &lt;h2 class="title" href="#"&gt;Level Two&lt;/h2&gt; &lt;div class="text"&gt; This is level two text. &lt;div class="wrapper"&gt; &lt;h2 class="title" href="#"&gt;Level Three&lt;/h2&gt; &lt;div class="text"&gt; This is level three text. &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I would have thought that putting something like <code>$(this).find(".text").slideUp();</code> after line 4 would allow this but apparently I am wrong. </p> <p>Any help would be much appreciated!</p>
jquery
[5]
1,615,502
1,615,503
How to set different images alternately in listView's row?
<p>I have a listview, in which I am fetching data from Twitter, I also show it in listView, but I want to show different images in different rows of listView.</p> <p>I used <code>convert-view.setBackGroundResource(R.drawable.strip1);</code>, it repeats this image in all rows, but I want to set it alternatively. How is it possible?</p>
android
[4]
4,539,145
4,539,146
Editing an asp.net DropdownList
<p>I have a dropdown list of 5 elements. My problem is that I want to make this dropdown list editable. Basically a user might want to delete one of these elements or might want to add more elements. Whats a good approach of doing that in asp.net ?</p>
asp.net
[9]
1,439,241
1,439,242
CONVERT MM/DD/YYYY HH:MI:SS AM/PM to DD/MM/YYYY in C#
<p>How can I convert MM/DD/YYYY HH:MI:SS AM/PM into DD/MM/YYYY using C# ?I am using C#2008.</p> <p>Thanks</p>
c#
[0]
5,307,797
5,307,798
How to Integrate yahoo calendar on ASP .NET Application
<p>I am working on a project where we would like to sync users events(Appointments) within our site with their yahoo calendar. Does anyone know if this is even supported?Any help would be greatly appreciated.</p>
asp.net
[9]
3,412,844
3,412,845
android download files problem
<p>i wanna download files in my application ,</p> <p>so i used threads to download , </p> <p>but i found that if i close application , the downloading stopped.</p> <p>should i use 「service」 to implement downloading?? or something else ??</p> <p>could someone give me suggestions?</p>
android
[4]
1,677,821
1,677,822
Count the number of rows in a database from an activity outside the adapter
<p>Trying to get a count of the rows in a database from a separate activity. I have been messing with the methods to do so, but I can't seem to instantiate them from another activity if the method is built in the database adapter class. Ideally, I would like the method in the adapter to return an int that I can then use in a number of different activities down the chain. Is there a way to do this that I am not thinking of? </p>
android
[4]
2,863,055
2,863,056
jQuery - Changing the src of another image on rollover
<p>Im wondering if someone could help me .... I have 2 images, and i want to be able to change the src of one when i rollover the other one if that makes sense.</p> <p>for example, i have 2 images</p> <p></p> <p></p> <p>When someone hovers over 'imimage2.jpg' i want 'imimage1.jpg' to change to 'imanewimage.jpg'</p> <p>Is that possible with jQuery?</p> <p>Cheers,</p>
jquery
[5]
2,880,254
2,880,255
Notification bubbles from nothing in C#
<p>in a C# application that has no graphics at all, and does a bunch of network operations, I need to be able to show notification bubbles (on top of everything, for a few seconds) near the icon tray on certain events.</p> <p>I've been looking at this : <a href="http://www.codeproject.com/KB/miscctrl/taskbarnotifier.aspx" rel="nofollow">http://www.codeproject.com/KB/miscctrl/taskbarnotifier.aspx</a></p> <p>But with no success. The problem with it is that the windows designed there won't show on asynchroneous events. It seems that I need a main form first on which I add delegates for it to work, which I have no need for. </p> <p>All options I've seen so far require me to have a form in my application, but that won't happen. Is it impossible then to have these bubbles ? Any ideas ? There must be a way to add an icon in the tray popping messages inconditionally and without GUI right ?</p>
c#
[0]
1,940,562
1,940,563
How to capture and convert textbox into pdf file format?
<p>I want to capture my text box and convert it into the PDF format.<br> I tried the following code, but it captures the whole screen. How can I capture only my textbox values?</p> <ol> <li><p>Code:</p> <pre><code>try { Rectangle bounds = this.Bounds; using (var bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); } bitmap.Save("C://Rectangle.bmp", ImageFormat.Bmp); } } catch (Exception e) { MessageBox.Show(e.Message.ToString()); } </code></pre></li> <li><p>for exporting pdf:</p> <pre><code>captureScreen(); var doc = new PdfDocument(); var oPage = new PdfPage(); doc.Pages.Add(oPage); oPage.Rotate = 90; XGraphics xgr = XGraphics.FromPdfPage(oPage); XImage img = XImage.FromFile(@"C://Rectangle.bmp"); xgr.DrawImage(img, 0, 0); doc.Save("C://RectangleDocument.pdf"); doc.Close(); </code></pre></li> </ol>
c#
[0]
2,703,608
2,703,609
can we get the ready made setting bundle?
<p>can i get setting bundle ready made so it can easily deploy in my app</p>
iphone
[8]
2,347,950
2,347,951
Whats the difference between theese two java code snippets?
<p>I have this code i am doing for university. The first code works as expected, the second one provides different results.</p> <p>I can not see what they are doing differently??</p> <p>first:</p> <pre><code>public Mat3 getNormalMatrix() { return new Mat3(this.getInverseMatrix()).transpose(); } </code></pre> <p>second:</p> <pre><code>public Mat3 getNormalMatrix() { Mat4 mat = this.getInverseMatrix(); Mat3 bla = new Mat3(mat); bla.transpose(); return bla; } </code></pre>
java
[1]
3,212,575
3,212,576
In a Python class, what is the difference between creating a variable with the self syntax, and creating one without ?
<p>What is the difference between creating a variable using the self.variable syntax and creating one without? </p> <p>I was testing it out and I can still access both from an instance: </p> <pre><code>class TestClass(object): j = 10 def __init__(self): self.i = 20 if __name__ == '__main__': testInstance = TestClass() print testInstance.i print testInstance.j </code></pre> <p>However, if I swap the location of the <code>self</code>, it results in an error. </p> <pre><code>class TestClass(object): self.j = 10 def __init__(self): i = 20 if __name__ == '__main__': testInstance = TestClass() print testInstance.i print testInstance.j &gt;&gt;NameError: name 'self' is not defined </code></pre> <p>So I gather that self has a special role in initialization.. but, I just don't quite get what it is.</p>
python
[7]
5,697,590
5,697,591
how to add tableview on scrollview programtically
<p>I have created one tableview programmatically. But i want to enable horizontal scroll for that tableview.So i think i need to add first scrollview programmatically and then on that scrollview i need to add tableview which i have created.Please help me how to do this or correct me if i am going wrong.</p>
iphone
[8]
3,908,184
3,908,185
How can i implement Feature Like "Precache Map Area" as like Google Map
<p>Can I Implement Feature Like <code>"Cache Google Map Tile" or "Precache Map Area"</code> which is in Google Maps?</p> <p>In Latest Google Maps Update, There is a option like <code>"Precache Map Area"</code> So i want to implement this Feature in My Own Application and on My Own Device. So can i Do this Using Google Android Open Source Code which is available on android Developer Website?? </p> <p>Basically want to see google map in offline mode, means i want to get Map from Cache Map Tile when GPRS or Wifi is not there. </p> <p>So can i save this google map tile to cache and use this map in future.?? Please Suggest me the way so if possible than i will proceed for next. </p> <p>Thanks Saurabh Patel </p>
android
[4]
3,517,509
3,517,510
When I change a parameter inside a function, does it change for the caller, too?
<p>I have written a function below:</p> <pre><code>void trans(double x,double y,double theta,double m,double n) { m=cos(theta)*x+sin(theta)*y; n=-sin(theta)*x+cos(theta)*y; } </code></pre> <p>If I call them in the same file by </p> <pre><code>trans(center_x,center_y,angle,xc,yc); </code></pre> <p>will the value of <code>xc</code> and <code>yc</code> change? If not, what should I do?</p>
c++
[6]
1,992,819
1,992,820
How to hide a value in a textbox?
<p>I am showing the value in the textbox.The value comes from the databse first I store it in the variable.I have three radio buttons and when the <strong>user click third radio button</strong> the textbox going to be disabled.<strong>At the time I want to hide the textbox value displayed within the textbox.</strong>But not to set NULL.How can I do <strong>Using Jquery</strong>?</p>
jquery
[5]
1,207,941
1,207,942
How to pass string from onListItemClick event to onButtonClick event of the same activity in android?
<p>I have to pass value of a string variable once the the list item is clicked to button click event of the same activity so that i can use it's value.Actually the value is passed and i am able to see in a toast but if i try to display in textveiw .It does't show.Basically i want to check its value with sqlite database so i want its value.Pleas help me!!! </p>
android
[4]
2,636,263
2,636,264
php API throttle (users/request)
<p>First off all this question is answered here: <a href="http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users/1500309#1500309">How do I throttle my site&#39;s API users?</a></p> <p>But i cannot understand what value it should give here:</p> <pre><code>$minute_throttle = $this-&gt;get_throttle_minute(); # get from the DB </code></pre> <p>Maybe even script author could help or provide more information regarding this question.</p>
php
[2]
2,273,281
2,273,282
why does python os.path.isfile seem to ignore certain file types?
<p>simple script on a unix system (Mac) which seems to only return certain files True. Can't figure out why:</p> <pre><code>workdir = '/Volumes/place/sub place' def myFunc(bla, dir, flist): for f in flist: print f, os.path.isfile(f) os.path.walk(workdir,myFunc,None) </code></pre> <p>Returns:</p> <pre><code>tests.py False utils.py False utils.pyc False writeXmlForMpgInPath.py False .DS_Store True Playout False Playout Masters False Projects False ProRes Masters False Source False Sydney Playout Masters False Web Preview False .AU009644-M.xml.swp False .DS_Store True .DS_Store True .DS_Store True .DS_Store True </code></pre>
python
[7]
3,349,493
3,349,494
Passing a function return result into a foreach loop
<p>Out of curiosity, are the two options below functionally equivalent?</p> <pre><code>$array_variable = function_that_creates_an_array(); foreach($array_variable as $a){ do_something() } </code></pre> <p>vs.</p> <pre><code>foreach(function_that_creates_an_array() as $a){ do_something() } </code></pre> <p>Just want to make sure I'm not calling the function on every iteration or anything dumb like that.</p> <p>Thanks!</p>
php
[2]
882,564
882,565
A panel to configure JavaScript parameters on a website
<p>I am looking for a library that would create a "settings panel" with configurable amount of sliders, checkboxes, etc and add it to a website. After a slider or checkbox is changed in the panel, a callback function would be executed.</p> <p>Rationale: I am building a canvas demo and I don't want to spend time on writing my own set of controls for configurable parameters. I want to outsource this job to a small library that does it right.</p> <p>I saw such thing few months ago but I cannot find it now.</p>
javascript
[3]
2,444,163
2,444,164
When not to use a private field?
<p>When should it be considered dangerous to use a <strong>private</strong> field all over the place in the methods of your class? I mostly just create the variable and set it to a default value like null. Then in my methods reference it and set it to an instance of that object type from the methods.</p> <p>I don't know if my question makes sense but let me know if it doesn't and I'll clarify.</p>
c#
[0]
1,925,744
1,925,745
Java checking no of days in a month and adding dates that are missing
<p>Hi I have the following arraylist strings of dates</p> <p>["2010-08-01","2010-08-02","2010-08-04","2010-08-05","2010-08-06","2010-08-07","2010-08-08","2010-08-09","2010-08-11","2010-08-12","2010-08-13","2010-08-14","2010-08-15","2010-08-17","2010-08-18","2010-08-20","2010-08-21","2010-08-26","2010-08-28","2010-08-29"]</p> <p>I have 2 aims that I want to achieve,</p> <p>1) how to get the number of days for each month based on the year and month above? 2) how to add in the missing date(same format as above) for the entire sequence of dates strings above? For eg: 2010-08-01,2010-08-02,2010-08-04 -->I should add in 2010-08-03 in between 2010-08-02 and 2010-08-04</p> <p>Thanks!</p>
java
[1]
1,580,029
1,580,030
opening file with php not working
<p>Why does:</p> <pre><code>$test='tester.txt'; $bigarr=str_getcsv($test,','); print_r($bigarr); </code></pre> <p><code>texter.txt</code> contains: <code>one,two,three,four</code></p> <p>Not work please?</p> <p>EDIT: It outputs just 'tester.txt' and does not put the individual elements into an array like it is supposed to...</p>
php
[2]
3,551,311
3,551,312
jQuery to flip div 180 degrees
<p>Bascially trying to show a series of cards similar to playing cards or Tarot which each have a unique picture or image on one side and a text description on the other.</p> <p>When page is loaded the image will show first off but on clicking a button the card will flip 180 degrees to show a text description of the card/image.</p> <p>So therefore I guess it's a question of flipping the image in 3d while revealing the div behind. Looked at the Cycle plugin but not sure it is what is needed.</p> <p>Anyone any ideas?</p>
jquery
[5]
2,640,928
2,640,929
passing value to function
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7998209/pass-by-reference-in-java">pass by reference in java</a> </p> </blockquote> <p>I am new to java. I tried to search a lot for my query but could not find. Please help me if you know. I have a function:</p> <pre><code>boolean func(int a, int b, myclass obj1, myclass2 obj2) { ... } void caller() { int a = 0, b=0; myclass obj1 = null; myclass1 obj2 = null; func(a,b,obj1,obj2); if (a == 5 &amp;&amp; b ==2) { ... } } </code></pre> <p>what should i do such that all passed variables have the value in caller function which was given by function func?</p>
java
[1]
2,794,353
2,794,354
Using the Android Pattern Lock screen as a LOG-in to my android application
<p>I am making an Android application and I want dat the entry into the application should be protected by keeping the pattern lock screen as a LOG-in. Is it possible to use the Android pattern lock screen as a Log-in to our own made applications... If possible HOW...?</p>
android
[4]
650,823
650,824
Iphone - how to programmatically answer a call
<p>I saw this application on Cydia ( forgot the name) that will answer/ reject a call when you shake the phone. Any ideea how is it done ? Couldn't find anything in SDK.</p> <p>Thanks</p>
iphone
[8]
4,374,209
4,374,210
Is binding a click event to document better than binding it to body?
<p>The question is simply between</p> <p><code>$("body").click(function(e){});</code> vs <code>$(document).click(function(e){});</code></p> <p>which is more efficient or advisable? Or does it depend on the situation?</p> <p>Honestly I have used them both interchangeably and haven't seen any differences until I got curious and asked this question here.</p>
jquery
[5]
1,939,865
1,939,866
How to exit a loop on condition?
<pre><code>$arr = array(1, 2, 3, 4); foreach ($arr as $value) { $i=0; if($i==1||$i==2){continue;} echo $value; $i++; } </code></pre> <p>I am a newbie of PHP, now i do a test, and i want to go out the loop not output 2 and 3, why the above code doesn't work?</p>
php
[2]
3,537,133
3,537,134
Hide select field on external click
<p>I am wondering how should I hide a drop down list by clicking on anywhere in page, I want same function like select field (<code>&lt;select&gt;&lt;/select&gt;</code>) do, if we open any select field and then click anywhere in page it pop back.</p> <p>Let me know if my question is not clear.</p> <p>Thanks.</p>
jquery
[5]
5,322,634
5,322,635
Double while loop to read a text file
<p>Is it possible to read a text file with a double while/for loop? </p> <p>I'd like to do something like this:</p> <pre><code>for( String row1 = 0; row1 &lt; file.length; row1++ ) { for( String row2 = row1 + 1; row2 &lt; file.length; row2++ ){ if( file[row1] == file[row2] ){ // other code } } } </code></pre> <p>I need a double loop because I have to find a duplicate row in the file with 2.500.000 rows. I can't use a Set to save the rows because the heap size is insufficient and if I try to increase it, I get this error: "Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.." (I've got a Windows 7 64 bit and 8 GB Ram)</p> <p>Thanks in advance</p>
java
[1]
4,757,087
4,757,088
Is there a way to invoke a static method of a class using a string which has the name of the class?
<p>I have an array of strings containing names of classes. Is it possible to invoke the static methods of the actual class using the 'name of the class' in the string array.</p> <pre><code>public class SortCompare { // There are classes called 'Insertion', 'Selection' and 'Shell' which have a // method called 'sort' private static String[] algorithm = { "Insertion", "Selection", "Shell"}; public static double timeTheRun(String alg, Comparable[] a) { for (int i = 0; i &lt; algorithm.length; i++) if (alg.equalsIgnoreCase(algorithm[i])) { Stopwatch timer = new Stopwatch(); // I want to invoke one of Insertion.sort(), Selection.sort() // or Shell.sort() depending on the value of 'alg' here break; } return timer.elapsedTime(); } </code></pre> <p>I could forget about the array of strings and simple use a if-else block to invoke them.</p> <pre><code> if (alg.equals("Insertion")) Insertion.sort(a); else if (alg.equals("Selection")) Selection.sort(a); else if (alg.equals("Shell")) Shell.sort(a); </code></pre> <p>But I will keep implementing other sorts and variations of them in future and every time I will have to make changes in multiple places(The above if-else loop, the help message of my program). If the former approach is possible then I'll just have to insert an extra string to the array every time.</p>
java
[1]
293,532
293,533
How can I copy value from ostringstream to string?
<p>I tried :</p> <pre><code>ostringstream oss; read a string from file and put to oss; string str; str &lt;&lt; oss.str();// error here "error: no match for ‘operator&gt;&gt;’ in 'oss &gt;&gt; str' " </code></pre> <p>If I use <code>str = oss.str();</code> Instead of printing the value of the string, it prints out <code>"....0xbfad75c40xbfad75c40xbf...."</code> likes memory address.<br/> Can anybody tell me why? Thank you.</p>
c++
[6]
5,281,009
5,281,010
change label text in usercontrol at run time
<p>hello i m new to c# and im working on a project,in which i made a usercontrol1 as *<em>label textbox datepicker</em>*now i wnt to change the label text,i m trying this code but it is not working</p> <pre><code>using System; using System.Windows.Forms; namespace library_system { public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } // private string DateLabel public string DateLabel { **get { return DateLabel.Text; }//error when i write dateLabel.Text set { DateLabel.Text= value;//error datelabel.Text }** } </code></pre> <p>i m using this code in usercontrol for is it right to do this way??</p> <p>and in the main form i m writing code as <code>userControl11.DateLabel="From Date</code>";//on for load event??Is this Right Thanks in advance!!</p>
c#
[0]
5,202,003
5,202,004
Get inner list from list of list C#
<p>I am working with C# and I have a following </p> <pre><code>List&lt;List&lt;UserObj&gt;&gt; obj; </code></pre> <p>How do I get the inner list (<code>List&lt;UserObj&gt;</code>) of obj?</p> <p>Thanks.</p>
c#
[0]
328,521
328,522
custom listview over an exsisting activity
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4547511/how-can-i-display-a-listview-on-the-top-of-another-activity-in-android">how can i display a listview on the top of another activity in Android</a> </p> </blockquote> <p>hi..i want to display a custom list view on one existing activity so that the custom list view will cover half screen of the existing activity without interrupting the actions of the existing activity...how can i do that..can any one pls help me thanks for help.</p>
android
[4]
1,523,305
1,523,306
how Open Dialog from BroadcastReceiver class
<p>I want to open dialog from BroadcastReceiver but it gives an error.</p> <p>Here is my code:</p> <pre><code>final Dialog mydata= new Dialog(context); mydata.getWindow().setFlags( WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); mydata.setTitle(" Library Information "); LayoutInflater li = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogView = li.inflate(R.layout.singup, null); mydata.setContentView(dialogView); mydata.show(); java.lang.RuntimeException: Unable to start receiver com.om.dave.MyBroadcastReceiver: android.content.res.Resources$NotFoundException: Resource ID #0x7f030001 </code></pre> <p>How do I open dialog Broadcastreceiver?</p>
android
[4]
5,888,335
5,888,336
How to read the client MAC Address using NetworkInterface in Java
<blockquote> <p>I have a code that reads the LocalHost Mac Address. The code is being called from the Servlet or JSP.<br /> But failed to read the address of REMOTE HOST or Client. I am using the NetworkInterface class to implement the functionality.<br /> One reason which I understand that its reading the localhost address is - able to Lookup the LocalHost address, but failed to lookup or do the reverse dns search on the Remote Host. <br /></p> </blockquote> <pre><code> InetAddress addr = InetAddress.getByName(clientIP); NetworkInterface ni = NetworkInterface.getByInetAddress(addr); if (ni == null) { throw new SocketException("Cannot reach the host ##"+clientIP+"."); // Throws exception here for REMOTE Host or CLient } byte[] macAddrs = ni.getHardwareAddress(); if (macAddrs == null) { throw new UnknownHostException("Host IP Adrress Lookup Failed..."); } for (int k = 0; k &lt; macAddrs.length; k++) { String macValue = String.format("%02X%s", macAddrs[k], (k &lt; macAddrs.length - 1) ? "-" : ""); macAddress.append(macValue); } </code></pre>
java
[1]
5,072,141
5,072,142
How to use custom functions in QT4 for slots
<p>Currently I'm working on a class project where I'm making an asteroids game, and what I'm trying to figure out is how to use a custom function for a slot so when an Open QAction in a QMenu is clicked, that function is called. From what I understand, writing your own custom functions isn't possible, but is it possible to overload another function such as AboutQT to do what I want it to do? I am able to use the quit() function in there with this line for my Close QAction:</p> <p>connect(closeSubAction, SIGNAL(triggered()), qApp, SLOT(quit()));</p> <p>but I want to make one where quit() can be replaced by another function or make a predefined function do something different.</p>
c++
[6]
976,861
976,862
allow specific extension in forms authentication
<p>I am using forms authentication with </p> <p> </p> <pre><code>&lt;authorization&gt; &lt;deny users="?" /&gt; &lt;/authorization&gt; </code></pre> <p>However, I want to allow all calls made for specific extension say *.abc.</p> <p>I tried:</p> <pre><code>&lt;location path=".abc"&gt; &lt;system.web&gt; &lt;authorization&gt; &lt;allow users="*"/&gt; &lt;/authorization&gt; &lt;/system.web&gt; </code></pre> <p></p> <p>but wildcards are not allowed.</p> <p>How can I allow *.abc calls to work for all users? Is there any web.config element I can use OR anything I can do in AuthenticateRequest httpmodule?</p>
asp.net
[9]
2,171,421
2,171,422
PHP shorthand rewrite
<p>Probably really easy for a pro, but could someone re-write this from it's PHP shorthand form to non-shorthand?</p> <pre><code>($facebook) ? $fb_active_session = $facebook-&gt;fbc_is_session_active() : $fb_active_session = false; </code></pre> <p>Thanks!</p>
php
[2]
1,688,773
1,688,774
insert null value when no selected value from ddl
<p>I had ddl which determine gender and user can donot choose any value from ddl so i tried to check if user didnot select any value from ddl inser null value or any value in database i made that but error apear(Procedure or Function 'InsertRegisteration' expects parameter '@Gender_Id', which was not supplied).any one help me</p> <p>(My Code)</p> <pre><code> if (DDLGender.SelectedItem.Value[0]!= null ) { command.Parameters.Add("@Gender_Id",SqlDbType.Int).Value=null; } else { command.Parameters.Add(Parameter.NewInt("@Gender_Id", DDLGender.SelectedValue)); } </code></pre>
c#
[0]
4,942,138
4,942,139
php API throttle (users/request)
<p>First off all this question is answered here: <a href="http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users/1500309#1500309">How do I throttle my site&#39;s API users?</a></p> <p>But i cannot understand what value it should give here:</p> <pre><code>$minute_throttle = $this-&gt;get_throttle_minute(); # get from the DB </code></pre> <p>Maybe even script author could help or provide more information regarding this question.</p>
php
[2]
2,069,644
2,069,645
Adding formatting tags to textbox value
<p>In my form I want to allow the user to format text and add lists and such (basic html functionality, without having to know html).</p> <p>Using the Bold button as an example:</p> <pre><code>&lt;div class="goBold button"&gt;B&lt;/div&gt; &lt;input type="text" name="txtMessage" /&gt; &lt;script&gt; $(".goBold").click(function() { formatText("bold"); }); function formatText(formatType) { var input = $("#txtMessage"); var text = input.val(); var ss = input[0].selectionStart; var se = input[0].selectionEnd; if (formatType == "bold") { if (ss == se) { // there's no text in the textbox, so just write in the tags input.val(text + "[b][/b]"); } else { // surround the highlighted text with the tags input.val(text.substr(0, ss) + "[b]" + text.substr(ss, se) + "[/b]" + text.substring(se, text.length)); } } } &lt;/script&gt; </code></pre> <p>While all this works, there is a slight problem:</p> <p>Lets assume my text value for this textbox is</p> <blockquote> <p>The quick red fox jumps over the lazy brown dog. This is the only sentence in the English language that uses all 26 letters of the alphabet</p> </blockquote> <p>With the words <code>all 26 letters</code> highlighted, clicking the bold button will wrap the text in the tags, but it will also add a second copy of the text that exists after the selection.</p> <p>I'm not sure why this is, can anyone provide any insight here?</p> <p>TIA :)</p>
jquery
[5]
2,966,394
2,966,395
ASP.NET: Questions about ASPNETDB.MDF
<p>in my web site i have two databases, ASPNETDB.MDF and a self created one (database.mdf). (The don't contain a lot of data yet) But i need a relationship (foreign key) between a table in ASPNETDB.MDF and a table in database.mdf.</p> <p>So i guess i need to merge both databases first, would you just extend the "ASPNETDB.MDF" with the tables from "database.mdf" ? or better configure "database.mdf" for the asp.net Applicatoin Services and then delete "ASPNETDB.MDF" ? Is "ASPNETDB.MDF" even meant to be used in a production online web application?</p> <p>(Right now i'm using sql server express but i will probably use sql server when deploying Site to a shared host)</p> <p>thanks a lot for answers</p>
asp.net
[9]
6,014,583
6,014,584
Why the following defined a cast operator?
<p>Saw the header definition from a library </p> <pre><code>operator const wchar_t*() const </code></pre> <p>anyone can explain to me why the above defined a cast operator?</p>
c++
[6]
2,464,842
2,464,843
How to Pass Data from One frame to Another and to all other frames in the project?
<p>I wanna want to pass or share data(values) from login frame to all frames in my project, H have made class of this variables like this </p> <pre><code>public class SharedData { public String LoginName; public SharedData() { } /** * @return the LoginName */ public String getLoginName() { return LoginName; } /** * @param LoginName the LoginName to set */ public void setLoginName(String LoginName) { this.LoginName = LoginName; } } </code></pre> <p>and from the first frame (login frame) I make object of this class and sets its username like this</p> <pre><code> public SharedData data1=new SharedData(); data1.setLoginName(Username_Login.getText().toString()); </code></pre> <p>and from the second frame i get the value :</p> <pre><code>public SharedData data=new SharedData(); ogin_labelName.setText(data1.getLoginName().toString()); </code></pre> <p>But finally it doesn’t work ... what is the problem or any solution ?</p> <p>thanks in advance</p>
java
[1]
5,542,431
5,542,432
What's the difference between this and super keywords in java?
<p>Check my coolMethod, babes:</p> <pre><code>package zoo; public class Zoo { public String coolMethod() { return "Wow baby!"; } } </code></pre> <p>My Moo Class, that extends my Zoo class, full of ways to do the same thing, which is calling my coolMethod.</p> <pre><code>package zoo; public class Moo extends Zoo { public void useAZoo(){ Zoo z = new Zoo(); System.out.println("A Zoo says: "+ z.coolMethod()); } public void useMyCoolMethod(){ System.out.println("My cool method says: " + super.coolMethod()); } public void useMyCoolMethodAgain(){ System.out.println("My cool method says: " + this.coolMethod()+ " (again)"); } public void inheritMyMethod(){ System.out.println("My inhertied method says: " + coolMethod()); } } </code></pre> <p>And my main, that calls my Moo class functionalities.</p> <pre><code>package javacert1; import zoo.Moo; public class Main { public static void main(String[] args) { Moo moo = new Moo(); moo.useAZoo(); moo.useMyCoolMethod(); moo.useMyCoolMethodAgain(); moo.inheritMyMethod(); } } </code></pre> <p>As you can see, all those four calls get the same results. I'm learning Java and I practiced with an example that used the "this" but I had seen the use of "super" elsewhere so I tested it and the results where the same. Why is this? What's the major difference between a this and super keyword?</p>
java
[1]
1,584,614
1,584,615
What are PHP 5.2 settnigs which affect compatibility with old code (developed for PHP 4 and 3)?
<p>What are PHP 5.2 settnigs which affect compatibility with old code (developed for PHP 4 and 3)?</p> <p>A web application using XTemplate 0.2.4-2 (officially meant for 3.0.11) works fine on one server running PHP 5.2 but works incorrect (seems that the form can't be submitted or processed correctly) on new PHP 5.2 and 5.3 installations. What may I need to tweak on new servers to make them able to run legacy code?</p>
php
[2]
3,073,021
3,073,022
How to use FieldPosition argument in java MessageFormat.format method?
<p>How is the FieldPosition argument used in the <code>MessageFormat.format</code> method in java? In all the examples I have seen online, there have been no uses of the FieldPosition argument. Is this argument used for anything? I am looking at the spec here: <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/text/MessageFormat.html" rel="nofollow">http://docs.oracle.com/javase/1.5.0/docs/api/java/text/MessageFormat.html</a>. Method signature is copied below.</p> <pre><code>public final StringBuffer format(Object[] arguments, StringBuffer result, FieldPosition pos) </code></pre>
java
[1]
1,346,323
1,346,324
Why is this chaining method not working?
<p>It's a simple counter. The method <code>add</code> is being called to increment the private variable <code>count</code> by 1 by default. I am returning the <code>Counter</code> class from the function so that it may be chained, but when I look at the output, it gives me 1 when I expect it to be 3 because I called <code>add</code> three times.</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; using std::cout; class Counter { public: Counter() : count(0) {} Counter add() { ++count; return *this; } int getCount() { return count; } private: int count; }; int main() { Counter counter; counter.add().add().add(); cout &lt;&lt; counter.getCount(); } </code></pre>
c++
[6]
3,740,883
3,740,884
Android app development for dummies book?
<p>has anyone ever read/skimmed through this book? it is valuable/very helpful to people such as myself, who are complete noobs to android programming? I am thinking of purchasing one on amazon for $20 but dont know if its going to be a really helpful book. </p> <p>Also, when i skim through the book on the amazon wesite, it seems to be missing alot of stuff. is that just amazon's preview method or is the book really that simple?</p>
android
[4]
3,934,755
3,934,756
Using Python's isinstance
<p>The following usage of <code>isinstance</code> doesn't seem to work in Python 2.5.2 or 2.6.2:</p> <pre><code>class BananaCake: def __init__(self): print 'Banana Cake' class ChocolateCake: def __init__(self): print 'Chocolate Cake' class CakeFactory: @staticmethod def create(name): if name == 'banana': return BananaCake elif name == 'chocolate': return ChocolateCake else: return None if __name__ == '__main__': banana_cake = CakeFactory.create('banana') print isinstance(banana_cake, BananaCake) </code></pre> <p>The above <code>isinstance</code> is returning <code>False</code> even though banana_cake is an instance of <code>BananaCake</code>. Does anyone know what I might be missing? I'm performing this check in my test scripts. You should be able to copy and paste the above and run it easily in a Python script.</p>
python
[7]
1,823,833
1,823,834
Android Log data
<p>I'am using log to store all the transfer. How can I check the logged data?</p> <pre><code>Log.i("login", "recevied " + getResponse(response.getEntity())); </code></pre>
android
[4]
4,213,072
4,213,073
Still confused about JavaScript's 'this'
<p>I've been reading through quite a few articles on the 'this' keyword when using JavaScript objects and I'm still somewhat confused. I'm quite happy writing object orientated Javascript and I get around the 'this' issue by referring the full object path but I don't like the fact I still find 'this' confusing. </p> <p>I found a good answer <a href="http://stackoverflow.com/questions/2148451/help-this-is-confusing-me-in-javascript">here</a> which helped me but I'm still not 100% sure. So, onto the example. The following script is linked from test.html with <code>&lt;script src="js/test.js"&gt;&lt;/script&gt;</code></p> <pre><code>if (!nick) { var nick = {}; } nick.lowman = function(){ var helloA = 'Hello A'; console.log('1.',this, this.helloA); var init = function(){ var helloB = 'Hello B'; console.log('2.',this, this.helloB); } return { init: init } }(); nick.lowman.init(); </code></pre> <p><strong>What kind of expected to see was</strong> </p> <pre><code>1. Object {} nick.lowman, 'Hello A' 2. Object {} init, 'Hello B' </code></pre> <p><strong>But what I get is this?</strong></p> <pre><code>1. Window test.html, undefined 2. Object {} init, undefined </code></pre> <p>I think I understand some of what's happening there but I would mind if someone out there explains it to me.</p> <p>Also, I'm not entirely sure why the first 'console.log' is being called at all? If I remove the call to the init function <code>//nick.lowman.init()</code> firebug still outputs <code>1. Window test.html, undefined</code>. Why is that? Why does nick.lowman() get called by the window object when the html page loads? </p> <p>Many thanks</p>
javascript
[3]
1,916,183
1,916,184
How to create a small box above selected text ( double click to select it )
<p>I try to write a dictionary extension for Google Chrome. Now, I want to pop out a small box when I double click to select text . How can I implement it :) Or like this one ( Fastest Chrome ). They're written in javascript.</p> <p><img src="http://img130.imageshack.us/img130/9721/abcjq.jpg" alt="alt text"> Thanks so much ! </p>
javascript
[3]
2,265,680
2,265,681
PHP appends localhost to out-going email
<p>Here's a PHP code that I'm using to test email sending for one of my forms. Although it works well, but for some reason it appends @localhost.mydomain.com to the sender email address. Here's an example:</p> <pre><code>From: James &lt;james.bond@hotmail.com@localhost.mydomain.com&gt; </code></pre> <p>Here's the full code below.</p> <pre><code>&lt;?php $email = sqlEscape($_POST['email']); $name = sqlEscape($_POST['name']); $to = 'me@yahoo.com'; $subject = 'Email From website'; $message = 'The message here'; $headers = 'From: "'.$name.'" &lt;"'.$email.'"&gt;' . "\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; if(mail($to, $subject, $message, $headers)){ echo('Message sent successfully'); }else{ echo('&lt;a href="contact.php"&gt;Click here&lt;/a&gt; to try again.'); } ?&gt; </code></pre> <p>Is there a way to make it not to append it? Thanks</p>
php
[2]
5,390,990
5,390,991
Deduping a complex list using a simplified copy of itself
<p>I have two lists of strings that are passed into a function. They are more or less the same, except that one has been run through a regex filter to remove certain boilerplate substrings (e.g. removing 'LLC' from 'Blues Brothers LLC').</p> <p>This function is meant to internally deduplicate the modified list and remove the associated item in the non-modified list. You can assume that these lists were sorted alphabetically before being run through the regex filter, and remain in the same order (i.e. original[x] and modified[x] refer to the same entity, even if original[x] != modified[x]). Relative order must be maintained between the two lists in the output.</p> <p>This is what I have so far. It works 99% of the time, except for very rare combinations of inputs and boilerplate strings (1 in 1000s) where some output strings will be mismatched by a single list position. Input lists are 'original' and 'modified'.</p> <pre><code># record positions of duplicates so we're not trying to modify the same lists we're iterating dellist_modified = [] dellist_original = [] # probably not necessary, extra precaution against modifying lists being iterated. # fwiw the problem still exists if I remove these and change their references in the last two lines directly to the input lists modified_copy = modified original_copy = original for i in range(0, len(modified)-1): if modified[i] == modified[i+1]: dellist_modified.append(modified[i+1]) dellist_original.append(original[i+1]) for j in dellist_modified: if j in modified: del modified_copy[agg_match.index(j)] del original_copy[agg_match.index(j)] # return modified_copy and original_copy </code></pre> <p>It's ugly, but it's all I got. My testing indicates the problem is created by the last chunk of code.</p> <p>Modifications or entirely new approaches would be greatly appreciated. My next step is to try using dictionaries.</p>
python
[7]
4,446,865
4,446,866
JQuery issue - http://jqueryui.com/latest/themes/base/ui.all.css not working
<p>I have never used J Query....Was wondering what does the link ..</p> <p><a href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="nofollow">http://jqueryui.com/latest/themes/base/ui.all.css</a></p> <p>link to? One of the websites i have taken over has stopped working. When i take this source out at the top of the page it works, when i put it back in stops working again?</p> <p>For now i have taken it out, but i assume jquery server has gone down or something. What does this source do and is it ok to leave it out? thanks</p>
jquery
[5]
4,675,063
4,675,064
Find the value in the minimum number of trials
<p>I have an array of 52 different values that I can pass through a class to get a number in return.</p> <pre><code>$array = array("A","B","C","D"...); </code></pre> <p>Each value passed through the class gives a different number that can be either positive or negative. The numbers are not equally distributed but are sorted in natural order.</p> <p>E.g.</p> <pre><code>$myclass-&gt;calculate("A"); // 2.3 $myclass-&gt;calculate("B"); // 0.25 $myclass-&gt;calculate("C"); // -1.3 $myclass-&gt;calculate("D"); // -6 </code></pre> <p>I want to get the last value that return a number >= 0.20 (in the example would be "B").</p> <p>This should be done in the minimum number of "class invocation" to avoid time wasting.</p> <p>I thought something like: divide $array in 2 pieces and calculate the number I get, if it is >= 20, then split the last part of $array in other 2 smaller pieces and so on. But I don't know if this would work.</p> <p>How would you solve this?</p> <p>Thanks in advance.</p>
php
[2]
2,570,242
2,570,243
Key Value pair storage in Settings file
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/1166496/key-value-storage-in-settings-file">Key Value Storage in Settings file</a> </p> </blockquote> <p>Hi, I am developing an application in C#, which needs to store an array of key value pair in settings file.Looking for a perfect solution Thanks in advance</p>
c#
[0]
1,578,208
1,578,209
In PHP 5.2 why is instantiating a class and calling a method on the same line invalid?
<p>This is what I'd like to do:</p> <pre><code>$app = (new Factory())-&gt;GetApp(); </code></pre> <p>However, I get an "unexpected T_OBJECT_OPERATOR" error.</p> <p>To avoid this, I have to do:</p> <pre><code>$Factory = new Factory(); $app = $Factory-&gt;GetApp(); </code></pre> <p>Why is this necessary? I'm running PHP 5.2 if it makes any difference.</p>
php
[2]
1,734,944
1,734,945
How to get interactive input from user and to be able to use arrowkeys while entering input?
<p>When I do a raw_input() and enter values, I am not able to use my arrow-keys to change stuff... is there any way for doing that?</p> <p>Thanx readline module helps in line editing features. How to use the readline module? Just importing the readline module works!</p>
python
[7]
1,524,593
1,524,594
Compiler complains about "missing return statement" even though it is impossible to reach condition where return statement would be missing
<p>In the following method, the compiler complains about a <em>missing return statement</em> even though there is only a single path through the method, and it contains a <code>return</code> statement. Suppressing the error requires another <code>return</code> statement. </p> <pre><code>public int foo() { if (true) { return 5; } } </code></pre> <p>Given that the <a href="http://stackoverflow.com/questions/1958563/does-java-recognize-infinite-loops">Java compiler can recognize infinite loops</a>, why doesn't it handle this situation as well? The linked question hints, but doesn't provide details for this specific case.</p>
java
[1]
3,984,963
3,984,964
Special Bidirectional Association
<p>I think it was called reflexive association but I'm not quite sure.</p> <p>This is the code (It should be enought to see what ist important):</p> <pre><code>CGmae::CGame(void) { CFigure * figure = new CFigure(this); } CFigure::CFigure(CGame * game) { CGame * game = game; } </code></pre> <p>I wanted to create an object of CFigure in the class CGame, so that CFigures knows CGame and the other way round ofc. Why isn't it working with 'this'? What do I need to do to solve the problem?</p> <p>Thanks in advance!!</p>
c++
[6]
5,294,676
5,294,677
Jquery and adding row to table
<p>I have the following jquery code.</p> <pre><code>var destTable = $("#numbers"); $(document).ready(function() { $("#btnAdd").click(function() { //Take the text, and also the ddl value and insert as table row. var newRow = $("&lt;tr&gt;&lt;td&gt;hi&lt;/td&gt;&lt;/tr&gt;"); $("#numbers").append(newRow); }); }); </code></pre> <p>What I would really like is to store a reference to an element once and then use it from there on it.</p> <p>The code above add's a row to my table as expected but if I use. <code>$(destTable).append(newRow)</code> or <code>destTable.append(newRow)</code> nothing happens could anyone shed any light on this for me?</p> <p>Thanks</p>
jquery
[5]
5,057,697
5,057,698
goto and RAII in C++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3179936/goto-out-of-a-block-do-destructors-get-called">Goto out of a block: do destructors get called?</a> </p> </blockquote> <p>I know that goto operator both in C and C++ is useless in almost all situations, but i want to know the answer for this question only by interest, it has no practical meaning.</p> <p>Does C++ standard guarantees that in such situations destructors of objects must be called properly?</p> <pre><code>#include &lt;iostream&gt; class Foo { public: Foo() { std::cout &lt;&lt; "Foo::Foo() \n"; } ~Foo() { std::cout &lt;&lt; "Foo::~Foo() \n"; } }; int main() { { std::size_t i = 0; _1: Foo instance; if (!++i) { goto _1; } } { Foo instance; goto _2; } _2: ; } </code></pre> <p><a href="http://liveworkspace.org/code/06031e6699c8fddda94b8594ccab1387" rel="nofollow">http://liveworkspace.org/code/06031e6699c8fddda94b8594ccab1387</a></p> <p>And what about other stange situations with goto and C++ RAII?</p> <p>It would be really cool if you can post here the quotes from the C++ standard.</p>
c++
[6]
3,810,907
3,810,908
How to create Syntax Highlighting Text Box
<p>How to create a Syntax Highlighting Textbox Using C#.Net</p>
c#
[0]
97,273
97,274
it there a better way to write the line in php?
<pre><code> &lt;div class="meta"&gt; &lt;?php echo $submitted."pubblished in".$fenl; ?&gt; &lt;a href="&lt;?php echo base_path().'comp/'.$node-&gt;nid;?&gt;"&gt; &lt;?php echo $comment_count;?&gt;comment&lt;/a&gt; &lt;/div&gt; </code></pre> <p>it there a better way to write the above code.</p> <p>2,</p> <pre><code>function blog_gettag(){ $terms = mysql_query('SELECT vid,name FROM term WHERE vid=2'); $items = array(); foreach ($terms as $term){ $items[] = $term-&gt;name; } return $items; } </code></pre> <p>could i delete <code>$items = array()</code>; this line. thank you.</p>
php
[2]
3,500,573
3,500,574
javascript get element by name
<p>Ok i have this little cute code as a expirement:</p> <pre><code>function validate() { var acc = document.getElementsByName('acc').value; var pass = document.getElementsByName('pass').value; alert (acc); } </code></pre> <p>and this html part</p> <pre><code>&lt;table border="0" cellpadding="2" cellspacing="0" valign="top"&gt; &lt;tr&gt; &lt;td class="td1"&gt;Account&lt;/td&gt; &lt;td class="td2"&gt;&lt;input type="text" name="acc" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="td1"&gt; &lt;td&gt;Password&lt;/td&gt; &lt;td class="td2"&gt;&lt;input type="password" name="pass" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div&gt;&lt;button onClick="validate()" class="cupid-greenx"&gt;Login now&lt;/button&gt;&lt;/div&gt; </code></pre> <p>yes its working, the alert box is showing but the problem is, the value of input("name:acc") is not showing as i specified that it must show whenever it gets the value of that input box instead it shows "undefined" on the alert box. thanks in advance.</p>
javascript
[3]
5,324,442
5,324,443
bypass password on android adb backup
<p>I am trying to write shell script to run android phone backup automatically using adb backup. Is there any methods to bypass password screen(no password), when doing android adb backup?</p>
android
[4]
2,040,711
2,040,712
Convert foreach to for in PHP
<pre><code>foreach ( $this-&gt;parent-&gt;get_sections(null, $this-&gt;parent-&gt;author) as $section) { //... } </code></pre> <p>I'm trying to do is force the loop to output each <code>$section</code> in the order I want. Each <code>$section</code>'s name can be retrieved by <code>$section-&gt;name</code>. Let's say that I want to output <code>$section</code> "Section 2" first and then "Section 1" (and not in the order of the <code>foreach</code>). How can I force it do that? I presume the proper way would be a <code>for</code> loop with an if checking section names each time.</p>
php
[2]
4,095,068
4,095,069
Is a class with static members and a public constructor a static class?
<p>If I have a class that is not marked <code>static</code>, but it does have <code>static</code> member variables, does this make the class itself <code>static</code>? It's being used in code like it is, but it has a public constructor. I thought they can only have private constructors?</p> <p>Also, in a web application in a web page I make a call to a static class and assign it to a static member variable to be used in the page. If a user leaves the page will the static member variable remain in memory? I'm thinking just for the duration of that user's session, correct? Or would GC refrain from collecting it for some longer period of time?</p> <p>Ok here's some code:</p> <pre><code> public class CustomerManager { private static MyFactory _customerFactory = MyFactory.GetInstance(); public CustomerManager() { } public static List&lt;CustUser&gt; GetCustomersByWebRequest(int iClientID, string sEmployeeNumber) </code></pre> <p>It is being called in another class that is static like so:</p> <pre><code> List&lt;CustUser&gt; customers = CustomerManager.GetCustomersByWebRequest(1, "23434"); </code></pre> <p>and this is in production. </p>
c#
[0]
4,430,798
4,430,799
AutoCompleteTextView from URL
<p>Hi I want to create AutoCompleteTextView from URL.Can anybody help me.Precisely speaking from JSon which returned from webservice</p>
android
[4]
2,432,753
2,432,754
how to make download.php ?id=number
<p>How to make a download.php where I can set the external download links by id 's.(id numbers). then I can make my link with my own domain like this:- <a href="http://link.domain.com/" rel="nofollow">http://link.domain.com/</a><em>*</em>*/download .php?id=number.</p> <p>Because I wanted to show my link but it will download from another link.</p> <p>Please give me the php code for it.</p>
php
[2]
4,091,945
4,091,946
What's the predicate in C++?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5921609/what-is-predicate-in-c">What is predicate in C++?</a> </p> </blockquote> <p>When I read the C++ primer, there is a defined term which is <strong>predicate</strong>.</p> <p>The definition is this :</p> <p><strong>Functions that returns a type that can be converted to bool. Often used by the generic algorithms to test elements . predicates used by the library are either unary (taking one argument) or binary(taking two).</strong> </p> <p>Anyone that returns a type that can be converted to bool can be predicate ! Right? Or there are some other restrictive conditions.</p> <p>Thanks!</p>
c++
[6]
2,501,624
2,501,625
Write to CLOB in Java
<p>Now we are using the following code to write the data into the .csv file ( i.e for creating)</p> <p>But Now I have to update this data directly to the one database column CLOB. without generating any .csv file.</p> <p>How can I add this data to CLOB. here we r passing each and every line as vector to the writeIT() and it is adding that to filewriter.</p> <p>what I should do to write it in CLOB? Please Help me out..</p> <pre><code>writeIt(mlh); &lt;Loop&gt; writeIt(row); &lt;End Loop&gt; writeIt(null); writeIt(commentLineHeader); &lt;Loop&gt; writeIt(row); &lt;End Loop&gt; protected void writeIt (Vector a){ if (filewriter==null) return; try { if (a!=null){ for (int i=0;i&lt;a.size();i++){ //Object o=a.elementAt(i); Object o=a.elementAt(i); if (o!=null) { String str=o.toString(); // replacing an komma inside a string with a point. str = str.replace(',','.'); // replacing a new line in hexa it's 0A and 0F with blank str = str.replace('\n',' '); // LF replace str = str.replace('\r',' '); // CR replace filewriter.write(str); } if (i!=a.size()-1) filewriter.write(","); } } } catch (IOException e){ errH.addMessage(L_ERROR,"_$EXCEPTION_RAISED -" + e.toString()); PAVSessionManager.getInstance().update_in_use_flag(); } } </code></pre>
java
[1]
2,927,817
2,927,818
jQuery: select checkbox based on name and value
<p>I have the following HTML:</p> <pre><code>&lt;form id="test"&gt; &lt;input type="radio" value="A" name="C1"/&gt; &lt;a href="javascript:selectCheckbox('C1', 'A');"&gt; OPTION-A &lt;/a&gt; &lt;input type="radio" value="B" name="C1"/&gt; &lt;a href="javascript:selectCheckbox('C1', 'B');"&gt; OPTION-B &lt;/a&gt; &lt;input type="radio" value="C" name="C1"/&gt; &lt;a href="javascript:selectCheckbox('C1', 'C');"&gt; OPTION-C &lt;/a&gt; // several other: C2, C3, .. &lt;/form&gt; </code></pre> <p>And I'm trying to implement <code>selectCheckbox( chkbox, value)</code>, which should:</p> <ol> <li>search for all radio's with <code>name = chkbox</code> and set <code>attr('checked') = false</code></li> <li>search for the radio having <code>name = chkbox AND val() = value</code> and set <code>attr('checked') = true</code></li> </ol> <p>I can't figure out, what the right selector is, I tried the following without any luck:</p> <pre><code>var name = "#" + chkbox + " :checked"; $(name).each(.. // doesn't work $('#'+chkbox).each( .. // if finds only the first occurence // of i.e. C1, although I would expect 3 $("input[@name='"+chkbox+"']").each( function() { .. // leaves me with the following error: // Warning: Expected attribute name or namespace but found '@name' </code></pre> <p>Please let me know what I'm doing wrong. Many, many thanks!</p>
jquery
[5]
3,834,847
3,834,848
How does one use TrafficStats.incrementOperationCount()?
<p>The documentation for <a href="http://developer.android.com/reference/android/net/TrafficStats.html#incrementOperationCount%28int,%20int%29" rel="nofollow"><code>TrafficStats.incrementOperationCount()</code></a> says:</p> <blockquote> <p>Increment count of network operations performed under the given accounting tag. This can be used to derive bytes-per-operation.</p> </blockquote> <p>I want to find the total number of bytes transferred during a particular network operation. Since this API claims to help in deriving bytes-per-operation, can someone help me understand how to use it?</p>
android
[4]
2,162,890
2,162,891
Help with php sessions
<p>I like to know how to use a condition on php sessions</p> <p>in this code if the user is not loged in page will redirect to login.php. </p> <pre><code>&lt;? session_start(); if(!session_is_registered(username)){ header("location: login.php"); } ?&gt; </code></pre> <p>what i want is to redirect user to another php if the user is loged in. if not stay on the same page. like if user is not loged in keep the user in index page and if user is loged in redirect the user to user.php</p> <p>for the login script im using a code fount in this site :http://www.phpeasystep.com/phptu/6.html</p> <p>thanks in advance.</p>
php
[2]
3,585,265
3,585,266
Retrieving element from a 2D array in column JAVASCRIPT
<p>i create a table with a 2D array displaying numbers. Now i want to retrieve element from it. the code below is retrieving it row wise. How can i modify the code below to retrieve it column wise?</p> <pre><code>var newArray; var buffer =""; newArray = totalRows.map(function(arrayNode){ return arrayNode.map(function(node){ buffer += node.nodeValue.trim(); cell.innerHTML=buffer; }); }); </code></pre>
javascript
[3]
5,271,925
5,271,926
Scope of enumerators
<p>In the following, I don't know if i'm confusing enums in C# with C++ but I thought you could only access enumerators in enum using <code>Forms::shape</code> which actually gives an error. </p> <pre><code>int main() { enum Forms {shape, sphere, cylinder, polygon}; Forms form1 = Forms::shape; // error Forms form2 = shape; // ok } </code></pre> <p>Why is <code>shape</code> allowed to be accessed outside of enum without a scope operator and how can i prevent this behavior?</p>
c++
[6]
5,024,004
5,024,005
C#, how to halve a byte array?
<p>I have a byte array defined like this</p> <pre><code>byte[] fileContents = File.ReadAllBytes(zfoFileName); </code></pre> <p>How can I get the first 1/2 of the fileContents byte array?</p> <p>In other words if the upper bound of the array is 10, I would like a new byte array to have the first 5 values of fileContents. </p> <p>Thanks in advance</p>
c#
[0]
2,519,619
2,519,620
screen orientation like portrait and landscape in iphone
<p>Im new to iphone development. here i want to view the screen like landscape porgrammaticaly in iphone. i completed like portrait side now when i turn left and right sides automaticaly i added some images and pickerview data these are also shown like portrait and landscape screens to iphone . </p> <p>Can any one plz help me for how to orientation the screen programmaticaly in iphone</p> <p>thank you in advance.</p>
iphone
[8]
2,217,983
2,217,984
Unexpected indent Python
<p>I keep getting the error "unexpected indent" for the line "lijst2 = lijst + [cat]" in the following code. I have no idea why, because as far as I can see indentation seems to be correct? Please keep in mind I am a beginner. Thank you! This is my code:</p> <pre><code>for fileid in corpus.fileids(): tekst1 = corpus.words(fileid) instantie = defaultdict(float) cat = mijn_corpus.fileids() for word in tekst1: if word in freq: instantie[word] +=1 for word in freq: if word not in tekst1: instantie[word] +=0 lijst1 = [] for key, value in instantie.iteritems(): lijst1.append(value) lijst2 = lijst + [cat] # Here I get the error message: unexpected indent resultaten.writerrow(lijst2) </code></pre>
python
[7]
624,300
624,301
java "cannot find symbol" - how to import a file in the same directory?
<p>I have two java files in a directory, neither of them are in a package. I want one of them to be able to reference the other. What is the right way to do this? </p> <p>Currently in Class A, I'm trying to reference class B, and getting this error:</p> <pre><code>[javac] A.java:11: cannot find symbol [javac] symbol : constructor B(java.lang.String) [javac] location: class B [javac] B b = new B(path); [javac] ^ </code></pre> <p>Nothing below worked:</p> <ul> <li>in A, doing "import B;"</li> <li>adding "package myPackage;" to both A and B</li> </ul> <p>Thanks!</p>
java
[1]
269,606
269,607
Calling a class method dynamically
<p><strong>Edit: In real life i don't have a Book class. This is just an example to be clear. Real problem really needs reflection to solve it.</strong></p> <p>Suppose that I have some classes:</p> <p>Book, Apple, Door.</p> <pre><code>class Book { ... public decimal getPrice() {...} public string getTitle() {...} public decimal getAuthor() {...} } </code></pre> <p>and something same for other classes.</p> <p>May i call a class method dynamically from a string:</p> <pre><code>Book myBook = new Book("Title", "Author", 44); string title = runMethod(myBook, "getTitle"); </code></pre>
c#
[0]
4,519,935
4,519,936
Select particular word while copying
<p>In this sample app I'm trying to copy the text from the edittext it is working fine , Now the thing is that I want to copy a particular word from the edittext how to achieve that</p> <p>Thanks in advance</p> <p>My sample app </p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mEditText = (EditText) findViewById(R.id.editor); Button mButton = (Button) findViewById(R.id.copybutton); mClipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); mButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub mText = mEditText.getText().toString(); if (mText != null) { mClipData = ClipData.newPlainText("sample text", mText); mClipboardManager.setPrimaryClip(mClipData); } final ClipData.Item item = mClipboardManager.getPrimaryClip() .getItemAt(0); Toast.makeText(getApplicationContext(), " " + item.getText(), Toast.LENGTH_LONG).show(); } }); } </code></pre>
android
[4]
5,501,632
5,501,633
if else for None in Python
<p>Any way to write this in one line in Python, or even better, as an expression instead of a statement?</p> <pre><code>parts = ['0', '1', 'None', '5', '4'] [int(p) for p in parts] </code></pre> <p>This of course gives an error,</p> <pre><code>ValueError: invalid literal for int() with base 10: 'None' </code></pre> <p>So:</p> <pre><code>[p=='None' and None or int(p) for p in parts] </code></pre> <p>Doesn't work because you can't use <code>None</code> with the and/or construct reliably. (Even if <code>p=='None'</code> is true, <code>None</code> is equivalent to false so it goes to the <code>or</code> part.)</p> <pre><code>[int(p) if p=='None' else None for p in parts] </code></pre> <p>Also doesn't work. I guess it evaluates <code>int(p)</code> before the conditions? (Seems odd semantics.)</p> <pre><code>a = [] for p in parts: if p=='None': k = None; else: k = int(p) a.append(k) </code></pre> <p>Nope, invalid syntax.</p> <pre><code>a = [] for p in parts: if p=='None': k = None; else: k = int(p) a.append(k) </code></pre> <p>Ah! Finally. But isn't there a shorter way to write such a simple loop?</p>
python
[7]
2,594,604
2,594,605
Using non-blocking scripts
<p>The more i use JavaScript the more i try to come up with efficient ways of loading and executing my scripts. One method i have found to be really useful is loading javascript without blocking. </p> <pre><code>function include_js(url) { var script = document.createElement("script"); script.type = "text/javascript"; script.src = url; document.getElementsByTagName("head")[0].appendChild(script); } include_js('script.js'); </code></pre> <p>JavaScript also has a window method that executes when the page has loaded.</p> <pre><code>window.onload = function() { alert('Script executed onload'); }; </code></pre> <p>What i want to know is, how does the browser treat script executed by the window.onload method, is it blocking or non-blocking script?</p>
javascript
[3]
1,890,614
1,890,615
Why is char being converted into a ushort instead of an int in this decompilation?
<p>When i write a for loop as below it works fine.</p> <pre><code>for (Char ch = 'A'; ch &lt; 'Z'; ch++) { Console.WriteLine(ch.ToString()); } </code></pre> <p>I thought that compiler converts Char type to int but when i looked at the decompiled code, this is what i saw:</p> <pre><code>for (char i = 65; i &lt; 97; i = (ushort)i + 1) { Console.WriteLine(i.ToString()); } </code></pre> <p>Can someone please explain why the compiler did not change the datatype of i from non-numeric to numeric?</p> <p>--EDIT-- Added decompiler screenshot <img src="http://i.stack.imgur.com/o3AkG.png" alt="enter image description here"></p>
c#
[0]
5,955,542
5,955,543
Convert Numbers to Numbers and Letters in PHP
<p>I have the following number 353711000 and I need to convert it to 35371TH in PHP.</p> <p>How would I go about this?</p>
php
[2]
2,605,904
2,605,905
Applying style to particular character in textview
<p>Currently I am using 26 <code>Textview</code> so that I can apply style to particular character depending on runtime situation. But if I can able to apply style on particular character in textview I can achieve my goal using only one textview.</p> <p>e.g. If I want to make character 'M' red in following code. Is it possible to achieve this?</p> <pre><code> &lt;TextView android:id="@+id/TextView01" android:layout_height="wrap_content" android:textSize="20dip" android:textStyle="bold" android:layout_width="15dip" android:text="ABCDEFGHIJKLMNOPQRSTUVWXYZ" android:background="#FFFFFF" android:textColor="#000000"/&gt;` </code></pre> <p>Or anybody have better option than using 26 <code>TextView</code> it also welcome.</p>
android
[4]
245,113
245,114
Python basics- why aren't the contents of my file printing?
<p>I'm running this from eclipse, the file name I'm working with is ex16_text.txt (yes I type it in correctly. It writes to the file correctly (the input appears), but the "print txt.read()" doesn't seem to do anything (prints a blank line), see the output after the code:</p> <pre><code>filename = raw_input("What's the file name we'll be working with?") print "we're going to erase %s" % filename print "opening the file" target = open(filename, 'w') print "erasing the file" target.truncate() print "give me 3 lines to replace file contents:" line1 = raw_input("line 1: ") line2 = raw_input("line 2: ") line3 = raw_input("line 3: ") print "writing lines to file" target.write(line1+"\n") target.write(line2+"\n") target.write(line3) #file read txt = open(filename) print "here are the contents of the %s file:" % filename print txt.read() target.close() </code></pre> <p>Output:</p> <p>What's the file name we'll be working with?ex16_text.txt we're going to erase ex16_text.txt opening the file erasing the file give me 3 lines to replace file contents: line 1: three line 2: two line 3: one writing lines to file here are the contents of the ex16_text.txt file:</p>
python
[7]
1,031,983
1,031,984
how to get data from the UIAddressbook in iphone?
<p>I want to import data frome the iphone address book to my applciation. Can you give me any reference sample code?</p>
iphone
[8]
5,318,730
5,318,731
Android - no connectivity for my App. How to debug?
<p>I have check for internet connectivity that goes like this:</p> <pre><code>public static boolean isInternetAvailable(Context ctx) { NetworkInfo info = ((ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); if (info == null || !info.isConnected()) return false; if (info.isRoaming()) { return Preferences.getIsRoamingAllowed(ctx); } return true; } </code></pre> <p>It's been working good for all installations so far. Today user came in with a phone where everything worked (browser, email, etc) and it wasn't roaming. But my app due to this check was giving "No connection" error.</p> <p>Phone is HTC Droid ERIS with 2.1</p> <p>Anyone saw this issue? Any pointers why?</p>
android
[4]