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,596,952
4,596,953
deque<bool> iterator compile error
<p>how to use deque to print its items?</p> <p>fatal error LNK1000: Internal error during IncrCalcPtrs</p> <pre><code>deque&lt;bool&gt; mandy3; mandy3.push_back(true); mandy3.push_back(false); mandy3.push_back(true); for(deque&lt;bool&gt;::iterator it=mandy3.begin(); it!=mandy3.end(); it++) printf("mandy3 : %d" , *it?1:0); </code></pre>
c++
[6]
3,803,127
3,803,128
How to terminate a call programmatically under Android?
<p>I am using the following code for dialing programmatically under Android. </p> <pre><code>try { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:123456789")); startActivity(callIntent); } catch (Exception exception) { log.e("dialing-example", "Call failed", Exception); } </code></pre> <p>But how can I terminate the call programmatically?</p>
android
[4]
1,113,595
1,113,596
Python: how to change (last) element of tuple?
<p>The question is a bit misleading, because a tuple is <em>immutable</em>. What I want is: </p> <p>Having a tuple <code>a = (1, 2, 3, 4)</code> get a tuple <code>b</code> that is exactly like <code>a</code> except for the last argument which is, say, twice the last element of <code>a</code>.</p> <p>=> b == (1, 2, 3, 8)</p>
python
[7]
3,064,475
3,064,476
Prevent from type converting of "this" during a call to a function with apply
<p>Servus Ninjas,</p> <p>this is what ecmascript 5 spec. (page 118) in the section <code>Function.prototype.apply(thisArg, argArray)</code> says:</p> <blockquote> <p>NOTE: The thisArg value is passed without modification as the this value. This is a change from Edition 3, where a undefined or null thisArg is replaced with the global object and <strong>ToObject</strong> is applied to all other values and that result is passed as the this value.</p> </blockquote> <p>This sounds promising, but this spec isn't implemented yet in any of the modern browsers so we have to deal with the 3rd spec implementation. </p> <p>My question now is „<strong>How to get the <code>typeof</code> statement become TRUE?</strong>“</p> <pre><code>var foo = function (arg1, arg2) { alert(typeof this == "string"); }; foo.apply("bar", ["arg1", "arg2"]); </code></pre> <p>any ideas?</p>
javascript
[3]
1,643,163
1,643,164
disable scroll bar on the div
<p>I have a div. </p> <p>I want that user should not be able to scroll the page if the height is more than 350px. Also the scroll bar should be visible in disable mode in that case.</p> <p>I want to achieve this using javascript.</p> <p>Thanks</p>
javascript
[3]
5,082,451
5,082,452
Detect when screen is scrolling?
<p>Here on my app I've got a small surfaceView that displays the camera preview. This surfaceView is put in a FrameLayout that is put in a ScrollView, alltogether with other components (like buttons, textViews and such). The thing is, that when i scroll the screen, the surfaceView leaves a black hole where it was, and this black hole is only filled when the screen is redrawn, so, I'd like to redraw the screen on each scrolling step (yes, I am willing to pay the performance trade off, if there's no other way). Someone has any ideas?</p>
android
[4]
5,260,810
5,260,811
if statement with img.src
<p>The problem: whenever, if i have the single '=' the variable will show up and be fine.. but it completely ignores the if statement. if i only do the double '=='.. the variable doesnt show up, and it goes to the else state. lemme know if u see anything wrong.</p> <pre><code>var pic1 = document.getElementById('team1pic').src; var win1 = document.getElementById('wins').innerHTML; if (pic1 == 'pens.jpg') { document.getElementById('wins').innerHTML = PittWins; } else { document.getElementById('wins').innerHTML = 'no'; } </code></pre> <p>here is some html to go along with it that i have</p> <pre><code>&lt;a class="dock-item" id="pens" href="#" onclick="document.getElementById('team1pic').src='pens.jpg'"&gt;&lt;span&gt;Pittsburgh Penguins&lt;/span&gt;&lt;img src="pens.jpg" alt="Pittsburgh Penguins" /&gt;&lt;/a&gt;` </code></pre> <p>and then </p> <pre><code>&lt;th width="35%" &gt;&lt;img src="" / id='team1pic'&gt;&lt;/th&gt; </code></pre>
javascript
[3]
526,660
526,661
Android loading in images of with different dpi, some do not appear
<p>I'm loading external images from a url, which they are all the same resolution. However, the images that are below 100dpi do not appear. The rest are 100 dpi and they do appear.</p> <p>I can't wrap my head around this dpi resolution concept, and why I can't use these images even though they are the same resolution at the others.</p> <p>I've added two test images. Could someone try to add these images externally to imageViews? I want to see if you are able to display them.</p> <p><a href="http://bloggr.geespot.ca/offbroadway-poster.jpg" rel="nofollow">http://bloggr.geespot.ca/offbroadway-poster.jpg</a><br> <a href="http://bloggr.geespot.ca/eppleworth.jpg" rel="nofollow">http://bloggr.geespot.ca/eppleworth.jpg</a></p>
android
[4]
5,148,198
5,148,199
Difference between File.renameTo and Files.move: Which is faster?
<p>Both <code>File.renameTo</code> and <code>Files.move</code> in Java can move a file. What's the difference between the two? And which has a better performance?</p>
java
[1]
3,754,498
3,754,499
C++ Pointers to Pointers in Java
<p>I am a Java noob. I have been able to grasp the concept of converting C/C++ pointers into Java references and this has gone fairly smoothly.</p> <p>I hit a piece of code that has pointers to pointers (ie **ptr). I need to dereference the pointer and change the value of the pointer it is pointing to (ie *ptr = &newthing;)</p> <p>This seems alot tougher in java. Does anyone have any ideas on how to solve this issue? Quick google search turned up nothing.</p> <p>Here's a code example in C++. I want to get something similar working in java but the ptr_to_ptr variable is a problem:</p> <pre><code>struct _coord { int x; int y; _coord * next_coordinate; } coordinate_t; coordinate_t buffer[100]; coordinate_t * head; coordinate_t ** ptr_to_ptr; if (wednesday) { ptr_to_ptr = &amp;head; } else { ptr_to_ptr = &amp;head-&gt;next_coordinate; } *ptr_to_ptr = &amp;buffer[3]; // &lt;&lt;&lt;---- HOW DO YOU MAKE THIS WORK? </code></pre>
java
[1]
388,557
388,558
how to store php array data into mysql database
<pre><code>&lt;?PHP // primarily a method for storing data // arrays are counted from 0 $hosts = array( array("ronmexico.kainalopallo.com/","beforename=$F_firstname%20$F_lastname&amp;gender=$F_gender","Your Ron Mexico Name is ","/the ultimate disguise, is ([^&lt;]+)&lt;\/b&gt;&lt;\/u&gt;/s"),&lt;u&gt;&lt;b&gt;([^&lt;]+)&lt;\/b&gt;&lt;\/u&gt;/s"), array("rumandmonkey.com/widgets/toys/mormon/index.php","gender=$F_gender&amp;firstname=$F_firstname&amp;surname=$F_lastname","Your Mormon Name is ","/ My &lt;p&gt;My Mormon name is &lt;b&gt;([^&lt;]+)&lt;\/b&gt;!&lt;br \/&gt;/s") ); return $hosts; ?&gt; </code></pre> <p>How to store this array into mysql database. </p>
php
[2]
2,477,311
2,477,312
Frustratingly simple jQuery problem
<p>I'm trying to do something very simple in Jquery which i just cant get to fire properly.</p> <p>The thing is, i'm writing this code in a separate HTML file on the same server and using PHP "include" to use it, the jQuery src is held on Google and referenced in the main index.php head tag.</p> <pre><code>&lt;script src="text/javascript"&gt; $(document).ready(function(){ $("#xmasOpen").click(function(){ $("#xmas").toggleSlide(); }); return false; }); &lt;/script&gt; </code></pre> <p>I've set #xmas to display: none in the CSS but just cant get it to action the jQuery if i click the href with id xmasOpen!?</p> <p>Anyone?</p>
jquery
[5]
267,913
267,914
Search in a two dimensional array and return the array list as a array
<p>How can I search in a two dimensional array and return the array list as a array?</p> <pre><code>var dataSet = new Array(new Array()); function searchAsset(){ dataSet.length = 0; var fileName = document.getElementById("fileName").value; var arr = new Array(["view_page.psd","test"],["ok_test.jpg","yes","kk"],["new_banner_2009.fla","good"],["gps-new-web.html","hot"]); var re = new RegExp(fileName ,'i'); var res = null; for(var i = 0;i&lt;arr.length;i++){ var newArr = arr[i][0]; //alert(newArr+":"+newArr.match(re)); var res = newArr.match(re); if(res != null){ dataSet.push("["+arr[i]+"]"); } } alert("Final --- "+dataSet); for(var m = 0;m&lt;dataSet.length;m++){ alert(dataSet[m]); } } </code></pre>
javascript
[3]
4,045,106
4,045,107
What's the point of "var t = Object(this)" in the official implementation of forEach?
<p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach" rel="nofollow">According to the MDC</a>, the ECMA-262, 5th edition gives the implementation of forEach as:</p> <pre><code>if (!Array.prototype.forEach) { Array.prototype.forEach = function(fun /*, thisp */) { "use strict"; if (this === void 0 || this === null) throw new TypeError(); var t = Object(this); var len = t.length &gt;&gt;&gt; 0; if (typeof fun !== "function") throw new TypeError(); var thisp = arguments[1]; for (var i = 0; i &lt; len; i++) { if (i in t) fun.call(thisp, t[i], i, t); } }; } </code></pre> <p>Can anyone tell me what the line "var t = Object(this)" is doing? How does Object(this) differ from plain this? And what work is that difference doing here?</p>
javascript
[3]
1,611,281
1,611,282
Website potential file lock issue
<p>I am writing a blog where I upload text documents to a directory that contain HTML. Using the code below, do you anticipate I will have any issues with file locking or other problems I am not seeing? I am most concerned about the File.ReadAllText().</p> <p>The directory will contain a list of files ex:</p> <p>20120101_2300.txt</p> <p>20120201_0100.txt</p> <p>etc...</p> <pre><code>public class Website { private string directory = "C:\\Web"; public List&lt;BlogEntry&gt; GetArchives() { return GetArchives(""); } public List&lt;BlogEntry&gt; GetArchives(string date) { var files = !string.IsNullOrEmpty(date) ? Directory.GetFiles(directory, "*.txt").Where(t =&gt; t.Contains(date)) : Directory.GetFiles("C:\\Web", "*.txt"); var sb = files.Select(file =&gt; new BlogEntry {FullPath = file}).ToList(); return sb.OrderByDescending(t =&gt; t.FileDate).Skip(5).ToList(); } public List&lt;BlogEntry&gt; GetRecent() { var files = Directory.GetFiles(directory, "*.txt"); var sb = files.Select(file =&gt; new BlogEntry {FullPath = file}).ToList(); return sb.OrderByDescending(t =&gt; t.FileDate).Take(5).ToList(); } } public class BlogEntry { public string FullPath { get; set; } public DateTime FileDate { get { return DateTime.ParseExact(Path.GetFileNameWithoutExtension(FullPath), "yyyyMMdd_HHmm", CultureInfo.InvariantCulture); } } public string FileContents { get { return File.ReadAllText(FullPath); } } } </code></pre>
c#
[0]
4,323,748
4,323,749
jQuery - Why won't select box info duplicate but the rest will
<p>I'm using the code below to try and duplicate information from one set of address fields to another set when a checkbox is checked. All of it works except for the state select box (drop down box). It's driving me crazy. </p> <pre><code> //on page load $(document).ready(function() { //when the checkbox is checked or unchecked $('#copyaddress').click(function() { // If checked if ($(this).is(":checked")) { //for each input field $('#cc input', ':visible', document.body).each(function(i) { //copy the values from the billing_fields inputs //to the equiv inputs on the shipping_fields $(this).val($('#info input').eq(i).val()); }); //won't work on drop downs, so get those values var c_state = $("select#c_state").val(); // special for the select $('select#cc_state option[value=' + c_state + ']').attr('selected', 'selected'); } else { //for each input field $('#cc input', ':visible', document.body).each(function(i) { // put default values back $(this).val($(this)[0].defaultValue); }); // special for the select $('select#cc_state option[value=""]').attr('selected', 'selected'); } }); }); </code></pre>
jquery
[5]
4,362,424
4,362,425
GPRS connection still connected while receiving phone call?
<p>Suppose one application is running which is using GPRS connection. If in between that if call comes what will happened with that GPRS connection?? It still persist or it is get disconnected??</p> <p>Thanks </p>
android
[4]
1,135,429
1,135,430
How can I create HTML database driven menubar in asp.net
<p>I have already menubar and database developed in Classic ASP &amp; SQL Server 2005. How can I convert this menubar in asp.net?</p>
asp.net
[9]
4,431,399
4,431,400
iphone customizing UIButtons
<p>how to customize the UIButton so that it will display other than the default button style.</p>
iphone
[8]
930,455
930,456
image resize from small to big without strech is possible?
<p>i want to script image size resize from small to big</p> <p>any idea?</p> <p>i used some script but when image size changed to big image is strech</p> <p>it is possible change image size without strech in php</p>
php
[2]
3,584,051
3,584,052
Dynamic change of the global clock in javascript
<p>I have to solve a problem that the user must change dynamic from global clock the time,day,date,city. Can someone help me.The different ways are: Sun Sunday</p> <p>28th March 2010 28 March 2010 28th Mar 2010 28 Mar 2010 28/03/2010 28th March 10 28 March 10 28th Mar 10 28 Mar 10 28/03/10 28th March 28 March 28th Mar 28 Mar 28/03</p> <p>5:28:12 am 5:28 am 5:28:12 5:28 17:28:12 17:28</p> <p>Thanks </p>
javascript
[3]
4,211,963
4,211,964
how to create a fragment in android 3.1?
<p>I want to create a fragment for my application. I have a book that talks about it but the activity is not good at all. I was wondering could anyone write up a small tutorial on how to create one and how to show information from a sqlite database in a list view in it? </p>
android
[4]
3,950,910
3,950,911
jQuery not working, need some serious help!
<p>i was working on a facebook like website and i had a modal window,curvy corners,auto grow-text area and a facebook like footer admin panel.but the modal window and auto grow-text area is not working since i added facebook like footer admin panel.im only using jQuery,no anyother famework and i dont know jQuery,i implement them to my site from downloading scripts can some one suggest me whats wron ?</p>
jquery
[5]
4,224,294
4,224,295
C# windows application not closing
<p>my post is same like <a href="http://stackoverflow.com/questions/465306/c-windows-application-not-closing">This</a>... but that post didn't solve'd my question, so my question is.</p> <p>m building a win app in c#, and in that im using <code>backgroundworkder thread</code> and <code>Application.DoEvents</code>. here's my code:</p> <pre><code>for(int i=0;i&lt;gridview.rows.count-1;i++) { if (backThread.CancellationPending) { e.Cancel = true; break; } string TargetFrame = ""; byte[] vPost = ASCIIEncoding.ASCII.GetBytes("_PostData"); string Header = "Content-Type: application/x-www-form-urlencoded" + "\n" + "\r"; autoWebPage.Navigate("https://xyz.com", TargetFrame, vPost, Header); while (car == false) { System.Threading.Thread.Sleep(500); Application.DoEvents(); } } </code></pre> <p>and this loop is under <code>BackGroundWorker_DoWork()</code> event, The Problem is m not able to close the form or application, i.e in taskmanager my app is still running, i dn't know what is the cause, maybe <code>Application.DoEvents</code> or <code>BackGroundWorker thread</code>, i google'd about this issue, but i didn't get any clear idea.. i tried to close the form using this:</p> <pre><code>//Application.Exit(); //mainmdiForm.Dispose(); //mainmdiForm.Close(); //backGroundWorker.CancelAsync(); </code></pre> <p>but no success. And one more thing while searchin' about this issue on google,, i got many results sayin' <code>Application.DoEvents()</code> is an EVIL, m curious why is that so ?</p>
c#
[0]
939,455
939,456
asp.net disconnected architecture
<p>can some one give me add new record program in sql database which include disconnected architecture? i want vb code not c#</p>
asp.net
[9]
5,683,401
5,683,402
open and save file dialog
<p>i use an openFileDialog to read from a text file and print the values in a listbox and a saveFileDialog to save the changes in textfile.i wrote this code but it doesn't work.if a change the listbox with a textbox works fine.But i need to print and save the items into a listbox.any suggestions?</p> <pre><code> private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { } private void button4_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { label7.Text = openFileDialog1.FileName; listBox1.Text = File.ReadAllText(label7.Text); } } private void button5_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { File.WriteAllText(saveFileDialog1.FileName, listBox1.Text); } } </code></pre>
c#
[0]
1,891,322
1,891,323
iphone - Interface Builder not loading custom class?
<p>I generally don't use Interface Builder (I hate it). But I am being forced to use it, because I was invited to a project where people are using it. I am trying to create a custom UISlider.</p> <p>I have created a UISlider custom class, with my own images for the slider parts.</p> <p>If I add a new object to my main code using </p> <pre><code>mySlider *one = [[mySlider alloc] initWithFrame:CGRectMake(0,0,60,30)]; </code></pre> <p>I see the slider as I created, beautifully.</p> <p>But if I use this class on interface builder, to change the appearance of a UISlider I create there, the slider continues to have the same appearance as before and when I run the app the interface shows the slider with the default appearance, not the one I designed.</p> <p>I created the slider on IB, simply dragging a UISlider on the interface and changing its class to the one I've created. Is there something else that has to be done? Why is it not showing as defined on the custom class?</p> <p>thanks</p>
iphone
[8]
605,188
605,189
how to check device is ipod when send sms inapps in iphone
<p>how to check device is ipod when send sms inapps in iphone. i want to diasable sending sms when device is ipod touch   here is my code</p> <pre><code> smsComposer = [[MFMessageComposeViewController alloc] init]; smsComposer.navigationController.navigationBarHidden = NO; smsComposer.wantsFullScreenLayout = YES; if([MFMessageComposeViewController canSendText]) { smsComposer.body = [NSString stringWithFormat:@"Join me : %@",urlStr]; smsComposer.recipients = numberArr; smsComposer.messageComposeDelegate = self; [self.view.superview addSubview:smsComposer animated:NO]; } </code></pre> <p>this wrking well for iphone For ipod sms sending facility not available . i want to chek if device is ipod .is antbody hav idea abt chking device type . Thanks</p>
iphone
[8]
5,338,857
5,338,858
jQuery - Targeting specific ID's
<p>I have the following code:</p> <pre><code>&lt;script type="text/javascript" language="javascript"&gt; $(document).ready(function() { $("input:checkbox").click(function(){ var group = "input:checkbox[name='"+$(this).attr("name")+"']"; $(group).attr("checked",false); $(this).attr("checked",true); }); }); &lt;/script&gt; </code></pre> <p>How do i get it to target a specific ID rather than every checkbox on the page?</p> <p>i.e if the group of checkboxes im trying to target is #thisgroup</p> <p>Cheers,</p>
jquery
[5]
1,484,778
1,484,779
How to do something before applicationDidFinishLaunching
<p>Apple allow us to define our own Logo image from simulator launch to execute applicationDidFinishLaunching end. Now I want to do something between Logo on screen to IPHONE display the first view. I don't know how to do this. Thanks everybody who help me</p>
iphone
[8]
2,855,648
2,855,649
Is it possible to let mouse events pass through a canvas layer?
<p>I have a grid of images and a canvas layer on top of it, I would like to do some animations on the canvas tag once the user rolls over a thumbnail image from the grid, so I wonder if is possible to let mouse events pass through the canvas layer?</p>
javascript
[3]
4,156,075
4,156,076
how to break chaining selectors in jquery
<p>I have some doubts in break the <code>jquery chaining selectors</code>.</p> <p>For example, Consider this is my sample code,</p> <pre><code>&lt;script&gt; $("#button1, #button2, #button3, #button4, #button5, #button6 ").show(); &lt;/script&gt; </code></pre> <p>I want to change like this format,</p> <pre><code>&lt;script&gt; $("#button1, #button2, #button3, #button4, #button5, #button6 ").show(); &lt;/script&gt; </code></pre> <p>Please help. Thanks in advance.. </p>
jquery
[5]
829,589
829,590
The roadmap to an Android development expert
<p>I just start to learn Android development.</p> <p>My previous experience is majorly about .NET framework in C#. Some experience with Linux. And basically no idea of Java.</p> <p>So, which is the good way to be an Android development expert? Some books? Study roadmap? Anything would be appreciated. I am all ears to your advices.</p> <p>Thanks.</p> <p>(Apologize if this is not the right place to post this.)</p>
android
[4]
5,737,357
5,737,358
processMessage(Chat chat, Message message) not working in Android
<p>I am using aSmack-2010.05.07 XMPP library for writing down chat application on android,</p> <p>Here is my associated code,</p> <pre><code>chatManager = LoginScreen.getConnection().getChatManager(); System.out.println("Chat Manager created ......."); chat = chatManager.createChat(JID,new MessageListener() { public void processMessage(Chat arg0, Message message) { System.out.println("MSG = "+message.getBody()); displayReceivedMesage(message.getBody()); } }); </code></pre> <p>but displayReceiveMessage()function never gets called, concludes that means the function</p> <p>processMessage() doesn't hit at all.</p> <p>Please Help me I am stuck here very badly.</p> <p>Any help will be appreciable. </p> <p>Best Regards,</p> <p>~Anup</p>
android
[4]
3,099,308
3,099,309
Stack over flow in java script inheritance!
<p>i have the below prog</p> <pre><code> Object.prototype.inherit = function(baseConstructor) { this.prototype = (baseConstructor.prototype); this.prototype.constructor = this; }; Object.prototype.method = function(name, func) { this.prototype[name] = func; }; function StrangeArray(){} StrangeArray.inherit(Array); StrangeArray.method("push", function(value) { Array.prototype.push.call(this, value); }); var strange = new StrangeArray(); strange.push(4); alert(strange); </code></pre> <p>and when irun it i get stack over flow? any ideas why?</p>
javascript
[3]
4,148,798
4,148,799
How can I use GLG toolkit in Java?
<p>Hello Everyone is Stack Overflow! =)</p> <p>I am doing my 3d transformation of an arm. After looking at one example in the Internet, I found out that the programmer is using GLG Toolkit to draw the robot arm he made, then connect(?) it to Java, to code the transformation.</p> <p>When I tried the code to my version of Java, it wouldn't work because the GLG toolkit can not be found in any of the Java Libraries. I am trying to find ways how can I use the GLG toolkit in my Java Application too.</p> <p>Through my further searches, I found out that there is a Java version for the GLG toolkit, however, I can't find one and I don't know how to connect(?) or use it in Java programs.</p> <p>Can you teach me how to use the GLG Java version in my application? Please send me answer if you know anything.</p> <p>Thank you. </p>
java
[1]
1,445,846
1,445,847
Accessing application data folder path for all Windows users
<p>How do I find the application data folder path for all Windows users from C#?</p> <p>How do I find this for the current user and other Windows users?</p>
c#
[0]
1,055,303
1,055,304
Integrate program on webserver
<p>I would like to make use of the tool "PDFToHTML" which you can find <a href="http://www.articlediary.com/article/php-script-for-pdf-to-html-conversion-125.html" rel="nofollow">here</a>. Unfortunately, I have no idea on how I need to install this and execute this on my webserver. I would like to know if some people are familair with this, if there are any tutorials available or something else because i have no idea on what to search for.</p> <p>Mainly I need help/tutorial on how to:</p> <ol> <li>Install the tool on the webserver. (My host is bluehost)</li> <li>Execute the program to create the files</li> <li>This is not necessary, but at the end I would like to zip the files.</li> </ol> <p>Here's some more information but they don't explain on how to install it. <a href="http://www.articlediary.com/article/php-script-for-pdf-to-html-conversion-125.html" rel="nofollow">http://www.articlediary.com/article/php-script-for-pdf-to-html-conversion-125.html</a></p>
php
[2]
3,925,360
3,925,361
Write to specific line in PHP
<p>I'm writing some code and I need to write a number to a specific line. Here's what I have so far:</p> <pre><code>&lt;?php $statsloc = getcwd() . "/stats/stats.txt"; $handle = fopen($statsloc, 'r+'); for($linei = 0; $linei &lt; $zone; $linei++) $line = fgets($handle); $line = trim($line); echo $line; $line++; echo $line; </code></pre> <p>I don't know where to continue after this. I need to write $line to that line, while maintaining all the other lines.</p>
php
[2]
1,746,374
1,746,375
jQuery animate height in different class
<p>Is it possible to have height of animate in different class as is in my case ".bar1"???</p> <p><code>$('.bar1').animate({'height':'58%'},1000);</code></p> <p>Just to get idea what I mean: <strong>'.bar_graf'</strong></p> <p><code>$('.bar1').animate({'.bar_graf'.'height':'58%'},1000);</code></p>
jquery
[5]
5,006,705
5,006,706
Store plus and minus in a variable PHP
<p>How can I solve this problem:</p> <pre><code>if ($variable == 1) { $math = "-"; } else { $math = "+"; } $numberOne = 10; $numberTwo = 10; $result = $numberOne $math $numberTwo; </code></pre> <p>This doesn´t work, is there any way to solve this?</p>
php
[2]
337,631
337,632
Access to Compiler's errors and warnings
<p>i'm developing a simple C# Editor for one of my university courses and I need to send a .cs file to Compiler and collect errors (if they exist) and show them in my app. In other words i want to add a C# Compiler to my Editor. Is there anything like this for the debugger?</p>
c#
[0]
4,518,161
4,518,162
Combining List<Base> with List<Derived>
<p>How can I do the follwing:</p> <pre><code>public class BaseItem { public string Title { get; set; } } public class DerivedItem : BaseItem { public string Description { get; set; } } class Program { static void Main(string[] args) { List&lt;BaseItem&gt; baseList = new List&lt;BaseItem&gt;(); List&lt;DerivedItem&gt; derivedList = new List&lt;DerivedItem&gt;(); baseList.Add(new BaseItem() { Title = "tester"}); derivedList.Add(new DerivedItem() { Title = "derivedTester", Description = "The Description" }); baseList.AddRange(derivedList); } } </code></pre> <p>Thanks, Henk</p>
c#
[0]
4,396,948
4,396,949
Jquery Animate DIV
<p>Hi Am using Jquery animate function to animate div content am trying to move div to -top,The problem is not able to stop function its moving to exteme top=-10px i wanna move it to in intervals that is onscrolling it should move to -10px of existing height in next interval again it should move to further -10px on movement of scroll</p>
jquery
[5]
1,547,061
1,547,062
log IP with php
<p>I found this script online:</p> <pre><code>&lt;?php $v_ip = $REMOTE_ADDR; $v_date = date("l d F H:i:s"); $fp = fopen("ips.txt", "a"); fputs($fp, "IP: $v_ip - DATE: $v_date\n\n"); fclose($fp); ?&gt; </code></pre> <p>Creating the entry works. However, the IP is not displayed. The entries created look like this:</p> <pre><code>IP: - DATE: Wednesday 09 March 03:36:15 IP: - DATE: Wednesday 09 March 03:36:41 </code></pre> <p>What's the problem?</p>
php
[2]
883,265
883,266
Losing Session Variables during internet reconnection
<p>I have looked for help on this problem, but not found anything quite like it.</p> <p>I have an asp.net web site which 1 user (that I know of) is getting problems with being logged out (forms auth) and losing session variables.</p> <p>I think basically what is happening is the user is using a mobile internet connection, which is sometimes flaky and drops the connection and reconnects, sometimes but not always with a new ip address. I think this is destroying the values stored in session state.</p> <p>Is this a problem anyone has had, and if so, how do you get round it? I guess it could get worse if more people connect to the internet in this way.</p> <p>Often the error is the View state mac error, but not always.</p> <p>Of course, it may not be related to internet connection issues.</p> <p>Many thanks</p>
asp.net
[9]
5,046,585
5,046,586
Prepend a DIV already hidden so I can animate a slide in
<p>I use an ajax call to retrieve a div that I want to prepend to my results DIV. I don't want to add the style display:none to the div before it is returned because I use the same code elsewhere and don't want that style attached.</p> <p>That being said how do I prepend an element to a div already hidden so I could use the fadeIn or slideIn function.</p> <p>Here is what I have so far:</p> <p>$('#results').prepend(singleresult);</p> <p>singleresult contains a div with the result. </p> <p>How do I make singleresult hidden before I prepend it so I can use a fancy automation function to get it to show?</p>
jquery
[5]
3,505,022
3,505,023
Protecting JavaScript? Or use Something else?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript">How can I obfuscate JavaScript?</a> </p> </blockquote> <p>I have been working on a web app in JavaScript. Nearing complete.</p> <p>How do I protect me JavaScript code from someone copying it? I mean if you view my page source, it references the .js files and one could really steal these.</p> <p>Should I be using something else? RoR?</p> <p>Does Google Maps have a RoR API?</p>
javascript
[3]
3,487,257
3,487,258
C++ class type copy-initialization
<p>If I write </p> <pre><code>T t = T(); </code></pre> <p>T is a class.</p> <p>I think this is calling T's default constructor and then the copy assignment operator. But the compiler is allowed to get rid of the assignment.</p> <p><strong>I'm trying to find the description of this behavior written in the C++ standard, but I can't find it. Could you point me to the right spot in the standard?</strong></p> <p>I'm asking this because I'm being asked to replace this :</p> <pre><code>T t; </code></pre> <p>with</p> <pre><code>T t = T(); </code></pre> <p>because of a coding rule checking program.</p> <p>and it happens that the T class is noncopyable and has a private copy constructor and copy assignment operator... So I'd like to see that the compiler is effectively always getting rid of the copy in this case.</p> <p><strong>edit:</strong> I have been mislead by something weird: the noncompyable class was actually inheriting from boost::noncopyable in this case it does compile. But if I declare the copy constructor and copy assignment operator private, it does not compile. exemple. This compiles : </p> <pre><code>class BA { protected: BA() {} ~BA() {} private: BA( const BA&amp; ); const BA&amp; operator=( const BA&amp; ); }; class A : BA { }; int main( void ) { A a = A(); return 0; } </code></pre> <p>and the following does not : </p> <pre><code>class A { public: A() {} ~A() {} private: A( const A&amp; ); const A&amp; operator=( const A&amp; ); }; int main( void ) { A a = A(); return 0; } </code></pre>
c++
[6]
239,217
239,218
Why can't an anonymous class have a lambda property, but it can have a Func<> property?
<p>I'm trying to learn C#'s restrictions on an anonymous type. Consider the following code:</p> <pre><code> var myAwesomeObject = new { fn1 = new Func&lt;int&gt;(() =&gt; { return 5; }), fn2 = () =&gt; { return 5; } }; </code></pre> <p>So we've got two properties that are actually functions:</p> <ul> <li><code>fn1</code>: A <code>Func&lt;int&gt;</code> that returns <code>5</code>.</li> <li><code>fn2</code>: A lambda function that returns <code>5</code>.</li> </ul> <p>The C# compiler is happy to work with fn1, but complains about fn2 :</p> <blockquote> <p>cannot assign lambda expression to anonymous type property.</p> </blockquote> <p>Can someone explain why one is ok but the other is not?</p>
c#
[0]
2,415,011
2,415,012
limit on string size in c++?
<p>I have like a million records each of about 30 characters coming in over a socket. Can I read all of it into a single string? Is there a limit on the string size I can allocate?</p> <p>If so, is there someway I can send data over the socket records by record and receive it record by record. I dont know the size of each record until runtime.</p>
c++
[6]
2,414,701
2,414,702
more space appears between spinner and EditTExt
<p><br> I am writing an android where I need to display Spinner and EditText . I am using LinearLayout with vertical orientation. I am getting lot of space between spinner and EditText. Can anyone help me in sorting out this issue. <br> Thanks in Advanvce</p>
android
[4]
3,729,659
3,729,660
Numberofcomparison and nunber of item movements
<p>Im using c++ and is using insertion sort</p> <p>Where in the insertion sort algoithm should we put a counter to monitor number of item movements and number of item comparison. I have included my setup below</p> <pre><code>void InsertionSort::insertion_sort() { int key,i,count = 0; for(int j=1;j&lt;10;j++) { key=Arr1[j]; i=j-1; while(Arr1[i]&gt;key &amp;&amp; i&gt;=0) { Arr1[i+1]=Arr1[i]; i--; numberOfItemMovements++; } Arr1[i+1]=key; } } } </code></pre> <p>as you can see, i cant seem to figure out where comparison counter should be put, although the item movement counter is good and work as expected. thanks</p>
c++
[6]
891,768
891,769
my app killed by android system when it running in background
<p>I want to create application that can play a streaming music . When I press home my app can running in background but when I open another application that use more memory my app will stop and killed by android system . Anyone have another idea to run my music player app in background? </p> <p>thank you</p>
android
[4]
5,681,513
5,681,514
converting binary string into float
<p>I have an object that I am storing bits in. </p> <pre><code>class Bitset: def __init__(self, bitstring): self.bitlist = [] for char in bitstring: self.bitlist.append(int(char)) def flipBit(self, index): val = self.bitlist[index] val = (val + 1) % 2 self.bitlist[index] = val self.newBitstring() def bitstring(self): newString = '' for val in self.bitlist: newString = newString + str(val) return newString def __len__(self): return len(self.bitlist) def __str__(self): return self.bitstring() def __repr__(self): return self.bitstring() </code></pre> <p>Is there anyway I can convert the bits into a float? Thanks.</p>
python
[7]
1,628,358
1,628,359
why there is no Center() method for Rectangle class in c#?
<p>previously, there is such method for Rectangle in MFC, i dont know why there is not for the c# version.</p>
c#
[0]
4,829,709
4,829,710
What effect does FireBug, Inspection Tools etc. Have on the window?
<p>I have a rather bizarre issue. I'm modifying the jQuery BookBlock plugin;</p> <p><a href="http://tympanus.net/codrops/2012/09/03/bookblock-a-content-flip-plugin/" rel="nofollow">http://tympanus.net/codrops/2012/09/03/bookblock-a-content-flip-plugin/</a></p> <p>To work with a full-screen page flip effect &amp; a sidebar. I've come to a brick-wall so to speak with is made more annoying by the following behaviour.</p> <p>On window load my sidebar slides in &amp; the page-flip effect gets knocked off centre. Strangely, opening and then closing any kind of 'Inspection Tools' in all browsers seems to reset a variable somewhere and re-centers my animation.</p> <p>So with that in mind here's my question, what effect does opening inspection tools or similar have on a window, and how can I replicate this within my jQuery?</p>
jquery
[5]
1,930,002
1,930,003
Weird PHP Behavior
<pre><code>&lt;?php $dog[] = "12"; $dog[] = "3"; for ($i = 0; $i &lt; 2; $i++) { $dig = $dog[i]; echo $dig; } ?&gt; </code></pre> <p><code>$dig</code> is always null. Why?</p>
php
[2]
721,895
721,896
Abstract Base Class with Data Members
<p>If I'm creating an abstract base class, and the classes derived from it are going to have some of the same data members, is it better practice to make those members private in the abstract base class and give protected access to them? Or to not bother and just put the data members in the derived classes. This is in C++.</p>
c++
[6]
3,480,964
3,480,965
slider gallery with touch recognition
<p>HI i was following this example to create a slider gallery</p> <p>"http://lievendekeyser.net/index.php?module=messagebox&amp;action=message&amp;msg_id=1351"</p> <p>But i stuck at one point. what i am trying to do is, when user double tap on current image, it should navigate to another view, like to view B.</p> <p>But i am not able to navigate and detect double tap on current image.</p> <p>suggestions needed. regards</p>
iphone
[8]
1,251,414
1,251,415
logical operators in java
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/684648/a-clear-laymans-explanation-of-the-difference-between-and-in-c">A clear, layman&#39;s explanation of the difference between | and || in c# ?</a><br> <a href="http://stackoverflow.com/questions/96667/whats-the-difference-between-and-in-java">What&#39;s the difference between | and || in Java?</a> </p> </blockquote> <p>what is the difference between the operator | and the operator || ?? and also what is the difference between &amp; and &amp;&amp; ??</p> <p>thanks...</p>
java
[1]
2,676,497
2,676,498
Killing the Background running Activities such as Messaging, Browser, Contact etc in Android
<p>I am trying to Kill the Background running Activities such as Messaging, Browser, Contact etc in Android. I have written the following code.</p> <pre><code>amm=(ActivityManager) getSystemService(ACTIVITY_SERVICE); List&lt;RunningTaskInfo&gt;task1=amm.getRunningTasks(20); for (ActivityManager.RunningTaskInfo aTask1 : task1) { packagename=aTask1.topActivity.getPackageName(); Log.d("raghutest", ""+packagename); myarraylist.add(packagename); } if(myarraylist.get(position) != null) { am.killBackgroundProcesses(myarraylist.get(position)); Log.d("result", "task successfully killed"+myarraylist.get(position)); } } </code></pre> <p>But I am getting warning something like this </p> <blockquote> <p>WARN/InputManagerService(68): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44f2ebf8</p> </blockquote>
android
[4]
788,136
788,137
Carriage return and new line with Java and readLine()
<p>I am using the following code to establish a HTTP connection and read data:</p> <pre><code>con = (HttpURLConnection) new URL("http://stream.twitter.com/1/statuses/sample.json").openConnection(); ... con.connect(); while (line = rd.readLine()) { if (line.contains("\r\n")) { System.out.println("Carriage return + new line"); } } </code></pre> <p>However, it seems like "\r\n" is not part of the string (<code>line</code>), although the server does return them. How can I read the data and detect "\r\n"?</p> <p>Thanks,</p> <p>Joel</p>
java
[1]
1,026,988
1,026,989
what is the pregmatch to retrieve these values using javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8355422/what-is-the-reg-expression-for-this-using-javascript">What is the reg expression for this using javascript</a> </p> </blockquote> <p>How to retrieve the value 100003119917070 and XgXELcliKMkSCcS from below document using preg match </p> <pre><code>&lt;script&gt; window.Env = window.Env || {}; (function(v) { for (var k in v) { window.Env[k] = v[k]; } })({ "user": "100003119917070", "locale": "en_US", "method": "GET", "ps_limit": 5, "ps_ratio": 4, "svn_rev": 479734, "static_base": "https:\/\/s-static.ak.facebook.com\/", "www_base": "http:\/\/www.facebook.com\/", "rep_lag": 2, "post_form_id": "6cea66d4118fac268304a538a5004ed7", "fb_dtsg": "AQAcBeoe", "ajaxpipe_token": "AXgXELcliKMkSCcS", "lhsh": "8AQGGa7eN", "tracking_domain": "https:\/\/pixel.facebook.com", "retry_ajax_on_network_error": "1", "ajaxpipe_enabled": "1" }); &lt;/script&gt; &lt;script&gt; CavalryLogger=false; window._incorporate_fragment = true; window._script_path = "\/home.php"; window._EagleEyeSeed="Se1E"; &lt;/script&gt; </code></pre>
javascript
[3]
5,368,695
5,368,696
how to fetch image path from database using byte array in android
<p><strong>W/System.err(15366): android.database.CursorIndexOutOfBoundsException: Index 1 requested, with a size of 1</strong> </p> <pre><code>byte[] bytes = cur.getBlob(cur.getColumnIndex(imgarr.get(i))); ByteArrayInputStream input = new ByteArrayInputStream(bytes); Bitmap bit = BitmapFactory.decodeStream(input); </code></pre>
android
[4]
993,078
993,079
How to create custom action for an object?
<p>I have an object, let's say FOO, with a variable, percent...</p> <p>I need to create an Action percentChanged, which will be triggered when the variable percent is changed, which will handled by an ActionListener in another object ...</p> <p>How to do it in java ?</p>
java
[1]
209,353
209,354
Question about the android .finish() method
<p>whats the difference between MyActivity.finish() and MyActivty.this.finish()? I see an example where MyActivty.this.finish() is called from hitting the OK button on a dialog asking if you want to exit the app. isn't the ".this" part redundant?</p>
android
[4]
2,691,626
2,691,627
Deleting table view cell without a red default delete button at left side
<p>how to delete cell of table view without a red default delete button at left side (peforming delete action on anoher button) so can any one help me </p>
iphone
[8]
1,465,910
1,465,911
C++ nested classes accessibility
<p>Given the following code <strong>without considering friendship</strong> between two classes:</p> <pre><code>class OutSideClass { ... public: int i_pub; protected: int i_pro; private: int i_pri; class InSideClass { ... public: int j_pub; protected: int j_pro; private: int j_pri; }; }; </code></pre> <p>Question 1> Is it true that OutSideClass can ONLY access public members of InSideClass</p> <p>Question 2> Is it true that InSideClass can access all members of OutSideClass</p> <p>Please correct me if my understanding is not correct.</p>
c++
[6]
3,058,197
3,058,198
How to implement expandable view (window shade) in Android?
<p>Does anybody know how to implement an expandable view which behaves like the status bar? I've seen it in many apps, so I assume it's not too difficult :)</p>
android
[4]
936,064
936,065
How can I bind distinct playlist title from database to checkbox list
<pre><code>private void chkDeletePlaylistBind() { chkDeletePlaylist.DataSource = objEntities.Playlists.OrderBy(del =&gt; del.PlaylistTitle).Distinct(); chkDeletePlaylist.DataTextField = "PlaylistTitle"; chkDeletePlaylist.DataValueField = "PlaylistID"; chkDeletePlaylist.DataBind(); } </code></pre> <p>It does not brings the distinct values to the check box list. Please help me to solve this issue. </p>
asp.net
[9]
159,976
159,977
check for undefined variable
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2559318/how-to-check-for-undefined-or-null-variable-in-javascript">How to check for undefined or null variable in javascript</a> </p> </blockquote> <p>I want to check for an defined variable in javascript. Please see the following few examples and help me which is the best method to check 'a' for undefined (and check for nothing else) in Javascript?</p> <p>one</p> <blockquote> <p>if(a === undefined) { ... }</p> </blockquote> <p>second</p> <blockquote> <p>if(a === "undefined") { ... }</p> </blockquote> <p>third</p> <blockquote> <p>if(typeof a == "undefined") { ... }</p> </blockquote> <p>last</p> <blockquote> <p>if(a) { ... }</p> </blockquote>
javascript
[3]
2,751,720
2,751,721
It is possible to get keys from $_GET in php?
<p>I just ask if it is possible to get keys from $_GET ...</p> <p>I want to do a switch statement like</p> <pre><code>switch($_GET key) //here I don't know { case "login": .... break; //if "login" key exists in $_GET then show page. .... } </code></pre> <p>Sorry for idiot question</p>
php
[2]
5,164,384
5,164,385
How to set style for spinner programmatically?
<p>I have spinner with a style selection (I set the spinner style in <code>strings.xml</code>) and it's works well if I set the style in <code>main.xml</code>. But I want to know how to set the style programmatically in which the style already defined in <code>strings.xml</code>.</p> <p>Refer my code below</p> <p><strong>main.xml:</strong></p> <pre><code> &lt;Spinner android:id="@+id/PassengersSpinner1" android:layout_width="100dp" android:layout_height="40dp" android:layout_span="3" android:layout_marginTop="6dp" style="@style/SpinnerStyle" /&gt; </code></pre> <p><strong>strings.xml:</strong></p> <pre><code> &lt;style name="SpinnerStyle" parent="@android:style/Widget.Spinner"&gt; &lt;item name="android:background"&gt;@android:drawable/btn_default&lt;/item&gt; &lt;/style&gt; </code></pre> <p>Now, I want to know that how can I set this <code>strings.xml</code> programmatically without <code>main.xml</code>?</p>
android
[4]
2,289,051
2,289,052
jQuery disable all button of a css class and input type button
<pre><code>&lt;input class="submit2" type="button" name="submit2" value="Submit" id="submit1" onclick=""&gt; </code></pre> <p>I want to disable the button on my page after clicking it. to avoid double click.</p> <p>i have tried following code</p> <pre><code>$(document).ready(function() { $('.submit2').click(function() { $("input.submit2").attr('disabled', true); }); });​ </code></pre> <p>but it is working only when the input type of button is submit not button.</p> <p>how to resolve this issue.</p> <p>Thanks in advance.</p>
jquery
[5]
3,188,623
3,188,624
How a parent view can control the drawing of it's children when they are not aware of each other but must share a common canvas
<p>My apologies if the question title is not very clear. Difficult to describe in a sentence!</p> <p>I have a view which contains a custom view which implements a graph plot. It also contains a cursor which the user can drag over the graph to get further data about the points of the graph. Imagine a sine wave with a cross hair which draws vertical and horizantal lines which intersect the graph. By dragging the vertical line, the user can see detailed information about the data point which is intersected by the horizantal line. </p> <p>My problem is that my current design follows good OOP principles, which I'd like to maintain, in that the graph and the cross hair have no knowledge of each other. The only common point is the parent view class. </p> <p>a. The cross hair ideally should draw on the canvas of the graph. </p> <p>b. When the graph redraws, the cross hair should also redraw. </p> <p>I can create an Interface to describe an onDrawListener which I would fire from within the onDraw method of the graph. Any declared callbacks to the interface would be passed a reference to the graph canvas. The parent view can then call the draw method of the cross hair, passing the canvas reference in as an argument.</p> <p>However, this just feels wrong and I'm wondering if there is a more elegant pattern to achieve this. The only alternative I can see is to make the cross hair a private class of the graph but I lose some elegance and reusability.</p> <p>I'm hoping it's nothing obvious as I've spent quite some time thinking this through :)</p>
android
[4]
1,281,466
1,281,467
execute flush javascript before finishing
<p>i've written a function which waits x milliseconds before executing another function. now i have problem with that it won't execute any change until it finishes.</p> <pre><code>this.changeColor('#99FFCC'); this.pausecomp(this, 'changeColor','#FFFFFF', 1000); changeColor = function (color) { this.inputElem.style.backgroundColor = color; }; pausecomp = function (element, meth, argument, ms) { ms += new Date().getTime(); while (new Date() &lt; ms) {} element[meth](argument); } </code></pre> <p>this script will execute as expected but it won't change color until it finishes all. so firt color won't be displayed for 500ms ...</p> <p>i can't use setTimeout() </p> <p>my main goal is to blink textbox background so if there's a way to do this with css or any other please tell me.</p> <p>Thanks</p>
javascript
[3]
3,706,874
3,706,875
How to use Android-Wheel into my project
<p>I have zip file of Android-wheel but dont know how to use it into my project.What possible things can i do, Please suggest me.</p>
android
[4]
2,605,409
2,605,410
Start a windows service and launch cmd
<p>Do I need to enable Interactive desktp for it to work and what is the correct code to start an EXE or cmd window? I'm still unable to start the service even when I had enable it to interact with desktop.</p> <p>I would be using an chat engine so it is easier to manage as a windows service. </p> <p>What wrong with my code?</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceProcess; using System.Diagnostics; using System.ComponentModel; using System.Threading; namespace MyNewService { class Program : ServiceBase { static void Main(string[] args) { } public Program() { this.ServiceName = "Chatter"; } protected override void OnStart(string[] args) { base.OnStart(args); //TODO: place your start code here ThreadStart starter = new ThreadStart(bw_DoWork); Thread t = new Thread(starter); t.Start(); } private void bw_DoWork() { Process p = new Process(); p.StartInfo = new ProcessStartInfo(@"C:\Windows\system32\cmd.exe"); p.Start(); p.WaitForExit(); base.Stop(); } protected override void OnStop() { base.OnStop(); //TODO: clean up any variables and stop any threads } } } </code></pre>
c#
[0]
1,602,165
1,602,166
General question about iPhone programming
<p>I have a question regarding nibs and how detail views are created in professional apps. I want to make an app that loads different uitextfields for each nib that is selected from a table. These textfields contain some logic that is different from each. I wanted to ask if it's possible to make one nib and change the data from thatto match all these scenarios. I'm unsure how this is done and how nib management can be done by arrays. Thanks and I hope I was clear enough :)</p>
iphone
[8]
3,540,618
3,540,619
Where is the SKU Number Iphone App
<p>Where do I find the SKU number for my iphone app? Is it in xcode somewhere?</p>
iphone
[8]
3,542,718
3,542,719
Java won't recognize defined variables?
<p>In <code>actionPerformed</code> it seems that all variables (submit, msg, input) "cannot be resolved" according to Eclipse. In my experience (of which I have very little) this means that I have not defined the variables. But, as you can see in the code, I have defined them. Submit is a JButton, msg is a string, input is a JTextField. </p> <pre><code>package levels; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import java.util.*; public class LevelOne extends JFrame implements ActionListener{ private Object msg; public void one(){ setTitle("Conjugator"); setSize(400,400); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); setLayout(new BorderLayout()); setContentPane(new JLabel(new ImageIcon("images/LevelOneBG.gif"))); setLayout(new FlowLayout()); JTextArea area = new JTextArea("You enter a castle. A Goblin demands you correct his sentences!"); add(area); setVisible(true); //these aren't being called to actionPerformed JButton submit = new JButton("Check sentence"); submit.addActionListener(this); setVisible(true); JTextField input = new JTextField("Ich spielen Golf."); input.setActionCommand("input"); add(input); input.addActionListener(this); setVisible(true); String msg = ("Test successful"); } //this should be successfully locating and utilizing "submit", "input" and "msg", but it won't public void actionPerformed(ActionEvent e) { if (e.getSource() == submit) { msg = submit.getText(); //!! Display msg only **after** the user has pressed enter. input.setText(msg); } } } </code></pre> <p>I am aware some of my imports are unnecessary.</p> <p>P.S., i'm making a small text adventure game for my German class</p>
java
[1]
3,211,957
3,211,958
Should you always refer to local class variables with "this"
<p>In C# you can refer to values in a class using the 'this' keyword.</p> <pre><code>class MyClass { private string foo; public string MyMethod() { return this.foo; } } </code></pre> <p>While I presume the answer will likley be user preference, is it best practice to use the this keyword within a class for local values?</p>
c#
[0]
861,027
861,028
What is most beneficial to use? $(this) vs. this
<p>When is it most beneficial to use <code>$(this)</code> and when should I use the plain old <code>this</code> (<code>$(this)[0]</code>)?</p> <p>I have posted on <a href="http://stackoverflow.com">SO</a> before, where someone told me I shouldn't use <code>$(this)</code> so much in my function but rather <code>this</code>.</p> <p>Why? Is <code>$(this)</code> rather memory intensive or something? Or does it sometimes contain more data than you are currently using in your function (too much overhead)?</p>
jquery
[5]
4,710,857
4,710,858
Java: having files containing only general methods?
<p>I was wondering if there was a way to have methods separated from the main and class files (like how in c you can have .c &amp; .h with just methods that you can import into projects).</p> <p>Specifically I have a 'logical exclusive or' function that I want to use across several classes and I thought it would be good practice not to have the same function repeated across several classes.</p>
java
[1]
773,701
773,702
how to place geopoints on the image as map in android
<p>hi this raju iam new to android. i created a small project in that project i displayed a image as map with custom view. I have latitude and longitude point then how to show geopoints on image by using my latitude and longitude points please anyone help me. if any one knows please provide some samples.</p>
android
[4]
4,279,508
4,279,509
Circle voice animation in Android
<p>Does anybody know how to build the growing circle animation like the "Talk now" in Android?</p> <p><img src="http://i.stack.imgur.com/vb8hj.png" alt="Animation"></p>
android
[4]
1,110,166
1,110,167
Permission denied in Android terminal Emulator
<p>i always get <strong>permission denied</strong> when i open the android terminal emulator? I want to change the hosts for android , but I cant because the permission denied ? How can I fix it ?</p> <p><strong>I want to change the host to point on another pc so i see the request there and check if there the service is from a mobile device so i can reroute it to mobile page</strong></p>
android
[4]
2,204,085
2,204,086
Android - some code executes after the phone went to a different Activity
<p>I have a strange scenario here. </p> <p>I have this code:</p> <pre><code>// For checking if the person is logged in. first_time_check(); setContentView(R.layout.main); // ...next lines of code </code></pre> <p>and the first_time_check() function checks if the user is logged in for the first time. If their user_id is not in the SharedPreferences, I redirect them to log in:</p> <pre><code>public void first_time_check() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences( ProblemioActivity.this); String user_id = prefs.getString( "user_id", null ); // First arg is name and second is if not found. String first_time_cookie = prefs.getString( "first_time_cookie" , null ); // About setting cookie. Check for first time cookie if ( first_time_cookie == null ) { // This user is a first-time visitor, 1) Create a cookie for them first_time_cookie = "1"; // 2) Set it in the application session. prefs.edit().putString("first_time_cookie", first_time_cookie ).commit(); // Make a remote call to the database to increment downloads number // AND send me an email that it was a new user. } else { // If not first time, get their id. // If user_id is empty, make them an account. // If id not empty, call the update login date and be done. if ( user_id == null ) { // User id is null so they must have logged out. Intent myIntent = new Intent(ProblemioActivity.this, LoginActivity.class); ProblemioActivity.this.startActivity(myIntent); } else { // Make a remote call to the database to increment downloads number } } return; } </code></pre> <p>So after the code executes the </p> <pre><code> Intent myIntent = new Intent(ProblemioActivity.this, LoginActivity.class); ProblemioActivity.this.startActivity(myIntent); </code></pre> <p>it still executes below the original code that calls this functions.</p> <p>Any idea how that can happen?</p> <p>Thanks!!</p>
android
[4]
4,322,494
4,322,495
What is the "double tilde" (~~) operator in JavaScript?
<p>I'm seeing this in some code, and I have no idea what it does:</p> <pre><code>var jdn = function(y, m, d) { var tmp = (m &lt;= 2 ? -1 : 0); return ~~((1461 * (y + 4800 + tmp)) / 4) + ~~((367 * (m - 2 - 12 * tmp)) / 12) - ~~((3 * ((y + 4900 + tmp) / 100)) / 4) + d - 2483620; }; </code></pre> <p>What's the <code>~~</code> operator do?</p>
javascript
[3]
2,455,052
2,455,053
Validating extra letter in encrypted text in php
<p>Here is the method i am using encrypt and decrypt in php.</p> <pre><code>function ecrypt($str){ $key = "ABCDEH"; for($i=0; $i&lt;strlen($str); $i++) { $char = substr($str, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)+ord($keychar)); $result.=$char; } return base64_encode($result); } function decrypt($str){ $str = base64_decode($str); $result = ''; $key = "ABCDEH"; for($i=0; $i&lt;strlen($str); $i++) { $char = substr($str, $i, 1); $keychar = substr($key, ($i % strlen($key))-1, 1); $char = chr(ord($char)-ord($keychar)); $result.=$char; } return $result; </code></pre> <p>}</p> <p>The encrypted text may contain name and expiry date.If my encrypted text is:</p> <p><code>1yUoaCToqmsqq+4unuFdXWJc4R5hnmL</code></p> <p>i will decrypt and will calculate the expiry date but the problem is if the user entered <code>1yUoaCToqmsqq+4unuFdXWJc4R5hnmLL</code>(i added extra one letter in end of the encrypted key).</p> <p>If i decrypt it and check the expiry date, its also working.I should throw the error message in case of extra letters.</p> <p>Please advice me.</p>
php
[2]
3,774,849
3,774,850
Service state is reported incorrectly
<p>I installed my c# application as windows service using the following command,</p> <p>Installutil.exe</p> <p>The installation is done in 32 bit machine.And the c# application is using 8088 port. After installing the service the service property has changed to Automatic. When the system restart the service also will be get restarted. But some times it shows started as status ,but actually it is in stopped state and we need to manually start the service. Can some one tell me what went wrong in this.</p> <p>Thanks in advance.</p> <p>sangita</p>
c#
[0]
1,617,450
1,617,451
saving a pdf to the filesystem
<p>How can i save a pdf from a url using NSData in my iphone resources, and then call those up after every app launch to load.?</p>
iphone
[8]
5,410,973
5,410,974
CryptographicException is thrown on new MailMessage()
<p>I have the following code in an ASP.NET site</p> <pre><code>using (MailMessage mailMessage = new MailMessage()) { ... } </code></pre> <p>throws System.Security.Cryptography.CryptographicException: The handle is invalid. exception.</p> <p>The SMTP setting in my web.config file is:</p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp deliveryMethod="Network" from="[email protected]"&gt; &lt;network host="smtp.gmail.com" defaultCredentials="false" enableSsl="true" port="587" userName="[email protected]" password="mypass" /&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; </code></pre> <p></p> <p>This was working yesterday. The exception started to thrown today - after I upgraded to VS 2012.</p> <p>Anyone has seen this before?</p>
asp.net
[9]
2,928,820
2,928,821
Creating a regex for parsing screens resolutions
<p>I have a string of text that somewhere will contain the resolution to my vid in the format <code>###x###</code> or <code>####x####</code> (ex. 320x240 or ex. 1024x1280 ex. 320x1024 etc.) or any combo in between. I am not great at regexes yet and I was wondering if anyone could point out where I am going wrong.</p> <pre><code>$res='some long string'; $search='/([0-9]{3-4})x([0-9]{3-4})/'; preg_match($search, $res, $matches); $res1=$matches[1]; $res2=$matches[2]; </code></pre>
php
[2]
381,797
381,798
add column title
<p>is it possible add column title in case of multicolumn autocomplete</p>
jquery
[5]
1,228,582
1,228,583
IE 8 not executing JQUERY slideDown/Up() Properly
<p>I'm trying to apply jquery functions to a drop down menu and for some reason it only works with Firefox 3.5.7. Below is the HTML for the Dropdown Menu:</p> <pre><code>&lt;select name="Delivery" id="Delivery" class="pulldown" tabindex="24"&gt; &lt;option id="pick_up" value="Pick up"&gt;Pick up&lt;/option&gt; &lt;option id="mail" value="First Class Mail"&gt;First Class Mail&lt;/option&gt; &lt;option id="fax_mail" value="Fax and Mail"&gt;Fax and Mail&lt;/option&gt; &lt;option id="fedex" value="FedEx"&gt;FedEx&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Here's the jquery for the above:</p> <pre><code>$(document).ready(function() { $("#mail").click(function() { $("#rec_address").slideDown("slow"); $("#faxnumber").slideUp("slow"); $("#pmtmethod").slideUp("slow"); } ); }); $(document).ready(function() { $("#fax_mail").click(function() { $("#faxnumber").slideDown("slow") $("#rec_address").slideDown("slow"); $("#pmtmethod").slideUp("slow"); } ); }); $(document).ready(function() { $("#fedex").click(function() { $("#pmtmethod").slideDown("slow") $("#rec_address").slideDown("slow"); $("#faxnumber").slideUp("slow"); } ); }); $(document).ready(function() { $("#pick_up").click(function() { $("#pmtmethod").slideUp("slow") $("#rec_address").slideUp("slow"); $("#faxnumber").slideUp("slow"); } ); }); </code></pre> <p>The above JQUERY works very very well with Firefox but does not work at all with any other browser. I'm only concerned with IE though so if you all have absolutely any idea how to make this work please let me know....I'm desperate!!! :( THanks and hope you all have a great week.</p>
jquery
[5]
2,090,742
2,090,743
Auto logoff while closing the winform
<p>I want to make auto logoff while closing the winform without timer access. How do I do that?</p>
c#
[0]
5,473,071
5,473,072
Sorting an object?
<p>How to sort this object lexicographically by its keys:</p> <pre><code>var obj = {'somekey_B' : 'itsvalue', 'somekey_A' : 'itsvalue'); </code></pre> <p>so that it outputs like this:</p> <pre><code>for (k in obj) { alert(k + ' : ' + obj[k]); //first "somekey_A : itsvalue"; then "somekey_B : itsvalue" } </code></pre>
javascript
[3]
1,335,129
1,335,130
C++ compilers implementing dynamic initialization after main
<p>The C++ standard section 3.6.2 paragraph 3 states that it is implementation-defined whether dynamic initialization of non-local objects occurs after the first statement of main().</p> <p>Does anyone know what the rationale for this is, and which compilers postpone non-local object initialization this way? I am most familiar with g++, which performs these initializations before main() has been entered.</p> <p>This question is related: <a href="http://stackoverflow.com/questions/6372032/dynamic-initialization-phase-of-static-variables">Dynamic initialization phase of static variables</a> But I'm specifically asking what compilers are known to behave this way.</p> <p>It may be that the only rationale for this paragraph is to support dynamic libraries loaded at runtime, but I do not think that the standard takes dynamic loading issues into consideration.</p>
c++
[6]