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
672,665
672,666
Retry AsyncTask
<p>For example I have following AsyncTask:</p> <pre><code> private class MyAsyncTask extends AsyncTask&lt;Void, Void, Boolean&gt; { @Override protected Void doInBackground(Void... params) { try { //some code that may throws exception return true; } catch (IOException ex) { return false; } } @Override protected void onPostExecute(Boolean param){ if (!param) { AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this); builder.setMessage("Error"); builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //I want to retry MyAsyncTask here } }); builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); AlertDialog alert = builder.create(); alert.show(); } } } </code></pre> <p>What is best practice to do this? I'm afraid of recursion this code.</p>
android
[4]
4,668,884
4,668,885
I'm running nginx with fastcgi, is that all I need to serve python apps also?
<p>I'm running ubuntu with nginx with fastcgi, is that all I need to serve python apps also?</p>
python
[7]
1,231,756
1,231,757
When I define a pointer to a class the error:expected constructor, destructor, or type conversion before '*' token happened
<pre><code>int buffer[gSizeOfGrid][gSizeOfGrid]; CList *currentCList; Grid *currentGrid; //this line get the error int aroundinfo[4]; //other functions are not revelant maybe? They don't //use currentGrid. </code></pre> <p>the class Grid has the header:</p> <pre><code>class Grid { public: Grid(); //create default cList object for the grid . Grid(CList*); //create cList and bind existing clist object. bool rebind(CList*); //rebind cList. ~Grid(); void init(int ants,int bugs); //init a grid with ants and bugs according to parameter. void GetSnapshot(); //synchronize grid buffer with clist. void Step(); //make the world go on! bool spawn(Creature&amp;,Position); //create a creature on the grid. //if success, return true. //if there are already another creature return false. void move(Position,int); void eat(Position,int); void breed(Position,int); void destroy(Position); private: CList* theList; }; </code></pre> <p>the Clist Class looks the same but is Okay in declaration:</p> <pre><code>using namespace std; class CList { public: CList(); int CreateObject(Creature&amp;,Position); Creature&amp; GetObject(int); bool RemoveObject(Position); bool RemoveObject(int); int getType(Position); void cleanup(); vector&lt;Creature*&gt; list; int size(); }; </code></pre> <p>Why the Grid* declaration goes wrong but CList* is OK? Thank you!</p>
c++
[6]
5,550,953
5,550,954
Remove LI from UL
<p>I'm trying to delete / remove a image from my image list. I'm too tired think straight, so I need some assistance please.</p> <p>Here is my HTML code:</p> <pre><code>&lt;li id="listItem_dsc_6436.jpg"&gt; &lt;a href="http://storelocator.com/wp-content/uploads/slgallery/brand/5f/c6/dsc_6436.jpg"&gt;&lt;img alt="dsc_6436.jpg" src="http://storelocator.com/wp-content/uploads/slgallery/brand/5f/c6/thumb/dsc_6436.jpg"/&gt;&lt;/a&gt; &lt;div class="buttonPanel"&gt; &lt;span title="Delete image" class="btnRemoveItem floatRight" id="dsc_6436.jpg"&gt; &lt;/span&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p>And this is my javascript code:</p> <pre><code>jQuery('.btnRemoveItem').click(function(){ jQuery('#listItem_' +jQuery(this).attr('id')).remove(); }); </code></pre> <p>This is not working. What am I missing?</p>
jquery
[5]
4,910,318
4,910,319
Kml File show Elevation profile
<p>I have found the following example:</p> <p><a href="http://gmaps-samples-v3.googlecode.com/svn/trunk/elevation/elevation-profile.html" rel="nofollow">http://gmaps-samples-v3.googlecode.com/svn/trunk/elevation/elevation-profile.html</a> </p> <p>and I have this kml File: </p> <p><a href="https://maps.google.at/maps/ms?authuser=0&amp;vps=2&amp;hl=de&amp;ie=UTF8&amp;msa=0&amp;output=kml&amp;msid=211992892838821122253.0004bd00127898df568d9" rel="nofollow">https://maps.google.at/maps/ms?authuser=0&amp;vps=2&amp;hl=de&amp;ie=UTF8&amp;msa=0&amp;output=kml&amp;msid=211992892838821122253.0004bd00127898df568d9</a></p> <p>Now I don't know how to bring the kml file and the example together. The example includes the path data hard coded.</p> <p>It would be great if someone could help me. Thanks a lot Max</p>
javascript
[3]
3,111,139
3,111,140
how to create drop down list in java script?
<p>For example if i have a list item like all,a,b,c,d. if i click all means it should not allow to choose other items, if i am not choosing all means it should allow to choose mulitle item from list</p>
javascript
[3]
1,739,253
1,739,254
How to disable sorting in TreeView?
<p>I have A TreeView in my aspx page as shown below.</p> <pre><code>&lt;asp:TreeView ID="TreeView1" runat="server" ExpandDepth="0" ShowCheckBoxes="All" ShowLines="True"&gt; &lt;/asp:TreeView&gt; </code></pre> <p>When I add nodes to this TreeView it always sorts in alphabetical order. What I really want, is the order that I have added the nodes.</p>
asp.net
[9]
1,138,296
1,138,297
how to pass interface as a paramerter to a method
<p>Hi iam newbie to C#.Can you please tell me how to pass a interface as a paramerter to a method?<br> ie<br> i want to access the interface members(property) and assign the values to it and send that interface as a parameter to other method,</p> <p>say for ex if i have an interface as <strong>Iapple</strong> which has members as property <strong>int i</strong> and <strong>int j</strong> i want to assign values to <strong>i</strong> and <strong>j</strong> and send the whole interface as a parameter say like this</p> <p><strong>Method(Iapple var);</strong> </p> <p>is it poss? Sorry if am poor at basics please help me out. thanks in advance</p>
c#
[0]
5,268,148
5,268,149
javascript function doesn't return any result
<p>I've got a javascript function</p> <pre><code>&lt;head&gt; &lt;title&gt; Test &lt;/title&gt; &lt;script type="text/javascript"&gt; function GetResult() { count = 0; for(var i=0;i&lt;10;i++){ for(var j=1;j&lt;4;j++){ if (document.getElementById("label"+i+j).checked){ count +=1; } } } if (count!=10) alert("Please answer all the questions"); else alert(count); } &lt;/script&gt; </code></pre> <p></p> <p>In the code there are a lot of radiobutton. ther look like</p> <pre><code>&lt;input type="radio" name="q1" value="1" id="label01"/&gt; </code></pre> <p>But my javascript function never shows alert. The button that is supposed to call function is</p> <pre><code>&lt;input type="button" value="Result" onclick="GetResult()"/&gt; </code></pre> <p>Maybe button doesn't call <code>GetResult</code>?</p>
javascript
[3]
2,605,162
2,605,163
jquery image click firing once
<p>I have a page with 3 tabs on it. The first tab has a few cancel images with the class "cancelBtn".</p> <pre><code>&lt;img src="images/cancel.gif" alt="Cancel Order" class="cancelBtn" id="49" /&gt; </code></pre> <p>The first time the page loads the click event fires fine, if I move away from the frist tab and return the click event doesn't fire. Each time a tab is clicked the html used on the tab including the cancel button is retrieved from the server.</p> <p>Does anyone know why the event only fires on when the page is loaded? thanks</p> <pre><code>$(function () { $(".cancelBtn").click(function () { alert('hello'); $.ajax({ type: "POST", url: "Default.aspx/CancelOrder", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { $("#divResult").html(msg.d); } }); }); }); </code></pre>
jquery
[5]
3,003,376
3,003,377
ASP.NET website - default namespace
<p>In Visual Studio you can set a default namespace for a VB.NET app using the following screen:</p> <p><img src="http://i.stack.imgur.com/bfFQJ.png" alt="enter image description here"></p> <p>You can do the same for an Visual Studio project that is an ASP.NET web application. It is not available for an ASP.NET website, why? I see this for a website:</p> <p><img src="http://i.stack.imgur.com/PdIvx.png" alt="enter image description here"></p>
asp.net
[9]
3,932,920
3,932,921
Dynamically Create Controls And Save The Controls Values Across Postback
<p>When i dynamically add tabs in tab container on first button click event in asp.net,it adds fine but when i going to add second tab on second button click event first tab removes from container and next one is added. And i want both tabs </p>
asp.net
[9]
894,338
894,339
android how to handle key events in async task
<p>i am using async task while retrieving data from server,everything is working fine but when i press the back key to navigate to previous activity it throws nullpointer exception</p> <p>i used <code>KeyDown()</code> and <code>KeyUp()</code> to handle the key events</p> <p>Please help me</p>
android
[4]
2,375,700
2,375,701
JQuery - Iterate over a subset of tds starting after a found class
<p>I am looking for a more jquery/cleaner way to be able to select all <code>td.some-class</code> and be able to start at 'selected' and apply some in order to the tds that follow.</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td class='some-class'&gt;A&lt;/td&gt; &lt;td class='some-class'&gt;B&lt;/td&gt; &lt;td class='some-class'&gt;C&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='some-class'&gt;A1&lt;/td&gt; &lt;td class='some-class'&gt;B2&lt;/td&gt; &lt;td class='some-class selected'&gt;C3&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class='some-class'&gt;A21&lt;/td&gt; &lt;td class='some-class'&gt;B22&lt;/td&gt; &lt;td class='some-class'&gt;C23&lt;/td&gt; &lt;/tr&gt; </code></pre> <p></p> <p>The current way I am doing it is pretty much like:</p> <pre><code>found = false; $('td.some-class').each(function(){ if ($(this).hasClass('selected')){ found = true; } if (found){ # do something } }); </code></pre>
jquery
[5]
3,612,530
3,612,531
Using new Date on value of an <input type="date" />
<p>I am trying to convert the value of an <code>&lt;input type="date" /&gt;</code> to an actual Javascript Date object. The example is below</p> <pre><code>new Date($('#myInput').val()); //where value of myInput is '2011-01-01' </code></pre> <p>turns out to be </p> <pre><code>Fri Dec 31 2010 19:00:00 GMT-0500 (Eastern Standard Time) </code></pre> <p>It appears that the Date is convert from UTC to EST (I think). Is there anyway to prevent this conversion????</p> <p>example: <a href="http://jsfiddle.net/2t2m8/" rel="nofollow">jsfiddle</a></p>
javascript
[3]
1,232,546
1,232,547
How to get the speaking sound that comes from the phone user and convert to byte array ?
<p>I writing simple application that need to make some record of the incoming sound. That mean that if the user will turn the record on => the application need to 'listen' what the user is saying and convert the sound of the user to byte array and save the byte array to some file ( mp3 format ) . </p> <p>I don't finding any way to get the sound that coming from the user .. </p> <p>Someone can help me with this issue ? </p> <p>Thanks for any help. </p>
android
[4]
3,885,609
3,885,610
jQuery parents not working with remove
<p>I have the following code:</p> <pre><code>$(document).ready(function(){ $(".uiCloseButton").click(function(e) { e.preventDefault(); var element = $(this).parents('.uiOverlay'); alert(element); element.fadeOut(200, function() { alert(element); element.remove(); }); }); }); </code></pre> <p>The idea is that when the close button is clicked it will remove it's highest parent using the <code>parents()</code> method. I have been alerting the variable element to check its value and it always returns as <code>[object Object]</code> when surely it should contain the parent element?</p> <p>However it does still fade the element so it's working BUT doesn't remove the element from the DOM so it's only half working...</p> <p>Any ideas why it's not removing the element and why the element var is empty?</p> <p>Thanks</p>
jquery
[5]
3,917,995
3,917,996
When a certain value of a drop down is selected change a different drop down selection
<p>I need to check to see if the user selects a certain value in a drop down menu. If that value is selected I need it to change another drop down menu's selection.</p> <p>Here is the html for the first drop down. If Quarterly is selected I need Quarterly to be selected in the 2nd drop down. If anything else is selected there will be no change.</p> <pre><code>&lt;select id="frequency" name="frequency"&gt; &lt;option selected="selected" value=""&gt;Select One&lt;/option&gt; &lt;option value="Monthly"&gt;Monthly&lt;/option&gt; &lt;option value="Quarterly"&gt;Quarterly (1 Year Minimum, 4 deliveries)&lt;/option&gt; &lt;/select&gt; &lt;select id="MonthPlan" name="MonthPlan"&gt; &lt;option selected="selected" value=""&gt;Select One&lt;/option&gt; &lt;option value="3Months"&gt;3 Months&lt;/option&gt; &lt;option value="6Months"&gt;6 Months&lt;/option&gt; &lt;option value="9Months"&gt;9 Months&lt;/option&gt; &lt;option value="12Months"&gt;12 Months&lt;/option&gt; &lt;option value="Quarterly"&gt;Quarterly (1 Year Minimum, 4 deliveries)&lt;/option&gt; &lt;/select&gt; </code></pre>
jquery
[5]
1,646,394
1,646,395
Easy way to replace placeholders in string with the list of values?
<p>I have a long string that contains placeholders, that should be replaced with some data.</p> <pre><code>strOut = "text text {{ }} text text {{ }}" </code></pre> <p>with this pattern</p> <pre><code>pattern = r'\{{(.+?)\}}' </code></pre> <p>It's easy for me to do something like this</p> <pre><code>pattern.sub(self.mymethod, strOut) </code></pre> <p>where mymethod will be called for substitution. It actually works great. However, this is the problem now. I need to replace all placeholders in string with the values from a list. For example, this is the string again:</p> <pre><code>strOut = "text text {{ }} text {{ }} text" </code></pre> <p>It will always have undetermined number of placeholders. If I also have a list of let's say 2 values</p> <pre><code>myList = [2, 3] </code></pre> <p>I need a way to inject these values into placeholders, and end up with this</p> <pre><code>"text text 2 text 3 text" </code></pre> <p>Number of values in a list and number of placeholder will always be the same, I just don't know in advance how many there will be.</p>
python
[7]
3,520,580
3,520,581
jquery - reload() callback
<p>I have the following jquery code working fine:</p> <pre><code>$('iframe#captcha')[0].contentDocument.location.reload(true); $('input#captchainput').val(''); $('img#ajaxLoader').hide(); $('h3#loginFailed').show(); </code></pre> <p>Is it possible to attached a callback to the <code>.reload(true)</code>?</p> <p>I want to delay the 3 lines of code until after the reload has occurred.</p>
jquery
[5]
846,985
846,986
Client and auth server
<p>I am trying to make a client, which connects to an auth server and checks to see if the username and password entered in the client is valid then if it is, the client downloads a .dll to the users machine.</p> <p>My question is, what is the best and most secure way to go about doing this.</p> <p>Thanks</p>
c++
[6]
4,100,051
4,100,052
Is possible to separate declaration and definition of inline functions?
<p>I need to define inline functions to improve performance of my code. At the moment declaration of functions are in .h file and definitions are in .cpp file. I added <strong>inline</strong> keyword at the front of each declaration of functions but I am getting link error. Is possible to separate declaration and definition of inline functions ?</p>
c++
[6]
2,598,584
2,598,585
symbolic c++ in GCC or microsoft visual c++
<p>can i use Symbolic C++ features in linux c++ compiler or in visual c++ 2010? and also one question sometimes in programs there is such headers code</p> <pre><code>#include &lt;iostream&gt; #include "symbolicc++.h" using namespace std; int main(void) { Symbolic x("x"); cout &lt;&lt; integrate(x+1, x); // =&gt; 1/2*x^(2)+x Symbolic y("y"); cout &lt;&lt; df(y, x); // =&gt; 0 cout &lt;&lt; df(y[x], x); // =&gt; df(y[x],x) cout &lt;&lt; df(exp(cos(y[x])), x); // =&gt; -sin(y[x])*df(y[x],x)*e^cos(y[x]) return 0; } </code></pre> <p>header <code>#include "symbolicc++.h"</code> i have tried </p> <p><code>#include " "</code> but it does not show me symbolicc++.h so how to do it please give me a few example</p> <pre><code>there is such error after compile symbolic.cpp:2:25: error: symbolicc++.h: No such file or directory symbolic.cpp: In function ‘int main()’: symbolic.cpp:7: error: ‘Symbolic’ was not declared in this scope symbolic.cpp:7: error: expected ‘;’ before ‘x’ symbolic.cpp:8: error: ‘x’ was not declared in this scope symbolic.cpp:8: error: ‘integrate’ was not declared in this scope symbolic.cpp:9: error: expected ‘;’ before ‘y’ symbolic.cpp:10: error: ‘y’ was not declared in this scope symbolic.cpp:10: error: ‘df’ was not declared in this scope symbolic.cpp:12: error: ‘cos’ was not declared in this scope symbolic.cpp:12: error: ‘exp’ was not declared in this scope </code></pre>
c++
[6]
1,347,355
1,347,356
Receving http network response code in app
<p>I want to get the network response code of server in webview/BrowserFrame/WebViewClient. Eailer it was working fine until 2.3 but from 3.0 /4.0 WebViewClient API(onReciveError) is not working and No http resource response is available in app.</p> <p>I there any other alternative to recive it whenever I pass a url to webview.</p>
android
[4]
3,884,330
3,884,331
Supporting Multiple Screens with size qualifier
<p>We would like to design layouts for specific resolutions as below:</p> <p>Samsung Duos: 480 X 800 Android Version 4.0.4 HTC Velocity: 540 X 960 </p> <p>To do so we have created layout folders for each as below:</p> <p>layout-w480dp-h800dp layout-w540dp-h960dp</p> <p>Assuming that if we run application on samsung duaos it should pick the layouts from layout-w480dp-h800dp folder but it is giving error and unable to start activity. </p> <p>The error is:</p> <p>android.content.res.Resources$NotFoundException: Resource ID #0x7f030029</p> <p>It means it could not locate the layout required by the activity. Same happen with HTC Velocity. </p> <p>Are we doing something wrong?</p> <p>Please let us know if you have any idea.</p>
android
[4]
81,020
81,021
Changing element p with input text field issue jquery
<p>I am facing small issue while firing jquery event to replace element p or span with text field and onblur event replace back to p or span field.</p> <p>Demo is here http://jsfiddle.net/yXcZG/</p> <p>It works well for first time while clicking on p text, but failed when you repeat same process second time.</p> <p>Can any one help me where should be the issue</p>
jquery
[5]
5,041,567
5,041,568
Suggestion Needed on using GSM to sip gateway with freeswitch in C#
<p>I am considering using 2N® VoiceBlue Lite with Freeswitch to serve as a GSM to sip gateway that will route gsm calls to fs server for an IVR system to be built with C# anybody who has tested this or anybody with any suggestions or opinion?</p>
c#
[0]
4,357,393
4,357,394
accordion of div's
<p>I am making an accordion of Div's here is the code:</p> <pre><code> $('.answer').hide(); $('.question').click (function(){ $('.answer').slideUp(); $('#question'+$(this).attr('target')).slideDown('slow'); }) </code></pre> <p>It is working fine, but I want it so when I click again on same question it closes.<br> Here is the HTML I used :</p> <pre><code>&lt;h1 class="question" target="1"&gt;Some Question&lt;/h1&gt; &lt;p id="question1" class="answer"&gt;Some Answer&lt;/p&gt; &lt;h1 class="question" target="2"&gt;Another question&lt;/h1&gt; &lt;p id="question2" class="answer"&gt;Another answer&lt;/p&gt; </code></pre> <p>Thanks in advance</p> <p>please look the code here : <a href="http://jsfiddle.net/FMLhc/" rel="nofollow">http://jsfiddle.net/FMLhc/</a></p>
jquery
[5]
4,705,525
4,705,526
LVL Returns unlicensed on phone startup
<p>I have implemented Google's LVL (License Verification Library) into my live wallpapers recently.</p> <p>It works perfectly fine if the phone is running, but if the wallpaper is chosen and the phone is restarted the LVL returns false until the user chooses another wallpaper, then mine again. Is there a way around this other than having to continually check while it returns false?</p>
android
[4]
2,118,473
2,118,474
c# Class extender
<p>I may be way off here, but I thought I remember reading a while back that there is a way to extend an existing class and override its existing functionality. </p> <p>For instance, is there a way to take LinkButton and extend it to expose a new method or property? Is there a way to override and existing method/property? Like NavigateURL?</p> <p>I am not talking about subclassing, I am talking about extending. Am I way off here?</p> <p>Thanks</p>
c#
[0]
5,711,550
5,711,551
performance issues in ASP.NET Membership
<p>I am working with Aspnet membership, and I have stored users information in membership related data e.g. userid and password stored in Aspnet_Membership table, member profile like firstname, lastname, surname, dob etc in aspnet_profile table. </p> <p>Now I need to add a search panel in my webpage. This search panel contains searching parameters like firstname, lastname and joining date etc. as per this searching parameters I need to search users from profile and user's last login information. I used profilecommon and profilebase class for retrieving this data. But it is seriously slow. The system takes at least 2 minutes to find data as per parameters from 70 records. </p> <p>Please help to resolve this program.</p> <p>Thanks in advance. Hiren V</p>
asp.net
[9]
1,394,051
1,394,052
Java: Are chars " and \" the same?
<p>Given:</p> <pre><code>char x = '"'; char y = '\"'; </code></pre> <p>Are x and y equal?</p>
java
[1]
1,297,105
1,297,106
php strlen function and 2 vars
<pre><code>if (strlen($title) &gt; 2 &amp;&amp; ($msg) &gt; 2 &amp;&amp; ($email) &gt; 2)) { //true } else { //false } </code></pre> <p>What would be the correct way of checking more than 1 var? This wont work..tried many ways</p>
php
[2]
208,777
208,778
In Android, is there a more elegant way to retrieve application context inside a inner class?
<p>In Android, is there a more elegant way to <strong>retrieve application context</strong> inside a inner class rather than passing context as a parameter?</p> <pre><code>public class MainActivity extends Activity { class SeekBarChangeListener implements SeekBar.OnSeekBarChangeListener { private Context context; private TextView distanceTextView; public SeekBarChangeListener(Context context, TextView distanceTextView) { this.context = context; this.distanceTextView = distanceTextView; } } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } } </code></pre>
android
[4]
5,573,332
5,573,333
how to test if TWO input fields are empty?
<p>Hi can someone please tell me what wrong with this line (getting an error...)</p> <pre><code>if ($("input[type=file]").val().length !==0) || $("#book_map_keys").val().length !==0) { // do something } </code></pre> <p>As you can probably see, I am testing to see either of these two input field are empty. (they don't both have to be empty) </p> <p>If you could advise how this should be re-written, I'd be much appreciated.</p> <p>//Edit: the error is pointing to the 'OR' pipe character. Adding those quotes didnt fix it, thanks anyway David</p>
jquery
[5]
2,544,206
2,544,207
Implementing IEnumerable<T> in List<T> derived Collection
<p>I'm getting an error. Here's the code copied across to a Console project and stripped down:</p> <pre><code>namespace ConsoleApplication1 { public interface IHexGrid { IEnumerable&lt;Hex&gt; hexs { get; } //error related location } public class HexC : Hex { public int var1;} public abstract class Hex { public int var2; } public class HexGridC : IHexGrid //error CS0738 { public List&lt;HexC&gt; hexs { get; set; } // error related location } class Program { static void Main(string[] args) { } } } </code></pre> <p>I'm getting the following: error CS0738: </p> <pre><code>'ConsoleApplication1.HexGridC' does not implement interface member 'ConsoleApplication1.IHexGrid.hexs'. 'ConsoleApplication1.HexGridC.hexs' cannot implement 'ConsoleApplication1.IHexGrid.hexs' because it does not have the matching return type of '`System.Collections.Generic.IEnumerable&lt;ConsoleApplication1.Hex&gt;`'. </code></pre> <p>Not sure why as IENumerable is Covariant. Any help much appreciated.</p> <p>Edit: the code has been simplified</p>
c#
[0]
2,175,757
2,175,758
Javascript - invalid quantifier error, can someone help me see my mistake?
<p>I'm not a JS guru, but could someone help me find the invalid quantifier error in the following snippet?</p> <p>THANKS IN ADVANCE! -mprototype</p> <pre><code>function $_GET(q,s) { s = s ? s : window.location.search; var re = new RegExp( '&amp;' + q + '(?:=([^&amp;]*))?(?=&amp;|$)' , 'i' ); return (s=s.replace(/^?/,'&amp;').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined; } </code></pre>
javascript
[3]
1,308,948
1,308,949
Advanced Help Universal Class for Comments inheritance problem
<p>I have a class called Comments for articles which implements a base class of BaseArticle that class has a protected object called settings. </p> <p>The settings object is a web.config section just for articles and I also have one also for blogs.</p> <p>My problem is that I want to make Comments usable for blog Comments, but the class Comments inherits BaseArticle, which I want it to inhereit it's own base class BaseBlog with it's own settings. </p> <p>I need to make it universal how do I do that. An example would be appreciated.</p> <pre><code>class Comments : BaseArticle {} class Comments : BaseBlog { inheritance problem} </code></pre>
asp.net
[9]
2,206,361
2,206,362
My JavaScript Object is too big
<p>I am creating a really big JavaScript object on page load. I am getting no error on firefox but on Internet Explorer I am getting an error saying:</p> <blockquote> <p>Stop running this script ? A script on this page is causing your web browser to run slowly. If it continues to run, your computer might become unresponsive.</p> </blockquote> <p>Is there any size limit for Javascript objects in Internet Explorer ? Any other solutions but not dividing the object?</p>
javascript
[3]
3,256,809
3,256,810
asp.net windows azure blob storage
<pre><code>protected void Button1_Click(object sender, EventArgs e) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("blobconn")); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve a reference to a container CloudBlobContainer container = blobClient.GetContainerReference("mamta"); //everything fine till here ; next line creates an exception :( wat to do // Create the container if it doesn't already exist container.CreateIfNotExist(); } </code></pre>
asp.net
[9]
790,248
790,249
Display a List in TextView
<p>I'm making a fake command-line system for a fun app, and I want to show the input and output in the same TextView, like this:</p> <pre><code>&gt;something &gt;something else &gt;even more stuff &gt;etcetera. </code></pre> <p>I already figured out how to store the text from the EditText into a string and add \n and >, but I can't use strings for the whole thing: to avoid clogging up RAM, I'd like to delete lines after, say 50? I figured that would be much easier to do using Lists.</p> <p>However, this doesn't work:</p> <pre><code>log.setText((CharSequence) logText); </code></pre> <p>But what will?</p>
android
[4]
1,987,538
1,987,539
Python Difference between x = x+1 and x += 1
<p>In Python, is there any difference (semantics, efficiency, etc.) between writing <code>x = x+1</code> and <code>x += 1</code>?</p>
python
[7]
72,213
72,214
String.replaceAll without RegEx
<p>I'd like to replace all instances of a substring in a string but <code>String.replaceAll()</code> only accepts a pattern. The string that I have came from a previous match. Is it possible to add escapes to the pattern that I have or is there a version of <code>replaceAll()</code> in another class which accepts a literal string instead of a pattern?</p>
java
[1]
2,306,720
2,306,721
Tool to draw a Javascript function map?
<p>i'm looking for a tool drawing a kind of function usage map (maybe there's a better name for that).</p> <p>I'm working on a project with many javascript files included in pages. This project has been developped for a while and we've reached a point where this is really messy. I'd like to have a clear view of what is included where, how functions are used, etc. .</p> <p>Do you know if such a tool exist ?</p> <p>thanks.</p>
javascript
[3]
5,289,306
5,289,307
How to exclude a $row['weight'] from $cat_fields
<p>Hi can you please help me to exclude a row from this peace of script:</p> <pre><code>&lt;?php if($ad_fields!="") { foreach ($ad_fields as $key =&gt; $value) { echo " &lt;nobr&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; ".$cat_fields[$key][0].": &lt;/strong&gt;". " ".$ad_fields[$key].$fld_dim[$key].$fld_dimd[$key].";&lt;br /&gt; &lt;/nobr&gt; "; }} ?&gt; </code></pre> <p>This script echo all rows, how can I achieve that script doesn't call out for example $row['weight'], or $row['weight'] &amp; $row['height']</p> <p>Thanks </p>
php
[2]
2,068,004
2,068,005
Does a function declaration create an object in Javascript?
<p>Function constructors are able to create objects in javascript but I have a more basic question.</p> <p>Declaring a plain function in Javascript using a "function declaration" such as </p> <pre><code>function Foo() { this.prop1 = 20; //some code } </code></pre> <p>Does this create an object internally in javascript heap with pointer as abc and prop1 as 20? </p> <p>Or is it that the objects are created only when the function constructor is called like</p> <pre><code>var a = new Foo() //This definately creates a new object </code></pre>
javascript
[3]
1,104,365
1,104,366
resize an image without UIScrollView
<p>I want to resize an image without UIScrollView in iPhone application.</p> <p>I want to use touchesMoved. How to do it?</p> <p>Thank you</p>
iphone
[8]
376,193
376,194
how to store files in phone memory when there is no sdcard in the device in android
<p>I am new to android can anybody help me to store files in the phone memory when there is no sdcard .How can I see after storing the file in the phone memory</p> <p>for any help Thanks In Advance. </p>
android
[4]
5,014,346
5,014,347
Add data to DataTable columns in multiple text files
<p>I'm trying to export data in multiple files to a single datatable. I was able to add data to the dataset but it doesn't provide the output that I need. I guess it should be an error in my loop and I tried in different ways but failed to get the correct output. Given below the output that I receive:</p> <p><img src="http://i.stack.imgur.com/XaFIN.png" alt="enter image description here"> </p> <p>And this is the output I need:</p> <p><img src="http://i.stack.imgur.com/WLHxz.png" alt="enter image description here"></p> <p>Please refer the coding that i use and please help me to find where i go wrong. Thanks in advance</p> <pre><code>OpenFileDialog thisDialog = new OpenFileDialog(); thisDialog.Multiselect = true; DataTable dt = new DataTable(); if (thisDialog.ShowDialog() == DialogResult.OK) { foreach (string files in thisDialog.FileNames) { //each file generates two columns DataColumn column1 = new DataColumn(); dt.Columns.Add(column1); DataColumn column2 = new DataColumn(); dt.Columns.Add(column2); using (System.IO.StreamReader file = new System.IO.StreamReader(files)) { string line; while ((line = file.ReadLine()) != null) { if (line.Contains("DISKXFER")) { string dataLine = line.ToString(); string[] split = dataLine.Split(','); int result = split.Length; DataRow row = dt.NewRow(); dt.Rows.Add(split[2], split[3]); } } } } dataGridView1.DataSource = dt; } </code></pre>
c#
[0]
4,060,820
4,060,821
Parameterized Strings in Java
<p>I find myself very frequently wanting to write reusable strings with parameter placeholders in them, almost exactly like what you'd find in an SQL PreparedStatement. </p> <p>Here's an example</p> <pre><code>private static final String warning = "You requested ? but were assigned ? instead."; public void addWarning(Element E, String requested, String actual){ warning.addParam(0, requested); warning.addParam(1, actual); e.setText(warning); //warning.reset() or something, I haven't sorted that out yet. } </code></pre> <p>Does something like this exist already in Java ? Or, is there a better way to address something like this ? </p> <p>What I'm really asking: <strong><em>is this ideal ?</em></strong></p>
java
[1]
3,494,407
3,494,408
How to define if a determinate point is inside a region lat, long?
<p>I have a region defined by a set List of geopoints and I need to know if a coordinate is inside this region</p> <pre><code>public class Region{ List&lt;Coordinate&gt; boundary; } public class Coordinate{ private double latitude; private double longitude; } public static boolean isInsideRegion(Region region, Coordinate coordinate){ } </code></pre>
java
[1]
3,720,738
3,720,739
Do I need to explicitly close the StreamReader in C# when using it with string variable?
<p>This is my code:</p> <pre><code>string data = "..."; var stream = new StreamReader(data); </code></pre> <p>Is that okay not call the <code>Close()</code> method?</p>
c#
[0]
3,581,279
3,581,280
Why don't constructor values inherit property limitations
<p>Why is the property definition of LifeCycle not enough, why does my constructor need to also define it as an ArrayList()? Even so, why doesn't my ArrayList inherit the limitation of <code>&lt;LifeCycle&gt;</code> from the property definition? I don't like having to set it in both places, seems very redundant.</p> <pre><code>class Search { private Collection&lt;LifeCycle&gt; lifeCycleCollection; public Search() { this.lifeCycleCollection = new ArrayList&lt;LifeCycle&gt;(); } ... </code></pre>
java
[1]
5,210,779
5,210,780
Save chart as image without using existing method
<p>How can I save my chart in image format without using it's existing 4 methods (saveimage())</p> <p>I have to implement my custom method.</p> <pre><code> public new void SaveImage(string Path) { } </code></pre> <p>I have to hide existing method.</p>
asp.net
[9]
2,383,493
2,383,494
jQuery: Select a href containing colon
<p>My anchor links should be animated, so that they do not jump immediate to the link but rather scroll in a smooth fashion. This should work in both directions, i.e. when clicking on the link containing the <code>footnote</code> and the <code>reversefootnote</code> class.</p> <h2>Structure</h2> <p>HTML</p> <pre><code>&lt;p&gt; Some text. &lt;a href="#fn:1" id="fnref:1" title="see footnote" class="footnote"&gt;[1]&lt;/a&gt; &lt;/p&gt; &lt;div class="footnotes"&gt; &lt;ol&gt; &lt;li id="fn:1"&gt; &lt;p&gt; A footnote. &lt;a href="#fnref:1" title="return to article" class="reversefootnote"&gt;&amp;nbsp;?&lt;/a&gt; &lt;/p&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; </code></pre> <p>jQuery</p> <pre><code>$("a[href*='#fn\\:']").click(function(event) { event.preventDefault(); var href = $(this).attr("href"); var $el = $(href); $("html, body").animate({"scrollTop": $el.offset().top}, 500); }); </code></pre> <h2>Problem</h2> <p>The problem that it does not work occurs only when I use a colon in <code>href</code>, therefore I would be more than happy if someone can show me a way how to escape these, or even show me a better approach.</p>
jquery
[5]
1,649,306
1,649,307
Printing random number of words per line
<p>I'm just trying to write a simple script that prints between 1 and 10 words per line from a source. I know this should be super simple but I'm having a brain fart. This is my best guess:</p> <pre><code>import random s = open("somefile.txt").readlines() for line in s: line.strip() rand_int = rand.randint(1,10) sentence = ''.join(s,rand_int) print sentence </code></pre> <p>Specifically, I'm just having trouble figuring out how to tell python print a random group of words a random number of times per line. Is this something a list comprehension might help with?</p> <p>I'd appreciate any help you could give. Thank you!</p>
python
[7]
3,821,616
3,821,617
Is there an easier way to truncate a string with PHP regex?
<p>I have a string that looks like the following:</p> <pre><code>Security/Flow_Setup/Steady_State/Verification </code></pre> <p>I only need the first two levels (e.g. <strong>Security/Flow_Setup</strong>) Is there an easier way to get this. Currently I explode the string into an array using: '/' as a delimiter and then piece together elements 0 and 1.</p> <p>This works but I was hoping for a more elegant solution.</p> <p>Any thoughts?</p>
php
[2]
503,626
503,627
Getting notified about program termination
<p>Please find below my piece of code. I crawled through Stack Overflow on how to get notified if a process is terminated and used the suggestions in my code as below(last 3 lines). </p> <pre><code> private void button1_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); //startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C rep_cmd "+textBox2.Text+" -text "+folderBrowserDialog1.SelectedPath+"\\"; process.StartInfo = startInfo; System.Diagnostics.Process.Start(startInfo); if (process.HasExited == true) MessageBox.Show("Process done successfully!"); } </code></pre> <p>But, when I run the program, I get a runtime exception saying "No process is associated with this object". Clueless of how to rectify this. </p> <p>Kindly help.</p>
c#
[0]
2,411,649
2,411,650
python classes dependant on eachother, how to init?
<p>I have two classes:</p> <pre> class A(object): def __init__(self, b): self b = b class B(object): def __init__(self, a): self a = a </pre> <p>I'd like to init them like this:</p> <pre> a = A(b) b = B(a) </pre> <p>But I can't since 'b' doesn't exist when doing <code>a = A(b)</code>. I have to do:</p> <pre> a = A() b = B(a) b.a = a </pre> <p>But that seems unclean. Is this solvable?</p>
python
[7]
485,996
485,997
Getting text input value when populated by another Javascript function
<p>I have a set of input text boxes that activate a calendar for selecting dates when clicked. This works fine. </p> <p>I now need to get the values entered into these inputs using the onblur event. My problem is that my Javascript isn't detecting the dates entered, but the default value of the input (i.e. garbage). Somehow I need to detect the values the first function is returning, and I have no idea on that at the moment.</p> <p>Data flow needed:</p> <p>onclick.input > calendar > input populated > onblur.input > detect new value > ...</p> <p>When attempting to detect the new value, JS is finding the inital value instead.</p> <p>The Code: (second set of functions)</p> <pre><code>var myDates = document.getElementById("step4"); myDates = myDates.getElementsByTagName("input"); for (var i = 0; i&lt; myDates.length; i++) { myDates[i].onblur = function () { step4param(); return false; }; } } function step4param () { var date1 = document.getElementById("day1"); var date2 = document.getElementById("monthyear1"); alert (date1.getAttribute("value")); } </code></pre> <p>Not sure what parts of the calendar are relevant...</p>
javascript
[3]
4,896,151
4,896,152
Add all members of one class to another class
<p>Using JQuery, is it possible to add all members of one class to another class? Here, I'm trying to add all members of the class <code>ui-widget-content</code> to the class <code>draggable</code>.</p> <p><a href="http://jsfiddle.net/j8czR/" rel="nofollow">http://jsfiddle.net/j8czR/</a></p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8" /&gt; &lt;title&gt;jQuery UI Draggable - Auto-scroll&lt;/title&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.8.3.js"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"&gt;&lt;/script&gt; &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt; &lt;style&gt; #draggable, #draggable2, #draggable3 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 0 10px 10px 0; } &lt;/style&gt; &lt;script&gt; $(function() { $(".draggable").draggable({ scroll: true }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="draggable" class="ui-widget-content"&gt; &lt;p&gt;Scroll set to true, default settings&lt;/p&gt; &lt;/div&gt; &lt;div style="height: 5000px; width: 1px;"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;​ </code></pre>
jquery
[5]
2,952,424
2,952,425
Android fastboot waiting for devices
<p>I am trying to load a customized kernel on my NVIDIA test git. I typed fastboot boot myImage then I can see</p> <pre><code>&lt;Waiting for device&gt; </code></pre> <p>I think this is a problem with a driver on fastboot mode on my device. But I don't know how to install the driver on linux.</p> <p>Do you guys know how to install the driver?</p> <p>Thanks in advance..</p>
android
[4]
3,433,894
3,433,895
How to resolve custom list view while scrolling checking condition not working properly
<p>I have implemented custom list view with arrayadapter. using Arraylist data object i am setting value for list view row .using data object value I am checking condition if the value is seller i am visble the row. when i am scrolling its not working properly.it is visible for some other value also.can anybody tell what is problem how to resolve it?</p> <p>Thanks</p>
android
[4]
2,997,614
2,997,615
speed up generate N unique random numbers code
<p>I've been asked to generate all possible combinations in the range AA0000-ZZ9999(let's call it <code>folio</code>), for each combination I also need a 8 digits unique ramdom number (let's call it <code>attcode</code>), can't be consecutive, I know that there are a lot of combinations and the process will be slow, but as I'm using the <code>rand</code> function, and I've to validate that every <code>attcode</code> has to be unique, it is making my code slower, so if is it possible (I know it is, just don't know how), give me recommendations 'bout how can I improve this in my code</p> <pre><code>$alph = str_split("ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1); $code_cache = array(); foreach ($alph as $value1) { foreach ($alph as $value2) { for ($i = 0; $i &lt;= 9; $i++) { $n=$i; if($i&lt;10){ $n="000".$i; } elseif($i&lt;100){ $n="00".$i; } elseif($i&lt;1000){ $n="0".$i; } $code = rand(10000000, 99999999); while(in_array($code, $code_cache)){ $code = rand(10000000, 99999999); } $code_cache[]=$code; echo $value1.$value2.$n.'-'.$code.'&lt;br/&gt;'; } } } </code></pre>
php
[2]
4,637,706
4,637,707
call MainWindow.xib
<p>I created my login screen(two field and one button) to MainWindow.xib. After some view I want to go back to MainWindow.xib (login screen). I really do not understand how to call MainWindow.xib again?</p> <p>Any help would be appreciated.</p> <p>Thank you, Snehal Mehta</p>
iphone
[8]
5,359,104
5,359,105
python opengl library
<p>I am searching for opengl library for python 2.7 nothing too fancy just for drawing pixels very fast.</p> <p>Tnxs</p>
python
[7]
2,434,880
2,434,881
How to update starred value of contact in android?
<p>In android, I want to make existing contact favorite from application. I am using <code>getContentResolver.update()</code> method for this. No exception is thrown, but when i check the contacts they are not updated. I tried all the solutions mentioned but somehow it is not working. Please can someone give me an exact solution for this. </p>
android
[4]
1,873,978
1,873,979
parse String into tokens based on the positions
<p>I have this string </p> <p>"Name, Show starts on 14/08/09, your ticket is booked on 14/08/09"</p> <p>In this string i want to get the value StartDate, bookedDate and nameofthePerson as a individual tokens.This should work with all the strings in the same format </p> <p>How can i parse them in java ?</p>
java
[1]
1,943,308
1,943,309
Is there a way of retrieving the specific lines of code for some sort of callback function?
<p>I am in the middle of a project which basically allows other users to install "add-ons" for my script. In general it will be something like the following:</p> <pre><code>function widget () { this.addControl = function (type,control) { control.call({ Object With Some Un-thoughtout Vars }); } } </code></pre> <p><em>Very basic example with pretty much everything removed</em></p> <p>The users who will be using this trust myself fully. Now I want to make sure any scripts other people make will be ran with limited permissions. So they can't hijack sessions or redirect the user or upright steal their passwords/keystrokes. </p> <p>I looked at a few results on Google and they basically suggest that you shouldn't really do this as its more trouble than its worth. But in my opinion I'd much rather limiting it than someone installing a widget that takes their information (which they more than likely will). So does anyone know of a way of breaking down the callback function into individual lines of code so I can check everything's fine before allowing it to run? </p> <p>Or will I have to go down some horrid string then <code>eval</code> method?</p>
javascript
[3]
5,238,808
5,238,809
How to pass a string as sdtin to python script from command line interface
<p>Currently iam using following command to do this</p> <p>python scriptName.py <p>This command uses "&lt;" to stdin the file to script. and it works fine, I can use sys.stdin.read to get the file data.</p> <p>But, what if i want to pass file data as a string, I dont want to pass file path in operator "&lt;".</p> <p>Is there is any way, where I can pass String as stdin to a python script.</p> <p>Thanks, Kamal</p>
python
[7]
1,839,981
1,839,982
I have one java problem for moving files one by one by name
<p>I would like to copy my image file by name From <code>E:\Tejas\FM_Operations\source</code> to <code>E:\Tejas\FM_Operations\destination</code> in a such way that if I call the <code>MovePhoto(source,destination,filename)</code> method, then my image will copied to the destination folder in Java.</p>
java
[1]
1,614,603
1,614,604
jQuery edit-in-place with dynamic content
<p>On my website I add elements to DOM this way</p> <pre><code>$('#header').load('header.html #template'); </code></pre> <p>So I load the contents of an external html file into the DOM. Then I call</p> <pre><code>$('.edit').editInPlace({ callback: function(){ alert("test"); } }); </code></pre> <p>The loaded content contains a <code>h2 with edit css</code> class.</p> <p>But there is no reaction at all. I tried many edit-in-place plugins. With all I had the same problem. Any ideas why? How do I solve this?</p>
jquery
[5]
2,139,871
2,139,872
in PHP, how to append incremental value to each tag
<p>I have a bunch of <code>&lt;P&gt;</code> tags in an HTML file that I would like to append a unique value to, for example, my HTML file has the following (i've dumped this HTML file into a PHP variable using <code>file_get_contents</code>):</p> <pre><code>&lt;P&gt; ... data ... &lt;/P&gt; &lt;P&gt; ... data ... &lt;/P&gt; &lt;P&gt; ... data ... &lt;/P&gt; &lt;P&gt; ... data ... &lt;/P&gt; &lt;P&gt; ... data ... &lt;/P&gt; </code></pre> <p>I would like to change it so it reads this instead:</p> <pre><code>&lt;P id='unique1'&gt; ... data ... &lt;/P&gt; &lt;P id='unique2'&gt; ... data ... &lt;/P&gt; &lt;P id='unique3'&gt; ... data ... &lt;/P&gt; &lt;P id='unique4'&gt; ... data ... &lt;/P&gt; &lt;P id='unique5'&gt; ... data ... &lt;/P&gt; </code></pre> <p>Since this is a regular HTML file, there are other tags that may reside in the file as well (such as <code>&lt;HTML&gt;</code>, <code>&lt;HEAD&gt;</code>, <code>&lt;STYLE&gt;</code>, <code>&lt;BODY&gt;</code>, etc., but I want to append a unique id to ALL <code>&lt;P&gt;</code> tags</p>
php
[2]
2,697,888
2,697,889
Convert long to char* const
<p>What is the right way to convert <code>long</code> to <code>char* const</code> in C++?</p> <p>EDIT:</p> <pre><code>long l = pthread_self(); ThirdPartyFunction("Thread_Id_"+l); //Need to do this ThirdPartyFunction(char* const identifierString) {} </code></pre>
c++
[6]
1,110,625
1,110,626
Google load jQuery and jQueryUI
<p>I'm trying to use the <a href="http://code.google.com/apis/ajaxlibs/documentation/#jquery" rel="nofollow">Google</a> to load jQuery for some pages and jQuery UI for others. On the pages where I just need jQuery, I do the following:</p> <pre><code>&lt;script src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function OnLoad() { // my jQuery goodness } google.load("jquery", "1"); google.setOnLoadCallback(OnLoad); &lt;/script&gt; </code></pre> <p>And on the pages where I need jQueryUI, I also add this:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="/Library/jQuery/UI/Smoothness/css/smoothness/jquery-ui-1.7.2.custom.css"&gt; &lt;script type="text/javascript"&gt; function OnLoadUI(){ $('div.tabs').tabs(); $('input.date').datepicker(); } google.load("jqueryui", "1"); google.setOnLoadCallback(OnLoadUI); &lt;/script&gt; </code></pre> <p>Q: Am I doing anything wrong? It's working, but I want to know if I'm writing code that doesn't make sense. Q: Does Google have the various UI css themes? Or am I right in thinking that I need to serve up the smoothness theme myself? (It's not really a custom theme - it's just the default one).</p>
jquery
[5]
1,748,715
1,748,716
Is there a generic data container for Android?
<p>I am coming from a <code>C#</code> world, and used <code>DataTable</code> class extensively.</p> <p>Is there a similar structure to .Net <code>DataTable</code> in Android SDK?</p> <p>Note that I need a structure which would hold metadata and actual records without knowing the actual structure in design time - it must be general, generic. This structure MUST NOT be linked to actual database records (like RecordSet).</p> <p>Is there such a thing or I must make something like that manually?</p>
android
[4]
5,497,397
5,497,398
Click outside > hide()
<p>I have this jquery code:</p> <pre><code>$(document).ready(function(){ //global vars var searchBoxes = $(".box"); var searchBox = $(".box"); var searchBoxDefault = "Search..."; searchBoxes.focus(function(e){ $(this).addClass("active"); $('#searchoptions').show(); }); searchBoxes.blur(function(e){ $(this).removeClass("active"); }); searchBox.focus(function(){ if($(this).attr("value") == searchBoxDefault) $(this).attr("value", ""); }); searchBox.blur(function(){ if($(this).attr("value") == "") $(this).attr("value", searchBoxDefault); }); }); </code></pre> <p>and html code:</p> <pre><code>&lt;div id="search" class="right"&gt; &lt;form method="post" class="clearfix"&gt; &lt;input class="box left" type="text" value="Search..." /&gt; &lt;input class="button right" type="submit" value="" /&gt; &lt;/form&gt; &lt;div id="searchoptions"&gt; Options:&lt;br /&gt;&lt;input checked="checked" type="radio"&gt; Option1&lt;/label&gt; &lt;input type="radio"&gt; Option2&lt;/label&gt; &lt;input type="radio"&gt; Option3&lt;/label&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The question is: How can I make when I click outside of #search id, to hide #searchoptions?</p> <p>I tried with body click, but have bugs...and does not run perfectly...</p>
jquery
[5]
824,817
824,818
Convert TabActivity to Fragments
<p>I have a <code>TabActivity</code> implemented for my project which is running fine up to 2.3 versions, but crashes for versions greater than 3.How can I convert the code written for <code>TabHostActivity</code> to <code>Fragments</code>.</p>
android
[4]
1,964,005
1,964,006
Creation of Piechart using mysql and php in tcpdf
<p>I want to create piechart from php and mysql data. i'am using tcpdf, anyone know this pls help its urgent </p> <p>Thanks in advance</p>
php
[2]
630,967
630,968
PHP formating date, without using date functions
<p>I am getting date in following format, which is a string:</p> <pre><code>31_Dec_2010 </code></pre> <p>Now, I need to convert it to following 2 format</p> <pre><code>2010-12-31 //(for use in mysql query) </code></pre> <p>and</p> <pre><code>31 Dec, 2010 //(for displaying purpose) </code></pre> <p>I <strong>cannot use Date-Time Functions</strong> because I am running code on PHP 4.8</p> <p>Please suggest me some way, other then "explode" function</p> <p>Thanks.</p>
php
[2]
1,282,055
1,282,056
Why I get syntax error?
<p>Hi I wrote this code, and I dont understand why give me <code>syntax error on token "}", delet this token</code>? </p> <pre><code>private class DemoView extends View{ public DemoView(Context context) { super(context); // TODO Auto-generated constructor stub }//here*** final int x = 0; final int y = 0; this.setOnTouchListener(new View.OnTouchListener(){ public boolean onTouch(View v, MotionEvent e){ switch(e.getAction()){ case MotionEvent.ACTION_DOWN: x++; break; case MotionEvent.ACTION_MOVE: // touch drag with the ball // move the balls the same as the finger x = x-25; y = y-25; break; } return true; }//here*** } </code></pre> <p>Thanks</p>
android
[4]
2,829,262
2,829,263
error in asp.net when building
<p>The type 'gp_ss_statement_run2' already contains a definition for 'some name' </p> <p>Has anyone ever got this error? If so how do you fix it?</p> <p>This happens when we try to build.</p>
asp.net
[9]
2,594,497
2,594,498
See if @ symbol is in field and proceed with form validation
<p>I am trying to set up a web form for my website and I want to search the user's input for an @ symbol and if it is not there, the form should not validate and a message should show up asking the user to recomplete the form.</p> <p>Here's what I have so far:-</p> <pre><code>$at = "@"; if (is_null($at[$email])) { return FALSE; } </code></pre> <p>I hope someone can help me!</p>
php
[2]
5,535,816
5,535,817
C# Best way to convert dynamic to string
<p>The following gets a field from a DataTable and converts it to string. Is there a cleaner way to convert dynamic to string?</p> <pre><code>dynamic value = dataTable.Rows[i].Field&lt;dynamic&gt;(columnName); value = (value == null) ? null : value.ToString(); </code></pre>
c#
[0]
2,308,805
2,308,806
jquery using filter to separate elements and act on them differently
<p>I have a <code>.infodiv</code> class with say 4 elements. I want to filter out 1 div by id and <code>fadeToggle</code> it, and <code>fadeOut</code> the others.</p> <p>My code now is </p> <pre><code>$(".infodiv").filter('#'+id+"div").fadeToggle("slow").fadeOut("slow"); </code></pre> <p>this now filters and acts correctly on my filter, but then the following fadeout command would also act on the filtered element.</p> <p>What extra commands/syntax in the chain is needed so that the fadeout only acts on the other 3 elements.</p> <p>TIA </p>
jquery
[5]
5,960,542
5,960,543
Generalization of envelope/letter allocation like boost::make_shared?
<p>One of the key features of the boost::make_shared construct that I like is the single allocation that it performs.</p> <p>It feels like this should be (at least somewhat) generalizable for other envelope/letter structures like a shared_ptr.</p> <p>Has anyone attempted such a feat?</p>
c++
[6]
776,927
776,928
PHP Form Question
<p>Is there a way I can check if a user enters a <code>&lt;p&gt;</code> tag inside a form using PHP?</p>
php
[2]
3,832,649
3,832,650
android set wallpaper as app background
<p>I want that when a user clicks a button in an app, they get a dialog box that allows them to select a wallpaper from albums, a set of live wall papers, system wall papers or even images. I'd like the functionality to be exactly like it is with the home page wallpaper except that I need this selected image to be the background of my <code>Main Activity</code>. So, When they select it and click set as wallpaper, this image should be used as app's background drawable.</p> <p>I have this for a start:</p> <pre><code> Intent intent = new Intent( WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); intent.putExtra(WallpaperManager.COMMAND_TAP, new ComponentName(MainActivity.class), Wallpaper.class)); startActivity(intent); </code></pre> <p>My second idea is to use set background bitmap using <code>WallpaperManager.getInstance(this).setBitmap(bitmap);</code> I don't know which direction to move..</p>
android
[4]
2,300,823
2,300,824
What's wrong with this php code? With variable
<pre><code>&lt;?php session_start(); //echo "Hello".$_SESSION['uname']; $unme=$_SESSION['uname']; include("connection.php"); $query_qt=mysql_query("SELECT * FROM regst WHERE unme='$unme'"); $info = mysql_fetch_array($query_qt); if($info) { $qt=$info['point']; } echo "Question ".$qt; if($qt=='0') header("location:question1.php"); else if($qt=='1') header("location:question2.php"); else if($qt=='2') header("location:question3.php"); ?&gt; </code></pre> <p>This code not working actually...Can anybody help me? I think I'm not getting any value on $qt variable. </p>
php
[2]
3,558,291
3,558,292
What is the correct implementation of erase function in vector class
<p>I'm trying to implement my own version of vector class without using iterators. Here is the parts which may be needed for the question.</p> <pre><code>template &lt;typename T&gt; class Vector { public: ... ~Vector() { delete [] m_data; } ... void erase(size_t position) { if (position &gt;= m_size) { throw std::out_of_range("erasing an element out of bounds"); } --m_size; for (size_t i = position; i &lt; m_size; ++i) { m_data[i] = m_data[i + 1]; } m_data[m_size].T::~T(); } ... private: T* m_data; size_t m_size; ... }; </code></pre> <p>Below is a quote from <a href="http://cplusplus.com/reference/stl/vector/erase/" rel="nofollow">cplusplus.com</a> for <code>erase</code> function of <code>std::vector</code>:</p> <blockquote> <p>This effectively reduces the vector size by the number of elements removed, calling each element's destructor before.</p> </blockquote> <p>So I tried to implement the same functionality by calling the destructor of the last duplicate element. The destructor of <code>m_data[position]</code> is unnecessary as it will be replaced by the next element.</p> <p>The problem is that the code in the destructor of vector class <code>delete [] m_data</code> will also call the destructors for each element which will cause double deletion of memory and crash.</p> <p>Can anyone help to write the correct erase function for my vector class?</p>
c++
[6]
2,981,861
2,981,862
storing space in DB and displaying giving me problems
<p>My spaces in text field get stored in mysql DB as <code>' name '</code> which was just like <code>' name '</code> in UI. But when i display it to screen it gets displayed properly. but when i get count of the variable like <code>strlen($var)</code> it gives me count as 8 instead of 6. So any thing wrong like the way i am doing?</p>
php
[2]
1,043,388
1,043,389
jQuery: how do I convert this to 1.3.2?
<pre><code>d = $j("#sort_sections &gt; li").map(function(index, element){ return [[element.id, $j(element).find("li.content").map(function(subindex, subelement){ return subelement.id; }).toArray()]]; }).toArray(); </code></pre> <p>It currently works in 1.4.2, but I need it to work in 1.3.2 =\</p>
jquery
[5]
523,761
523,762
How can I avoid rewriting construction logic present in initializer lists?
<p>Suppose I have a CPP class like</p> <pre><code> class A { A() : max_(0), num_(0), sum_(0), sum_squares_(0) {} void Clear() { min_ = bucketMapper.LastValue(); max_ = 0; num_ = 0; sum_ = 0; sum_squares_ = 0; } void SomethingElse {} } </code></pre> <p>I have the initialization code in the constructor and in Clear, is there a way I can avoid having the same code twice.</p>
c++
[6]
1,628,486
1,628,487
System.IO.FileStream is super slow on huge files
<p>I have a piece of code that needs to be able to modify a few bytes towards the end of a file. The problem is that the files are huge. Up to 100+ Gb.</p> <p>I need the operation to be as fast as possible but after hours of Googeling, it looks like .Net is rather limited here???</p> <p>I have mostly been trying using System.IO.FileStream and know of no other methods. A "reverse" filestream would do but I have know idea how to create one (write from the end instead of the beginning).</p> <p>Here is sort of what I do: (Note: the time is spent when closing the stream)</p> <pre><code> static void Main(string[] args) { //Simulate a large file int size = 1000 * 1024 * 1024; string filename = "blah.dat"; FileStream fs = new FileStream(filename, FileMode.Create); fs.SetLength(size); fs.Close(); //Modify the last byte fs = new FileStream(filename, FileMode.Open); //If I don't seek, the modification happens instantly fs.Seek(-1, SeekOrigin.End); fs.WriteByte(255); //Now, since I am modifying the last byte, //this last step is very slow fs.Close(); } } </code></pre>
c#
[0]
1,034,919
1,034,920
Performing math operation when operator is stored in a string
<p>I have 2 integers:</p> <pre><code>int first= 10; int second = 20; </code></pre> <p>and a string representing the operation (one of <code>+</code>, <code>-</code>, <code>/</code>, or <code>*</code>):</p> <pre><code>String op = "+"; </code></pre> <p>How can I get the result of 10 + 20 in this example?</p>
java
[1]
3,529,814
3,529,815
How to get UILabel (UITextView) auto adjusted font size?
<p>Is it possible to get final font size, after autoadjusting? (property adjustsFontSizeToFitWidth set to YES, and text font size is being shrinked to fit into the label)</p> <p>I am subclassing drawTextInRect in UILabel to put gradient on the text, but the gradient size needs to be the same, as the size of the font. I am not able to get proper size of the adjusted font...Is it even possible?</p> <pre><code> //draw gradient CGContextSaveGState(myContext); CGGradientRef glossGradient; CGColorSpaceRef rgbColorspace; size_t num_locations = 2; CGFloat locations[2] = { 0.0, 1.0 }; CGFloat components[8] = { 1, 1, 1, 0.25, // BOTTOM color 1, 1, 1, 0.12 }; // UPPER color //scale and translate so that text would not be rotated 180 deg wrong CGContextTranslateCTM(myContext, 0, rect.size.height); CGContextScaleCTM(myContext, 1.0, -1.0); //create mask CGImageRef alphaMask = CGBitmapContextCreateImage(myContext); CGContextClipToMask(myContext, rect, alphaMask); rgbColorspace = CGColorSpaceCreateDeviceRGB(); glossGradient = CGGradientCreateWithColorComponents(rgbColorspace, components, locations, num_locations); //gradient should be sized to actual font size. THIS IS THE PROBLEM - EVEN IF FONT IS AUTO ADUJSTED, I AM GETTING THE SAME ORIGINAL FONT SIZE!!! CGFloat fontCapHeightHalf = (self.font.capHeight/2)+5; CGRect currentBounds = rect; CGPoint topCenter = CGPointMake(CGRectGetMidX(currentBounds), CGRectGetMidY(currentBounds)-fontCapHeightHalf); CGPoint midCenter = CGPointMake(CGRectGetMidX(currentBounds), CGRectGetMidY(currentBounds)+fontCapHeightHalf); CGContextDrawLinearGradient(myContext, glossGradient, topCenter, midCenter, 0); CGGradientRelease(glossGradient); CGColorSpaceRelease(rgbColorspace); CGContextRestoreGState(myContext); </code></pre>
iphone
[8]
5,668,260
5,668,261
Make a widget show up has a normal App
<p>How to make a widget show up has a normal App?</p>
android
[4]
1,249,200
1,249,201
Can't add parenthesis in the second parameter of addEventListener method
<p>This confused me a lot</p> <pre><code>var show = function(){ console.log('wow'); }; var show2 = function(word){ console.log(word); }; button_element.addEventListener('click', show2('wow'), false) </code></pre> <p>'wow' //it return the string immediately but hit the button, nothing output in the console,</p> <p>but</p> <pre><code>button_element.addEventListener('click', show. false) </code></pre> <p>No string return as we expect and then hit the button <code>wow</code> shows in the console as intended</p> <p>anybody explain why does it act this way?</p>
javascript
[3]
5,223,086
5,223,087
how to add search functionality to a txtbox
<p>i want that while writing some text in an asp.net textbox, a listview page should open which will show the related topics containing that text just below that txtbox .</p> <p>i want to implement something as in stackoverflow title txtbox how it it showing related topics</p>
asp.net
[9]
1,381,692
1,381,693
Compiling a C program that was entered into a textbox and received via PHP?
<p>I have this problem: I want to pass a whole C code from a php textbox onto server and want to compile it with gcc and want the output back on php page. Is it possible?</p> <p>Sample code:</p> <pre><code>php page input &lt;textarea&gt; #include&lt;stdio.h&gt; void main() { printf("hello world"); } </code></pre> <p>Compiled on server terminal/shell</p> <p>php page output:</p> <pre><code>hello world </code></pre>
php
[2]