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
1,759,191
1,759,192
does clipsToBounds = YES reduce my memory footprint?
<p>I have a pretty big view which is like 1000 x 1000. So I did clipToBounds = YES. Will this actually produce smaller bitmaps for the views?</p>
iphone
[8]
1,398,892
1,398,893
asp.net: moving from session variables to cookies
<p>My forms are losing session variables on shared hosting very quickly (webhost4life), and I think I want to replace them with cookies. Does the following look reasonable for tracking an ID from form to form:</p> <pre><code>if(Request.Cookies["currentForm"] == null) return; projectID = new Guid(Request.Cookies["currentForm"]["selectedProjectID"]); Response.Cookies["currentForm"]["selectedProjectID"] = Request.Cookies["currentForm"]["selectedProjectID"]; </code></pre> <p>Note that I am setting the Response cookie in all the forms after I read the Request cookie. Is this necessary? Do the Request cookies copy to the Response automatically?</p> <p>I'm setting no properties on the cookies and create them this way:</p> <pre><code>Response.Cookies["currentForm"]["selectedProjectID"] = someGuid.ToString(); </code></pre> <p>The intention is that these are temporary header cookies, not persisted on the client any longer than the browser session. I ask this since I don't often write websites.</p>
asp.net
[9]
63,989
63,990
Cannot call method 'reload' of undefined jQuery error
<p>My jQuery keeps chucking this error up - 'Cannot call method 'reload' of undefined'. </p> <p>I basically want the parent page to reload after 8 Seconds (this is synced to refresh once the colorbox closes)</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $('#success').trigger('click'); }); var t=setTimeout(parent.$.fn.colorbox.close,8000); var s=setTimeout(parent.location.reload(),8000); &lt;/script&gt; </code></pre> <p>Many thanks in advance.</p>
jquery
[5]
5,957,809
5,957,810
Java escaped sequence syntax error
<p>I'm trying to create a string array with lines of codes, so that the program can over-write a portion of existing code once it hits a mark. My problem comes on this line:</p> <pre><code>var finalTitle = (str.replace("()", ("(" + num + ")"))); </code></pre> <p>As I am attempting to convert that line into a valid string, I understand that the quotation mark can be somewhat tricky to parse. This is what I have so far:</p> <pre><code>"var finalTitle = (str.replace(\"()\", (\"(\" + num + \")\")));" </code></pre> <p>However, eclipse will not stop complaining that the syntax of this line is incorrect. Does anyone know how to correctly format this line? Or possibly more specifically, how to parse quotation marks into a string?</p> <p>Here is an example of the string array I am filling. I am going to loop through it with each iteration writing a new line to the .js file:</p> <pre><code>String[] lines = {"var patientTree = getPatientMenuTree();", "var rootNode = patientTree.getNodeById('Patients');", "var str = rootNode.title;", "var num = patientArray.length;", "var finalTitle = (str.replace(\"()\", (\"(\" + num + \")\")));" }; </code></pre>
java
[1]
4,882,647
4,882,648
How to enforce my Android web app to ask the user for a browser choice
<p>How to enforce my Android web app to ask the user for a browser choice in which the application should be open.</p> <p>EDITED : I will shed more light into what exactly i am planning to do. Actually i am using jquery mobile to add fixed toolbar function. But when i deploy it on the device i saw some flickering on the toolbar. So, i thought that maybe i should see how my app behaves when i deploy it to something else then opera. I am new to android and web dev so please TOLERATE ;)</p>
android
[4]
3,555,148
3,555,149
Auto line break after 5 characters
<p>Guys i just wanna ask if there's a possibility: for example <code>$currenttext = "someexamplepls";</code> if you would like to show or print it just use <code>print "$currenttext";</code> then the prepared output look like this <code>someexamplepls</code>. My question is if i would like to print it like this:</p> <pre><code>somee xampl epls </code></pre> <p>in every 5 character there is automatic newline what should I do?</p>
php
[2]
5,628,273
5,628,274
save pixel array to jpeg image file c++
<p>i have a pixel array containing the values from 0 to 255 ... i have passed it to my c++ function ... this pixel array i want to save it to jpeg image file...</p> <p>how to do it with correct encoding ??</p> <p>i have converted the array to binary string and saved it into the file in the below code but it just saves an empty image of 4 byte size ...</p> <pre><code> FILE *file = fopen("/media/internal/wallpapers/04.jpeg", "w+"); fwrite(binaryStr , 1 , sizeof(binaryStr) ,file ); fclose(file); </code></pre> <p>thnks </p>
c++
[6]
4,802,720
4,802,721
How to upload JSON Object to PHP?
<p>I have an activity which contains a Button,Whenever user click on button, we create one JSON object. I want to post this JSON object in PHP.I search for that,I got so many solution.But i didn't understand what is going there.pls explain and send sample code plz.</p> <p>pls help thanks</p>
android
[4]
574,818
574,819
Can not start new activity
<p>I have two classes. The main class is BundleActivity, and another sub class. I'm trying to start sub activity from BundleActivity but It's not working and app is force closing.</p> <p>Here is my onClick method in BundleAcitvity class:</p> <pre><code>public void onClick(View v) { // TODO Auto-generated method stub Intent i=new Intent(this,sub.class); this.startActivity(i); } </code></pre> <p>My manifest file :</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.bundle" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:name=".BundleActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".sub" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="com.bundle.sub" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Any one help me to fix it?</p>
android
[4]
3,429,911
3,429,912
How to do my own custom list?
<p>How to do my own custom list? I mean, that each element of list will be looking like I want.</p>
android
[4]
1,905,187
1,905,188
Indirect access to a protected member of an object in PHP
<p>I have a question about pointer in PHP.</p> <p>In a A class i have : </p> <pre><code>protected $startDate; public function getStartDate() { return $this-&gt;startDate; } public function setStartDate($startDate) { $this-&gt;startDate = $startDate; } </code></pre> <p>I use it in my code like this : </p> <pre><code>$day = new \DateInterval('P1D'); $a-&gt;startDate-&gt;add($day); </code></pre> <p><strong>Result : "Cannot access protected property" (as expected)</strong></p> <hr> <p>if I try : </p> <pre><code>$day = new \DateInterval('P1D'); print_r($a-&gt;getStartDate()); $date = $a-&gt;getStartDate(); $date-&gt;add($day); print_r($a-&gt;getStartDate()); die(); </code></pre> <p>Result : </p> <pre><code>DateTime Object ( [date] =&gt; 2012-11-08 00:00:00 [timezone_type] =&gt; 3 [timezone] =&gt; Europe/Paris ) DateTime Object ( [date] =&gt; 2012-11-09 00:00:00 [timezone_type] =&gt; 3 [timezone] =&gt; Europe/Paris ) </code></pre> <p>I modified a protected value without the setter</p> <p>I think that I modified the date value because it was returned as a pointer by the getter method. I don't understand how I could modify a protected value without using a setter method.</p> <p>Do you know why?</p> <p>Thanks</p> <p>Edit : Ok the member of my A class is a DateTime Object as I explained. If I want it to be really protected, maybe I have to make a "timestamp" member and return a new DateTime of my timestamp (or clone the member).</p> <p>Thanks again ! </p>
php
[2]
3,711,469
3,711,470
How do I access a class from within a class defined above it?
<p>If I have classes A and B, how can I create a reference to B inside of A? I read that you need use a pointer or a reference, but I can't find out more than that. Here's an example of what I'm talking about:</p> <pre><code>class B; class A { public: B * b_pointer; void setSelf(B * given_b_pointer) { b_pointer = given_b_pointer; }; void printBName() { print (b_pointer.my_name); }; }; class B { public: string my_name; void setSelf(string my_given_name) { my_name = my_given_name; }; } </code></pre> <p>This gives me several errors. What am I doing wrong, and how can I fix it?</p> <p>EDIT: The relevant error message:</p> <blockquote> <p>error: request for member 'my_name' in '((B*)this)->A::b_pointer', which is of non-class type 'B*'.</p> </blockquote> <p>Error message slightly edited to replace actual class names with psuedo-class names.</p>
c++
[6]
2,692,161
2,692,162
jslint.js download link
<p>Can't find download link for jslint.js from <a href="http://www.jslint.com/" rel="nofollow">http://www.jslint.com/</a>. I have downloaded <a href="http://jslint.com/webjslint.js" rel="nofollow">http://jslint.com/webjslint.js</a>, but it doesn't work well Can anyone give me correct url to download it ?</p>
javascript
[3]
2,650,647
2,650,648
var jQuery = jQuery.noConflict(); not work in IE7 and IE8
<p>my code is</p> <pre><code>var jQuery = jQuery.noConflict(); $(document).ready(function() { var $filterType = $('#filterOptions li.active a').attr('class'); var $holder = $('ul.ourHolder'); var $data = $holder.clone(); $('#filterOptions li a').click(function(e) { $('#filterOptions li').removeClass('active'); var $filterType = $(this).attr('class'); $(this).parent().addClass('active'); if ($filterType == 'all') { var $filteredData = $data.find('li'); } else { var $filteredData = $data.find('li[data-type=' + $filterType + ']'); } $holder.quicksand($filteredData, { duration: 800, easing: 'easeInOutQuad' }); return false; }); }); </code></pre> <p>when i comment ( //var jQuery = jQuery.noConflict();) noConflict then this code is work but if not commented this then its not work with ie7 and also ie8</p> <p>i use also $jQuery = jQuery.noConflict();</p>
jquery
[5]
5,862,351
5,862,352
How to prevent an object from being deleted in places where it shouldn't, at compile-time?
<p>I have classes <code>Graph</code> and <code>Algorithm</code>:</p> <pre><code>class Graph { ... }; class Algorithm { ... private: Graph * mGraph; ... }; </code></pre> <p>I want my algorithm to be able to do everything with <code>mGraph</code> except deleting it. I.e. I want to detect (at compile time) if somewhere in algorithm I'm deleting the graph. Is there a good (elegant) way to do such a thing? (The only way I realized is making <code>Graph</code>s destructor private so only friend classes have permission to delete it)</p>
c++
[6]
1,537,470
1,537,471
How can I split two digit into two different strings?
<p>I have month in, which contains a value such as <code>12</code>. I am trying to split it into two different strings e.g. a=1 and b=2. How do I do this? </p>
java
[1]
3,785,859
3,785,860
Set icon for multichoiceitem
<p>I hava an alerDialog which enables the user to select multiple items.(set using the multichoiceitems() method).I want to add an icon for each of these items.Is this possible.</p> <p>I want a separate icon to be displayed for each of the selectable items.I have the icons stored in a drawable array.Any help would be appreciated.</p>
android
[4]
4,639,541
4,639,542
How to add a uneditable url in a popup window using javascript
<p>I am using javascript for opening a new window when clicked on the link. I want that the new window should dispaly the address bar but the value of that bar should not change.</p> <p>Can i do that?</p> <p>the script code i am usng is:</p> <pre><code>="Javascript:void(window.open('help.aspx?ID=" + Fields!ID.Value +"','mywindow','_self','width=500,height=500'))" </code></pre> <p>thanks in advance</p>
javascript
[3]
1,029,294
1,029,295
replacing a custom tag's value with a string in php
<p>I want to read a html file and replace what ever is inside mytag.</p> <p>so in html file we have something like this :</p> <pre><code> &lt;div&gt; &lt;h3&gt;&lt;mytag&gt;_THIS_DAY&lt;/mytag&gt;&lt;/h3&gt; &lt;div&gt; [LOGIN] &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and then in php file , i need to read the file and replace the values inside tags.</p> <p>str_replace() ?</p> <p>how to get the value inside those tags in php and then how to replace them with something like a string ?</p>
php
[2]
3,880,031
3,880,032
DIV Hover makes the other DIV Move
<p>I would like to ask your help.</p> <p><a href="http://jsfiddle.net/perRL/9/" rel="nofollow">http://jsfiddle.net/perRL/9/</a></p> <pre><code>&lt;div class="header-logo"&gt; &lt;a href="#"&gt;&lt;img src="http://www.bendaggers.com/wp-content/themes/Anakin%20Skywalker/Images/BenDaggers%20Logo.PNG" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="xbdlogo"&gt; &lt;img src="http://www.bendaggers.com/wp-content/themes/Anakin%20Skywalker/Images/Bendaggers%20Logo%20Two.PNG" /&gt; &lt;/div&gt; </code></pre> <p>What I'm trying to do is when you hover the logo "bendaggers", the little logo beside it will change from it css style (from) <strong>Top:-50px; to Top:30px;</strong></p> <p>IF anyone could help me do this on javascript? Thank you!</p>
javascript
[3]
3,481,851
3,481,852
How to fire an jquery action when a div is appended?
<p>I need to fire an jquery action when a div is appended.</p> <p>Something like: </p> <pre><code>if ($('div#myDiv').is_appended()) { console.log('the div has been appended'); } </code></pre> <p>Is this possible?</p> <p><strong>Why do I need this</strong></p> <p>This question is related to this <a href="http://stackoverflow.com/questions/15083511/how-to-execute-jquery-inside-a-modal-window">question</a> where I have I modal div which is loaded after the jquery library, then I can't target the element in it. </p> <p>Now I'm trying to do something when the modal div is load, not sure if I get it done though,</p>
jquery
[5]
5,668,773
5,668,774
Get list of Google Fonts
<p>I want to get list of google web fonts in select box to select a font. I am trying following function, but it gives the error.</p> <p><strong>Code:</strong></p> <pre><code>function get_google_fonts() { $url = "https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha"; $result = json_response( $url ); $font_list = array(); foreach ( $result-&gt;items as $font ) { $font_list[] .= $font-&gt;family; } return $font_list; } function json_response( $url ) { $raw = file_get_contents( $url, 0, null, null ); $decoded = json_decode( $raw ); return $decoded; } </code></pre> <p><strong>Error:</strong> </p> <pre><code>Warning: file_get_contents(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP. </code></pre> <p>If I change the https to http, I get this error:</p> <pre><code>file_get_contents(http://www.googleapis.com/webfonts/v1/webfonts?sort=alpha): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in </code></pre> <p>I guess this is because of PHP settings on my server, which I am unable to change. So, is there any alternative way to get the font list from Google? Thanks.</p>
php
[2]
2,353,621
2,353,622
Why is my range function printing untruncated floats?
<p>I made this range function so I could have something other than an integer step, and it works, but I am wondering why the floats are not truncated.</p> <pre><code>def drange(start, step): values = [] r = start while r &gt;= 0: values.append(r) r += step return values print drange(2, -0.2) </code></pre> <p>Upon debugging I find that instead of this printing</p> <pre><code>[2, 1.8, 1.6, 1.4, 1.2, 1.0, 0.8, 0.6, 0.4, 0.2, 0] </code></pre> <p>it instead prints</p> <pre><code>[2, 1.8, 1.6, 1.4000000000000001, 1.2000000000000002, 1.0000000000000002, 0.8000 000000000003, 0.6000000000000003, 0.4000000000000003, 0.2000000000000003, 2.7755 575615628914e-16] </code></pre> <p>Lol, no wonder my module isn't working. Why does this happen and how might I fix it?</p>
python
[7]
4,493,332
4,493,333
Detecting touch by user at any point of time
<p>I have a child view in my parent view. Now I am using animation to show child view for 10 sec and hide it after that. I want to show the child view even after 10 sec only if user touches it while animating. So how can I determine if the child view is touched by user or not? Does android provide any API to determine if view is touched by user at any instance of time?</p>
android
[4]
5,908,383
5,908,384
About the copy constructor and pointers
<p>I'm reading through an example in primer and something which it talks about is not happening. Specifically, any implicit shallow copy is supposed to copy over the address of a pointer, not just the value of what is being pointed to (thus the same memory address). However, each of the pos properties are pointing to two different memory addresses (so I am able to change the value of one without affecting the other). What am I doing wrong?</p> <p>Header</p> <pre><code>#include "stdafx.h" #include &lt;iostream&gt; class Yak { public: int hour; char * pos; const Yak &amp; toz(const Yak &amp; yk); Yak(); }; </code></pre> <p>END HEADER</p> <pre><code>using namespace std; const Yak &amp; Yak:: toz(const Yak &amp; yk) { return *this; } Yak::Yak() { pos = new char[20]; } int _tmain(int argc, _TCHAR* argv[]) { Yak tom; tom.pos="Hi"; Yak blak = tom.toz(tom); cout &lt;&lt; &amp;blak.pos &lt;&lt; endl; cout &lt;&lt; &amp;tom.pos &lt;&lt; endl; system("pause"); return 0; } </code></pre>
c++
[6]
4,379,630
4,379,631
parent_id - recursion - get all dependent categories
<p>In my database each category record has got column CategoryId and CategoryParentId. How can I get List with id all children categories for current category and children its children etc? I have that code:</p> <pre><code>public void AllDependentCategories(int categoryId) { IQueryable&lt;Category&gt; categoriesList = Context.CategoryRepository .FindAll() .Where(x =&gt; x.CategoryParentId == categoryId); foreach (var category in categoryList) { AllDependentCategories(category.CategoryId); } } </code></pre>
c#
[0]
4,008,696
4,008,697
How to get the value of particular cell value in JsGrid
<p>how to get the value of particular cell value instead of column title in JsGrid using "OnCellEditCompleted" event as below: </p> <pre><code>&lt;script type="text/javascript"&gt; Type.registerNamespace("GridManager"); GridManager = function () { this.Init = function (jsGridControl, initialData, props) { control = jsGridControl; var dataSource = new SP.JsGrid.StaticDataSource(initialData); var jsGridParams = dataSource.InitJsGridParams(); // This event is triggered after the standard grid error checking. jsGridControl.AttachEvent(SP.JsGrid.EventType.OnCellEditCompleted, GotHere); jsGridControl.Init(jsGridParams); } }; function GotHere(obj) { alert('Got Here, ' + obj.fieldKey); } &lt;/script&gt; </code></pre>
javascript
[3]
5,514,944
5,514,945
error C2679 template class
<p>The error occurs in the default constructor</p> <p><strong>Error:</strong> error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)</p> <p>The Code:</p> <pre><code>#ifndef _SLOT_H #define _SLOT_H #include &lt;string&gt; using namespace std; template &lt;class T&gt; class slot { private: string key; T data; public: slot(); slot(string str); slot(string str, T tempdata); slot(const slot &amp;source); string getkey(); T getdata(); void setkey(string str); void setdata(T tempdata); }; template&lt;class T&gt; slot&lt;T&gt;::slot() { key = ""; data = NULL; } </code></pre>
c++
[6]
1,667,086
1,667,087
The difference between putting functions into an object and prototyping them?
<p>What's the difference between adding functions to an object and prototyping them onto the object?</p> <p>Prototyping allows the object/model to call itself?</p>
javascript
[3]
5,025,668
5,025,669
Android In App purchase example without transactions from Google checkout?
<p>Is there any app purchase example without cut off any charges from google checkouts account?? I mean Totally free app purchase demo for android...</p>
android
[4]
4,510,448
4,510,449
what is the problem with auto_ptr?
<p>I heard auto_ptr is being deprecated in the new C++. What is the reason for this. Also I would like to know difference between auto_ptr vs shared_ptr</p>
c++
[6]
4,418,728
4,418,729
uint vs int in C#
<p>I have observed for a while that C# programmers tend to use int everywhere, and rarely resort to uint. But I have never discovered a satisfactory answer as to why.</p> <p>If interoperability is your goal, uint shouldn't appear in public APIs because not all CLI languages support unsigned integers. But that doesn't explain why int is so prevalent, even in internal classes. I suspect this is the reason uint is used sparingly in the BCL.</p> <p>In C++, if you have an integer for which negative values make no sense, you choose an unsigned integer.</p> <p>This clearly signifies that negative numbers are not allowed or expected, and the compiler will do some checking for you. I also suspect in the case of array indices, that the JIT can easily drop the lower bounds check.</p> <p>However, when mixing int and unit types, extra care and casts will be needed.</p> <p>Should uint be used more? Why?</p>
c#
[0]
2,189,004
2,189,005
pixel spacing for bitmap
<p>i have create bitmap of size 220*220 , what default pixel spacing will be considered</p>
c#
[0]
2,129,009
2,129,010
Cannot read sections of config files containing []
<p><em>Edited post</em></p> <p>I'm not able to read the configuration file sections that contain <code>[]</code>... for e.g if any section in ini file is something like <code>[c:\\temp\\foo[1].txt]</code> than my script fails to read that section..</p> <pre><code>config.read(dst_bkp) for i in config.sections(): config.get(i,'FileName') </code></pre> <p>Thanks, Vignesh</p>
python
[7]
345,287
345,288
file_get_contents() failed to open stream:
<p>I'm trying to use file_get_contents() to grab a twitter feed, however I'm getting the following warning: </p> <pre><code>failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request </code></pre> <p>My code:</p> <pre><code>$feed = 'http://twitter.com/statuses/user_timeline.rss?screen_name=google&amp;count=6'; $tweets = file_get_contents($feed); </code></pre> <p>I'm using google just for the sake of testing. allow_url_fopen is enabled in my php.ini file.</p> <p>Any idea what could be wrong?</p>
php
[2]
632,923
632,924
Android Layouts Scrolling in Landscaped Mode
<p>I have a strange issue in which on rotating the Screen to Landscaped mode the Views present inside Remain at the same place But I cannot scroll them inside the screen.</p> <p>How can I make them Scroll so that every thing that move out should be displayed properly to the user.</p> <p>Should there be any more attribute to be set for allowing such kind of behavior.</p>
android
[4]
3,829,332
3,829,333
I want to set image and also text on tab
<pre><code>TabSpec spec1 = tabHost.newTabSpec("Tab1"); spec1.setIndicator("Tab1", getResources().getDrawable(R.drawable.news) ); Intent in1 = new Intent(this, Act1.class); spec1.setContent(in1); </code></pre> <p>I did use this code.but when i using this code the image not show on the tab only text are showing.so please tell me any suggestion.and this code only for one tab.</p>
android
[4]
2,838,008
2,838,009
Selective Service permissions, binding only
<p>Is it possible to restrict access to a <code>Service</code> such that a client can only bind to it? For example, I want clients to access the service's AIDL API, but do not want them to be able to call <code>startService()</code> or, more importantly, <code>stopService()</code> on the service.</p> <p>I have tried using the <code>android:permission</code> attribute within the <code>&lt;service&gt;</code> tag of the manifest. This works for restricting access to <code>startService()</code> and <code>stopService()</code> but binding to the Service configured in this way results in:</p> <blockquote> <p>java.lang.SecurityException: Not allowed to bind to service</p> </blockquote> <p>Any thoughts?</p>
android
[4]
2,181,195
2,181,196
Similar object transform java
<p>I have a java class that models an object, another that models the same object with few differences. How I can transform the second object in the first? thanks</p>
java
[1]
818,878
818,879
Find the Duration in Months between the contents in an Iterator
<p>Code:</p> <pre><code> Iterator&lt;String&gt; termIncomeKeys = termIncome.keySet().iterator(); while(termIncomeKeys.hasNext()){ String month = termIncomeKeys.next(); System.out.println(month); } </code></pre> <p>The month is printed as </p> <p>Jan(2012) - Jan(2012)</p> <p>Feb(2012) - Mar(2012)</p> <p>Apr(2012) - May(2012)</p> <p>Jun(2012) - Jun(2012)</p> <p>Jul(2012) - Oct(2012)</p> <p>What I want to achieve is I want to print the duration in terms of months between each of the entries. That is, Duration between first entry is 1 month, duration between second is 2 and so on.</p>
java
[1]
2,925,468
2,925,469
c# - How do I round a decimal value to 2 decimal places (for output on a page)
<p>Newbie programmer question - When displaying the value of a decimal currently (with .ToString()..), it's accurate to like 15 decimal places, and since I'm using it to represent dollars and cents, I only want the output to be 2 decimal places. Do I use a variation of .ToString() for this?</p> <p>Thanks.</p>
c#
[0]
5,878,382
5,878,383
I am new to Java. Please explain the concept of hash code and hash set in simple terms
<p>I am new to Java. Can someone explain the concept of hash code and hash set in simple terms please</p>
java
[1]
4,231,160
4,231,161
jquery semantic
<p>well I have a question about the semantics, we can tie in a jQuery event to a node using <code>.on ('event', fn)</code>, so I wonder if using for example: <code>$node.on('click', fn)</code> is more semantic and better than using <code>$node.click (fn)</code> ? </p>
jquery
[5]
4,983,441
4,983,442
Calculating pi using a series in my book
<p>I'm trying (yet again) to get better at programming, this time in python, and I've hit a roadblock. I've been trying to figure out why this doesn't work for a while now, so if I could have some help that would be really, really great. I have the instructions as a comment, but the series wouldn't copy to text, it's on wikipedia though as <a href="http://en.wikipedia.org/wiki/Pi#Estimating_.CF.80" rel="nofollow">http://en.wikipedia.org/wiki/Pi#Estimating_.CF.80</a> </p> <pre><code>#19. Write a program that approximates the value of pi by summing the terms of this series: #The program should prompt the user for n, the number of terms to sum # and then output the sum of the first n terms of this series. def pi() : n = 0.0 p = input() for i in range(-3,p*4,4): n = n + 4.0 / i - 4.0 / ( i + 2) print n </code></pre> <p>When I say 1000000, it gives me 5.80825432026; that value doesn't change much. Anyway, can someone help me please? At this point I have nothing else I can think of.</p>
python
[7]
4,010,696
4,010,697
how to forward variable number of arguments to another function?
<p>In my application I have a lot of logs. I do accumulate all errors from all logs in one place called <code>errorsLogger</code>. I've implemented it this way:</p> <pre><code>static Logger errorsLogger; .... void Logger::Error(std::string format, ...) { va_list arglist; va_start(arglist, format); if (this != &amp;errorsLogger) { errorsLogger.Error(format, arglist); // how to forward parameters? } vfprintf(logFile, , format.c_str(), arglist); fprintf(logFile, "\n"); fflush(logFile); va_end( arglist ); } </code></pre> <p>However this code doesn't work as expected <code>errorsLogger</code> contains a little bit strange strings - it seems variable arguments was not passed. How to fix my code to be valid?</p>
c++
[6]
1,070,598
1,070,599
c# using directive depth
<p>I'm trying to understand the c# using directive...Why does this work...</p> <pre><code>using System; using System.ComponentModel.DataAnnotations; namespace BusinessRuleDemo { class MyBusinessClass { [Required] public string SomeRequiredProperty { get; set; } } } </code></pre> <p>but this does not?</p> <pre><code>using System; using System.ComponentModel; namespace BusinessRuleDemo { class MyBusinessClass { [DataAnnotations.Required] public string SomeRequiredProperty { get; set; } } } </code></pre> <p>The second results in a compile error "The type or namespace DataAnnotations cannot be found. Are you missing are missing a using directive or an assembly reference?</p>
c#
[0]
4,574,880
4,574,881
find out the previous year date from current date in javascript
<p>I need to find out the previous year date from current date and then set as minDate in jqury UIdatepicker in javascript</p> <p>My date formaqt is <code>dd-mm-yy</code> </p> <p>Ie </p> <p>current date is <code>25-07-2012</code> i need to get <code>25-07-2011</code></p>
javascript
[3]
5,531,216
5,531,217
Jquery get Children with level
<p>I want get child for element but only the child selector For example:</p> <p><code>$(“#tree”).find('.list ul li a')</code></p> <p>I got all the children and children of children<br> There is the <code>children()</code> function, but this is just one level, and I want get children with more than one level.</p>
jquery
[5]
5,715
5,716
Access <html> node
<p>I'd like to add a class to the <code>&lt;html&gt;</code> element and run the code for it in the <code>&lt;head&gt;</code> element. What's the best way to do that?</p> <p><code>document.getElementsByTagName('html')[0].className = 'class';</code></p> <p>or</p> <p><code>document.documentElement.className = 'class';</code></p>
javascript
[3]
1,655,875
1,655,876
How to connect Android App connecting to a web service
<p>I created a small app and with this app I want to send the data (over wifi or bluetooth) to a PC/server.</p> <ol> <li><p>I am thinking of creating a webservice that will run on the PC and will be listening constantly to any incoming client requests.</p></li> <li><p>Once it receives request from client, the data transfer takes place.And after the webservice receives the data it should automatically open an application/GUI window showing the data received.</p></li> </ol> <p>My question is Can I create a webservice using TCP/IP in JAVA and have it constantly run in background and listening to client request? Also how do I start a GUI as soon as the webservice detects a client request and receives the data?</p>
android
[4]
5,403,699
5,403,700
How to decide when to introduce a new type instead of using list or tuple?
<p>I like to do some silly stuff with python like solving programming puzzles, writing small scripts etc. Each time at a certain point I'm facing a dilemma whether I should create a new class to represent my data or just use quick and dirty and go with all values packed in a list or tuple. Due to extreme laziness and personal dislike of <code>self</code> keyword I usually go with the second option. </p> <p>I understand than in the long run user defined data type is better because <code>path.min_cost</code> and <code>point.x, point.y</code> is much more expressive than <code>path[2]</code> and <code>point[0], point[1]</code>. But when I just need to return multiple things from a function it strikes me as too much work.</p> <p>So my question is what is the good rule of thumb for choosing when to create user defined data type and when to go with a list or tuple? Or maybe there is a neat pythonic way I'm not aware of?</p> <p>Thanks.</p>
python
[7]
5,910,102
5,910,103
PHP & Implementing .Netish Properties
<p>I've decided to have some fun, and implement .Net Properties in PHP. </p> <p>My current design centers around something like:</p> <pre><code>$var; method Var($value = null) { if($value == null) { return $var; } else { $var = $value; } } </code></pre> <p>Obviously this runs into a bit of an issue if someone is trying to set the property (and associated variable) to null, so I am thinking of creating a throwaway class that would never be used. Thoughts, comments?</p>
php
[2]
4,126,378
4,126,379
Storing simple data on cloud
<p>I am new to android programming. I want to store some simple values (settings) for my app locally. I want the app to update these values from the net whenever internet connection is available (which will be stored on web... if data connection is not available, the app should use the local data... What approach is best?</p>
android
[4]
1,383,447
1,383,448
get total of dynamic clone rows
<p>I'm doing jquery based order sheet. As i searched similar question, there are hundreds of way to get total value of each TABLE ROW. But in my case, Total value fires strange way.</p> <p>Full source code is uploaded to jsfiddle.</p> <p><a href="http://jsfiddle.net/pR9Qd/" rel="nofollow">http://jsfiddle.net/pR9Qd/</a></p> <p>There are two main problem.</p> <ol> <li><p>Total value of .total_amount is strange. it's bigger than sum of each .amount</p></li> <li><p>When i delete some rows, the .total_amount won't changed.</p></li> </ol> <p>Thanks in advance.</p>
jquery
[5]
5,855,519
5,855,520
Which collection structure I should use for parametrical grouping ordering in c#?
<p>I have various windows forms applications that contain various controls that build up custom "group by" and "where" clauses for my class methods.</p> <p>I am thinking to pass a collection structure of some kind in order for the methods to be able to build the group by's and the where clauses. </p> <p>Let's say a list containing the field and the value for the group by or where.</p> <p>Am I going to the right direction?</p> <p>Update:</p> <p>I dont have code yet but let me try to explain better:</p> <ol> <li>We have a form with 10 dropdownlists and a checkmark beside them.</li> <li>Also we have adatagrid on the form.</li> <li><p>Every dropdownlist corresponds to a field in a table.</p> <ul> <li><p>If a dropdownlist has its checkbox checked means that it must be part of the group by clause in the select statement.</p></li> <li><p>The value of the dropdownlist must be part of the where clause.</p></li> </ul></li> </ol> <p>*<strong>note: *</strong> Another application could have different numbers of dropdownboxes and different corresponding fields.</p> <p>I want to create a common method that will retrieve data with user selectable group by and where clauses.</p> <p>So what i think is to pass to the method 2 lists.</p> <ul> <li><p>One with (fieldname, value) for the where clauses</p></li> <li><p>And one with (fieldname) for the group by</p></li> </ul> <p>depending on the logic above...</p> <p>I hope this is more clear.</p>
c#
[0]
2,269,549
2,269,550
Check for Page Load
<p>I've got a set of radiobuttons on my page. When you select any one of them, I'm forcing a postback to the server.</p> <p>I default one of the radio buttons when the page initially loads. But then I do not want that default button to fire my jQuery script on the first page load because it causes an unecessary postback. Once the page loads, it's fine if later that radio button is selected, that it posts back, just not on page load.</p> <p>Is there a way to check for page load in jQuery? I looked around but it's not surfacing in my search yet.</p>
jquery
[5]
249,123
249,124
Undefined index & Invalid argument supplied for foreach()
<p>I am struggling with generating an output if none of the check boxes are selected from the code below.</p> <p>HTML - Form</p> <pre><code>&lt;label&gt;Item 1:&lt;/label&gt;&lt;input type="checkbox" name="selected[]" value="Item 1"/&gt; &lt;label&gt;Item 2:&lt;/label&gt;&lt;input type="checkbox" name="selected[]" value="Item 2"/&gt; &lt;label&gt;Item 3:&lt;/label&gt;&lt;input type="checkbox" name="selected[]" value="Item 3"/&gt; </code></pre> <p>PHP Code</p> <pre><code>&lt;?php foreach ($_REQUEST['selected'] as $key =&gt; $selected) { echo "$selected"; } ?&gt; </code></pre> <p>The code outputs the correct value when selected, but generates the "Undefined index: selected in..." &amp; "Invalid argument supplied for foreach():"</p> <p>Can anyone point me in the right direction? Thank you</p>
php
[2]
2,232,433
2,232,434
Delete unused argument names in function definition(coding standards).
<p>Herb Suttter C++ coding standards says, It is good practice to delete unused argument names in functions to write zero warning program.</p> <p>Example:</p> <pre><code>int increment(int number, int power=0){ return number++; } </code></pre> <p>should be</p> <pre><code>int increment(int number, int /*power*/=0){ return number++; } </code></pre> <p>If there is 'unused variable warning' to <code>power</code> argument. This works fine for programs (no compile errors), So new function definitions will be</p> <p><code>int increment(int number, int =0)</code></p> <p>So what does <code>int=0</code> mean to compiler?</p>
c++
[6]
5,418,980
5,418,981
how to check a folder already exists before extracting from zip file to a specific location?
<pre><code>$zipfile = 'zipfilename'; $extractpath= 'C:\extract'; $zip = new ZipArchive(); if ($zip-&gt;open($zipfile) !== TRUE) { die ("Could not open archive"); } // extract contents to destination directory $zip-&gt;extractTo($extractpath); </code></pre> <p>How to avoid overwriting a folder if it already exist?</p>
php
[2]
2,010,777
2,010,778
printing contents of 2d vector
<p>this is the code I am running:</p> <pre><code>std::vector&lt;std::vector&lt;double&gt;&gt; test; test.push_back(std::vector&lt;double&gt;(30)); std::vector&lt;std::vector&lt;double&gt; &gt;::iterator it=test.begin(), end=test.end(); while (it!=end) { std::vector&lt;double&gt;::iterator it1=it-&gt;first.begin(),end1=it-&gt;first.end(); while (it1!=end1) { std::copy(it1.begin(),it1.end(),std::ostream_iterator&lt;double&gt;(std::cout, " ")); ++it1; } ++it; } </code></pre> <p>this is the compilation error I get:</p> <pre><code>data.cpp:33:45: error: ‘class std::vector&lt;double&gt;’ has no member named ‘first’ data.cpp:33:68: error: ‘class std::vector&lt;double&gt;’ has no member named ‘first’ data.cpp:35:16: error: ‘class std::vector&lt;double&gt;::iterator’ has no member named ‘begin’ data.cpp:35:28: error: ‘class std::vector&lt;double&gt;::iterator’ has no member named ‘end’ data.cpp:35:34: error: ‘ostream_iterator’ is not a member of ‘std’ data.cpp:35:56: error: expected primary-expression before ‘double' </code></pre> <p>any suggestions on how to fix it so I can print the contents of test</p>
c++
[6]
4,244,497
4,244,498
how to set text in button with image in center - android?
<p>I have a button with inage in background and I set text for the button on the right of the image, how to set the text verticaly ??</p>
android
[4]
5,440,226
5,440,227
Python search folder and make a Dictionary
<p>I need to make a Dictionary out of some folder hierachy.</p> <p>I have a folder in /home/Desktop/songs --- inside there are Folder: "A" and another "B". Inside of folder A and B there are folder: "1" and "2"</p> <p>I want to get the FOLDERS inside "songs" and get the folders inside A and B . Then make a Dictionary with them. Like THIS:</p> <pre><code>A={'1','2'} B={'1','2'} </code></pre> <p>That way, If I update my folders the script gets updated.</p> <p>I started looking to something like this:</p> <pre><code>os.chdir('/home/Desktop/songs') letter = [d for d in os.listdir('.') if os.path.isdir(d)] print letter -----&gt; A,B </code></pre> <p>But I dont know how to append them in a dictionary.</p>
python
[7]
903,673
903,674
jquery Ellipse: How To Create Ellipse shape Gallery With jQuery
<p>This code is somewhat near to ellipse shape. I want my gallery shape to be arrange is ellipse shape like cloud carousel example. Right now i am using roundabout plugin shape tearDrop and below function used for tearDrop. I require similar function for ellipse shape.</p> <pre><code>tearDrop: function (a, b, c) { return { x: Math.sin(a + b), y: -Math.sin(a / 2 + c) + .35, z: (Math.cos(a + b) + 1) / 2, scale: Math.sin(a + Math.PI / 2 + b) / 2 + .5 } }; </code></pre>
jquery
[5]
5,359,453
5,359,454
passing arguments from one function to another in javascript
<p>I have date value </p> <pre><code> for(i=0;i&lt;data['before'].length;i++) { var day = data['before'][i]; var dte = new Date(day); </code></pre> <p>I am trying to display the dates as a link in a div dynamically from java script. On clicking the link I am passing dte as object to <code>date_click</code> function. </p> <pre><code>$('#before_dates').append('&lt;tr&gt;&lt;td&gt;&lt;a onclick="date_click('+dte+');" href="javascript:void(0)"&gt;'+dte.toDateString()+'&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'); </code></pre> <p>On clicking the link the </p> <pre><code>function date_click(date){ alert("Hi..."+dte); } </code></pre> <p>I am getting following error:</p> <p><strong>Error: SyntaxError: missing ) after argument list<br> Source Code: date_click(Fri Aug 31 2012 00:00:00 GMT+0100 (IST));</strong></p> <p>I know its small error, but I could not figure a way to do that. Any help would be great.</p> <p>Thank You</p>
javascript
[3]
2,446,102
2,446,103
click on div using jquery error
<p>I have this <code>html</code>:</p> <pre><code>&lt;div class="divHolder"&gt; &lt;a href="./"&gt;&lt;img src="./images/image6.jpg"/&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="divHolder"&gt; &lt;a href="./IT.aspx"&gt;&lt;img src="./images/image7.jpg"/&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>In <code>javascript</code> I have:</p> <pre><code>$('.divHolder').click(function () { var link = $(this).find("a").attr("href"); if (link != null) { location.href = link; } }); </code></pre> <p>However, every time I click on a div, the href of the div is always the last one: for example in this case is: IT.aspx.</p> <p>What did I do wrong? could you please help?</p> <p>Thanks in advance.</p>
jquery
[5]
5,811,887
5,811,888
how can i replace json string?
<p>i want to replace particular data's in json string </p>
iphone
[8]
3,624,357
3,624,358
loading image once file submit clicked
<p>I allow registered users to submit an image to the server. Problem here is, if image's size is too large or if user's internet connection is slow (many people still use dial up here) it take a while before its submitted. And some users keep clicking submit button while the image is in loading process. At one website, I saw that once user click on file submit, form disappears and loading image appears. How can I do that with jquery?</p> <pre><code>&lt;form method="POST" ENCtype="multipart/form-data" action="imageupload.asp?Process=Add"&gt; &lt;p align="center"&gt;&lt;b&gt;--- Upload Image ---&lt;/b&gt;&lt;br&gt; &lt;input type="FILE" size="23" name="FILE"&gt; &lt;input type=submit value="Upload"&gt; &lt;/p&gt; &lt;/form&gt; </code></pre>
jquery
[5]
2,283,217
2,283,218
python - Why can extend modify a value without a global designation?
<pre><code>&gt;&gt;&gt; x = [] &gt;&gt;&gt; y = [1,2,3] &gt;&gt;&gt; def func1(L): ... x+=L ... &gt;&gt;&gt; def func2(L): ... x.extend(L) ... &gt;&gt;&gt; func1(y) Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "&lt;stdin&gt;", line 2, in func1 UnboundLocalError: local variable 'x' referenced before assignment &gt;&gt;&gt; func2(y) &gt;&gt;&gt; x [1, 2, 3] </code></pre> <p>Why can the list extend() method alter the non-global variable, but the += operator cannot? From what I understand, as long as the function doesn't assign the variable, it can read it without the global designation. but in this case the function does set the value.</p>
python
[7]
1,776,135
1,776,136
How to put a while loop in a variable?
<p>Well, it aren't more then the code actually!</p> <pre><code>$toq = mysql_query("SELECT * FROM users") or die(mysql_error()); $to = while($row = mysql_fetch_array($toq)) { echo "".$row['mail'].", "; }; echo $to; </code></pre>
php
[2]
1,442,438
1,442,439
jQuery blur event except when clicking a particular div
<p>This is my code:</p> <pre><code> $("#newGenreTxt").blur(function () { $("#txtAddGenreContainer").slideUp(); }); </code></pre> <p>I want to hide the text box if it loses its focus, but the problem is that I want to hide it if a user clicks anywhere but my button: </p> <pre><code>$("#addGenreFinal").click(function () {}); </code></pre> <p>So If user clicks the addGenreFinal nothing happens and if it's something else hide the textbox. </p>
jquery
[5]
6,008,529
6,008,530
jQuery - How to show/hide text box based on selected drop down
<p>Sorry if this is extremely obvious, but I have looked and looked for a solution but haven't found anything. I'm very new to jQuery, so even looking for what I want to do has been hard.</p> <p>I have a page with a bunch of fields and drop down boxes that are populated from a database. So each drop down has the correct item (the one stored in the database) selected when the page loads. When that option is "Other" I want my Other text box to show up. </p> <p>So, the question is; how do I show/hide that text box based on the selected drop down item when the page loads? Everything I have been able to find in my research has been related to the drop down menu changing. This works fine for one of the other pages I have. I don't want to have to reselect "Other" (triggering the change event).</p> <p>Thanks</p>
jquery
[5]
2,372,409
2,372,410
How can I get the next month End Date from the given Date
<p>I am implementing a code to find quarter start date and End date every thing was implemented fine but if user enters a date like <code>2011,2,1</code> I would like to get the <code>quarter</code> end date based on this date </p> <pre><code>DateTime dtTempStartDate = new DateTime(2011, 2, 1); var qrtrDate = DateTime.ParseExact(dtTempStartDate.ToString("MM-dd-yyyy"), "MM-dd-yyyy", System.Globalization.CultureInfo.InvariantCulture); var dtMnthEnd = qrtrDate.AddMonths(1);` </code></pre> <p>should I add <code>days</code> or <code>add milliseconds</code> can some one help me...</p>
c#
[0]
4,525,448
4,525,449
Best way to generate a consecutive id in Python
<p>Given a class that has an attribute <code>self.id</code> I need to populate that attribute with a counter starting at 0 and all objects of that class need a unique id during a single run of the program. What is the best/ most pythonic way of doing this? Currently I use</p> <pre><code>def _get_id(): id_ = 0 while True: yield id_ id_ += 1 get_id = _get_id() </code></pre> <p>which is defined outside the class and</p> <pre><code>self.id = get_id.next() </code></pre> <p>in the class' <code>__init__()</code>. Is there a better way to do this? Can the generator be included in the class?</p>
python
[7]
3,410,296
3,410,297
How the packagemanager gets the information in Android?
<p>I came to know that after booting device, all the system apps and market apps( if there) will be loaded right. These all things will be handled by PackageManager means which are the already installed apps, based on that it will load all the apps. But how the PackageManager gets the information about installed apps in the device. I want to know to know more about PackageMAnager. I have gone through developer.android.com, but I want to know more about this. Can anybody help me regarding on the same.</p> <p>Regards Abhilash</p>
android
[4]
4,363,533
4,363,534
The fastest way to learn C#?
<p>I am currently doing more "grunt work" at a software company that I work for, but was told that if I learned C# that I could start working more directly with the dev team. I was wondering what the best way to learn C# is. I have some experience with JavaScript and understand most of the basic programming concepts, but that is the extent of my knowledge.</p>
c#
[0]
5,667,519
5,667,520
Assigning value to allocated char array fails
<p>I simply allocate some memory for a character and wanna do then some pointer arithmetic. In this case I wanna write '\x0a' to byte 32 as follows:</p> <pre><code>#define HDR_SIZE 32 int size = 52; unsigned char *readXPacket = (unsigned char *) malloc (size * sizeof (unsigned char)); *readXPacket + HDR_SIZE = '\x0a'; </code></pre> <p>When I try doing that I get the following error message: non-value in assignment. Anyone an idea what is wrong here?</p> <p>Thanks</p>
c++
[6]
4,689,556
4,689,557
EditText without auto-correction, etc
<p>My EditText needs to accept input consisting of partial words, names, etc. At least on my HTC Desire, this is difficult since the keyboard wants to suggest and/or correct some entries (e.g., changes "gor" to "for"). I tried setting textNoSuggestions on the view, but that doesn't fix it.</p> <p>Any simple solution to this?</p>
android
[4]
4,267,367
4,267,368
Txt file input error Java
<p>I'm getting the error </p> <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "scores.txt" at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222) at java.lang.Double.parseDouble(Double.java:510) at ExamAverage.main(ExamAverage.java:30) C:\Users\Peter\AppData\Local\Temp\codecomp5461808896109186034.xml:312: Java returned: 1 </code></pre> <p>for my code listed below what does this error mean? I'm trying to go line by line from a given text file path and output it in a certain format.</p> <pre><code> import java.io.FileReader; import java.io.FileNotFoundException; import java.util.Scanner; import java.io.PrintWriter; public class ExamAverage { public static void main(String[] args) throws FileNotFoundException { String inputFileName = "scores.txt"; String outputFileName = "examScoreAverage.txt"; Scanner console = new Scanner(System.in); Scanner in = new Scanner(inputFileName); PrintWriter out = new PrintWriter(outputFileName); int TestNumber = 1; double totalPoints = 0; double avg = 0; double test = 0; while (in.hasNextLine()) { String line = in.nextLine(); test = Double.parseDouble(line); out.println("Score" + TestNumber + " : " + test); totalPoints += test; TestNumber++; } avg = totalPoints/TestNumber; out.println("Number of scores read: " + TestNumber ); out.println("Average Score " + avg ); in.close(); out.close(); </code></pre> <p>} }</p>
java
[1]
2,318,867
2,318,868
iphone+string operation
<p>i am having an string like bellow:</p> <blockquote> <p>J B Tower, Drive In, Ahmedabad, &amp;# 2327; &amp;# 2369; &amp;# 2332; &amp;# 2352 ;&amp;# 2366 ;&amp;# 2340 ;<br> 380054 (Kabir Restaurant),</p> </blockquote> <p>Now i want to remove this --</p> <blockquote> <p>&amp;# 2327 ;&amp;# 2369 ;&amp;# 2332 ;&amp;# 2352 ;&amp;# 2366 ;&amp;# 2340 ; </p> </blockquote> <p>i had used this operation:-</p> <pre><code>NSString *substring = nil; NSRange newlineRange = [lblAddress.text rangeOfString:@"&amp;#"]; if(newlineRange.location != NSNotFound) { substring = [TargetString substringFromIndex:newlineRange.location]; //[substring stringByReplacingOccurrencesOfString:substring withString:@""]; TargetString=[TargetString stringByReplacingOccurrencesOfString:substring withString:@""]; } </code></pre> <p>As a result i got the TargetString===>J B Tower, Drive In, Ahmedabad, substring===>&amp;# 2327 ;&amp;# 2369 ;&amp;# 2332 ;&amp;# 2352 ;&amp;# 2366 ;&amp;# 2340 ; 380054 (Kabir Restaurant),</p> <p>But i want the string as====> J B Tower, Drive In, Ahmedabad,380054 (Kabir Restaurant),</p> <p>Please help me.</p>
iphone
[8]
3,350,028
3,350,029
how to determine the Class inside a Collection in Java?
<p>How can I tell what type of class is inside a Collection? I need to handle simple data types differently than complex types and therefore I must know the contained class. At the moment, I have to iterate through the collection to find out the class which doesn't sound right. This <a href="http://stackoverflow.com/questions/2651632/how-to-check-if-an-object-is-a-collection-type-in-java/2651654#2651654">link</a> was quite helpful but didn't fully address my issue. Basically, here are the questions: 1. How to determine the class inside the collection? 2. how can I tell if the object is a java wrapper class (Integer, String, Date, etc..) or a proprietary class (Student, Vehicle, etc...).</p> <p>Thank you Jabawaba</p> <pre><code>entity = new SomeObject(); Class entityClass = entity.getClass(); for (Method method : entityClass.getDeclaredMethods()) { Class&lt;?&gt; returnType = method.getReturnType(); if (returnType != null) { if (returnType.isPrimitive() || (returnType.getName().startsWith("java.lang.")) || (returnType == java.util.Date.class)) { // handling primitive and wrapper classes handleScalar(method); } else if (Collection.class.isAssignableFrom(returnType)) { Collection collection = (Collection) method.invoke(entity); if (collection == null || collection.isEmpty()) { continue; } for (Object value : collection) { if (value.getClass().getName().startsWith("java.lang.") || (value.getClass() == java.util.Date.class)) { handleSimpleVector(method); // no need to go through all the simple values continue; } else { // Each 'value' is itself a complex object. handleComplexObject(method); } } } else if (&lt;return-type-is-an-Array&gt;){ // do something similar as the above. } } } </code></pre>
java
[1]
2,775,384
2,775,385
What is the most efficient way to save game status in Android?
<p>I have a game app that save game status in the onPause() function of the game board activity.</p> <p>That seems very wasteful, because the user might be briefly switching to another app and return to play later. But if they never return, my app could be garbage collected and the status gets lost, so I save it just in case. </p> <p>I think status gets saved many times for every time it gets read. Is there a better way to lazily save the status when I know they are leaving the app? </p> <p>Does anybody know of a guaranteed callback that I could use? e.g. if I move the save status code to onDestroy(), it might never get called. </p> <p>Is there a way to leverage onSaveInstanceState() to help?</p> <p>Thanks</p>
android
[4]
3,652,219
3,652,220
Using the Drawline function to create a "pencil stroke"
<p>Ok so I'm making a game and I'm having a problem, that Is I don't have anyway of going about this, Making a line that looks like a pencil stroke. I start out with </p> <pre><code>drawLine(float startX, float startY, float stopX,float stopY, Paint paint); </code></pre> <p>of course and then I I use all the stuff involved with <code>Paint()</code> and the paint class so I set the color and the thickness in the paint...</p> <p>So What I'm wondering is how do I give my paint a texture that resembles a pencil stroke. is there a way I can make the paint look like a repeated bitmap, what are my options with this.</p> <p>Thanks, Brian</p> <p>p.s. if you want more detail I can expound on it a little more like give you the exact code that I'm using and explain more about my game.... also here are links to the paint class and the canvas class if you need them.</p> <p><a href="http://developer.android.com/reference/android/graphics/Paint.html" rel="nofollow">http://developer.android.com/reference/android/graphics/Paint.html</a></p> <p><a href="http://developer.android.com/reference/android/graphics/Canvas.html" rel="nofollow">http://developer.android.com/reference/android/graphics/Canvas.html</a></p> <p>Also</p> <pre><code>void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width, int height, boolean hasAlpha, Paint paint) </code></pre> <p>Treat the specified array of colors as a bitmap, and draw it." Can I use that I'm really not sure what its saying. </p> <p>please even if you have a little information please reply.</p>
android
[4]
4,235,265
4,235,266
How to find the center point on the page with JavaScript?
<p>How can I find the (x,y) point of the center of the viewable area of the browser?</p> <p>I am using jQuery, if there are any good jQuery helper functions for this.</p>
javascript
[3]
4,088,075
4,088,076
how to compare the Java Byte[] array?
<pre><code>public class ByteArr { public static void main(String[] args){ Byte[] a = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; Byte[] b = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; byte[] aa = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; byte[] bb = {(byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00}; System.out.println(a); System.out.println(b); System.out.println(a == b); System.out.println(a.equals(b)); System.out.println(aa); System.out.println(bb); System.out.println(aa == bb); System.out.println(aa.equals(bb)); } } </code></pre> <p>I do not know why all of them print false</p> <p>when i run "java ByteArray" the answer is "false false false false"</p> <p>I think the a[] equals b[] but the JVM tell me i am wrong, why??</p>
java
[1]
3,596,496
3,596,497
Python Sort Collections.DefaultDict in Descending order
<p>I have this bit of code:</p> <pre><code> visits = defaultdict(int) for t in tweetsSQL: visits[t.user.from_user] += 1 </code></pre> <p>I looked at some examples online that used the sorted method like so:</p> <p><code>sorted(visits.iteritems, key=operator.itemgetter(1), reverse=True)</code></p> <p>but it is giving me:</p> <p><code>"TypeError: 'builtin_function_or_method' object is not iterable"</code></p> <p>I am not sure why.</p>
python
[7]
3,098,050
3,098,051
Where should I store images if the user doesn't have an SD card?
<p>There are a few G1 users reporting that my app won't display images. I can only imagine this is because they don't have an SD card.</p> <p>My app is heavy on images. Is it appropriate to store images on the internal memory? I don't even know if there'd be enough space.</p>
android
[4]
2,382,358
2,382,359
Could be a bug, after I send and SMS the LAST_TIME_CONTACTED field is not updated
<p>Contacts have a field called LAST_TIME_CONTACTED, it is updated with the time after you make a call.</p> <p>But as I noticed when I send an SMS by the inbuilt Messaging app, it does not update. Could this be a bug?</p>
android
[4]
5,577,344
5,577,345
Sms Inbox - ListView
<p>Hello i am trying to create aplication witch shows me sms in ListView but i dont know how i can fill listview by datas.I tried do that but it doesn't work.Can you check my source code and give me some resolution? Thanks</p> <p>Source code:</p> <pre><code>import java.util.ArrayList; import java.util.List; import android.app.Activity; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; public class Mynewtwo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView list = (ListView) findViewById(R.id.list); List&lt;String&gt; msgList = getSMS(); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,R.layout.main, msgList); list.setAdapter(adapter); } public List&lt;String&gt; getSMS(){ List&lt;String&gt; sms = new ArrayList&lt;String&gt;(); Uri uriSMSURI = Uri.parse("content://sms/inbox"); Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null); while (cur.moveToNext()) { String address = cur.getString(cur.getColumnIndex("address")); String body = cur.getString(cur.getColumnIndexOrThrow("body")); sms.add("Number: " + address + " .Message: " + body); } return sms; } </code></pre> <p>}</p> <p>XML : </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout android:id="@+id/widget30" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;ListView android:id="@+id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
3,454,480
3,454,481
Widget displayed on app : https://play.google.com/store/apps/details?id=ds.cpuoverlay&hl=en
<p>The app Cool Tool (https://play.google.com/store/apps/details?id=ds.cpuoverlay&amp;hl=en) displays cpu information as an overlay on top of home screen. I have verified the panel is not a customised toast.</p> <p>I did a lot of research but unable to sort out what kind of widget it is.</p> <p>Can someone please help me in identifying the widget being used here.</p> <p>Thanks in advance.</p>
android
[4]
4,451,795
4,451,796
Getting a value from an ArrayList java
<p>I am trying to get a value from with in an <code>ArrayList</code>. I have two classes, the main and a Car class. here is the code:</p> <pre><code> public class CarOrders { public static void main (String [] args){ Car toyota= new Car("Toyota", "$10000", "300"+ "2003"); Car nissan= new Car("Nissan", "$22000", "300"+ "2011"); Car ford= new Car("Ford", "$15000", "350"+ "2010"); ArrayList&lt;Car&gt; cars = new ArrayList&lt;Car&gt;(); cars.add(toyota); cars.add(nissan); cars.add(ford); } public static void processCar(ArrayList&lt;Car&gt; cars){ int totalAmount=0; for (int i=0; i&lt;cars.size(); i++){ cars.get(i).computeCars (); totalAmount+= ?? // in need to add the computed values of totalprice from the Car class? } System.out.println (totalAmount); } } class Car { public Car (String name, int price, int, tax, int year) { constructor....... } public void computeCars () { int totalprice= price+tax; System.out.println (name + "\t" +totalprice+"\t"+year ); } } </code></pre> <p>How would i be able to calculate <code>totalAmount</code> in the <code>processCar()</code> method where <code>totalAmount=totalAmount+totalPrice</code> from the <code>computCar()</code> method in the Car Class?</p>
java
[1]
4,425,479
4,425,480
Canceling a Process started via System.Diagnostics.Process.Start()
<p>I am writing an application where I have a Process running in a <code>BackgroundWorker</code>. I would like to support cancellation from the user interface, but I don't see an easy way to do this.</p> <p>The <code>Process</code> is actually a fairly long running command line exe. The output is getting redirected asynchronously via the <code>Progress.OutputDataReceived</code> event and is being used to report progress to the GUI.</p> <pre><code>private void worker_DoWork(object sender, DoWorkEventArgs e) { using (var process = new Process()) { //... process.Start() //... process.WaitForExit(); } } private void CancelWorker() { worker.CancelAsync(); // where to actually listen for the cancellation??? } </code></pre> <p>There doesn't appear to be a way to have the process "listen" for any input from the main thread aside from the <code>StandardInput</code>, but that won't work unless the app itself will response to a specific input to abort.</p> <p>Is there a way to cancel a process based on a cancel request from the main thread?</p> <p>For the purposes of my of the EXE running in the process, I can just call <code>Process.Close()</code> to exit without any side-effects, but the <code>Process</code> object is only known to the <code>worker_DoWork()</code> method, so I'll need to keep track of the <code>Process</code> instance for cancellation purposes... that's why I'm hoping there might be a better way.</p> <p>(if it matters, I am targeting .NET 3.5 for compatibility issues.)</p>
c#
[0]
1,223,752
1,223,753
Offset top does not return the expected value
<pre><code>$(window).scroll(function(e){ if($(this).scrollTop()&gt;=400) $('#jtop').show('slow'); if($(this).scrollTop()&lt;400) if($('#jtop').width()) $('#jtop').hide('slow'); }); </code></pre> <p>I'm using the function to determine if someone scrolls down over 400 an toggling an image and it's working fine but when I try to get notified if someone reaches my footer's top position it doesn't return the expected value. I used offset().top but it alerts me when I scroll down to bottom 0. I just want to know when user is entering and leaving my footer. Hope someone will help me. Thanks in advance. If you want to see it in action then here is the link <a href="http://heera.it" rel="nofollow">heera.it</a></p> <p>Non working code</p> <pre><code> var ftop=$('#footer').offset().top; $(window).scroll(function(e){ if($(this).scrollTop()&gt;=400) { $('#jtop').show('slow'); } if($(this).scrollTop()&lt;400) { if($('#jtop').width()) $('#jtop').hide('slow'); } if($(this).scrollTop()&gt;=ftop) console.log('true'); if($(this).scrollTop()&lt;ftop) console.log('false'); }); </code></pre>
jquery
[5]
3,861,352
3,861,353
How can I change an input to be disabled using jQuery?
<p>I have an input looking like this:</p> <pre><code>&lt;input type="text" value="1.1" size="5" name="Topic" id="Topic"&gt; </code></pre> <p>What's the best way to change it so this input is disabled using jQuery?</p> <p><strong>Update</strong></p> <p>Sorry I forgot to ask but is there also a way that I can make it read only. The original answers are great but this is just one more thing I need to be able to do.</p>
jquery
[5]
1,854,450
1,854,451
error when creating an object in php
<p>hey guys i just installed wamp server on my computer , but when i do some php on it i have an error when i creat just a simple new object here is the code </p> <pre><code> &lt;?php class foo { function affichage () { echo 'xxxx'; } $display = new foo(); $display -&gt; affichage(); } ?&gt; </code></pre> <p>and the error is</p> <blockquote> <p>( ! ) SCREAM: Error suppression ignored for<br/> ( ! ) Parse error: syntax error, unexpected '$display' (T_VARIABLE), expecting function (T_FUNCTION) in C:\wamp\www\new 4.php on line 6.</p> </blockquote>
php
[2]
3,922,568
3,922,569
Compiling time is high c++
<p>I am writing a code in c++. Compared to my friends the compiling time high. what could be the reason for this? Its taking around 4 seconds. But for my friends its getting compiled immediately. </p>
c++
[6]
4,051,055
4,051,056
jTruncate / live()
<p>I been looking at <a href="http://blog.jeremymartin.name/2008/02/jtruncate-in-action.html" rel="nofollow">http://blog.jeremymartin.name/2008/02/jtruncate-in-action.html</a>. It doesn't seem to work for html added to the page after page load.</p> <p>Does anyone know how that would work or if there is a better solution? </p>
jquery
[5]
1,491,444
1,491,445
how to close dialog in jquery automatically on some condition
<p>I have some group of check box of which user has to select atleast one and proceed further activity. when the user clicks on a button i check the above functionality if the user has selected one than allow to open a dialog else alert the user to select minimum one and don't open the Dialog.</p> <p>following is the function to open a dialog.</p> <pre><code>function openLoadInfo(){ global.getElementById("diaLoad").value=""; global.getElementById("diaReadydate").value=""; global.getElementById("diaCanceldate").value=""; $("#loadinfo") .dialog( { modal: true, draggable: false, closeOnEscape: true, title: "Load # info", resizable: false, width: 300, // open: function() { // // }, buttons: { Ok: function () { $(this).dialog('close'); } } }); </code></pre> <p>through the following script i am able to get value if check box is selected .</p> <pre><code>$('input:checked').each(function() { alert("Value : "+$(this).val()); }); </code></pre> <p>if the above code fails than i have to close the dialog and prompt the user to select at least one check box.</p> <p>Please help me to get this.</p> <p>Regards</p> <p>}</p>
jquery
[5]
3,048,181
3,048,182
file not found in webview in android
<p>Hi friends I have placed my static web application in asset folder.my static web application have lot of folder with files adn placed in asset folder .I am calling html from another html with sub folder .I am getting file not found can anybody tell what is problem? I post my code below</p> <pre><code>wv=(WebView)findViewById(R.id.webView); //wv.loadDataWithBaseURL("file:///android_asset/Opana_Changes/html/_assets/asset_001/index.html","","html"); try { InputStream is=getAssets().open("Opana_Changes/index.html"); BufferedReader br=new BufferedReader(new InputStreamReader(is)); String line = null; while ((line = br.readLine()) != null) { html=html+line; } br.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } wv.loadDataWithBaseURL("file:///android_asset/Opana_Changes/",html,"text/html", "UTF-8",null); wv.getSettings().setJavaScriptEnabled(true); } </code></pre>
android
[4]
2,693,121
2,693,122
How to define C++ preprocessor variable in Makefile
<p>I have a C++ preprocessor written like this:</p> <pre><code> #ifdef cpp_variable //x+y; #endif </code></pre> <p>please anyone tell me how to define this in Makefile.</p> <p>thanks!</p>
c++
[6]
3,892,102
3,892,103
I have two Array i want add two array into One.But How..?
<p>My question is if i have an array....<br> <code>int[] one;</code> and another array. <code>int[] two;</code><br> So i want to add both the array into a single array... <strong>in easyest way</strong> that means..!<br> <code>int[] combine=// what i do hear</code></p>
java
[1]