Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,370,033
2,370,034
Web Platform Installer says asp.net is already installed (its not)
<p>Just trying to download it from <a href="http://www.asp.net/downloads" rel="nofollow">http://www.asp.net/downloads</a> for the first time. Web Platform Installer says regarding "Frameworks and Runtimes" (and also "Visual Studio Tools"), "All the recommended products from this group are already installed", even though they're not. Did have something called Visual Studio Runtime Redistributable installed which is just a handful of DLL's. I uninstalled it though - made no difference. Also removed entries from registry with "Visual Studio" in them, also made no difference.</p>
asp.net
[9]
228,090
228,091
JQuery works only for a one time
<p>I wrote jquery function for emphasis clicked <code>&lt;h4&gt;</code> tag. but it only works an one time. so how I solve that problem. this is my code.</p> <pre><code> $(document).ready(function(){ $('h4').click(function(){ var a = $('h4').attr('style'); if(a=='font-size: 1.5em'){ $(this).css('font-size','2.5em'); } else{ $(this).css('font-size','1.5em'); } }); }); </code></pre>
jquery
[5]
2,776,600
2,776,601
string args error on compiling command prompt
<p>I'm a biginner and got an error on this command, whou'ld someone please help me ? I've got this when I tried to compile my first programm.... get this in command prompt...</p> <blockquote> <p>HelloWorld.java:3: cannot find symbol<br /> symbol : class string location: class HelloWorld<br /> public static void main(string args[])<br /></p> </blockquote> <p>and my whole command is this</p> <pre><code>public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World"); } } </code></pre>
java
[1]
3,957,922
3,957,923
Alert message not popped up after using Array.concat method
<p>I tried the following code in <code>IE9, Chrome</code>. But it is not working in both browsers.</p> <p>In <code>Firefox</code>, it is working fine</p> <pre><code>&lt;script type="text/javascript"&gt; var first = ['a','b','c','h','i','j']; var second = ['d','e','f','g']; var insertPosIndex = 3; first.splice.apply(first, Array.concat(insertPosIndex, 0, second)); alert(first); &lt;/script&gt; </code></pre> <p>I am expecting the output as <code>a,b,c,d,e,f,g,h,i,j</code></p>
javascript
[3]
3,782,336
3,782,337
Problems when reading from a FILE and use strtok function
<p>I have writen a code in C++ that must read information from a txt file and when it finds a "|" character it must jump to a new line. Its something quite easy but Im having problems when executing and Ive been trying to find the problem for hours and I havent suceed. :( I attached the code. </p> <p>Thaaaanks in advance for your help.</p> <pre><code>#include&lt;iostream&gt; #include&lt;fstream&gt; #include&lt;string&gt; #include &lt;stdio.h&gt; using namespace std; int main () { string ruta_base( "C:\\a\\" ); char * pch; ifstream myReadFile; const string rutaFichero=ruta_base.append("text.txt"); myReadFile.open(rutaFichero.c_str()); char* temp; if (myReadFile.is_open()) { while (!myReadFile.eof()) { myReadFile.read(temp,1); pch = strtok(temp,"|"); while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, "|"); } } } myReadFile.close(); system("pause"); return 0; } </code></pre>
c++
[6]
3,637,972
3,637,973
Simplified Object Data Source Control
<p>Is there any simplified Data Source Control that would allow binding to a local (code behind) page method? Any way to accomplish this with an ODS?</p> <p>The ODS requires the TypeName parameter which I can't figure out to to point to the local page (code behind) in a Web Site Project.</p> <pre><code>&lt;asp:DropDownList ID="DropDownListMain" runat="server" DataTextField="Text" DataValueField="Value" DataSourceID="DataSourceMain" /&gt; &lt;asp:ObjectDataSource ID="DataSourceMain" runat="server" SelectMethod="GetMyRecords" /&gt; protected IEnumerable&lt;MyRecord&gt; GetMyRecords() { yield return new MyRecord("Red", "1"); yield return new MyRecord("Blue", "2"); yield return new MyRecord("Green", "3"); yield return new MyRecord("Black", "4"); } protected class MyRecord { public MyRecord(string text, string value) { this.Text = text; this.Value = value; } public string Text { get; set; } public string Value { get; set; } } </code></pre>
asp.net
[9]
100,675
100,676
Is there a synonym for "Blittable" that is more common?
<p>Is there a more common name for a "Blittable" data type? In my software there is a distinction between a variable sized structure and a fixed size structure that has a similar behavior to "blittable" but I have only seen the name used in Microsoft software.</p>
c#
[0]
800,140
800,141
detect a single ball out of two (Python)
<p>So i've got an image in input an i transformed it into an array. There is two ball, and i want to remove one ball. My idea is to run through a loop, and detect line by line if there is a red pixel. And if in this array at an i, and there is not red pixel in i+1 it erase the entire rest of the line.</p> <pre><code>for i in range(0, len(data)): h = h + 1 #print("0"), if (i&gt;1) and (((data[i - 1])[1] &gt; 40 and (data[i - 1])[2] &gt; 40 ) and ((data[i + 1])[1] &gt; 40 and (data[i+1])[2])): print("_"), elif (data[i])[1] &lt; 40 and (data[i])[2] &lt; 40 and (data[i])[0] &gt; 50 : j = j + 1 print "#" , else : print("."), #else : # print data[i], if h == 64 : h = 0 test = True print("\n") </code></pre> <p>What is wrong with my code and how can i erase a ball through my method ?</p>
python
[7]
4,263,652
4,263,653
How do I allocate a class (using new) when that class has a nested abstract class?
<p>I'm new to C++ and am porting over code from Java. I have a renderer class which has a method that takes an interface as an argument. This way the caller can define how to render its buffers. Now I'm running into trouble when I try to 'new' the ported over class. I get the error 'allocating an object of abstract class type'. This is the part of my code that I think I need to do something about:</p> <pre><code>// Interface to the OpenGL ES renderer; consumed by GLView struct IRenderingEngine { virtual void initialize(int width, int height) = 0; virtual void render() const = 0; virtual ~IRenderingEngine() {} }; class Renderer : public IRenderingEngine { public: ... class IDrawGLBuffer { public: virtual ~IDrawGLBuffer() {}; virtual void function(VBODescription vboDescription, ShaderDescription shaderDescription); }; class ShaderDescription { public: ShaderDescription(){}; ShaderDescription(string vertexShaderText, string fragmentShaderText, map&lt;string,GLint&gt;&amp; variableMap, IDrawGLBuffer&amp; callback, int vertexDimensions); GLuint getProgramID() const {return shaderProgramID;}; int getVertexDimensions() const {return vertexDimensions;}; friend class Renderer; private: string vertexShaderText; string fragmentShaderText; GLuint shaderProgramID; IDrawGLBuffer callback; int vertexDimensions; map&lt;string,GLint&gt; variableMap; }; class VBODescription { public: VBODescription(){}; VBODescription(string shaderName, map&lt;string, Buffer&gt;&amp; variableMap, GLenum usage, int indexTotal, GLuint textureID); int getIndexTotal() const {return indexTotal;}; GLuint getTextureID() const {return textureID;}; friend class Renderer; private: GLenum usage; map&lt;string, Buffer&gt; variableMap; string shaderName; int indexTotal; GLuint textureID; }; ... }; </code></pre>
c++
[6]
5,640,446
5,640,447
PHP multiple If conditions are true
<p>I have this PHP code:</p> <pre><code>$supplier = $line[2]; if ($supplier == "supplier") { } else { Header("Location: premium.php"); } </code></pre> <p>Now I want that to include $supplier == "demo" to the PHP code to be as follows:</p> <pre><code>$supplier = $line[2]; if ($supplier == "supplier" &amp;&amp; $supplier == "demo") { } else { Header("Location: premium.php"); } </code></pre> <p>but the latter code is not working for either... I mean if the $supplier is equal to something else besides "supplier" or "demo" it is still bypassing it. It only worked for the first one. </p> <p>How can I arrange it please?</p>
php
[2]
2,348,883
2,348,884
Why does this attribute not change?
<p>In the code below the last line is not setting the src attribute. Why?</p> <pre><code>$("div.galerina").each(function(){ var gal=$(this); var bullet=gal.children("img.galerina1"); var width=12*(gal.children("img").size())+'px'; gal.children("p").css({width:width}) gal.children("img").each(function(){ var img=$(this); gal.children("p").append("&lt;img class='bullet' src='images/bullet1.png'&gt;&lt;/img&gt;"); $("img.bullet").last().click(function(){ bullet.animate({opacity:0},300,function(){ bullet.css({display:'none'}); bullet=img; img.css({display:'block'}); img.animate({opacity:1},300); }); }) }) gal.children("img.bullet").first().attr("src","images/bullet2.png") }) </code></pre> <p><a href="http://lookaroundyou.net/galerina" rel="nofollow">LIVE VERSION HERE!!!</a></p>
jquery
[5]
3,680,090
3,680,091
Simple map<> instantiation, I can't compile, please help
<p>Why I can't compile this code?</p> <pre><code>#include &lt;map&gt; using namespace std; class MyTest { template&lt;typename T&gt; void test() const; }; template&lt;typename T&gt; void MyTest::test() const { map&lt;string, T*&gt; m; map&lt;string, T*&gt;::const_iterator i = m.begin(); } </code></pre> <p>My compiler says:</p> <pre><code>In member function ‘void MyTest::test() const’: test.cpp:8: error: expected `;' before ‘i’ </code></pre> <p>What is it about? Many thanks in advance!</p>
c++
[6]
3,751,641
3,751,642
ImageView inside of a ScrollView
<p>I am working on a android project. I n that I have to deal with <code>ScrollViews</code> to scroll image. But when I am using <code>ImageView</code> inside <code>ScrollView</code> image given to me is not fit in UI layout. So I am thinking I convert a <code>ScrollView</code> to <code>ImageView</code>. Is there any procedure in android. Plz help me. </p>
android
[4]
1,580,890
1,580,891
How to run an application before any other application in android?
<p>I want to write a program in that if somebody wants to open a application (like Contacts Application) , first my program starts and user enter a password and if password is correct , let contacts program to open.</p> <p>i know it s possible because <a href="https://market.android.com/details?id=com.cc.applock&amp;feature=search_result" rel="nofollow">App Lock</a> program does it.</p> <p>should i run a service?</p>
android
[4]
1,983,440
1,983,441
change first line of a file in python
<p>I only need to read the first line of a huge file and change it.</p> <p>Is there a trick to only change the first line of a file and save it as another file using Python? All my code is done in python and would help me to keep consistency.</p> <p>The idea is to not have to read and then write the whole file.</p>
python
[7]
2,793,697
2,793,698
Redirecting to file on network drive from asp.net page
<p>I need to open a file that is in the network location from a asp.net page. I have a service method that returns the path of the file.</p> <p>string fpath=string.empty; fpath=service.GetDocumentPath();</p> <p>The path of the file returned will be fpath="\myserv1\downloads\xyz.pdf"</p> <p>How do I redirect users to fpath?</p> <p>Thanks in advance</p>
asp.net
[9]
16,784
16,785
JS alert doesn't fire after php update
<ol> <li>The alert message 'Test' fires on load correctly. </li> <li>The tblRoles table is updated correctly after the button is clicked. HOWEVER </li> <li>The alert message 'Update' does not fire after the update/button click.</li> </ol> <p>Code: </p> <pre><code> &lt;?php //works correctly--On load---------------- echo '&lt;script type="text/javascript"&gt; alert("Test"); &lt;/script&gt;'; //works correctly------------------ if (($_GET["Action"])=='edit') { $result = mysql_query("UPDATE tblRoles SET Role='" .$_GET["strA"] ."',Test='".$_GET["strA"] ."' WHERE ROLEID= " . $_GET["ID"]); //does not work------------------ echo '&lt;script type="text/javascript"&gt; alert("Update"); &lt;/script&gt;'; }?&gt; &lt;input class="grid" type="text" id="?php echo($row[1]);?&gt;" onblur="UpdateDiv('grid','edit','&lt;?php echo $row[0]?&gt;',document.getElementById('&lt;?php echo($row[1]);?&gt;').value)", value="&lt;?php echo($row[1]);?&gt;" size="20" maxlength="20" /&gt; </code></pre>
javascript
[3]
1,141,496
1,141,497
Why python round so strange?
<p>My code:</p> <pre><code> #!/usr/bin/python # -*- coding: utf-8 -*- print (round(1.555,1)) #It seems normal print (round(1.555,2)) #Why it is not output 1.56? print (round(1.556,2)) #It seems normal </code></pre> <p>Output:</p> <pre><code> sam@sam:~/code/python$ ./t2.py 1.6 1.55 1.56 sam@sam:~/code/python$ </code></pre> <p>round(1.555,1) is output 1.6 .</p> <p>Why round(1.555,2) is not output 1.56?</p> <p>Thank you~</p>
python
[7]
2,672,034
2,672,035
Android Development which sound file type?
<p>I have been getting the loop error where the soundpool plays a sound twice if they are WAV's and decided to convert all my audio to either OGG or MP3. I have seen mixed reviews.</p> <p>Generally for Android Development which is the better audio file type?</p>
android
[4]
3,117,057
3,117,058
one android app XML resources for different versions of build
<p>I need one information regarding , one android app XML resources for different versions of build. That means, i have a string XML files related to one android app. i have to use same string resource file for two different builds(in second build i need to change some strings of xml file instead of create new string.xml. this is like MACRO concept of C- programing).</p> <p>Please tell me how to solve this issue. </p>
android
[4]
3,978,804
3,978,805
How can I convince Python to import a class from a submodule when you import the package?
<p>Example: <code>mypkg/submodule.py</code> with class <code>MyClass</code> inside.</p> <p>I want to be able to do:</p> <pre><code>import mypkg obj = MyClass() </code></pre> <p>What I need to do in order to make this work with default import?</p> <p>I note that <code>from pkg import *</code> and <code>import pkg.submodule</code> works are working but I want to change the behaviour of the <strong>default import</strong>.</p> <p>This is clearly related to <code>__init__.py</code> and <code>__all__</code>.</p>
python
[7]
3,419,186
3,419,187
Where to start in learning how PHP works?
<p>I know PHP but I don't know why things work the way they do. I just know it has worked in the past so I just put it in there. </p> <p>I can't seriously call myself a web developer until I truely know the languages I am working with. And if someone asks me why this does that etc., and I can't answer them, it's just wrong.</p> <p>So my question is, where would be a good place to start learning how things work? I know there is the PHP Documentation but it's quiet large and intimidating. And I know there is college, but are there any other ways?</p> <p>Appreciate it!</p>
php
[2]
2,355,130
2,355,131
RingtonePreference: Is it possible to change the dialog title?
<p>By default, the title of the RingtonePreference dialog is "Ringtones". I'd like to change it to something else, but I'm not seeing an obivous way to do that. </p> <p>Setting the title in the xml does not work:</p> <pre><code>&lt;RingtonePreference android:key="@string/pref_key_notifications_sound" android:title="@string/prefs_notification_sound" android:ringtoneType="notification" android:showDefault="true" android:showSilent="true" android:persistent="true" /&gt; </code></pre> <p>Any suggestions?</p>
android
[4]
3,301,296
3,301,297
Setting focus in ASP
<p>I’m maintaining a site in ASP, one of the tasks is to set the focus on textbox on a page. Here is what I have tried:</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- document.psForm['password'].focus(); //AND document.getElementById("password").focus(); --&gt; &lt;/script&gt; </code></pre> <p>I didn't think this would work... and it doesn't:</p> <pre><code>&lt;form id="psForm" action="logonpw.asp" method="post" defaultfocus="password"&gt; </code></pre> <p>This doesn't work:</p> <pre><code>&lt;body onload="javascript:docuument.psForm.password.focus();"&gt; </code></pre> <p>Here is the form:</p> <pre><code>&lt;form id="psForm" action="logonpw.asp" method="post"&gt; &lt;table border="0" cellpadding="5"&gt; &lt;tr&gt; &lt;td&gt; Password: &lt;/td&gt; &lt;td&gt; &lt;input type="password" name="password" value="&lt;%= password %&gt;" size="50"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre>
javascript
[3]
1,372,846
1,372,847
I have a text file of a paragraph of writing, and want to iterate through each word in Python
<p>How would I do this? I want to iterate through each word and see if it fits certain parameters (for example is it longer than 4 letters..etc. not really important though). </p> <p>The text file is literally a rambling of text with punctuation and white spaces, much like this posting.</p>
python
[7]
3,445,301
3,445,302
How do you alias a python class to have another name without using inheritance?
<p>If I have a python class, how can I alias that class-name into another class-name and retain all it's methods and class members and instance members? Is this possible without using inheritance?</p> <p>e.g. I have a class like:</p> <pre><code>class MyReallyBigClassNameWhichIHateToType: def __init__(self): &lt;blah&gt; [...] </code></pre> <p>I'm creating an interactive console session where I don't want my users' fingers to fall off while instantiating the class in the interactive sessions, so I want to alias that really long class name to something tiny like 'C'. Is there an easy way to do this without inheritance?</p>
python
[7]
1,946,280
1,946,281
how to get function's name from within the function (or kind of "self" reference to the function)?
<p><a href="http://stackoverflow.com/questions/251464/how-to-get-the-function-name-as-string-in-python/255297#255297">This answer</a> shows that there is a built-in <code>__name__</code> attribute of a function which can be used from <strong>outside</strong> the function, i.e. <code>print f.__name__</code>. However, how can I get this attribute from <strong>within</strong> the function itself?</p> <p>Just using unqualified <code>__name__</code> does not help: <code>print __name__</code> prints <code>__main__</code>.</p> <p>Using <code>print f.__name__</code> from within <code>f()</code> looks stupid - I can type <code>"f"</code> just as well.</p> <p>Alternatively, is there a kind of <code>self</code> object for functions, i.e. can I get a pointer to the function that is executing in a common way?</p> <p>I don't like the method proposed in <a href="http://stackoverflow.com/questions/245304/how-do-i-get-the-name-of-a-function-or-method-from-within-a-python-function-or-me">this question</a> - it feels that hacking the stack for such simple task is not the proper way. </p> <p><strong>Motivation</strong>: I have a dictionary of <code>{keyword:function}</code>, the keywords are read from the input and an appropriate function is executed. I want each function to be executed only once, so I want each function to register itself in some data structure when executed. I know I can do it in the dictionary itself, but I thought of using a separate data structure for this.</p> <p>Python version is 2.6.4 BTW</p>
python
[7]
614,074
614,075
How to override the behavior of the volume buttons in an Android application?
<p>I'd like to use the volume buttons for something else in my Android application. The Dolphin browser does this I am told. Anyone know how?</p>
android
[4]
5,753,986
5,753,987
How to look through multiple arrays?
<p>I have an array that looks like this?</p> <pre><code>Array ( [0] =&gt; 15 [id] =&gt; 15 ) Array ( [0] =&gt; 16 [id] =&gt; 16 ) </code></pre> <p>I was wondering how can I know one from each other, if I want to echo the values separately?</p> <pre><code>$getid = mysql_query($query); while ($get_id = mysql_fetch_array($getid)){ print_r($get_id); } </code></pre> <p>any ideas? </p> <p><strong>edit</strong>:</p> <p>If I <code>echo $get_id['id'].', ';</code> I will get <code>15, 16</code>. What I want is to be able to echo them separately.</p> <p>or the arrays to become:</p> <pre><code>Array ( [0] =&gt; 15 [id] =&gt; 15 ) Array ( [1] =&gt; 16 [id] =&gt; 16 ) </code></pre> <p><strong>edit 1</strong>: I figured it out:</p> <pre><code> $i = 0; $getid = mysql_query($query); while ($get_id = mysql_fetch_array($getid)){ $test[$i] = $get_id; $i++; } </code></pre>
php
[2]
4,057,587
4,057,588
Getting fixed headers to stay inside container w/ jquery
<p>I'm trying to get a div to get fixed positioning when it's parent gets to the top of the window, and lose it when it hits the bottom... for some reason, i can get it to get the fixed positioning, but not lose it. been at this for awhile and i just cant figure it out...</p> <p>Here is my code so far. Can anyone see something I'm missing or screwed up on?</p> <pre><code> $(window).bind('scroll',function(event) { $('.posthead').each(function(e) { var y = $(window).scrollTop(); var windowHeightS = $('body').height(); var postheadh = $(this).height() + 30; var top = $(this).offset().top - parseFloat($(this).css('margin-top').replace('auto', 0)); var postheight = $(this).parent('.type-post').height(); var windowHeight = windowHeightS - top; //var top = getposition.top; var postTop = top - y; var postBottom = postheight + top - y; $(this).parent('.type-post').children('.debug').html('Position from top: &lt;span&gt;' + y + "&lt;/span&gt; bottom: &lt;span&gt;" + postBottom + "&lt;/span&gt;"); if(postTop &lt;= 0) { $(this).addClass('fixed'); } else if(postTop &gt;= 0) { $(this).removeClass('fixed'); } if(postBottom &lt;= 0) { $(this).removeClass('fixed'); } }); }); </code></pre>
jquery
[5]
306,128
306,129
How many bytes is unsigned long long?
<p>How many bytes is <code>unsigned long long</code>? Is it the same as <code>unsigned long long int</code> ?</p>
c++
[6]
4,354,602
4,354,603
Understanding ASP.Net toolbar controls
<p>I am new to ASP.Net and am looking for a resource to describe the asp.net controls in the toolbar. Any ideas and suggestions are greatly apreciated.</p>
asp.net
[9]
4,561,451
4,561,452
How to generate a string containing private and public key in PhP?
<p>I saw this code:</p> <pre><code>&lt;?php class MyEncryption { public $pubkey = '...public key here...'; public $privkey = '...private key here...'; public function encrypt($data) { if (openssl_public_encrypt($data, $encrypted, $this-&gt;pubkey)) $data = base64_encode($encrypted); else throw new Exception('Unable to encrypt data. Perhaps it is bigger than the key size?'); return $data; } public function decrypt($data) { if (openssl_private_decrypt(base64_decode($data), $decrypted, $this-&gt;privkey)) $data = $decrypted; else $data = ''; return $data; } } ?&gt; </code></pre> <p>What are samples of public_key? What kind of public key should be put on $pubkey? Should it be base_64encoded or not? How do I generate one?</p> <p>I added:</p> <pre><code>$privKey = openssl_pkey_new(); </code></pre> <p>And all I got is $privKey==false</p>
php
[2]
2,533,370
2,533,371
How to Crop a Zoomin image in Android
<p>In my app,user can select image from gallery and after that he can zoom in/ zoom out that image .</p> <p>After that user wants to save that zoomin/zoom out image.</p> <p>I dont want the default android crop method.</p> <p>How to get the zoomed image's current height &amp; width for cropping.</p> <p>Anybody have any idea how to implement this?</p>
android
[4]
5,244,872
5,244,873
Asp.Net CSS Friendly Menu Adapter
<p>I have used the CSS Friendly menu in one of my projects and have found it great, however I have 2 different areas in the same project and would like to use the CSS Friendly menu in just some of my pages.</p> <p>How can I prevent all other menus from using the Css Friendly menu dll?</p> <p>Thank you</p> <p>Josimari</p>
asp.net
[9]
6,029,949
6,029,950
Show/hide an image works only on IE
<p>I have that JavaScript code:</p> <pre><code> var state = 'hidden'; function Show_Picture() { if (state == 'visible') state = 'hidden'; else state = 'visible'; document.getElementById('loader').style.visibility = state; } </code></pre> <p>'loader' is the </p> <pre><code>&lt;img alt="" id="loader" src="file:///D:/ajax-loader.gif"/&gt; </code></pre> <p>Why that code doesn't work on FF ? Ont the IE it works OK.</p> <p>Here's the code: <a href="http://pastebin.com/m38aa1847" rel="nofollow">http://pastebin.com/m38aa1847</a></p>
javascript
[3]
4,646,104
4,646,105
Is there a sensible way to refer to application resources (R.string...) in static initializers
<p>Is there a sensible, clean way to refer to application resources from static initalizer code in my android classes.</p> <p>I would specifically like to define an enum which contains the values of some resource strings in its constants.</p> <p>Here is some pseudo code for the enum</p> <pre><code>private enum MyEnum { Const1(getString(R.string.string1)), Const2(getString(R.string.string2)), Const3(getString(R.string.string3)); private String strVal; MyEnum(String strVal){ this.strVal = strVal; } } </code></pre> <p>This question applies to any kind of static initialization.</p>
android
[4]
1,249,467
1,249,468
Get name of prototype object
<p>I'm planning on writing a convention over configuration template source engine for KnockoutJS / MVC. I'm started with a little client side POC and ran into a show stopper right away</p> <p>My plan is use this syntax or something similar</p> <pre><code>MyApp.EditCustomersViewModel = function() { ko.templates.loadView(this); }; </code></pre> <p>When doing this it will check the tamplate cache or fetch the templates from server using the object name as key. The problem is I cant get the name of the prototype object, i tried this</p> <pre><code>Object.prototype.getName = function() { var funcNameRegex = /function (.{1,})\(/; var results = (funcNameRegex).exec((this).constructor.toString()); return (results &amp;&amp; results.length &gt; 1) ? results[1] : ""; }; </code></pre> <p>If works for objects defined like this</p> <pre><code>function MyClass() { } </code></pre> <p>If you add a prototype to the above object it will not work, or if you define it like this</p> <pre><code>MyApp = {}; MyApp.MyClass = function() { }; </code></pre> <p>Prototype and scoping is two musts so this is a showstopper, any ideas?</p> <p>Fiddle: <a href="http://jsfiddle.net/aRWLA/" rel="nofollow">http://jsfiddle.net/aRWLA/</a></p> <p><strong>edit:</strong> The background for this is like this.</p> <p>On the server you have structure like this </p> <ul> <li>Templates\ [ViewName]\index.html</li> <li>Templates\ [ViewName]\sub-model-template.html</li> </ul> <p>on the client you will do </p> <pre><code>MyApp.EditCustomersViewModel = function() { ko.templates.loadView(this); }; </code></pre> <p>which will generate a ajax request with the objects name as key, which will fetch all the templates for the view in question</p>
javascript
[3]
5,115,353
5,115,354
Capturing a shift+tab keypress in C#
<p>I'm trying to capture shift + tab in c# using the following cpp syntax:</p> <pre><code>if (GetAsyncKeyState(VK_SHIFT) &amp; 0x8000) { // The key is currently down } </code></pre> <p>Can anyone point me to the c# equivalent?</p> <p>Thanks, Drew</p>
c#
[0]
4,707,688
4,707,689
Reducing CPU Usage while using reading a file
<p>This is the idea, behind my project, playing around with the hashlib modules, when user enters a hash, all uppercase lower case combination are tried to find if a match is found, everything is fine, works great, the only problem Is with the CPU usage, which shoots upto 50%-60%.. Anyhow, is there a way to decrease the cpu usage? </p> <p>OS: Windows</p> <p>Part Of The Code:</p> <pre><code>def md5(file, torev): with open(file) as f: for i in f: i = i.replace("\n", "") s = map(''.join, itertools.product(*zip(i.upper(), i.lower()))) for k in s: rev = hashlib.md5(k).hexdigest() if rev == torev: print "[+] Hash Value Found" print "[+] Value: "+k break </code></pre> <p>Thanks </p>
python
[7]
5,511,272
5,511,273
Are there any pitfalls in displaying a "No JavaScript" warning in the following fashion?
<p>I have a webpage that has a comment box that can be toggled by clicking a link (the opening and closing of the box is controlled using JavaScript, specifically JQuery). This box is hidden by default, so naturally, it's impossible to display without the use of JavaScript. I'm not concerned by this fact: the comment box is not a "necessary" feature and this is a small personal site, so I don't mind that a tiny percentage of visitors may not experience full functionality. However, I would like to display a warning if the user does not have JavaScript enabled.</p> <p>I've considered the idea of doing this by presenting a small message (with the use of a simple HTML <code>&lt;p&gt;</code> tag) near the link that toggles the comment box, using the following bit of code:</p> <pre><code>&lt;p class="alert" id="nojs-warning"&gt;You must have JavaScript enabled to leave a comment.&lt;/p&gt; </code></pre> <p>Of course, I don't want to display this if JavaScript <em>is</em> enabled, so I have the following JQuery trigger set up to immediately hide the box when the page is loaded:</p> <pre><code>$(function() { $('#nojs-warning').hide(); }); </code></pre> <p>Thus, if the user has JavaScript enabled, the event will fire and the warning will be hidden; if the user doesn't have JavaScript enabled, the event <em>won't</em> fire, and thus the warning will still be displayed.</p> <p>For such a small, personal site, this seems like an elegant solution. Are there any pitfalls to this approach?</p>
javascript
[3]
3,624,092
3,624,093
How to remove the first two BR tags with jquery?
<p>My customer's CMS from the last century outputs the following code.</p> <p>And I'd like to remove only the first two BR tags with jquery.</p> <pre><code>&lt;div id="system"&gt; &lt;BR CLEAR="ALL"&gt;&lt;BR&gt;// I want to remove both BR. ... &lt;BR&gt;... ... &lt;BR&gt; </code></pre> <p>I assume something like this. But I am not sure.</p> <pre><code>$('#system br').remove(); </code></pre> <p>Could anyone tell me how to do this please?</p> <p>Thanks in advance.</p>
jquery
[5]
713,305
713,306
Initialise class object by name
<p>Since everything in python is an object, i was wondering if there was a way i could initialise a class object using the name of the class</p> <p>for example, </p> <pre><code>class Foo: """Class Foo""" </code></pre> <p>How could i access this class by "Foo", ie something like <code>c = get_class("Foo")</code></p>
python
[7]
2,182,204
2,182,205
when sending mail via a Intent we are getting bluetooth also in th echooser why?
<p>when sending mails from intent we are calling the intent using such as these <code>codestartActivity(Intent.createChooser(emailIntent, "Send your email in:"))</code>, but we are getting Bluetooth also in the chooser, how to avoid Bluetooth from the chooser.</p>
android
[4]
1,043,382
1,043,383
AutoComplete combobox (search anywhere within list, not just first letter )
<p>I have a combobox that fill with a datatable in form load.</p> <pre><code>Mycombo.DisplayMember = "FullName"; MyCombo.ValueMember = "ID"; MyCombo.DataSource = MyDattable; </code></pre> <p>And set <code>AutoComplateMode</code> to <code>SuggestAppend</code> and <code>AutoComplateMode</code> to List item.</p> <p>When I insert a text into combobox it is fill with suggested that started with my text.</p> <p>But I want it is fill wit all suggested that like mytext.</p>
c#
[0]
3,771,712
3,771,713
Android click and touch events not working properly
<p>Actually i have an activity that downloads data from server and that data contains lattitude ,longitude and images of various venues, this images are downloaded from server and shown in listview and on same activity i am showing listview and mapview alternatively , by hiding the listview and mapview respectively.I am getting this error bimap size exceeds Virtual memory</p> <p>For this i simply added try-catch statement but On clicking listview, my clickevents are responding very late and my application is forced close without showing any error in Logcat.</p>
android
[4]
1,272,566
1,272,567
How to connect ireports from php
<p>I am developing a web application with PHP and MySQL. Now I am facing problem with selecting the reporting tool. I am developing in Windows XP environment. But the hosting server is Linux. Therefore I have selected iReports as it has Linux version too.</p> <p>I want at the clicking of a button from front end (which is written in PHP), the Jasper report should be generated. But how can I connect iReport with PHP code?</p> <p>I have learnt that iReport can connect MySQL with JasperServer (Don't know yet, how) but need help to connect it from PHP front end.</p>
php
[2]
1,869,327
1,869,328
C# Rich text box , add string, output to different textbox
<p>I'm looking for a way to take each item in a rich text box that a user can customize and take those items and put them into a different text box with a string attatched. </p> <p>for example: the richtextbox would contain and be separated like this: </p> <pre><code>Sad Glad Mad </code></pre> <p>The string i want those to go into is: <code>John was ____ today.</code></p> <p>id like it to output all 3 on different lines but in a the same textbox (different from the richtextbox). </p> <pre><code>John was Sad today. John was Glad today. John was Mad today. </code></pre> <p>This is all simplified to make it easier to understand, i have been pulling my hair out trying to get it to work.</p> <p>Thanks in advance. </p>
c#
[0]
4,683,172
4,683,173
2D arrays comparison - nested for loop error
<p>I have the following function which compares the first column value in two 2D arrays.</p> <pre><code>var new_array = [['EMI_007','lion','cat'], ['EMI_008','cat','dog'] ]; var existing_array = [['EMI_002','cat','tiger'], ['EMI_004','hen','pig'], ['EMI_007','pigeon','hen'], ['EMI_001','boar','tiger'] ]; </code></pre> <p>The value in new_array[i][0] is compared to the value in existing_array[j][0].</p> <p>If they are the same, the entire row is replaced by the row in <code>new_array</code>, otherwise the <code>new_array</code> row is concatenated to the existing array.</p> <p>In the above example, new_array is compared to existing_array.</p> <p>EMI_007 exists in 'existing_array', so it's replaced by <code>['EMI_007','lion','cat']</code> and ['EMI_008','cat','dog'] is appended to the existing array.</p> <p>I have created the following function but there seems to be an error.</p> <p>If a row with an EMI id found in new_array does not exist in 'existing_array', it is inserted several times.</p> <pre><code>function concat_2D_array(existing_array, new_array){ for (var i=0; i&lt;new_array.length; i++) { for (var j=0; j&lt;existing_array.length; j++) { if(new_array[i][0] == existing_array[j][0]){ alert("ok,it already exists in the existing_array"); existing_array.splice(j,1,new_array[i]); } else{ alert("It is not in the existing array"); // existing_array.concat(new_array[i]); } } } alert("returned existing_array"+existing_array) return existing_array; } </code></pre> <p>Any help is most appreciated</p>
javascript
[3]
2,765,777
2,765,778
Get Uri of All Images in SDCard in Android
<p>I want to get <strong>URI</strong> or <strong>Path</strong> of all the <strong>Images</strong> of <strong>SDCARD</strong>.</p> <p>How I can achieve this ?</p> <p>Thanks.</p>
android
[4]
1,234,172
1,234,173
Why do I get a parse error when running this PHP code?
<p>Im new to PHP programming. I get this error when running the following PHP code to generate a URL. Im using PHP 5.3.5. </p> <blockquote> <p>( ! ) Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting '&amp;' or T_VARIABLE in C:\wamp\www\test\urlgen.php on line 30</p> </blockquote> <pre><code>function bg_gen_secure_uri( 'http://demo.com/abc/secure/movie/movie-full-film_256x144-150.mp4', 'MqG9$fso2lt7(', $expiry = 0, $allowed_countries = '', $disallowed_countries = '', $allowed_ip = '', $allowed_useragent = '', $allowed_metros = '', $disallowed_metros = '', $progressive_start = '', $progressive_end = '', $extra_params = '' ) { return $url; } </code></pre> <p>I will be very thankful if I get an answer.</p>
php
[2]
4,086,891
4,086,892
How to convert any audio format to MP3 using C#
<p>I want to play the audio uploaded by the users. The uploaded audio will be in any format. Is there a way to convert any audio file into mp3 format? </p>
c#
[0]
1,724,215
1,724,216
POST a hidden input + multiple options PHP
<p>Hi there I'm quite new to PHP</p> <p>I have this problem:</p> <p>I would like to POST a multiple choice + a hidden field from a form:</p> <pre><code>&lt;?php if (isset($_SESSION['nickname'])) { $result = mysql_query("SELECT * FROM users"); $teamsCount = ceil(mysql_num_rows($result)/2); for ($i=1; $i&lt;=$teamsCount; $i++) { // TEST: echo $i . " TeamsCount er: " . $teamsCount. "&lt;br&gt;"; ?&gt; Team &lt;? echo $i; ?&gt; &lt;form name="addTeam" action="buildTeams.php" method="POST"&gt; &lt;input type="hidden" name="hiddenField" value="&lt;?php $i; ?&gt;" /&gt; &lt;select name="teams[]" multiple="multiple" size="&lt;?php echo mysql_num_rows($result); ?&gt;"&gt; &lt;?php $query = mysql_query("SELECT * FROM users"); while ($row=mysql_fetch_array($query)) { $id=$row["ID"]; $nick=$row["Nick"]; ?&gt; &lt;option value="&lt;?php echo $id; ?&gt;"&gt;&lt;?php echo ucfirst($nick); ?&gt;&lt;/option&gt; &lt;?php } ?&gt; &lt;/select&gt; &lt;input type="submit" value="Make them teams!!" /&gt; &lt;/form&gt; &lt;?php } } ?&gt; </code></pre>
php
[2]
4,833,997
4,833,998
Is it necessary temporary variable when allocating ivar used only in that class?
<p>If ivar is used by other classes, I use @property (noatomic, retain) and @synthesize. And I add it to the view like this. label is ivar.</p> <pre><code>UILabel *aLabel = [UILabel alloc] initWithFrame:frame]; self.label = aLabel; [aLabel release]; [self.view addSubview:label]; </code></pre> <p>But if it is not used by other classes, I do not use @property and @synthesize. And I add it to the view like this.</p> <pre><code>label = [UILabel alloc] initWithFrame:frame]; [self.view addSubview:label]; </code></pre> <p>Am I right?</p>
iphone
[8]
4,520,034
4,520,035
CSS doesn't affect new items on asp.net web form
<p>I have a web form with a CSS, I'm working on it with visual studio.</p> <p>Yesterday I edited the CSS and it worked just fine, new fonts, positions, labels, everything works.</p> <p>Today I decided to add a new label and dropdown box to my web form, and I did some styling for them in the same CSS. In the visual studio preview the CSS for the new items takes effect, but when I run the debug the new items are not affected by the CSS, but the old items are still working fine.</p>
asp.net
[9]
4,912,826
4,912,827
Send music control keys from my app in android
<p>Is there a simple way to tell the default media player to change track back or forward?</p> <p>I want the ability to send commands to the system media player (Music) to change track back and forward from within my app.</p> <p>Is there a simple way? Code examples or descriptive explanation please, I have not developed for Android before.</p> <p>Update: Is it just the HTC Music that isn't part of the SDK or even the stock one? Either player would be fine if I could manage way to change tracks.</p> <p>The HTC Lock screen has some method of changing tracks in the music player. Is it possible I could get hold of this and use it?</p> <p>Baksmali?</p>
android
[4]
3,946,557
3,946,558
Session variable Error
<p>I'm not getting value to the session variable. Please have a look at the following code. </p> <pre><code>&lt;?php session_start(); $uname=$_SESSION['uname']; include("connection.php"); $qtno=$_POST['qtno']; $uans=$_POST['answer']; $query_qt=mysql_query("SELECT * FROM answr WHERE No='$qtno' "); $info = mysql_fetch_array($query_qt); if($info) { $ans=$info['Answer']; } if($ans==$uans) { $query_ap=mysql_query("UPDATE regst SET points=points+1 WHERE unme='$uname'"); $query_sel=mysql_query("SELECT * FROM regst WHERE uname='$uname'"); $infor = mysql_fetch_array($query_sel); if($infor) { $_SESSION['pid']=$infor['points']; } header("location:account.php"); } else { echo "FALSE"; } ?&gt; </code></pre> <p>The session variable <code>$_SESSION['pid']</code> does not hold any value. Actually it should contain the value of the column <code>points</code> after increasing it's value. </p>
php
[2]
4,704,230
4,704,231
Browser Display Problem on Motorola Droid Phone
<p>I have the mobile page displayed fine in iPhone with the meta element set.</p> <p></p> <p>It also work fine in HTC G1 and G2 phone without the above meta tag.</p> <p>However, it is totally screwed up when displayed on the HTC Droid phone such as Motorola Droid. </p> <p>Does anyone know that what parameters I should set to display it properly? I have the background image with 320X480 which is the exact size of device resolution (320X480).</p>
android
[4]
919,653
919,654
Handling physical buttons on Android
<p>I'm creating a 2d game for android.I want to handle physical buttons on Android but what i have to do if i will handle these buttons from another class not from Activity.Because i'm using my own screen class based on opengl in my game and i want to handle menu buttons from different screens.</p>
android
[4]
4,565,436
4,565,437
access an array of type class which is internal in a public class
<p>I have an internal class </p> <pre><code>namespace commonNamespace { internal class A{} } </code></pre> <p>i have another public class within the same assembly</p> <pre><code>public class B{} </code></pre> <p>I want to declare an array of type A in classB. ex:</p> <pre><code>namespace commonNamespace { public class B { A[] array; } } </code></pre> <p>I am getting inconsistent accessibility Level error message.Please let me know how can i do this.</p>
c#
[0]
4,442,479
4,442,480
Passing objects in javascript
<p>I want to pass an object in javascript. But i am getting an error <code>javascript:callbackCredits(1,dotsContainer_credits); is undefined</code></p> <p>My code is as follows:</p> <pre><code>var dotSlideCredits = { show : 3, width : 430, functionName : "callbackCredits", title: "title", itemId: "#s_credit" } var test = { data[] } $(document).ready(function(){ dynamicList(dotSlideCredits); } function dynamicList(dotSlide){ var divItems = "dotsContainer_"+dotSlide.title; test.data.push({title: dotSlide.title+[i], callBack: "javascript:"+dotSlide.functionName+"("+i+","+divItems+");"}); } function callbackCredits(current, container){ var prev = $("#previousCredit").val(); slideShow(current, prev, container); $("#previousCredit").attr("value", current); } </code></pre>
javascript
[3]
1,879,847
1,879,848
How to split a string based on every third character regardless of what the character is in c#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/105770/net-string-format-to-add-commas-in-thousands-place-for-a-number">.NET String.Format() to add commas in thousands place for a number</a> </p> </blockquote> <p>I am trying to add commas to a number for the presentation layer and need to cast and then split the number on every third character in order to join on a ','. </p> <p>So if i have a string like this </p> <pre><code>546546555 </code></pre> <p>desired output:</p> <pre><code>546,546,555 </code></pre> <p>Other times, the number could be longer or shorter:</p> <pre><code>254654 </code></pre> <p>desired output:</p> <pre><code>254,654 </code></pre> <p>Is it possible to split in this manner then join with a comma?</p> <p>tahnks!</p> <p>EDIT:</p> <p>Hi Everyone,</p> <p>Thanks very much for your help.</p> <p>To add to this post I also found a way to do this in SQL:</p> <p>SUBSTRING(CONVERT(varchar, CAST(NumItems AS money), 1), 0, LEN(CONVERT(varchar, CAST(NumDocs AS money), 1)) - 2) as [NumDocs]</p>
c#
[0]
2,665,239
2,665,240
Convert month number to month short name
<p>I have a variable with the following value</p> <pre><code>$month = 201002; </code></pre> <p>the first 4 numbers represent the year, and the last 2 numbers represent the month. I need to get the last 2 numbers in the month string name eg. Feb</p> <p>My code looks like this</p> <pre><code>&lt;?php echo date('M',substr($month,4,6)); ?&gt; </code></pre> <p>I can I go about to obtain the month name</p>
php
[2]
4,685,970
4,685,971
Error resolving getLayoutInflater
<p>While am compiling the program with the below code, an error is occurring. it says getLayoutInflater ( ) is undefined. Could anyone please help me to resolve it asap.</p> <pre><code> final LayoutInflater inflater = getLayoutInflater ( ); </code></pre> <p>Thanks in advance.</p>
android
[4]
2,305,667
2,305,668
PHP curly string syntax question
<p>I'm running PHP 5.3.0. I've found that the curly string syntax only works when the first character of the expression is <code>$</code>. Is there a way to include other types of expressions (function calls, etc)?</p> <p>Trivial example:</p> <pre><code>&lt;?php $x = '05'; echo "{$x}"; // works as expected echo "{intval($x)}"; // hoped for "5", got "{intval(05)}" </code></pre>
php
[2]
4,114,105
4,114,106
Maps - difference between satellite and hybrid modes
<p>I can see the difference on Google Maps, but on an Android MapActivity I'm struggling to find the difference.</p> <p>For 'map' I call: mapView.setSatellite(false);</p> <p>For 'satellite' I call: mapView.setSatellite(true);</p> <p>But for hybrid view... I tried playing with mapView.setStreetView(true); but this doesn't seem to affect anything either way.</p> <p>Any ideas? </p>
android
[4]
3,670,047
3,670,048
How do I recursively try different SSH passwords in Python?
<p>We use multiple sets of predefined passwords here for test servers - I would like to try a portable Python SSH library (like the one below - spur.py) and get it to try each one in succession - but obviously stop when it is successfully connected or if it can't - ask me for a password. I'm after some sort of recursion with the exception handling I think. </p> <pre><code>def ssh_connection(user, host): try: shell = spur.SshShell( hostname=host, port=findport(host), username=user, password="abc123", private_key_file= expanduser("~") + "/.ssh/id_rsa", missing_host_key=spur.ssh.MissingHostKey.accept ) shell.run(["true"]) return shell except spur.ssh.ConnectionError as error: print error raise </code></pre> <p>Coming from the Java world I'd check if the object is null and iterate through a list until the end and then ask for a password. I can't see how to do it in Python... Here's an example I found for the list part:</p> <pre><code>passwords = ['abc123', 'abc456', 'abc789'] for password in passwords: # Second Example print 'trying password :', password </code></pre>
python
[7]
5,609,339
5,609,340
calculate result from a string expression dynamically
<p>Is there a way to calculate the result of a string expression, for example <code>mystring = "2*a+32-Math.Sin(6)"</code> dynamically knowing that <strong>a</strong> is a variable that I have, may be there is some dynamic solution or using <code>System.Reflection</code></p> <pre><code>string mystring = "2*a+32-Math.Sin(6)"`; decimal result = SomeMethod(mystring,3); // where a = 3 for example </code></pre>
c#
[0]
1,295,045
1,295,046
PNG file won't display in ImageView if source is set programatically
<p>I have a png file in my res/drawable-ldpi folder. I'm working in Eclipse with the emulator, but I've tried this on my 2.2.1 Android phone and I get the same behavior. I have an ImageView and I want to set the src programatically, based on a database call. If I just put </p> <pre><code>src="@drawable.norusdpyr" </code></pre> <p>in the Activity's XML file, the file displays fine. BUT, if I put</p> <pre><code>String imageresource = "R.drawable." + parsedData[4].toString(); chart.setImageURI(Uri.parse(imageresource)); </code></pre> <p>where parsedData[4].toString() = "nor_usdpyr" I don't see anything. I've also tried</p> <pre><code>String imageresource = "android.resource://" + getPackageName() + "/R.drawable." + parsedData[4].toString(); chart.setImageURI(Uri.parse(imageresource)); </code></pre> <p>and</p> <pre><code>InputStream is = getClass().getResourceAsStream("/drawable/" + parsedData[4].toString()); chart.setImageDrawable(Drawable.createFromStream(is, "")); </code></pre> <p>and</p> <pre><code>String imageresource = "R.drawable." + parsedData[4].toString(); File file = new File(imageresource); chart.setImageDrawable(Drawable.createFromPath(file.getAbsolutePath())); </code></pre> <p>and</p> <pre><code>Context context = getApplicationContext(); int ResID = context.getResources().getIdentifier(imageresource, "drawable", "com.KnitCard.project"); chart.setImageResource(ResID); </code></pre> <p>finally,</p> <pre><code>chart.setImageURI(Uri.parse("android.resource://" + getPackageName() + "/R.drawable.nor_usdpyr")); </code></pre> <p>doesn't work.</p> <p>None of these work. What am I doing wrong? Thanks!</p>
android
[4]
4,981,255
4,981,256
SetText by Database Column Value
<p>i have a db named: "dbtest.db" , a table named: "mensagens" , a column named: "usuarioorigem". in my XML file i have a textview and a button, when button is clicked i want to the value of textview change to the value in the column: "usuarioorigem" .</p> <p>How do i do it? and can you explain how it works.</p> <p>i have this code but it doesnt work. </p> <pre><code> TextView mostrar = (TextView) findViewById(R.id.tvUSUARIO); mostrar.setText(usuarioorigem.valueOf(returning)); </code></pre>
android
[4]
1,965,912
1,965,913
Asp.net do you leave the debugging server open while developing?
<p>I'm new to ASP.net but not to C#, .net or Web Development.</p> <p>In PHP it was nice to be able to go right to the browser and refresh whenever I made a change. Using ASP.net with VS08 however seems a bit awkward.</p> <p>Should I launch a development server and keep it open, refreshing the browser when I make a change or should I close the development server between editing code?</p> <p>Sorry if this sounds silly but I'm just not sure what the "accepted" practice is here.</p>
asp.net
[9]
2,546,745
2,546,746
Convert string date to timestamp in Python
<p>How to convert a string in the format <code>"%d/%m/%Y"</code> to timestamp?</p> <pre><code>"01/12/2011" -&gt; 1322697600 </code></pre>
python
[7]
4,352,187
4,352,188
Gallery adapter (in fragment) misbehaves when Activity instance is destroyed with "Don't keep activities"
<p>I've an activity (<code>FragmentActivity</code>) which instantiates a Fragment onCreate</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MyFragment fragment = MyFragment.newInstance(rowId); // simply does new MyFragment(); getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment) .commit(); } </code></pre> <p>Fragment has the layout with few imageviews and Gallery adapter. ALL runs fine until "Don't keep activities" is enabled in developer options.</p> <p>When enabled, the Gallery Adapter's binder is initialized and onBind gets called but images(bitmaps) don't appear. When I debug this code, all appears to be working but on UI, images don't appear.</p> <p>Adapter is initialized in onStart of the fragment when it reads from database:</p> <pre><code>mPhotoAdapter = new MyPhotoAdapter(mContext, PhotosProvider.PHOTO_URI, getRowId()); // rowId is retained in onSaveInstance </code></pre> <p>Is it still referring to some old fragment instance? I tried setting retainInstance enabled and disabled, but nothing helped.</p>
android
[4]
5,741,124
5,741,125
Looking for free online webservice for getting zipcode(/postalcode) from lat, long?
<p>I am Looking for free online webservice for getting zipcode(/postalcode) from lat, long ?</p> <p>There is one : </p> <p><a href="http://ws.geonames.org/findNearbyPostalCodesxml?formatted=true&amp;lat=latValue&amp;lng=longValue" rel="nofollow">http://ws.geonames.org/findNearbyPostalCodesxml?formatted=true&amp;lat=latValue&amp;lng=longValue</a></p> <p>but its not working.....!</p> <p>Do you know other than this...?</p> <p>Thanks</p>
iphone
[8]
4,599,468
4,599,469
jQuery, filtered list using links and a data selector
<p>I have a list that when a link is selected, the div's associated will hide.</p> <p>First of all, is there an easier way to write the code to make the selector find the data associated to the button pressed? </p> <p>Secondly, when multiple links are selected and one is clicked again, the list goes back to default. Is there a fix for this?</p> <pre><code> $(document).ready(function() { $('#show-free').click(function() { if ($('#show-free').hasClass('active')) { $('.book[data-price!="0"]').trigger('show') $(this).removeClass('active'); } else { $('.book[data-price!="0"]').trigger('hide'); $(this).addClass('active'); } }); $('#show-paid').click(function() { if ($('#show-paid').hasClass('active')) { $('.book[data-price="0"]').trigger('show') $(this).removeClass('active'); } else { $('.book[data-price="0"]').trigger('hide'); $(this).addClass('active'); } }); $('#show-new').click(function() { if ($('#show-new').hasClass('active')) { $('.book[data-weeks-on-list="0"]').trigger('show') $(this).removeClass('active'); } else { $('.book[data-weeks-on-list="0"]').trigger('hide') $(this).addClass('active'); } }); $('#show-old').click(function() { if ($('#show-old').hasClass('active')) { $('.book[data-weeks-on-list!="0"]').trigger('show') $(this).removeClass('active'); } else { $('.book[data-weeks-on-list!="0"]').trigger('hide') $(this).addClass('active'); } }); $('.book').on('show', function() { $(this).show('slow'); }).on('hide', function() { $(this).hide('slow'); }) }); </code></pre>
jquery
[5]
4,547,317
4,547,318
I want to "intercept" a delete button press
<p>I would like to "intercept" a delete button press - I believe this is possible with Javascript? I don't know the exact terminology.</p> <p>Here's my code:</p> <pre><code>&lt;button type="submit" name="del" value=' . stripslashes($cultrow["cult_id"]) . '&gt;Del&lt;/button&gt;&lt;/td&gt; </code></pre> <p>I would like to intercept any and all presses of this button with the name "del". The value will, as you can see, change.</p> <p>How would I go about this? I want to throw up a dialogue asking the user for confirmation, which I believe can be done using the confirm() function.</p> <p>Thank you for your assistance all!</p>
javascript
[3]
4,311,061
4,311,062
How to remove space from para in php
<pre><code>$string="This is testing para"; $string_withoue_whitespace=trim($string," "); </code></pre> <p>My expcted output is <code>Thisismypara</code> but <strike>whites</strike>paces are not removed. </p> <p><strong>How can i remove <strike>white</strike> spaces within a paragraph in php</strong></p>
php
[2]
5,671,669
5,671,670
C++ converting a float to individual digits
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/339150/extracting-individual-digits-from-a-float">Extracting individual digits from a float</a> </p> </blockquote> <p>For part of my program I need to read a number as a float (eg. 123.45) and get each of the individual digits in that float (e.i. 1,2,3,4,5) to do things with them. storing each digit as a character would be ideal so i can do what i want with each number. Is there anyway i can do this, perhaps using cin.get?? please help.</p>
c++
[6]
5,568,465
5,568,466
.val() not returning correct value
<p>I have the following code that runs on change for a select box:</p> <pre><code> $('#reg-phone-type').change( function() { console.dir($(this)); console.log("$(this).val():" + $(this).val()); if( $(this).val == 'work' ) { // do one thing } else { // do something else } }); </code></pre> <p>When I print out <code>console.dir($(this));</code> I can see that the selected option is set (in my screenshot example) to "work" (the label is proper case, but the actual option value is lower, so I know I'm not dealing with a case issue).</p> <p><img src="http://i.stack.imgur.com/qdiot.png" alt="enter image description here"></p> <p>Here's the HTML from Firebug after the select box was changed (default is "home"):</p> <p><img src="http://i.stack.imgur.com/7iwxA.png" alt="enter image description here"></p> <pre><code>&lt;select name="regPhoneType" id="reg-phone-type" style="display: none;" value="work"&gt; &lt;option value="home"&gt;Home&lt;/option&gt; &lt;option value="work" selected="selected"&gt;Work&lt;/option&gt; &lt;option value="cell"&gt;Cell&lt;/option&gt; &lt;/select&gt; </code></pre> <p>So you can see that the option is correctly selected. Why, then, when in my jquery, just one line later, I call <code>console.log("$(this).val():" + $(this).val());</code>, do I get "home" instead of "work"? My understanding was that <code>.val()</code> returns the value of the selected option of a select box, so I should be getting "work".</p> <p><img src="http://i.stack.imgur.com/WOJaA.png" alt="enter image description here"></p>
jquery
[5]
4,841,598
4,841,599
How to create a dialog for multiple consecutive entries?
<p>I am currently working on an Android application that can manage a card game. I have (let's say) 4 players and after each round I click a button that opens a dialog to enter the score of the players during this round. How can I achieve this in an opened dialog? I tried several things, for example a ViewFlipper in the dialog, none of them working so far. The ViewFlipper for example doesn't have the chance to go to the next view since the dialog is already closed again when I hit the OK-button.</p>
android
[4]
699,214
699,215
how to split variable data from string using C#
<p>Could someone please help meto improve this part of code? </p> <p>The string is something like this: <strong>Current Hourly Price (HOEP): $20.09/MWh (2.01¢/kWh)</strong>. this is one line on website where data of 20.09 and 2. 01 changes within time </p> <pre><code>static void get_HOEP(string web) { int x = web.IndexOf("Current Hourly Price"); ... } </code></pre> <p>I want just to display something like: <strong>Current Hourly Price: &nbsp; 2.01 &nbsp; ¢/kWh</strong></p> <p>Thanks for help</p>
c#
[0]
3,312,785
3,312,786
Java for Beginners
<p>I am familiar with Microsoft technologies. First time I am going to learn Java.Like Visual Studio ,is there any Java GUI IDE is available to compile and run Java programs?</p>
java
[1]
4,760,712
4,760,713
PHP scan image in folder and read image property
<p>PHP scan image in folder and read image property.</p> <p>Folder1:</p> <pre><code>1.jpg 2.gif 3.jpg </code></pre> <p>Property:</p> <pre><code>title Description </code></pre> <p>I would like to crate PHP code list all images in folder. I want to display it on browser and want to display image properties such as Title, description. How to do that ? Thank.</p>
php
[2]
5,046,372
5,046,373
JS Form validation issue
<p>I am new to JS ! This is my first program. It validates that the text field shouldn't be null. I tried everthing but nothing seems to work.</p> <pre><code>&lt;script type="text/javascript"&gt; var data_age = document.getElementById("ages") ; function check() { if (data_age==null) { alert("no data") ; return false ; } else { return true ; } } &lt;/script&gt; &lt;form name="frm" action="a.php" method="post" onsubmit="return check(this)"&gt; &lt;input type="text" name="age" id="ages"&gt; &lt;input type="submit" value="submit"&gt; &lt;/form&gt; </code></pre>
javascript
[3]
955,130
955,131
What are the best practices for loading javascript with the least amount of impact on display performance of the page?
<p>Is there a way to download javascript without executing it? I want to decrease my page load times so am trying to "lazy load" as much javascript onto the page while the user is idle. However I don't want the javascript to execute, I just want it to be in the browser cache.</p> <p>Should I use an object tag? I noticed that I can use a LINK tag but that makes the browser think it's css which has a negative impact on my ui perf / responsiveness.</p>
javascript
[3]
1,887,537
1,887,538
Deep clone an object in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2156120/java-recommended-solution-for-deep-cloning-copying-an-instance">Java: recommended solution for deep cloning/copying an instance</a> </p> </blockquote> <p>I have an object which has to be cloned. However while cloning it should also clone the objects inside it. How is this possible ??</p>
java
[1]
4,940,496
4,940,497
"unrecognized selector" within a simple internal call
<p>I would like my custom controller (opened by a UITabBarController) to immediately load a UIImagePickerControllerSourceTypeCamera as soon as it is loaded. To achieve this, I added a method - acquirePhoto() and I'm trying to call it from within the - viewDidLoad() but this is causing the error above.</p> <p>This is the call:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [self aquirePhoto]; } </code></pre> <p>While this is the method:</p> <pre><code>- (void)acquirePhoto { [[TopBarViewController instance]view].hidden = TRUE; UIImagePickerController *picker = [[UIImagePickerController alloc] init]; [picker setDelegate:self]; [picker setAllowsEditing:NO]; picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentModalViewController:picker animated:YES]; [picker release]; } </code></pre>
iphone
[8]
3,956,537
3,956,538
adaptive bitrate in android
<p>Hello In my android application i would like to shift from 2G or 3G depending on the bitrte available. Is there any method that i can get the bitrate in android.</p> <p>Please forward your valuable suggestions.</p> <p>Thanks i advance :)</p>
android
[4]
4,405,189
4,405,190
Date incorrectly interpreted in my string
<p>I have the following javascript code:</p> <pre><code>var myDate = new Date("10/04/2013"); var d = myDate.getDate(); var m = myDate.getMonth(); var y = myDate.getFullYear(); </code></pre> <p>When I debug this code I got:</p> <p>d = 4</p> <p>m = 9</p> <p>y = 2013</p> <p>This is not was I expected. I would like to interpret my date as day / month / year.</p> <p>How to proceed?</p> <p>Thanks.</p>
javascript
[3]
1,989,906
1,989,907
Python RE question - proper state initial formatting
<p>I have a string that I need to edit, it looks something similar to this:</p> <pre><code>string = "Idaho Ave N,,Crystal,Mn,55427-1463,US,,610839124763,Expedited" </code></pre> <p>If you notice the state initial "Mn" is not in proper formatting. I'm trying to use a regular expression to change this:</p> <pre><code>re.sub("[A-Z][a-z],", "[A-Z][A-Z],", string) </code></pre> <p>However, re.sub treats the second part as a literal and will change Mn, to [A-Z][A-Z],. How would I use re.sub (or something similar and simple) to properly change Mn, to MN, in this string?</p> <p>Thank you in advance!</p>
python
[7]
4,444,826
4,444,827
using callback functions in dialogs
<p>I am using the jQuery dialog. I want to be able to use the script for a single the dialog for more than one use. To do so, I am thinking of assigning some callback function which can be called in the dialog. Is this an appropriate way to do so? What do I need to do to make the below code alert "hi" when the dialog button is clicked? Thank you</p> <pre><code>function somefunction() {alert('hi');} $("#clickme").click(function(){$("#dialog").data('callback',somefunction).dialog("open");}); $("#dialog").dialog({ buttons: [ { text : 'Click', click : function() { //If $(this).data('callback') is defined, then execute the function } }] }); </code></pre>
jquery
[5]
2,384,207
2,384,208
Building with Ant
<p>I've installed Ant. From an existing Eclipse project I am able to generate the build.xml file from the command line using ant -update project. When I now try ant release I get this error: <code>build.xml:65: java.lang.NullPointerException.</code></p> <p>This project builds fine under Eclipse. I have no idea where to even begin to figure this out. I wouldn't bother with this except that I need to use ProGuard later on (which I have not done yet). Any ideas?</p>
android
[4]
5,587,123
5,587,124
Android sdk main.out.xml parsing error
<p>I just started a new Android project, helloword" to continue learning Android development and I got stumped compiling the default 'helloword' compile / run. I think that I missed a step in configuration and setup, but I am at a loss to find out where. I have an AVD configured, set and launched.</p> <p>When I press 'run as', i can not find android2.1 simulator.and find these errors:</p> <pre><code>[2012-07-25 08:59:49 - helloword] res\layout\activity_main.xml:0: error: Resource entry activity_main is already defined. [2012-07-25 08:59:49 - helloword] res\layout\activity_main.out.xml:0: Originally defined here. [2012-07-25 08:59:49 - helloword] E:\android软件开发\新建文件夹\helloword\res\layout\activity_main.out.xml:1: error: Error parsing XML: no element found [2012-07-25 10:03:12 - helloword] /helloword/gen already exists but is not a source folder. Convert to a source folder or rename it. [2012-07-25 10:03:13 - helloword] /helloword/gen already exists but is not a source folder. Convert to a source folder or rename it. [2012-07-25 10:03:15 - helloword] File is Out of sync [2012-07-25 10:05:13 - helloword] /helloword/gen already exists but is not a source folder. Convert to a source folder or rename it. [2012-07-25 10:08:44 - helloword] activity_main.out.xml is out of sync. Please refresh. [2012-07-25 10:08:45 - helloword] activity_main.out.xml is out of sync. Please refresh. </code></pre>
android
[4]
2,654,774
2,654,775
Why does the Void wrapper class exists in the JDK?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/643906/uses-for-the-java-void-reference-type">Uses for the Java Void Reference Type?</a> </p> </blockquote> <p>What is the real usage of Void class in real world problems? In which scenario can we use this class?</p>
java
[1]
946,275
946,276
Questions re deciding what version of Android to target in 2013
<p>I'm an experienced Java programmer but new to Android. Two basic questions:</p> <ul> <li>as of now (i.e. let's say, an app to be released early 2013), what Android version should one be thinking of targeting to cover a reasonable majority of devices? Has this changed, for example, from the <a href="http://stackoverflow.com/questions/8335302/what-android-version-to-target">advice given a year ago</a>?</li> <li>as I understand, whether or OS updates are available on Android devices is down to the manufacturer. In practice nowadays, what indication can we get as to what roughly what proportion of devices allow the user to update the OS version?</li> </ul> <p><strong>Please note that I am asking for answers based on factual information about the current state of affairs regarding Android installs and not asking for a "debate" about the morals of programming for different APIs as for some reason seems to have been assumed by the trigger-happy closers.</strong></p>
android
[4]
4,530,824
4,530,825
Javascript: Hijack Copy?
<p>I was just reading the Times online and I wanted to copy a bit of text from the article and IM it to a friend, but I noticed when I did so, it automatically appended the link back to the article in what I had copied. </p> <p>This is not a feature of my IM client, so I assume this happened because of some javascript on Times website.</p> <p>How would I accomplish this if I wanted to implement it on my site? Basically, I would have to hijack the copy operation and append the URL of the article to the end of the copied content, right? Thoughts?</p> <p>Here's the article I was reading, for reference: <a href="http://www.time.com/time/health/article/0,8599,1914857,00.html" rel="nofollow">http://www.time.com/time/health/article/0,8599,1914857,00.html</a></p>
javascript
[3]
4,417,161
4,417,162
Get event of Home button
<p>My requirement is that when user clicks the home button at any screen in application, he is redirected to device home screen and when he comes back to the application he will redirect to app home screen rather than at screen where he pressed the home button.</p> <p>Any help would be appreciaed. </p>
android
[4]
21,228
21,229
Parse_url and remove slash only on first folder only?
<p>PHP dummy here. <br/><br/>Let's say that I have my domain like this:<code>http://www.domain.com/somefolder/index.html</code> so now i need to make it like <b>this</b> :<code>somefolder/index.html</code></p> <p>In order to do so I am using following code:</p> <pre><code>&lt;?php $urlparts = parse_url("http://www.domain.com/somefolder/index.html"); $extracted = $urlparts['path']; print $extracted;?&gt; </code></pre> <p>Now I am getting output like this: <code>/somefolder/index.html</code> <br/><br/>what I like to to do is to <b>remove first slash only</b> so that it looks like this: <b><code>somefolder/index.html</code></b>, it would be also nice that if I can get the same result (removed slash on first folder but not the other's) even if I have more folders like this: <b><code>other_folder/somefolder/index.html</code></b> or <b><code>other_folder/yet_another_folder/somefolder/index.html</code></b>. </p> <p>Is there a nice person who can help a dummy like me? THX! </p>
php
[2]
4,761,840
4,761,841
Javascript: Could not really understand the function return
<p>It is maybe incredibly easy but I couldn't solve what was going on.</p> <pre><code> function doSomething(a) { var num=10; return setTimeout( function(){ a(num); }, 1000); } </code></pre> <p>The only thing that actually confuses me is the <b>a(num)</b> part. What actually it does?<br/><b>Reminder: </b> I really am asking because I'm not familiar with the javascript syntax.</p>
javascript
[3]
3,331,337
3,331,338
Convert two dimensional array to List in java?
<p>I have a<code>m X n</code> two dimensional array of an Object say <code>Foo</code>. So I have <code>Foo[][] foosArray</code>. What is the best way to convert this into a <code>List&lt;Foo&gt;</code> in Java?</p>
java
[1]