Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
5,677,121
5,677,122
Zoom an image with mouseover on image in another div
<p>There is many plugins for zooming image (like <a href="http://www.mind-projects.it/projects/jqzoom/index.php" rel="nofollow">jqzoom</a>). But I want to zoom image with hovering on image in another div: <img src="http://i.stack.imgur.com/6bHta.jpg" alt="enter image description here"></p> <p>Is there any way to have an effect like jqzoom (inner zoom)but with mouseover on another element? I want this effect : seavello.com/r/zoom/zoom.html, but with mouseover on thumbnial not main image Thanks in advance</p>
jquery
[5]
5,022,112
5,022,113
Splitting array not working in android
<p>I am splitting a string with some sample text in the middle. But it is not splitting. Please help me where i went wrong</p> <pre><code>String[] str; parts[1] = "loopstWatch out this is testingloopstThis makes the difference"; str = parts[1].trim().split("loopst"); </code></pre>
android
[4]
653,676
653,677
android volatile variable in BroadcastReceiver
<p>i have </p> <pre><code>public class ScreenReceiver extends BroadcastReceiver { private volatile boolean wifiNetwork = false; private volatile boolean mobileNetwork = false; } </code></pre> <p>and i am cheking boolean variable all the time receiver is executed. Is it smart to use <code>volatile</code> variable here or not? I don't have any thread but i always want the latest state of this variable.</p>
android
[4]
5,154,264
5,154,265
Android WebView consumes lots of power when the application is running in the background
<p>I have a WebView inside my android app, and this WebView is running a website with a fair bit of Javascript on it. Users have reported high power consumption when my app is running in the background, and I expect it is due to this javascript. However, I don't want to completely unload or remove the WebView, as this would hurt the time-to-resume.</p> <p>Is there any way to selectively turn off Javascript and/or disable the WebView completely when the app is in the background (onPause())?</p>
android
[4]
1,171,582
1,171,583
iPhone Application Deploy without using iTunes
<p>I want to build an application for the iPhone to be used inside a customer enterprise (very small, only 5 to 10 devices). But since they will be paying the application development, I don't want to distribute that application to the world inside the App Store in iTunes. How can I distribute this app to my customer? Should I get the Enterprise level subscription from the Apple Developer Program? Since I work as a freelancer, I think I can't subscribe to that program.</p>
iphone
[8]
3,054,039
3,054,040
jQuery Show/Hide Div
<p>I'm using this for a show/hide div expander, which is working fine, however, the HTML entities aren't being outputted.</p> <pre><code>$(document).ready(function() { $('.slickbox').hide(); $("#slick-toggle").toggle(function() { $(this).text("&amp;#9650; See Less"); $('.slickbox').slideToggle(500); }, function() { $(this).text("See More &amp;#9660;"); $('.slickbox').slideToggle(500); }); }); </code></pre> <p>Instead of showing the up or down arrow entities, it just outputs <code>&amp;#9660;</code></p> <p>How can I make it so it'll output the entities?</p> <p>Thanks.</p>
jquery
[5]
5,525,389
5,525,390
jquery offset behavior
<p>When you do something like this:</p> <pre><code>var originalOffset = something.offset() something.offset({top:0,left:0}) something.offset(originalOffset) </code></pre> <p>I would expect <code>something</code> to be in exactly the same position in the page afterwards. Well, this is not the case in my context. What properties of <code>offset()</code> destroy this desired behavior?</p>
jquery
[5]
3,310,487
3,310,488
Android games android apps beginner question
<p>as a title how to start creating android games? Is there any sample code for android games creation , what graphic library used ? </p> <p>Thanks.</p>
android
[4]
800,618
800,619
Validate textarea before form submission
<p>How can you validate a <code>&lt;textarea&gt;</code> after data has been entered (blur?) and before a form has been submitted?</p> <p>For instance, I have a <code>&lt;textarea&gt;</code> and the user enters in this data:</p> <pre><code>alpha beta charlie delta </code></pre> <p>After the user is done entering in this data and the textarea is no longer focused, I'd like for it to validate and alert the user if they entered the word <code>beta</code></p>
jquery
[5]
4,746,574
4,746,575
Putting core classes above the web root - good or bad idea?
<p>We are developing several web applications to run on our own server that will share a number of core classes as part of their MVC setup.</p> <p>I'm thinking of putting the classes above the web root so all applications can autoload() those classes using just one copy and not worry about synching issues.</p> <p>Specialised classes would go in their relevant web directory, but shared libraries would go under /var/www/shared-libraries or something similar.</p> <p>Apart from the potential to crash all sites simultaneously with a bad line of code, is there any reason why I wouldn't want to go down this path?</p> <p>Thanks.</p>
php
[2]
5,328,678
5,328,679
Looping over input elements with jQuery each()
<p>I have written some code that basically attach handler to onsubmit event, but there is a bug that I don't know how to fix.The problem is that when input fields in the form are empty , and code enters the <code>if</code> block, it doesn't stop after return statement, ajax code below is also executed, but I don't understand why ?</p> <pre><code>$('document').ready(function() { $('form').bind('submit', function(event) { event.preventDefault(); $('form input').each(function() { if( !$(this).val()) { $(this).addClass('warning'); return; } }); $.ajax({ url: 'http://example.com/', dataType: 'json', type: 'GET', }); }); }); </code></pre>
jquery
[5]
2,685,369
2,685,370
jQuery texbox .val() returns + sign for space
<p>When we type 'a d' (a space d) the .val returns a+d using a plus sign. I need the actual string of 'a d'? How do I do this?</p> <p>HTML textbox</p> <pre><code>&lt;input type="text" name="term" value="" id="term" title="term" size="30px"/&gt; </code></pre> <p>JQuery</p> <pre><code>function() { $('#results').load('search.aspx', $('#term').val()); } </code></pre>
jquery
[5]
516,147
516,148
Throwing an exeption in a catch section
<p>I've got a new project. Every time you dealing with somebody else code it's an adventure. </p> <p>Here is what I found:</p> <pre><code>try { ..... } catch (InvalidOperationException e) { throw e; } catch (Exception e) { throw; } </code></pre> <p>Anybody has an idea why?</p> <p>PS Thanks everybody. It really helps. Here are some good sources that you recommended:</p> <p><a href="http://stackoverflow.com/questions/881473/why-catch-and-rethrow-exception-in-c">Why catch and rethrow Exception in C#?</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/0yd65esw.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/0yd65esw.aspx</a></p> <p><a href="http://msdn.microsoft.com/en-us/library/ms229005.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms229005.aspx</a></p>
c#
[0]
3,696,917
3,696,918
Time to learn JavaScript properly, but how?
<p>Firs off, thanks for reading! A bit of a non-technical query for all you javascripters out there. Here's my situation. I've been in Front-End development now four years full time. But for different reasons javascript hasn't been in the priorities that I've been asked to do. Don't get me wrong I've developed dozens of websites and I've used my own snippets of javaScript and used also many Jquery plugins. But I think it's time to really learn and be able to do something better than the meaningless stuff that I usually do with this great language.</p> <p>The problem is that I think it's quite overwhelming to study this language properly, I just don't know which approach I should give it. I keep reading books but either I feel that I already know some stuff or I feel completely clueles...</p> <p>I know you're going to say, stop writing stupid questions and go on cracking them books. You are right but I do think you folks could give me some advice and some tips on how did you manage to master the language, what was that you find the hardest, what would you tell a beginner to focus on... believe me this is useful stuff for me and hopefully it is also for someone else out there.</p> <p>Thanks a lot folks!</p>
javascript
[3]
2,769,855
2,769,856
Strange Behevior when trying to create a Template containing maps
<p>i'm new to Templates and when i tried to implement templates methods which needs to use a map (which is a member in private), the map can only do 3 things: insert, swap, and operator =. and i don't get the full functionality of map.. </p> <p>Here's the code:</p> <pre><code>#include &lt;map&gt; using namespace std; template &lt;class T,class SortKey, class SearchKey&gt; class GarageDataBase { public : GarageDataBase(); virtual ~GarageDataBase(); const T&amp; Top() const; bool Add(T data,SortKey key2, SearchKey key2); T Remove(SearchKey toRemove); T Find(SearchKey toFind) const; bool isEmpty()const; private: multimap&lt;SortKey,T&gt; firstMap; multimap&lt;SearchKey,pair&lt;SortKey,T&gt;*&gt; secondMap; }; #endif template &lt;class T,class SortKey, class SearchKey&gt; GarageDataBase&lt;T,SortKey,SearchKey&gt;::GarageDataBase() { } template &lt;class T,class SortKey, class SearchKey&gt; GarageDataBase&lt;T,SortKey,SearchKey&gt;::~GarageDataBase() { } template &lt;class T,class SortKey, class SearchKey&gt; const T&amp; GarageDataBase&lt;T,SortKey,SearchKey&gt;::Top() const { firstMap. } </code></pre> <p>in the last func when trying to get into firstMap mathods, all i get is: insert, swap or, =...</p> <p>how do i get to "first" or "second" in the map?</p> <p>Thank you and sorry i'm just a beginner here</p>
c++
[6]
3,796,812
3,796,813
storing a value in a parameter
<p>hi please can anyone tell me how to store some int values in an array</p> <pre><code>public int getStatistics(int teamid) { int stats = 0; for(int runid = 0; runid &lt; 4; runid++) { stats = teams[teamid].getRunTime(runid); } } </code></pre> <p>i am writting a method to retrieve the statistics contained for a team in an array location.it contains 4 values.the team id is an int an is selected by user while the run id brings out the values in each location.my problem is to store the value i have in the stats to a place which can contain for seperate values. example 5,7,8,4</p>
java
[1]
4,810,589
4,810,590
Counting vowels
<p>Can anyone please tell me what is wrong with this script. I am a python newb but i cant seem to figure out what might be causing it not to function.</p> <pre><code>def find_vowels(sentence): """ &gt;&gt;&gt; find_vowels(test) 1 """ count = 0 vowels = "aeiuoAEIOU" for letter in sentence: if letter in vowels: count += 1 print count if __name__ == '__main__': import doctest doctest.testmod() </code></pre>
python
[7]
5,475,643
5,475,644
jquery emulate key press "ctrl and +"
<p>I know the technique for zoom the page using the shift of CSS.</p> <p>I want to make a button for emulate the user that press <kbd>CTRL</kbd> and <kbd>+</kbd> in same time.</p> <p>In firefox if I press <kbd>CTRL</kbd> and <kbd>+</kbd> in the same time the page zooms. I want to write a function that I call and I emulate the press of <kbd>CTRL</kbd> and <kbd>+</kbd></p> <p>How can I do that?</p>
jquery
[5]
4,410,267
4,410,268
Using variable length argument lists and named parameters together
<p>I need some help with figuring out Pythons <code>*args</code> and <code>**kwargs</code>. It's simple but I haven't entire wrapped my head around them. Here's one of scenarios that's bewildering to me.</p> <p>I have two functions <code>mainfunc</code> and <code>wrapperfunc</code> (which is a wrapper function for the main function). It looks like this.</p> <pre><code>def mainfunc(fname=None, lname=None): print 'Firstname: ' + fname print 'Lastname: ' + lname def wrapperfunc(uname, *args): print uname mainfunc(*args) </code></pre> <p>I can call <code>wrapperfunc</code> like this:</p> <pre><code>wrapperfunc('j.doe', 'john', 'doe') </code></pre> <p>In this method, all three parameters are positional. Since <code>j.doe</code> comes into <code>uname</code>, the other two params can be accessed by <code>*args</code></p> <p>..but is it possible to pass some of the params to <code>wrapperfunc</code> from a dict so that I can still access <code>uname</code> inside <code>wrapperfunc</code> directly and then pass the remaining positional parameters to the <code>mainfunc</code>. Something like the following snippet:</p> <pre><code>params = {'uname':'j.doe'} wrapperfunc(**params, 'john', 'doe') </code></pre> <p>I want to access the named parameters directly inside <code>wrapperfunc</code> but pass all the positional parameters to <code>mainfunc</code>.</p>
python
[7]
2,163,852
2,163,853
Few Stack related questions in Java
<pre><code>import java.util.Iterator; import java.util.Stack; public class StackExample { public static void main(String args[]){ Stack&lt;String&gt; sk = new Stack&lt;String&gt;(); sk.push("Hello"); sk.push("Hello1"); sk.push("Hello2"); sk.push("Hello3"); System.out.println("The Values of Stack" +sk); Iterator it=sk.iterator(); System.out.println("Size before pop() :"+sk.size()); while(it.hasNext()) { String iValue=(String)it.next(); System.out.println("Iterator value :"+iValue); } String value =(String)sk.pop(); System.out.println("value :"+value); System.out.println("Size After pop() :"+sk.size()); } } </code></pre> <p>Can anyone explain me the below questions. </p> <pre><code>while(it.hasNext()){ String iValue=(String)it.next(); System.out.println("Iterator value :"+iValue); } </code></pre> <ol> <li><p>Why do we iterate in this manner and what does the hasNext and next do? Can i not do the same with an for loop.</p> <pre><code>String value =(String)sk.pop(); </code></pre></li> <li><p>What does the (String)sk.pop means... why does it not compile when i remove the (String)</p></li> <li><p>Can anyone lead me to some good and complex Stack examples in Java</p></li> </ol>
java
[1]
3,095,450
3,095,451
asp.net web.config encryption - The RSA key container was not found
<p>I've done the following in order to encrypt the web.config using RSA provider.</p> <p>RDP to Web Server and opened the VS Command Prompt with my account.</p> <p>Create a custom RSA encryption key:</p> <blockquote> <p>aspnet_regiis -pc "MyKey" -exp</p> </blockquote> <p>Encrypt the connectionStrings section using the custom RSA key:</p> <blockquote> <p>aspnet_regiis.exe -pef "connectionStrings" "D:\Web\" -prov "MyRsaProvider"</p> </blockquote> <p>I can see that the web.config has been encrypted. However when I try to load the web page it throws an error below:</p> <blockquote> <p><em>"<strong>....The RSA key container was not found.</strong>"</em></p> </blockquote> <p>I then tried these commands one by one and tested:</p> <blockquote> <p>aspnet_regiis -pa "MyKey" "domain\appPool_serviceAccount"</p> <p>aspnet_regiis -pa "MyKey" "ASPNET"</p> <p>aspnet_regiis -pa MyKey" IIS APPPOOL\CRSAppPool" -full</p> <p>aspnet_regiis -pa "MyKey" "NT Authority\Network Service"</p> </blockquote> <p>And, I still get this error:</p> <blockquote> <p><em>"....The RSA key container was not found."</em></p> </blockquote> <p>Could some one please help me whether it's a framework bug or am I doing something not right?</p>
asp.net
[9]
1,941,907
1,941,908
Some hints to improve writing of JavaScript code
<p>The basic idea for writing good code is that the code must be readable, well-commented and documented.</p> <p>Other basic facts for writing good code regarding all the program languages are structuring the code in directories and files and indentation of course.</p> <p>In the case of javascript the things could be more complicated, because the language allows you to use different style to accomplish similar task.</p> <p>For example there are three different ways to define a JavaScript class.</p> <p>Said that, which are the best resource (books/sites) or suggestion for writing good code (library) in javascript?</p>
javascript
[3]
5,125,211
5,125,212
How to get this attribute in a table using jquery?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9891960/how-to-access-this-attribute-using-jquery-given-a-div-defined-by-this">How to access this attribute using jquery, given a div defined by this</a> </p> </blockquote> <p>I have included a simple jsfiddle to illustrate my difficulty:</p> <p><a href="http://jsfiddle.net/7HCyS/" rel="nofollow">http://jsfiddle.net/7HCyS/</a></p> <p>I wish to access the itemid attribute of this:</p> <pre><code>&lt;td itemid="1488324"&gt; &lt;div style="margin: 0 auto; width:88px"&gt; &lt;div class="twitter-tweet" style="width:22px; height:22px;"&gt;&lt;/div&gt; &lt;div class="facebook-post" style="width:22px; height:22px;"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/td&gt;​ </code></pre> <p>I can't lookup itemid using jquery directly, I have to start with</p> <pre><code> $('.facebook-post') </code></pre> <p>and go from there. I have been advised to use the parent method but it isn't helping me, any ideas?</p>
jquery
[5]
859,764
859,765
Javascript command for pausing movie stream?
<p>I need a Javascript command that pauses video stream embeded from Putlocker as soon as specific DIV pops up.</p> <p>Here is an example that works with JWPlayer</p> <pre><code>var interval = setInterval(function(){ if (document.getElementById("gw-node-overlay"){ jwplayer().stop(); clearInterval(interval); }}, 1000); </code></pre> <p>Edit: Video is iframed. Example: <code>&lt;iframe src="http://www.putlocker.com/embed/#####" width="700" height="360" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;</code></p>
javascript
[3]
2,774,477
2,774,478
Python: can call __subclasses__() on build in types, not on custom object
<pre><code>class Test: pass print(Test.__subclasses__()) </code></pre> <p>returns:</p> <pre><code>AttributeError: class Test has no attribute '__subclasses__' </code></pre> <p>And</p> <pre><code>print(int.__subclasses__()) </code></pre> <p>returns:</p> <pre><code>[&lt;type 'bool'&gt;] </code></pre> <p>Why can't I call <strong>subclasses</strong>() on my custom object?</p> <p>This build in methods aren't reserver for custom types, are they?</p> <blockquote> <p>Each class keeps a list of weak references to its immediate subclasses. This method returns a list of all those references still alive. Example:</p> </blockquote>
python
[7]
5,588,697
5,588,698
Troubleshooting ui.item in jQuery
<p>I'm currently using the jQuery sortable plugin and one of the things I can do is on change I can run a function:</p> <pre><code>$( "#listA, #listB" ).sortable({ connectWith: ".connected_sortable", delay: 100, receive: function(event, ui) { alert(ui.item.text()); } }).disableSelection(); </code></pre> <p>In this case I'm using an alert. How do I figure out what objects are in the ui.item? <code>text()</code> currently gives me the text I've used in the but how do I find out all of the other information? <b>More specifically the id?</b> I couldn't find information on this in the <a href="http://docs.jquery.com/UI/Sortable" rel="nofollow">jQuery Documentation</a>. Is there a way to use Firebug to find out what functionality ui.item has?</p> <p>Thank you!</p>
jquery
[5]
1,027,733
1,027,734
PHP, Cannot use object of type stdClass as array
<pre><code>&lt;?php foreach ($blogs as $blog) { $id = $blog['id']; $title = $blog['title']; $content = $blog['content']; ?&gt; &lt;h1&gt; &lt;?php echo $title; ?&gt;&lt;/h1&gt; &lt;h1&gt; &lt;?php echo $content; ?&gt; &lt;/h1&gt; &lt;?php } ?&gt; </code></pre> <p>This my code. everytime i run this code, this error pops up:</p> <blockquote> <p>Fatal error: Cannot use object of type stdClass as array</p> </blockquote> <p>Please help.</p>
php
[2]
5,145,616
5,145,617
failed to open stream: HTTP request failed! HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request
<p>I am strugling with this code:</p> <pre><code>$auth = base64_encode('domain\username:password'); $aContext = array( 'http' =&gt; array( 'proxy' =&gt; 'tcp://proxy:80', 'request_fulluri' =&gt; true, 'header' =&gt; "Proxy-Authorization: Basic $auth", ), ); $cxContext = stream_context_create($aContext); $sFile = file_get_contents("http://www.codecraft.gr", false, $cxContext); echo $sFile; </code></pre> <p>i keep getting the following message</p> <blockquote>Warning: file_get_contents(http://www.codecraft.gr) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web P in C:\wamp\www\test17\tarantula.php on line 17</blockquote> <p>the thing is that myusername and password are correct, and i realy cant find something to help me with that ISA server :S any suggestions?</p>
php
[2]
4,061,530
4,061,531
java output hex (ByteArrayOutputStream)
<p>I have :</p> <pre><code>ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); encoder.encode(question, outputStream); </code></pre> <p>and when <code>System.out.println(outputStream)</code> prints this .. i see <code>0►☻☺♣▬♂test some</code> and I want to see this in HEX like <code>30 04 12 54 33</code></p> <p>How can I do that ?</p> <p>Thanks</p> <p>I was able to write the binary to a file like this :</p> <pre><code>File file = new File("out.bin"); FileOutputStream filename = new FileOutputStream(file); outputStream.writeTo(filename); </code></pre>
java
[1]
731,893
731,894
How do I move this div down the page when user scrolls down?
<p>In this example: <a href="http://jsfiddle.net/3YrDD/" rel="nofollow">http://jsfiddle.net/3YrDD/</a></p> <p>How do I make the "SideBar" move down as the user scrolls the main content down? I would like it to stop at the footer. </p>
jquery
[5]
1,524,954
1,524,955
Get content from jquery CLEditor
<p>How can I get content data what I am write in <a href="http://premiumsoftware.net/cleditor/" rel="nofollow">CLEditor</a> using jquery keyup?</p>
jquery
[5]
2,279,121
2,279,122
Converting bool to byte
<pre><code>bool myBool = true; byte myByte; </code></pre> <ul> <li>This conversion runs <code>myByte = Convert.ToByte(myBool);</code></li> <li>This conversion does not run <code>myByte = (byte)myBool;</code> </li> </ul> <p>For a newbie(<code>me</code>): why are the above different? </p>
c#
[0]
4,315,234
4,315,235
dynamic global value replacement in javascript
<pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; var str="Welcome to Microsoft! "; var val="Microsoft!"; document.write(str.replace('/'+val'+/gi', "W3Schools")); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>this is not working, how to use val dynamically ?</p>
javascript
[3]
5,110,509
5,110,510
What does the term Principal mean in .NET Security?
<p>I'm reading this article <a href="http://www.codeguru.com/Csharp/.NET/net_security/authentication/article.php/c7415/" rel="nofollow">http://www.codeguru.com/Csharp/.NET/net_security/authentication/article.php/c7415/</a></p> <p>I still don't understand the concept of "Principal" (why this name) what's difference with just Identity in common language ?</p> <p>For example in the tutorial I don't understand the distinction between UserIdentity and SecurityPrincipal ?</p>
asp.net
[9]
5,340,785
5,340,786
Code highlighted as syntax error. Why?
<p>I'm new to java and I'm trying to write this code but somehow it sees it as an error when using my variables. which has been declared ofc. </p> <pre><code>import java.io.*; public class FileRead { public void readCountries(String file){ try{ ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream("countries")); Object obj = null; while ((obj = inputStream.readObject()) != null) { if (obj instanceof Country) { System.out.println(((Country)obj).toString()); } } } catch (EOFException ex) { //This exception will be caught when EOF is reached System.out.println("End of file reached."); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } finally { //Close the ObjectInputStream try { if (inputStream != null) { //////////ERROR: inputStream cannot be resolved to a variable inputStream.close(); //////////// Same here } } catch (IOException ex) { ex.printStackTrace(); } } } } </code></pre>
java
[1]
3,485,626
3,485,627
Web Based file manager (I'm on a hosting account)
<p>I seem to be having issues accessing my cpanel from work and so I'm trying to find a web-based file editor that can serve as an alternative. However, all of those that I found require me to have actual linux server access.</p> <p>I'm just looking for a simple php editor that I can set up and use to edit and manage a couple of files.</p> <p>Thanks!</p>
php
[2]
5,534,145
5,534,146
How to show uploaded file on the webpage with download option?
<p>Actually I am uploading a file by using file upload control. After successful upload, when I am viewing that page then at that time I want to show that uploaded file on the page which will have the options to download it too. Please help me out on this.</p> <p>Thanks.</p>
asp.net
[9]
1,096,549
1,096,550
How to exit a program: sys.stderr.write() or print
<p>I am writing a small app and I need to quit the program multiple number of times.</p> <p>Should I use:</p> <p><code>sys.stderr.write('Ok quitting')</code><br><code>sys.exit(1)</code></p> <p>Or should I just do a:</p> <p><code>print 'Error!'</code><br/><code>sys.exit(1)</code></p> <p>Which is better and why? Note that I need to do this a lot. The program should completely quit.</p>
python
[7]
1,153,425
1,153,426
How to use Google Map JavaScript v3 API in android native app
<p>I would like to use google map v3 api in android native app. I think it is not same as v2 api. Please provide sample demo app if anyone have.</p>
android
[4]
1,261,868
1,261,869
Apply formatting after string formatting
<p>I don't know if it's possible with common string formatting or advanced string formatting, so thought to ask...</p> <p>I have this simplified snippet:</p> <pre><code>&gt;&gt;&gt; s = 'some string' &gt;&gt;&gt; y = 10 &gt;&gt;&gt; '&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;%4d&lt;/td&gt;' % (s, y) '&lt;td&gt;some string&lt;/td&gt;&lt;td&gt; 10&lt;/td&gt;' </code></pre> <p>I want to pad numeric cell with <code>&amp;nbsp;</code> as my html backend doesn't accept text aligning. Is there easy way to format numerical value with <code>&amp;nbsp;</code> instead empty space?</p>
python
[7]
1,003,942
1,003,943
Still confused about JavaScript Expressions and Statements
<p>I found this PDF <a href="http://www.fbeedle.com/javascript/69-4ch04.pdf" rel="nofollow">here</a> and in it the author describes an expression as any valid set of literals, variables, operators, function calls and expressions that evaluate to a single value i.e.</p> <pre><code>3 + 7 3 + 7 + 10 + "" "Dr." + " " + "Pepper" </code></pre> <p>That all seems fine to me. An a statement is any set of declarations, method and function calls and expressions that performs some action i.e.</p> <pre><code>var num = 1 document.write("hello") </code></pre> <p>But later on they refer to the last line of the examples below as statements</p> <pre><code>var salutation = "Greetings, " var recipient = "Earthlings" salutation + recipient //statement var greeting = "Greetings, " greeting += "Earthlings" //statement </code></pre> <p>Why isn't <code>salutation + recipient</code> and <code>greeting += "Earthlings"</code> considered an expression when they are adding two strings like in their expression example <code>"Dr." + " " + "Pepper"</code></p> <p>Many thanks</p>
javascript
[3]
3,450,033
3,450,034
use variables defined in header without extern C++
<p>I'm a library that drives a LED board. Files include led.cpp, led.h, font.h</p> <p><strong>led.cpp</strong></p> <pre><code>#include "led.h" //function implementation </code></pre> <p><strong>led.h</strong></p> <pre><code>#ifndef led_h #define led_h #include "font1.h" class LED{ //some code, which uses char defined in font.h } </code></pre> <p><strong>font.h</strong></p> <pre><code>#ifndef font_h #define font_h //Letter mapping to pixel char CH200[] PROGMEM = "11111111"; char CH201[] PROGMEM = "11000011"; char CH202[] PROGMEM = "11111111"; char CH203[] PROGMEM = "11111001"; char CH204[] PROGMEM = "11000111"; char CH205[] PROGMEM = "11111111"; char CH206[] PROGMEM = "11111111"; char CH207[] PROGMEM = "11111111"; // many many more definition here #endif </code></pre> <p>Now I want to use this library in other program, so in that program I did</p> <pre><code>#include "led.h" </code></pre> <p>but if I compile like this, it complains about multiple definition of those CH20X chars. Any advice on how to fix this?</p>
c++
[6]
3,273,558
3,273,559
iphone table view-problem with index.section and index.row
<p>I have one table view and in each row two radio buttons is there, for selecting the radio button need to calculate the section number and row number and in current logic up to 9th row its working fine but after 9th row it was not changeing the radio button image.</p> <p>here is my piece of logic implementation code .</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { cell._option1Btn.tag = ((indexPath.section+1)*10)+(indexPath.row+1); cell._option2Btn.tag = ((indexPath.section+1)*10)+(indexPath.row+1); return cell; } -(void) respondToRightBtnAction:(UIButton*) sender { if(debug)NSLog(@"In the Right button clicked method"); if(debug)NSLog(@"left button in %d row is YES", sender.tag); int section = (sender.tag/10 -1); int row = (sender.tag%10 -1); </code></pre> <p>}</p>
iphone
[8]
566,465
566,466
java inheritance after compilation
<p><code>class Car extends Viecle</code></p> <p><code>Car</code>is compiled.</p> <p>Class <code>Client</code> uses <code>Car</code>.</p> <p>Are fields and methods from <code>Viecle</code> put into <code>Car</code> class during compilation, or <code>Car</code> simply needs class <code>Viecle</code> to be compiled (and not removed) in compile and after - during runtime?</p>
java
[1]
4,491,217
4,491,218
Replacing in Python
<p>I need to complete a basic task on Python that requires me to convert a standard phone number into an international one.</p> <p>So for example, if the users phone number was <code>0123456789</code>, the program should display, <code>Your international phone number is +44123456789.</code></p> <p>I don't know how to <code>replace</code> the <code>0</code> with a <code>44</code>. I don't know many techniques on Python so advice on how to is welcomed, thanks.</p> <p>EDIT:</p> <pre><code> #Python Number Conversion def GetInternational(PhoneNumber): if num.startswith('0'): num = num.replace('0','+44',1) return GetInternational PhoneNumber = input("Enter your phone number: ") print('Your international number is',GetInternational,'') </code></pre> <p>I'm missing something obvious but not sure what...</p>
python
[7]
291,828
291,829
determine the average time to look up a key in a randomly generated balanced binary search tree in C#?
<p>I'm trying to determine the average amount of time it takes to loop up a key in a randomly generated balanced binary search tree, as a function of the size of the tree.. I'm unable to write the code to calculate the time.. so if i can get help or at least best way to write the code i would appreciate it... its been a while since i coded</p>
c#
[0]
5,889,807
5,889,808
Identifying App Installations
<p>so there a nice blog to Identifying App Installations using the following code</p> <pre><code>public class Installation { private static String sID = null; private static final String INSTALLATION = "INSTALLATION"; public synchronized static String id(Context context) { if (sID == null) { File installation = new File(context.getFilesDir(), INSTALLATION); try { if (!installation.exists()) writeInstallationFile(installation); sID = readInstallationFile(installation); } catch (Exception e) { throw new RuntimeException(e); } } return sID; } private static String readInstallationFile(File installation) throws IOException { RandomAccessFile f = new RandomAccessFile(installation, "r"); byte[] bytes = new byte[(int) f.length()]; f.readFully(bytes); f.close(); return new String(bytes); } private static void writeInstallationFile(File installation) throws IOException { FileOutputStream out = new FileOutputStream(installation); String id = UUID.randomUUID().toString(); out.write(id.getBytes()); out.close(); } } </code></pre> <p>in a different java class i have a WebView going to a URL as shown</p> <pre><code>public class Notes extends Activity { WebView mWebView; /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.timsnotes); mWebView = (WebView) findViewById(R.id.webview3); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadUrl("http://www.somedomain.com/notes.php?phoneid=" + "sID" + ""); mWebView.setWebViewClient(new HelloWebViewClient()); } </code></pre> <p>but all it passes is the text sID. is there a uses-permission I'm missing to access the sID?</p>
android
[4]
3,127,109
3,127,110
Python API to know the location
<p>Is there an Python API from which if we input the ipadress, will we be able to know the location and place of the access </p>
python
[7]
21,175
21,176
ASPX PDF conversion
<p>Is there any way to convert current aspx page on button click in to PDF without using third party tool?</p>
asp.net
[9]
5,094,990
5,094,991
jquery ID starts with
<p>I am trying to get all elements with an id starting with some value. Below is my jquery code . I am trying to use a javascript variable when searching for items. But it does not work. What Am I missing below? So the id 'value' am searching is the value of the clicked element</p> <pre><code>$(document).ready(function() { $('input[name$="_chkmulti"]').click(function(){ var value = $(this).val(); $("td[id^= + value +]").each(function(){ alert("yes"); }); }); }); </code></pre>
jquery
[5]
1,784,018
1,784,019
shared preferences (putStringSet) or other?
<p>I build a simple program (an array string with the 10 commandment), later I create another class (index to choose other activities).</p> <p>I'd like save by saved preferences this array, so the user when re-start application can continue from last point.</p> <p>I read that putStringSet is available only from api 11 while I'd keep compatibily also version 2.3</p> <p>Is there a way to save an array string?</p> <p>thanks!</p>
android
[4]
3,595,488
3,595,489
Disable a link that has href="javascript:;" until option is selected
<p>I have a link I need to disable until a selection is made from a select box</p> <pre><code>&lt;select id="shippingSelect" onchange="simpleCart.update();"&gt; &lt;option value="nothing" selected="selected"&gt;Choose Shipping Location&lt;/option&gt; &lt;option value="uk"&gt;UK - FREE&lt;/option&gt; &lt;option value="world"&gt;Rest of World + £2.00&lt;/option&gt; &lt;/select&gt; &lt;a href="javascript:;" class="simpleCart_checkout"&gt; Place Order &lt;/a&gt; </code></pre> <p>How can I disable the place order link until customer chooses shipping location?</p> <p>This is what I have at the moment:</p> <pre><code>&lt;script&gt; $('#shippingSelect').change(function() { if ($(this).val() != "nothing") { $('.place_order').slideDown(); } else { $('.place_order').slideUp(); } }); &lt;/script&gt; </code></pre> <p>Which works but I would rather have the link visible all the time just not clickable. Thanks</p>
jquery
[5]
1,383,345
1,383,346
error : The method getFilter() is undefined for the type FriendsActivity.ListAdapter
<p>Trying to implement search functionality in list view having problem in search,here i am placing code where i am getting error</p> <pre><code> friendsearch.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) { // When user changed the Text FriendsActivity.this.adapter.getFilter().filter(cs); //*in the above line i am getting error.* } public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub } public void afterTextChanged(Editable arg0) { // TODO Auto-generated method stub } }); </code></pre>
android
[4]
3,824,639
3,824,640
jquery error: val() is not a function
<p>Why I'm getting this error? <code>val is not a function</code> when I validate the number.</p> <pre><code>$(this).find('#register-validation .next').click(function() { var _parent = $(this).parents('#register-validation'); $('.loading-big').html(loadMsg).fadeIn(300); _parent.find('input.required').each(function(index) { if($(this).val() == "" || $(this).val() == errReq) { // here is fine $(this).val(errReq); $(this).addClass("error"); } else if(isNaN($(this).hasClass('number').val())) { // but when validation goes here, I got this error. $(this).val(errNum); $(this).addClass("error"); } else { $(this).removeClass("error"); } }); }); </code></pre> <p>Please help. Thanks a lot.</p>
jquery
[5]
5,026,431
5,026,432
clearing the contents of an input textbox using onblur event handler
<p>i have an input box whose value i want to clear if the user's input is wrong. i want to accomplish this using the onblur event and a javascript function. </p> <p>this is the textfield i want to apply the onblur function to:</p> <pre><code>&lt;tr&gt; &lt;td&gt;&lt;input id="TryMe" type="text" onblur="checkMe('TryMe')"/&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>the function that does that is this:</p> <pre><code>&lt;script&gt; function checkMe(elemID){ elem = document.getElementById(elemID); if (elemID.value == "CORRECT"){ alert ("you are correct!"); } else{ document.getElementById(numericElemID).value=""; document.getElementById(numericElemID).focus(); return false; } } </code></pre> <p></p> <p>and it works as i intend it to. however, why is it that when i remove the "return false;" part, it does not work anymore:</p> <pre><code> else { document.getElementById(numericElemID).value=""; document.getElementById(numericElemID).focus(); } </code></pre> <p>EDIT: including the javascript and the text input</p>
javascript
[3]
4,857,319
4,857,320
Using foreach loop to print all results
<p>I'm new to jQuery and I have got stuck on an each loop. </p> <p>I'm trying to get the values from a variable with objects and when I print it using <code>alert()</code>, I get all the results.</p> <p>But when I'm trying to print it to the HTML I only get the last result printed to the HTML instead of 3, in this case. </p> <pre><code>$.each(playlist, function(index, item) { alert(item.title); $('.playlist1').text(item.title); }); </code></pre>
jquery
[5]
3,691,721
3,691,722
Option besides using $_GET
<p>GET is a convenient method to post the form id, post the website id or any id. However, it is insecure because it leaks out the id to the visitors. </p> <p>Are there any method that I can use that is similar to GET format that i need not to submit the form but i can retrieve the id easily at the same time?</p> <pre><code>sorry, i am so green at it. how to use a session ? if use get , i can define $get?id=aaa for each link,but how can i achieve it in session? </code></pre> <p><strong>What i actually want to do:</strong></p> <p>In my case i want to develop several form , each one has a id on it, say formA , formB , formC ..</p> <p>IF i use get i will define <code>&lt;form id="myform" method="get" action="verify.php?id="formA"&gt;</code> however, since it is insecure, how can i use session to do this?</p> <p>*Ans: put the $_session[id]='formid' and get it in the same way.*</p> <p><strong>It is ok for a form , but.....</strong></p> <p>If i want to create a page that has a lot of links , how can i achieve using a session ? how can i bind the session to the link? Thank you.</p>
php
[2]
2,199,147
2,199,148
why we use Using Declaration in derived class?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1896830/why-shall-i-use-the-using-keyword-to-access-my-base-class-method">Why shall I use the &ldquo;using&rdquo; keyword to access my base class method?</a> </p> </blockquote> <p><code>using</code> declaration introduces a name of data member or member function from a base class into the scope of derived class which is implicitly accomplished when we derive a class from base class, then what is the utility of using "using declaration"?</p> <p>i want to know in depth the use of using declaration in classes in c++.</p>
c++
[6]
5,201,800
5,201,801
Why a default assignment operator not synthesis by compiler if a class has a reference data member
<p>In C++, if a class has a reference data member the default assignment operator is not synthesized by compiler. Why? </p>
c++
[6]
3,968,201
3,968,202
Simple text imput , then results on label
<p>I want to make my first android application , it would be a very basic utility. It would be like a text input where the users time the date they want , and on a label it would say how many days its been since that date. </p> <p>EG: User type date ---> label shows how many days as past ---> user can save their entered date and app would show still show output from the label.</p> <p>something as simple as that. Anyone knows how I could do this ? </p>
android
[4]
3,736,326
3,736,327
select element in JQuery
<p>Hi would you please help how can i extract "Men" text in this case?</p> <pre><code>&lt;div class="comwebstore-LeftNavBrowse-2"&gt; &lt;ul class="linkList browseLadder"&gt; &lt;li&gt; &lt;a href="example.com"&gt; Men &lt;/a&gt; &lt;/li&gt; &lt;ul class="linkList browseLadder"&gt; &lt;li&gt; &lt;a href="example.com"&gt; Full Logo T-Shirt &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="example.com"&gt; Short Logo T-Shirt &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="example.com"&gt; Grey Hoodie 1 Full Logo &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="example.com"&gt; Grey Hoodie 2 Short Logo &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="example.com"&gt; Women &lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="example.com"&gt; Accessories &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I have tried </p> <blockquote> <p>jQuery('#mainContentWrapper #leftColumn #A #A-1 .com-amazon-webstore-LeftNavBrowse-2 > :first-child a').text();</p> </blockquote> <p>but without succeed. Thanks</p>
jquery
[5]
2,354,815
2,354,816
Output alternatives in Python
<p>Is there any alternatives to the print statement for output in Python.<br> Also, how can I format my output text to be color-coded?</p> <p>I'm a beginner programmer, pretty new to it.<br> Thanks</p>
python
[7]
2,929,969
2,929,970
java how to use classes in other package?
<p>can I import,use class from other package? In Eclipse I made 2 packages one is main other is second</p> <pre> main -main (class) second -second (class) </pre> <p>and I wanted the main function of main class to call the function x in second class. how can I do it? I tried:</p> <pre><code>import second; second.x(); (if both classes are in the same package then it works) second.second.x(); </code></pre> <p>but none of them worked. I'm out of idea now.</p>
java
[1]
950,517
950,518
Will Application_End be fired even if …
<p><code>Application_Start</code> and <code>Application_End</code> are called only once during the lifetime of the application domain – thus they aren’t called for each <code>HttpApplication</code> instance</p> <p><code>Application_Start</code> runs when first user requests a page, thus when the first instance of the <code>HttpApplication</code> class is created, while <code>Application_End</code> runs when the last instance of an <code>HttpApplication</code> class is destroyed.</p> <p>But what if at the time of application domain being restarted there wasn’t any user requests and thus no <code>HttpApplication</code> instances created? Will in that case <code>Application_End</code> still be fired?</p> <p>Thank you</p>
asp.net
[9]
5,975,803
5,975,804
Download all the links(related documents) on a webpage using Python
<p>I have to download a lot of documents from a webpage. They are wmv files, PDF, BMP etc. Of course, all of them have links to them. So each time, I have to RMC a file, select 'Save Link As' Then save then as type All Files. Is it possible to do this in Python? I search the SO DB and folks have answered question of how to get the links from the webpage. I want to download the actual files. Thanks in advance. (This is not a HW question :)).</p>
python
[7]
1,937,854
1,937,855
Dynamic multidimensional post form
<p>I have a form with a variable number of inputs. The inputs are inside the table and I need to get three values from them: the row, the column and the actual value inside the input. </p> <p>Some may be populated some may not and I need all their values to update a mysql db (row and column to know what to update, value to know the new value to insert in the database).</p> <p>This is my form (an example version of it):</p> <pre><code>&lt;form method="post" action=""&gt; &lt;input name="data[111][222]" value="2" /&gt; &lt;input name="data[112][221]" value="0" /&gt; &lt;input name="data[113][223]" value="4" /&gt; //goes on &lt;input name="data[324][435]" value="11" /&gt; &lt;input name="data[325][436]" value="" /&gt; &lt;/form&gt; </code></pre> <p>And that's as far as I go. How can I get the data from this form so I can do a simple update in my database that goes like this (for all the affected inputs):</p> <pre><code> update table set res="value_from_input" where row="row_value" and col="col_value" </code></pre>
php
[2]
2,673,496
2,673,497
didFinishLaunchingWithOptions not being called
<p>the method didFinishLaunchingWithOptions is not being called when i launch via push notification on a multitasking OS4.1 3GS device. I just get AppdidEnterForeground called. Is this the way it is on a multitasking device. The docs don't say this. If it is not called how do i access the launchOptions dict.</p> <p>Thanks</p>
iphone
[8]
5,504,968
5,504,969
Android bundles passing Pointer or copies of objects
<p>If I attach an object to a bundle and store the bundle in an intent and start another activity, does that activity work on a copy of the original object or does it use the same object but just passes along a pointer?</p>
android
[4]
4,417,927
4,417,928
How to get value on a certain index, in a python list?
<p>I have a list which looks something like this</p> <pre><code>List = [q1,a1,q2,a2,q3,a3] </code></pre> <p>I need the final code to be something like this </p> <pre><code>dictionary = {q1:a1,q2:a2,q3:a3} </code></pre> <p>if only I can get values at a certain index e.g List[0] I can accomplish this, is there any way I can get it?</p>
python
[7]
5,977,291
5,977,292
Get exact cursor coordinates in textarea for FireFox
<p>I try to get the exact co-ordinates of cursor (x,y) in textarea for Gecko (firefox). I get co-ordinates of cursor (x,y) in IE but in Gecko can't get anything.</p> <pre><code>if (document.selection) { // for IE it working. var r = document.selection.createRange(); if(input.nodeName == 'TEXTAREA') { var x = r.offsetLeft - r.boundingLeft; var y = r.offsetTop - r.boundingTop; } else { var x = r.offsetLeft; var y = r.offsetTop; } return { x : x, y : y }; </code></pre>
javascript
[3]
5,631,700
5,631,701
which is best server for developing java web applications?
<p>I'm confused. There are lot of servers(GlassFish, Tomcat, Apache,etc.,). But which one is used to implement easy for developing web application? Please suggest me. Thanks in advance.</p>
java
[1]
3,798,894
3,798,895
jQuery doesn't understand wildcard
<p>I have this code that uses <code>load()</code>:</p> <pre><code>function showFullWork() { $('.work .desc h2 a').on('click', function() { var href = $(this).attr('href'); $('.work').slideDown(); $('.showWork').slideUp(); var el = $(this).parent().parent().parent(); var top = $(el).offset().top-100; $(el).slideToggle('fast',function() { $(el).after('&lt;div class="showWork span12"&gt;&lt;button type="button" class="close" &gt;×&lt;/button&gt;&lt;div class="expanded row-fluid"&gt;&lt;/div&gt;&lt;/div&gt;'); $(el).next('.showWork').slideToggle(); $(el).next('.showWork').children('div.expanded').load(href + ' .workdisplay &gt; *', function() { $(this).slideDown('fast', function() { $('html, body').animate({ scrollTop: top },500) }); }); $('.showWork button.close').on('click', function() { $(this).parent().slideToggle('fast', function() { $(this).prev().slideToggle(); var top = $(this).prev().offset().top-100; $('html, body').animate({ scrollTop: top },500) }); }); }); return false; }); } </code></pre> <p>It is very simple and straight-forward. It takes <code>href</code>, filters it and should load the content. But it doesn't. jQuery doesn't seem to understand the <code>*</code> wildcard. When I ommit it and put simply <code>href + ' .workdisplay'</code>, it works. But I don't want to have this additional container included. What can I do?</p>
jquery
[5]
3,077,782
3,077,783
Timestamp calculation function
<p>I am trying to write Java code as a part of my project to get current time for a process and then i need to add a fixed timeout period to it. This new time has to be compared with my above currenttime and take decision based on that. I am not able to add time to the currenttime and compare it. Can anyone help me by suggesting a way?</p> <p>This is my code:</p> <pre><code> public class SessionDetails { public String getCurrentUtcTimestamp() { TimeZone timeZone = TimeZone.getTimeZone("UTC:00"); DateFormat dateFormat = DateFormat.getDateTimeInstance(); dateFormat.setTimeZone(timeZone); timeStamp = dateFormat.format(new Date()); return timeStamp; } public void createSession() { int value = getsession(); String timeStamp = getCurrentUtcTimestamp() ; System.out.println("New session Details :"); System.out.println("session value:" + value); System.out.println("Time of creation :" + timeStamp ); } public boolean checkTimeout(int value) { private static long c_Timeout = 10000; String currentTime = getCurrentUtcTimestamp() ; if ( currentTime &gt; timeStamp + c_Timeout ) //failing to implement this logic efficiently .please do suggest a way.Thanku.. System.out.println("Sorry TimeOut"); else System.out.println("Welcome"); } } </code></pre>
java
[1]
2,072,515
2,072,516
C# Static Variable forgets value
<p>It sounds a little weird, but I've got some code (which actually is a plugin for MS Blend) that runs perfect in unit testing, but is not working within Blend.</p> <p>The code is the following.</p> <pre><code> private static volatile QWGUIRepository s_instance; public static void Initialize(IUnityContainer container, string themeuri) { lock (s_lock) { s_instance = new QWGUIRepository(); QWRepository.Initialize(container); } } </code></pre> <p>In the debugger (after attaching it to Blend), I can see that s_instance gets initialized with a value (is not null afterwards), however as soon as I get out of the method "s_instance" will forget it's value and will be null. </p> <p>Any ideas?</p> <p>Thanks, Andreas</p>
c#
[0]
6,033,310
6,033,311
How to animate View swap on simple View iPhone App?
<p>Have a simple iPhone app with a single UIViewController and two Views in one xib.</p> <p>the first view is very simple with a button and upon button press the second more complex view is loaded via setting the view property on the controller. </p> <p>what I would like is to animate the view swap (flip the views).</p> <p>The samples I have seen all require having multiple view controllers and building a hierachy, but that would be overkill in this case, any suggestions?</p>
iphone
[8]
2,638,338
2,638,339
How to change characters of a string into '*'
<p>So I'm trying to make a simple Wheel of fortune type game. But I'm having a serious issue getting started. I'm just trying to convert my phrase into "*" so that it can't be seen until the user guesses what one of the letters is. Here's what I have so far:</p> <pre><code>public class Puzzle { private String solution="DOG PILE"; private StringBuilder puzzle; public Puzzle(String solution) { int startindex=puzzle.indexOf(solution); puzzle.replace(startIndex, endIndex, "-"); } } </code></pre>
java
[1]
3,126,211
3,126,212
replace empty string(s) in tuple
<p>Is there an easy way (hopefully a one liner) to replace '' with something like '-'?<br> Many thanks.</p> <pre><code>tup = (1,2,'ABC','','','','text') </code></pre>
python
[7]
5,695,533
5,695,534
PHP conditions and echoing HTML
<p>When I'm using PHP and HTML I normally do it this way:</p> <pre><code>&lt;?php if ($myvar = 'blah') { echo '&lt;div&gt;some html here&lt;/div&gt;'; } else { echo 'Nothing here'; } ?&gt; </code></pre> <p>This works but I now have a bunch of html and I need to add a condition and I am trying to avoid having to do this:</p> <pre><code>&lt;?php if ($myvar = 'blah') { echo '&lt;div&gt;some html here&lt;/div&gt;'; echo '&lt;div&gt;some other html here&lt;/div&gt;'; echo '&lt;div&gt;some other html here&lt;/div&gt;'; } ?&gt; </code></pre> <p>Is there a way to wrapper the whole of the html block instead?</p>
php
[2]
673,971
673,972
Insert separte URL into a page using PHP
<p>Is there a function in PHP to go out to a separate URL and insert whats returned into the page? The include() function is only for local files right? Would I have to use javascript on the client side to accomplish this? Thanks, Brian</p>
php
[2]
4,179,590
4,179,591
C# encrypt string variable
<p>I'm trying to encrypt a text and save the encrypted text to a string variable and a text file.</p> <p>But the amazing thing is that the encrypted text in string doesn't look the same as the encrypted text in a text file .</p> <p>E.g string = bpAz1pcidPuCXbpO+5RYvQ==</p> <pre><code>textfile = n3Ö—"tû‚]ºNû”X½ </code></pre> <p>I would really like my string variable to have same data as my textfile.txt . My intension is to encrypt the string variable not the textfile. So how do i encrypt my string variable to look the same way as my textfile data?</p> <p>Here is my code below :</p> <pre><code> byte[] plainTextBytes = Encoding.UTF8.GetBytes("my name is calito"); MemoryStream memoryStream = new MemoryStream(); TripleDESCryptoServiceProvider cryptAlgorithm = new TripleDESCryptoServiceProvider(); CryptoStream csEncrypt = new CryptoStream(memoryStream, cryptAlgorithm.CreateEncryptor(), CryptoStreamMode.Write); csEncrypt.Write(plainTextBytes, 0, plainTextBytes.Length); //copying encrypted text to string byte[] cipherTextBytes = memoryStream.ToArray(); string cipherText = Convert.ToBase64String(cipherTextBytes); //copying incrypted text to text file File.WriteAllBytes(@"G:\New Text Document.txt", memoryStream.GetBuffer()); </code></pre>
c#
[0]
3,633,803
3,633,804
PHP Framework for large scale application
<p>We are growing rapidly and have 200,000+ customers. We currently have our CRM and e-commerce built on the Kohana framework. I have searched around the questions here and have not noticed much mention about Kohana in the answers for frameworks. Not knowing much about it, could I get some feedback on whether or not this is a stable framework to build on taking into consideration we are estimating reaching over 1,000,000 customers in the next few years. I appreciate any feedback to get ideas on what route we should take. Our programmers originally built our system on Kohana and we are in the early stages of redesigning the whole CRM. Thank you for any feedback.</p>
php
[2]
2,422,429
2,422,430
access object name within the object with this
<p>in i want to alert the 'image' which is the object name, how can i access with <code>this</code> ?</p> <pre><code>Objectswitch={ 'image': { addCount:function(){ alert('count'); }, addCountandCreate:function(){ this.addCount(); alert(this); } } } </code></pre>
javascript
[3]
2,493,245
2,493,246
Add key to hash if condition is true
<p>I've got this code:</p> <pre><code>function myFunction(serializeData, extraSerializedData){ //serializeData is boolean var formSerializedData = ''; if(serializeData){ var formSerializedData = $("#myform").serialize(); if (typeof extraSerializedData !== 'undefined'){ formSerializedData += extraSerializedData; } } $.ajax({ type: "get", url: "/123", data: formSerializedData, //TODO!!! success: function(data){ //...... </code></pre> <p>I want to add the <code>data</code> key only if <code>serializeData</code> exists. Is it possible and how to do this in a way that the code remains "beautiful"?</p>
javascript
[3]
844,014
844,015
How to break closures in JavaScript
<p>Is there any way to break a closure easily in JavaScript? The closest I have gotten is this:</p> <pre><code>var src = 3; function foo () { return function () { return src; } } function bar (func) { var src = 9; return eval('('+func.toString()+')')(); // This line } alert(bar(foo())); </code></pre> <p>This prints '9', instead of '3', as a closure would dictate. However, this approach seems kind of ugly to me, are there any better ways?</p>
javascript
[3]
5,183,850
5,183,851
how to bind an thumbnail image in repeater control
<p>I have an requirement where in my datatable. I have 3 columns. </p> <pre><code>serverpath,image name, id </code></pre> <p>Now I need to get the imagepath from that the datatable[serverpath] and bind it in a repeater control or gridview control and show the thumbnail images there. Actaully in the path <code>d:/application/images</code> folder I have images. </p> <p>When I bind to repeater control or grid control I need to convert the orignal images into thumbnail and display in reater control. In (5x5) rows x columns but I need to show only thumbnail images no other details like[server path,id].</p> <p>ex:</p> <pre><code>thumailimge1 thumailimge2 thumailimge3 thumailimge4 thumailimge5 thumailimge6 thumailimge7 thumailimge8 thumailimge9 thumailimge10 </code></pre> <p>so once the user click on this thumbnail orignal image will be displayed in a new window </p> <p>hope my question is clear...</p> <p>how can I achieve this functionality? any help would be greatly appreciated</p>
asp.net
[9]
1,728,747
1,728,748
limit page request with php
<p>I have this code that prevents users from making multiple requests on a page and it records ip address in a text file along with a string of numbers i assume its a time stamp but im not sure looks like this <code>173.1.1.100 - Requested on: 1303521541</code>how do i change that to readable time with a date?</p> <pre><code>$ipLog='log.txt'; //Logfile $timeout='1'; //Wait Time $goHere=$headers; //Page To Access $register_globals = (bool) ini_get('register_gobals'); if ($register_globals) $vis_ip = getenv(REMOTE_ADDR); else $vis_ip = $_SERVER['REMOTE_ADDR']; function recordData($vis_ip,$ipLog,$goHere) { $log=fopen("$ipLog", "a+"); fputs ($log,$vis_ip." - Requested on: ".time()."\n"); fclose($log); // // // exit(0); } function checkLog($vis_ip,$ipLog,$timeout) { global $valid; $ip=$vis_ip; $data=file("$ipLog"); $now=time(); foreach ($data as $record) { $subdata=explode(" - Requested on: ",$record); if ($now &lt; ($subdata[1]+600*$timeout) &amp;&amp; $ip == $subdata[0]) { $valid=0; echo "$timeout min wait."; break; } } } checkLog($vis_ip,$ipLog,$timeout); if ($valid!="0") recordData($vis_ip,$ipLog,$goHere); </code></pre>
php
[2]
824,300
824,301
Display 0.999 as 0.99
<p>How can I display a <code>float number = 0.999</code> as <code>0.99</code>?</p> <p>The code below keeps printing out <code>1.00</code> ? I thought using <code>setprecision(2)</code> specifies the number of digits after the decimal point? </p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std; int main(int argc, char** argv) { const float numberToDisplay = 0.999; cout &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; numberToDisplay &lt;&lt; endl; return 0; } </code></pre>
c++
[6]
2,803,176
2,803,177
Problems using the python WConio library
<p>I'm trying to use the WConio library for python, but when I import it, it gives this error:</p> <blockquote> <p>Traceback (most recent call last):<br> File "WConioExample.py", line 15, in &lt; module><br> import WConio File "d:\tools\development\python2.5\lib\site-packages\WConio.py", line 23, in <br> <strong>from _WConio import * ImportError: DLL load failed with error code 193</strong></p> </blockquote> <p>I've installed <code>WConio-1.5.win32-py2.5.exe</code> and made sure the _WConio.pyd file exists. I'm using it on Win7.</p> <p>I have searched for this problem, but the results were of no good use.</p> <p>What can I do to solve this?</p>
python
[7]
3,068,937
3,068,938
Wanting to prevent someone from taking a snapshot
<p>I'm building a app for a business. In this app I'm wanting to place some exclusive coupons people can use at the store for having the app installed. Because its a free app, I'm going to have ads placed in the app. Wanting to keep the rev coming in, I don't want people to just take a snapshot of the coupons, and then delete the app... Is there a way to prevent them from doing this? Or is there a way I could have a VOID pop up on the snapshot of the coupon when they take the snapshot? </p>
android
[4]
2,452,846
2,452,847
jQuery appendTo (switching back and forth)
<p>So what I'm trying to accomplish is a simple appendTo a certain element. The issue I'm having is after execute is run, it appends to the location but then proceed to go back to the ul it resides in.</p> <pre><code>&lt;script type="text/javascript"&gt; function execute() { $('#desCopy').appendTo('#description') $('#imgPlace').appendTo('#IMGbox') } &lt;/script&gt; &lt;div id="content" style="background:#000; width:989px;"&gt; &lt;div style="float:left; left:18px; margin:0; width:337px; position:relative; padding:15px 0 0 0; color:#FFF;"&gt; &lt;div id="description"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="IMGbox" style="float:left; position:relative; display:block; background:#F00; width:652px; height:258px; background:#0FF; overflow:hidden;"&gt; &lt;/div&gt; &lt;div style="float:right; background:#CCC; height:25px; width:652px;"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="" onclick="execute()"&gt;Slide 1&lt;/a&gt; &lt;ul style=""&gt; &lt;li&gt;&lt;span id="desCopy"&gt;Test description, Test description&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="images/test.jpg" id="imgPlace"&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
1,783,783
1,783,784
window.onbeforeunload not working in Chrome
<p><code>window.onbeforeunload=function();</code> is not working in chrome. It works for IE and Mozila but it not for chrome. Is there any another way to use <code>window.onbeforeunload=function();</code> in chrome?</p> <p>Please find the below code. Failure.jsp is not calling in Chrome. Thanks in advance.</p> <pre><code>window.onbeforeunload = function() { window.location='Failure.jsp'; confirm("onbeforeunload&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+window.location); } </code></pre> <p>Failure.jsp:</p> <pre><code>&lt;body&gt; &lt;h3&gt; &lt;b&gt; Your session Expired&lt;/b&gt;&lt;/h3&gt; &lt;% session.invalidate(); System.out.println("invalidate&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"); %&gt; Click here to &lt;a href="http://localhost:8080/myApplication"&gt;Relogin&lt;/a&gt; &lt;/body&gt; </code></pre>
javascript
[3]
917,397
917,398
maximize window and view size
<p>my activity has a single custom view class and I'd like to make that full screen. According to other answers I should call </p> <pre><code>getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); </code></pre> <p>in Activity.onCreate but it doesn't work for me (at least in the emulator). The default size doesn't change. The only thing that worked so far is </p> <pre><code>getWindow().setLayout(600, 400); </code></pre> <p>or any other fixed values. Calling setLayout with MATCH_PARENT doesn't work either (and I have tried uncounted other ways without success). So the question is: what is the canonical way to start a maximized activity? (somewhat like full screened in a graceful sense, that is do not hide title bars, status bars and so on).</p> <p>Thanks in advance Olaf</p> <p>Edit 1:</p> <p>This is the relevant part:</p> <pre><code>public void onCreate(Bundle b) { super.onCreate(b); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); tableView = new DrawView(this); setContentView(tableView); } </code></pre> <p>I readded the FEATURE_NO_TITLE flag in the above snippet because I didn't know that in the android world this is considered the default (but it is completely OK for me). DrawView is a direct subclass of View and does not override onMeasure. Also there is no layout.xml. The effect is an (expected invisible) window, which is far to small (or at least the contained DrawView is). I tried with XOOM and Galaxy skins.</p> <p>Update 2: The issue seems not to be in the source code. I tried BitmapPixels from the ApiDeoms and it worked as expected (full sized window). Then I copied the source code (just one file) in a new fresh project and suddenly I got the same results: the app covers only a small portion of the screen (and one bitmap gets clipped). I guess it has something to do with the parent activity. but I can't find any differences between the project properties of APIDemos and my test project.</p>
android
[4]
5,101,152
5,101,153
How do i display digital pulse in android using Eclipse?
<p>I would like to build an android app to take the audio data from microphone and to display both the analog signal and digital gear pulse. I had succeeded in developing the app to display analog signal in graph with plotting corresponding samples on it, but so far i am unable to display the digital pulse for the same, can anyone help regarding this.,</p> <p>Thanks in advance...!</p>
android
[4]
1,437,655
1,437,656
how to get the real path of java application at runtime?
<p>i am crated an Java application,where i am using log4j,i given the absolute path of configuration log4j file and also i given an absolute path of generated log file(where this log file are generated). my problem is how i am get the absolute path of Java application at run time.In respect of web application we using</p> <pre><code> String prefix = getServletContext().getRealPath("/"); </code></pre> <p>but in context of Java application.what we have used?</p> <p>Thanks</p>
java
[1]
4,231,005
4,231,006
Display latest 5 posts on homepage
<p>I'm currently using a custom made Twentytwelve child theme and would like to display the last 5 posts on the homepage using a shortcode. I have tried using the code below (added to <code>functions.php</code>) but to no avail - when I add the shortcode to the homepage, it doesn't display anything although as far as I can see, it should and I have a test post live.</p> <pre><code>function custom_prev_posts($limit = 5){ global $wpdb, $post; $html = ''; $prev_posts = $wpdb-&gt;get_results( $wpdb-&gt;prepare( "SELECT * FROM $wpdb-&gt;posts WHERE $wpdb-&gt;posts.post_date &lt; '%s' AND $wpdb-&gt;posts.post_type = 'post' AND $wpdb-&gt;posts.post_status = 'publish' ORDER BY $wpdb-&gt;posts.post_date DESC LIMIT $limit", $post-&gt;post_date ) ); if($prev_posts){ $html .= '&lt;ul&gt;'; foreach ( $prev_posts as $prev_post ) { $html .= '&lt;li&gt;&lt;a href="' . get_permalink( $prev_post-&gt;ID ) . '"&gt;' .$prev_post-&gt;post_title . '&lt;/a&gt;&lt;/li&gt;'; } $html .= '&lt;/ul&gt;'; } return $html; } add_shortcode('last5', 'custom_prev_posts'); </code></pre> <p>I'm thinking the issue may be related to the Twentytwelve theme. Any ideas what I'm doing wrong or does anyone know of a working way to display the latest 5 posts inside a page?</p>
php
[2]
3,429,176
3,429,177
jquery: how can i create a simple overlay?
<p>how can i create a really basic overlay in jquery without UI ?</p> <p>which is a lightweight plugin ?</p>
jquery
[5]
4,168,407
4,168,408
Nested for-loops with Iterators?
<p>I have the following code which uses nested for-each loops to traverse two ArrayList properties in the Job class and the Category class (as well as performing a little logic on the properties):</p> <pre><code>for(Object dobj : hospice.getCategorys()) { Category cat = (Category) dobj; for(Object pobj : cat.getJobs()) { Job job = (Job) pobj; if(job.getID() == id) { System.out.println( String.format("The Job %d belongs to the (%s) %s Category.", id, cat.getCode(), cat.getName())); catFound = true; } } } </code></pre> <p>Is there anyway to make use of Java Iterators with this approach to create a more elegant and future-proof solution?</p> <p>Thanks.</p>
java
[1]
1,468,289
1,468,290
echo text if .php extentin exists in a folder using a php script
<p>im trying to make a php script that if a .php extention exists in a folder it says check mail, if no .php files exist no mail either one or the other results show up not both.</p> <pre><code>&lt;?php $directory = "http://server1.bioprotege-inc.net/roleplay_realm_online/contact_us_files/"; if (glob($directory . "*.php") != true) { echo 'Check Mail:'; } else { echo 'No mail Today'; } ?&gt; </code></pre> <p>that what I got but it aint working it only shows the same result if there is a .php file in the folder or not</p>
php
[2]
3,048,504
3,048,505
How to change php.ini by PHP?
<pre><code>short_open_tag = On </code></pre> <p>Is it possible?</p> <p><strong>EDIT</strong></p> <p>I tried this :</p> <pre><code>&lt;?php if (!ini_get('short_open_tag')) { ini_set('short_open_tag', 'On'); } $a=1; ?&gt; &lt;?=$a;?&gt; </code></pre> <p>which outputs <code>&lt;?=$a;?&gt;</code>,so it's not working.</p>
php
[2]
4,770,900
4,770,901
jQuery: Trying to run $.get within .each function
<p>This code does get the index value of each element with the "profileName" class. It also does run a $.get using each index value as the url. But it fails when I try to make it put the ajax response into each element with the "details" class that is the child element of each "profilName" div. Is this doable? </p> <pre><code>$('.profileName').each(function(index) { var urlVal = $(".showProfile", this).attr('profile'); $.get(urlVal, function(data) { $(".details", this).html(data); }, "html"); }); </code></pre>
jquery
[5]