Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
4,565,440
4,565,441
Can the as keyword replace try/catch block?
<p>If you are doing something trivial that if succeeds its a bonus but can fail and you don't want to use a try/catch for overhead costs, can the <code>as</code> keyword and test for null semantically replace the try/catch?</p> <pre><code>var item = new CreateItem(filename) as Item; if (item != null) { ItemList.Add(item); } </code></pre>
c#
[0]
1,806,674
1,806,675
How do you create a link from data retrieved from the database
<p>I have products stored in a database. These items have ID, NAME, QUANTITY, and STOCK_NUMBER fields. I want to make an <code>href</code> for all of the data in the database:</p> <pre><code>$Result=mysql_query("SELECT * FROM Products"); while($row=mysql_fetch_array($Result)){ href ..... } </code></pre> <p>I want the result like this </p> <p><code>item_id=1&amp;name_1_tv&amp;quantity_1=2&amp;stock_number_1=1411 &amp;item_id=2&amp;name_2_mobile&amp;quantity_2=5&amp;stock_number_2=5894 &amp;item_id=3&amp;name_3_radio&amp;quantity_3=2&amp;stock_number_3=18541 &amp;item_id=4&amp;name_4_tv&amp;quantity_4=2&amp;stock_number_4=1025 &amp;item_id=5&amp;name_5_computer&amp;quantity_5=1&amp;stock_number_5=1455 &amp;item_id=6&amp;name_6_cd&amp;quantity_6=2&amp;stock_number_6=5888</code></p> <p>all these under the link</p>
php
[2]
3,323,712
3,323,713
$("article").filter*(while).each(repeat_me) - loop while filter matches
<p>I'd like to have a custom function repeatedly called as long as a custom filter function matches.</p> <p>use case:</p> <pre><code>// filter function overflow() { return this.clientHeight &lt; this.scrollHeight; } // apply $("article").filter(overflow).css_calc({fontSize: -1}); </code></pre> <p>Is there a generic way in jQuery to call the subsequent function <strong><em>as long as</em></strong> the filter matches? Or wasn't there something to call the <em>preceeding</em> function multiple times? <em>Any way</em> to loop in a jQuery function chain?</p> <p>Or otherwise; how would you write something like an <code>.each_while()</code> combo that does the usual .each() but also performs a while() on each element as long as said .filter() matches.</p>
jquery
[5]
5,019,207
5,019,208
How To Retrieve data from Bundle data in target activity Passed from source activity
<p>first activity:</p> <pre><code> String s="create_newfile"; Intent i = new Intent("com.monster.android.Showfile"); Bundle extras = new Bundle(); extras.putString("task",s); i.putExtras(extras); startActivity(i); </code></pre> <p>second activity:</p> <pre><code> Bundle extras = this.getIntent().getExtras(); String s = extras.getString("task"); if (extras!=null &amp;&amp; s=="create_newfile") { setContentView(R.layout.edit); } </code></pre> <p>its showing error!!! </p>
android
[4]
4,797,839
4,797,840
Passing an argument to a decorator inside a list accessing self vars?
<p>How can I modify a <code>self</code> variable with a <code>decorator</code>?</p> <p>Ex.</p> <pre><code>class Foo: def __init__(self,a): self.a = a self.li = [] def afunction(self): pass </code></pre> <p>I want to add the function object <code>afunction</code> to the list <code>self.li</code> so I can call it in a list. Ex. Have a list of functions defined by the class. How would I do that?</p> <p>Thanks</p>
python
[7]
4,137,528
4,137,529
javascript calling console.log function with variable length
<p>i want to call console.log function with variable length argument</p> <pre><code>function debug_anything() { var x = arguments; var p = 'DEBUG from ' + (new Error).stack.split("\n")[2]; switch(x.length) { case 0: console.log(p); break; case 1: console.log(p,x[0]); break; case 2: console.log(p,x[0],x[1]); break; case 3: console.log(p,x[0],x[1],x[2]); break; case 4: console.log(p,x[0],x[1],x[2],x[3]); break; // so on.. } } </code></pre> <p>is there any (shorter) other way, note that i do not want this solution (since other methods from the x object (Argument or array) would be outputted.</p> <pre><code>console.log(p,x); </code></pre>
javascript
[3]
953,557
953,558
Tinynav.js isn't responsive in my layout
<p>I put this script tinynav.viljamis.com/ in my layout and after that my selective menu has static width. But tinynav should be responsive. My layout here jsfiddle.net/8BNFy But jsfiddle dont show responsive layout. My site <a href="http://b.pusku.com/" rel="nofollow">http://b.pusku.com/</a> I appreciate any help. Thank you!</p>
javascript
[3]
962,598
962,599
Downloading files from webservice to specific location on android device
<p>IDE Eclipse Using emulators</p> <p>I am downloading files from a webservice. I have no problem saving the files to the sdcard. This can then be accessed via a filemanager. </p> <p>However, if there is no sdcard available I would like to save the files to 'Downloads' on internal storage. I can't seem to get the files to download to 'Downloads' as it would were you downloading from a browser. </p> <p>I can however manage to save the files in the application directory on internal storage. Eg data/data/com.example.appname/files/.</p> <p>The problem is this can only be access via the application. </p> <p>I need the files to be available to the user to view/open after downloaded.</p> <p>Is this possible? Or will the user have to have an SDCARD?</p>
android
[4]
1,960,300
1,960,301
ASP.NET Adding Multiple footers rows to Gridview
<p>i.e at the moment I am adding a footer row to my gridview as follows</p> <pre><code> Protected Sub gvShoppingCart_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvShoppingCart.RowDataBound ' If we are binding the footer row, let's add in our total If e.Row.RowType = DataControlRowType.Footer Then e.Row.Cells(5).Text = "&lt;strong&gt;Total Cost:&lt;/strong&gt;" e.Row.Cells(6).Text = ShoppingCart.Instance.GetSubTotal().ToString("C") End If End Sub </code></pre> <p>How can I add more footer rows i.e. Total Discount, Total Saved etc likewise as above</p>
asp.net
[9]
86,647
86,648
Cannot exclude element from string
<p>I have a paragraph of text and I need to wrap each group of words (comma separated) in a span tag so I can animate them when hovered on... easy enough. I need to do this to everything except the "a#close". I have tried using the ":not" selector but can't seem to get it to work as desired.</p> <p>HTML</p> <pre><code>&lt;div id="stuff"&gt;&lt;p&gt;Words Words Words, Words Words Words, Words Words Words, Words Words Words, Words Words Words, Words Words Words, Words Words Words, &lt;a href="#" id="close"&gt;Close&lt;/a&gt;&lt;/p&gt;&lt;/div&gt; </code></pre> <p>jQuery</p> <pre><code>$(function() { $('#stuff:not(a#close)').each(function(){ var text = $(this).html().split(','), len = text.length, result = []; for( var i = 0; i &lt; len; i++ ) { result[i] = '&lt;span&gt;' + text[i] + '&lt;/span&gt;'; } $(this).html(result.join(' ')); }); </code></pre> <p>I can make it work as desired by changing the html mark up and putting the a#close in a p tag with a different ID, but would like to understand the :not selector better, that is if it is the right one to use. thank you</p>
jquery
[5]
2,853,076
2,853,077
Adding properties file to java classpath at runtime
<p>My code generates few properties file at runtime and these will be used by other portion of code.But the other portion of code expects that those properties files in the classpath.</p> <p>Is there any way to generate the files in classpath at runtime.</p>
java
[1]
70,551
70,552
Iphone and iTouch problem
<p>i have created an app that is working fine on iTouch but is creating problems on iPhone. Is there is any difference in iPhone and iTouch that can create problems in running an app. the things that has to be taken care while coding for both.</p>
iphone
[8]
2,425,193
2,425,194
java.lang.SecurityException: Not allowed to bind to service Intent
<p>I implemented reverse geocoding inside GCMIntentService onMessage method. I got exception <strong>java.lang.SecurityException: Not allowed to bind to service Intent { act=com.android.location.service.GeocodeProvider pkg=com.google.android.location }</strong> after application running long time. If i restart device it works again fine. Also i seen android open isssue <strong><a href="https://code.google.com/p/android/issues/detail?id=39635" rel="nofollow">Reconnection with Geocoder services not possible when Network Location Service is killed.</a></strong>. Is it any work around to solve this issue?</p> <p>Note : I am running Application in Samsung galaxy Tab 2(Android 4.1.1)</p>
android
[4]
4,379,391
4,379,392
Use MultiSelectListPreference ofr Android PreferenceScreen
<p>I'm use Android ICS SDK and I would like to do a PreferenceScreen which use MultiSelectListPreference (avalaible for API Level 11&amp;+.</p> <p>I just want to persist the value in SharedPref, refresh the summary of the MultiSelectListPreference and refresh the dialog list.</p> <p>Here's my code :</p> <pre><code>Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.newgame); mMultiCharacters.setOnPreferenceChangeListener(this); } @Override public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor settingsEditor = settings.edit(); settingsEditor.putStringSet( preference.getKey() , (Set&lt;String&gt;) newValue); settingsEditor.commit(); //display new summary initChar(); return false; } </code></pre> <p>XML part :</p> <pre><code> &lt;MultiSelectListPreference android:entries="@array/characterNames" android:entryValues="@array/characterNames" android:key="pref_characters" android:persistent="true" android:title="Chars :" /&gt; </code></pre> <p>The behavior is quite strange. The dialog list doesn't refresh… some ideas ? Thanks!</p>
android
[4]
1,949,894
1,949,895
How to understand that the app is being closed with the TaskManager?
<p>Is there a way to catch this kind of event?</p> <p>UPD:</p> <p>I want to collect information about how often do person closes my app this way. It's going to be a joke: when user closes the app with task killer very often - he gets special behaviour.</p> <p>That's the minimum requirements.</p>
android
[4]
4,738,745
4,738,746
Lazy loading of images with graceful degradation (JavaScript)
<p>Consider a HTML page with a bunch of tags each with their own content. I want to transform each tag to a slide in a slideshow powered by JavaScript. Each tag can contain images and they should be lazy loaded in this slideshow. I don't want all images to load at once.</p> <p>On the other hand, users with no JavaScript enabled and search engines should just the see markup and all the images. How do I avoid images from loading when JavaScript is enabled, and how do I make sure images are loaded when no JavaScript is enabled?</p> <p>One way would be to replace all images with this format:</p> <pre><code>&lt;img src="" data-src="myimage.png"&gt; </code></pre> <p>The problem with that solution is there's no graceful degradation.</p> <p>Instead, I have to do:</p> <pre><code>&lt;img src="myimage.png"&gt; </code></pre> <p>The problem with that is that you can't prevent the browser from loading all of the images in the HTML page. I've tried to modify the HTML in several ways when the document is ready. For example, replace all src attributes in images with data-src, empty the entire body and so on.</p> <p>Do I really have to sacrifice graceful degradation?</p> <p>Thanks in advance.</p>
javascript
[3]
799,591
799,592
C++: Pointer to char array
<p>I can't cope with pointers. Could you have a look at my problem.</p> <p>A function is as follows:</p> <pre><code> char * string_to_char_array(string line, int size) { char *a = new char[size]; &lt;..........&gt; return a; } </code></pre> <p>I call it and get this:</p> <pre><code>string autor = "Wern"; char * a = string_to_char_array(autor, 20); </code></pre> <p>Then I can do this:</p> <pre><code>char Autor[20]; for (int i = 0; i &lt; 20; i++) { Autor[i] = a[i]; } for (int i = 0; i &lt; 20; i++) { cout &lt;&lt; Autor[i]; } </code></pre> <p>I suppose this clumsy but somehow I don't know how to make it easier. Will you be so kind as to give me a piece of advice?</p>
c++
[6]
3,726,086
3,726,087
exactly as contact list some up
<p>all i need to do is, when i launch my app,contacts of my iphone should come up.</p> <p>exaclty same as we see on contact.</p> <p>any suggestion,how can achieve it.</p> <p>regards shishir</p>
iphone
[8]
951,718
951,719
Restore SSL certificate override check
<p>I am writing a test to test a service I am deploying, to bypass the ssl cert check I implemented an ssl override using the snippet below:</p> <pre><code> public static void SSLValidationOverride() { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OnValidationCallback); } private static bool OnValidationCallback(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors errors) { if (cert.subject == MyCertSubject) return true; else return false; } </code></pre> <p>Now I have to call another webservice using ssl in the code and want to switch to default ssl check before calling that. What's the best way to do that. MS help says the default value of ServicePointManager.SecurityProtocol is null(http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.securityprotocol.aspx). Will setting it to null switch to default ssl validation and is there any other way to do this.</p>
c#
[0]
5,630,228
5,630,229
how to get the information from first spinner to second spinner in android?
<p>i have 2 spinners :</p> <p>FIRST SPINNER :</p> <pre><code> array_spinner=new String[3]; array_spinner[0]="Color"; array_spinner[1]="Model"; array_spinner[2]="Price"; Spinner s = (Spinner) findViewById(R.id.select); ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, array_spinner); s.setAdapter(adapter); SECOND SPINNER : array_color=new String[3]; array_color[0]="Black"; array_color[1]="Pink"; array_color[2]="Green"; array_model=new String[3]; array_model[0]="Ipod"; array_model[1]="mp3"; array_price=new String[3]; array_price[0]="1000-2000"; array_price[1]="3000-4000"; Spinner val=(Spinner)findViewById(R.id.select_val); ArrayAdapter adapter1 = new ArrayAdapter(this, android.R.layout.simple_spinner_item, array_color); val.setAdapter(adapter1); </code></pre> <p>When the user clicks Model in the First Spinner , immediately the Second Spinner should display the models which are in the array_model ... Please Help !!!!</p>
android
[4]
1,614,214
1,614,215
Adding event handler (with parameters) to element created using document.createElement
<p>In the function below I'm trying to create a dynamic element <em>(textArea)</em>. I'm trying to bind a function <em>(resize)</em> to the text area using <em>textArea.onclick = resize;</em> which works fine.</p> <p>What I'd like to do is pass a parameter to the resize function (either the generated id or, if possible, the textArea itself)</p> <pre><code> function addElement(elm, event) { var textArea = document.createElement('textarea'); var id = Math.random(); textArea.setAttribute('id', id) textArea.setAttribute('cols', 1); textArea.setAttribute('rows', 3); textArea.onclick = resize; elm.appendChild(textArea); } </code></pre> <p>if I say <em>textArea.onclick = resize(id);</em> then that just calls the function.</p> <p>How can i bind the function, and pass a parameter to it?</p>
javascript
[3]
4,682,779
4,682,780
I want to load a page content in a variable with .load and then alert it
<p>but below code doesnt work. submit.php: echo "Hi";</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#button").click(function(){ var input; input.load("submit.php"); alert(input); }); }); &lt;/script&gt; </code></pre>
jquery
[5]
509,738
509,739
C# Windows Services Alternative
<p>Could anyone please tell me whether there is any alternative to Windows Services? The reason for my question is that I find windows services hard to test as it requires it be installed first.</p> <p>Thank you.</p>
c#
[0]
157,604
157,605
Detect if Shift is pressed
<p>I have a situation on a phone field. On this field, the user can type the following phone numbers:</p> <p>(00)9999 9999 <br> (00)99999 9999 (in São Paulo Brasil) <br> and 1234*12 (Nextel Numbers) </p> <p>On the field phone I configure an onkeydown event that call this javascript function:</p> <pre><code>function validateKeyDownPhone(event) { var c = event.keyCode keychar=String.fromCharCode(c) valid = true /** * Excluding enter, backspace, etc. */ if (c &gt; 46 ) { if (keychar != null) { var re = new RegExp("^[0-9\*#\(\) ]+$") matched = keychar.match(re) valid = matched != null &amp;&amp; matched.length &gt; 0 } } event.returnValue = valid } </code></pre> <p>It works fine, but when the I press SHIFT + 5 results in %, for example. </p> <p>How can I identify if the shift key was pressed? </p>
javascript
[3]
3,307,660
3,307,661
How long does it take to become proficient in Java if you are new to programming?
<p>I am a 25-year-old who is new to programming. My ultimate goal is to get into mobile programming in the near future.</p> <ol> <li>About how long would it take a newbie such as myself to get up to speed with the Java language?</li> <li>Is Java a hard language for someone new to programming? If so, what alternatives should I look into?</li> </ol>
java
[1]
4,285,380
4,285,381
Android Twitpic Application -upload Images
<p>I am doing project on uploading Images and to share that in twitter , I have Oauth and Twitpick Key can anyone send some sample on this. I have checked Grepcode but not clear,I have to complete today can anyone guide me plz. </p> <p>Thanks in Advance</p>
android
[4]
3,182,509
3,182,510
I am getting a syntax error on line 42(4th last line) and I cant fix it can someone please help?
<pre><code>def main(): # This code reads in data.txt and loads it into an array # Array will be used to add friends, remove and list # when we quit, we'll overwrite original friends.txt with # contents print"Welcome to the program" print "Enter the correct number" print "Hockey fan 1, basketball fan 2, cricket fan 3,Numbers of favorite players-4" choice = input("Select an option") while choice!=3: if choice==1: addString = raw_input("Who is your favorite player??") print "I love Kessel" elif choice==2: remInt = raw_input("Do you think that the Cavaliers will continue ther loosing ways?") print "I think they can beat the Clippers" else: inFile = open('data.txt','r') listNumbers = [] for numbers in inFile: listNumbers.append(numbers) print numbers inFile.close() print "Cricket is a great sport" def quit(): Print "Quitting Goodbye!" if __name__ == '__main__': main() </code></pre>
python
[7]
1,216,831
1,216,832
timespan between now and past datetime
<p>I want to calculate how much time elapsed between a datetime and now in minutes. This is what I have:</p> <pre><code>TimeSpan SinceStatusChange = new TimeSpan(); SinceStatusChange = (double)(DateTime.Now.Date - StatusDateTime).TotalMinutes; </code></pre> <p>Basically, I'm looking to write this conditional statement:</p> <pre><code>if (SinceStatusChange is greater than 180 minutes) </code></pre> <p>How do I write the line "SinceStatusChange = " so I can later test if the value is greater than 180?</p> <p>Thanks.</p>
c#
[0]
3,896,654
3,896,655
Why is my UIViewController initializer never called?
<p>I made a view-based project from a fresh template. There's a UIViewController which is created with an XIB.</p> <p>In the implementation I uncommented that and added an NSLog. But this is never called:</p> <pre><code>// The designated initializer. Override to perform setup that is required before the view is loaded. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { // Custom initialization NSLog(@"nib"); } return self; } </code></pre> <p>since that is initialized from a nib / xib, that should be called for sure, right? however, it doesn't. I do get an NSLog message when I put that in viewDidLoad.</p>
iphone
[8]
1,919,511
1,919,512
display URL Name same as whatever Travels Package selected by user
<p>I am developing a Travels website in asp.ne. for that I need to display URL Name same as whatever Travels Package selected by user.</p> <p>What I have to do. I have to design a separate Form for each Travels Package. or i can do another way.</p> <p>Please give me your advise how to do this</p>
c#
[0]
2,213,440
2,213,441
PHP - Possible to call member function of object stored in an array?
<p>I'm new to PHP and spent some time searching for a similar question, but none seemed to quite answer it for me.</p> <p>I have an array of Objects (a class I created called StatusMessage) and I want to access a member function of each object in the array. I am able to do this using a foreach loop, but I only need to access the first 10 objects (they are sorted) so I am trying to use a for loop. When I make the member function calls, I get a fatal error about not being able to call member functions on non-objects. Do the StatusMessage objects in $statObjs need to be cast or something?</p> <p>Any suggestions?</p> <pre><code>function collectStatuses($statusesAPI){ $statusObjects = Array(); foreach($statusesAPI as $status) { //StatusMessage is a class I created array_push($statusObjects, new StatusMessage($status)); } return $statusObjects; } //$statutuses[data] was populated further up $statObjs = collectStatuses($statuses[data]); //This loop works, but prints all StatusMessage objects in $statObjs foreach ($statObjs as $value) { //getInteractions() and getMessages() are both member functions of the StatusMessage class I created. echo '[' . $value-&gt;getInteractions() . '] ' . $value-&gt;getMessage(); } //This loop doesn't work. Throws the error mentioned above for ($i = 0; $i &lt; 10; $i++) { echo '[' . $statObjs[$i]-&gt;getInteractions() . '] ' . $statObjs[$i]-&gt;getMessage(); } </code></pre>
php
[2]
4,663,627
4,663,628
show only last 4 digits in bank account using javascript
<p>I need help with Javascript. I need to replace however many characters there are previous to the last 4 digits of a text field that contains bank account number. I have searched through the net on this, but cannot find one code that works. I did find a code here on stackoverflow, which was regarding credit card, </p> <pre><code>new String('x', creditCard.Length - 4) + creditCard.Substring(creditCard.Length - 4); </code></pre> <p>I just replaced the creditCard with accounNumObject:</p> <pre><code>var accounNumObject = document.getElementById("bankAcctNum") </code></pre> <p>The input is pretty simple.</p> <pre><code>&lt;cfinput type="text" name="bankAcctNum" id="bankAcctNum" maxlength="25" size="25" value="#value#" onblur="hideAccountNum();"&gt; </code></pre> <p>Can anyone help please?</p>
javascript
[3]
5,157,922
5,157,923
Set drag & drop in graphiti.js
<p>I have created set on Between node in that I push label, Line object. It's working fine, but the problem is that if I drag that between node it only drags that node, not a whole set of that node. I want to drag whole set inside that between node. </p> <p>Can I do this in graphiti.js?</p>
javascript
[3]
4,789,277
4,789,278
ObjectDataSource Filtering on DateTime
<p>I am currently using <code>ObjectDataSource</code> filtering on my gridview control. The <code>ObjectDataSource</code> filtering works well with Date. However, if there is a column with timestamp, the <code>ObjectDataSource</code> filtering doesn't work at all.</p> <p>For Example, if the column only contains the <code>DateTime</code> like '02/01/2011', the <code>ObjectDataSource</code> filtering works fine with the data. If the column contains the <code>Datetime</code> with the timestamp, '02/01/2011 10:30 AM', the user tried to filter it by entering '02/01/2011 10:30 AM' to filterexpression. the <code>ObjectDataSource</code> filter doesn't work at all. I was wondering if anyone can give me a hint on this one.</p>
asp.net
[9]
5,594,007
5,594,008
Defining private variables in prototype that are not shared among children and other prototyping tricks
<p>I want private variables to be constructed for each child and not shared. (That's the minimum I need...)</p> <pre><code>function AbstractClass(){ var private_var; // not shared // todo : how to create a static(shared) variable? this.virtual_method = function(){}; this.some_fun = function(){ console.log(private_var); } // todo : how to access static(shared) variable? } </code></pre> <p>this base abstract class should be convenient enough for constructing many children out of it</p> <pre><code>function Child1(param){ private_var = param; this.virtual_method = function(){alert('child1');}; //redefining this.some_fun(); } var first_child = new Child1(5); //console : 5 var second_child = new Child1(16); //console : 16 first_child.some_fun() //console : 5; second_child.some_fun() //console : 16; fist_child.virtual_method(); // alert </code></pre> <p>Please help me... I need some working code to be a guide for me</p>
javascript
[3]
5,868,094
5,868,095
How to implement multicast sockets?
<p>How can I implement multicast sockets in C#? Any code snippet along with a simple explanation is highly appreciated.</p> <p>Thanks in advance.</p>
c#
[0]
1,233,872
1,233,873
DirectSound - how to get started
<p>I need to use the direct sound librarys for my C# application.</p> <p>Do I need to download a SDK and install?</p> <p>Are the libraries already installed as part of windows xp sp3?</p> <p>In C# under references I just include microsoft.directsound?</p> <p>Many thanks,</p>
c#
[0]
1,977,169
1,977,170
`sys.dont_write_bytecode` is True, but .pyc files are still generated
<p>I'm setting the <strong><em>PYHTONDONTWRITEBYTECODE</em></strong> environment variable to avoid .pyc files, and I have checked that <code>sys.dont_write_bytecode</code> is True.</p> <p>But .pyc files are still generated everywhere.</p> <p>PS: I'm using Python 2.6.6</p> <p><strong>The reason is that my script is running under <code>env -i</code>.</strong></p>
python
[7]
439,747
439,748
VIN scanning library or SDK for android
<p>I am working on one android application which requires VIN scanning. I didn't found any good library or sdk for the same. I tried Zxing but it doesn't do VIN scanning. Can anybody help me out to implement VIN scanning in my app. Any sdk or library will be preferable.</p> <p>Thanks</p>
android
[4]
5,087,958
5,087,959
Problem with HTMLInputElement in jquery
<p>This code is giving me objecxt.HTMLInputElement in jquery </p> <pre><code>var values = $('input[name=delete]:checked').each(function(i, selected) { return $(selected).attr('value'); }).get().join(","); </code></pre> <p>What is the problem ? </p>
jquery
[5]
877,838
877,839
How to stop a running thread when Activity on destroy at Android?
<p>I used some thread objects in my Android activity. But these threads do not stop itself when Activity on destroy. My code for thread-stopping as following:</p> <pre><code>@Override public void onDestroy() { super.onDestroy(); thread.interrupt(); } </code></pre> <p>Above code is not only working for thread object stopping but also throws an InterruptedException. What's the correct way to stop a running thread without exceptions?</p> <hr> <p>is it not an error when thread object throws InterruptedException?</p>
android
[4]
2,584,634
2,584,635
java generics and extends
<p>I've read the docs but don't see what I'm doing wrong here ... the goal is a generic collection class Wlist to contain ItemIFs. The Java source for java.util.TreeMap uses:</p> <pre><code>public V put(K key, V value) { Comparable&lt;? super K&gt; k = (Comparable&lt;? super K&gt;) key; cmp = k.compareTo(t.key); </code></pre> <p>I was hoping to avoid the cast by using the code below, but get a warning "unchecked call" when I compile with -Xlint:unchecked. Suggestions?</p> <pre><code>interface ItemIF&lt;TP&gt; { int compareItem( TP vv); } // end interface ItemIF class Wlist&lt;TP extends ItemIF&gt; { TP coreItem; void insert( TP item) { // *** Following line gets: warning: [unchecked] unchecked call *** // *** to compareItem(TP) as a member of the raw type ItemIF *** int icomp = coreItem.compareItem( item); } } // end class class Item implements ItemIF&lt;Item&gt; { String stg; public Item( String stg) { this.stg = stg; } public int compareItem( Item vv) { return stg.compareTo( vv.stg); } } // end class Item class Testit { public static void main( String[] args) { Wlist&lt;Item&gt; bt = new Wlist&lt;Item&gt;(); bt.insert( new Item("alpha")); } } // end class Testit </code></pre>
java
[1]
1,855,297
1,855,298
what is the difference between user-defined conversion and user-defined operator?
<p>In the context of operator overloading, what is the difference between user-defined conversion and user-defined operator?</p>
c++
[6]
5,204,990
5,204,991
flooring values does not calculate to 100 percent
<pre><code>-------------------------- Fruit Trees -------------------------- Apple 1098 Banana 500 Grapes 460 -------------------------- TOTAL 2058 -------------------------- </code></pre> <p>Now, I want to find out, in form of percentage, how many trees are there for each fruit type. So, this is what I did</p> <pre><code>--------------------------------------------------------- Apple floor((1098*100)/2058) 53% Banana floor(( 500*100)/2058) 24% Grapes floor(( 460*100)/2058) 22% --------------------------------------------------------- TOTAL 99% </code></pre> <p><strong>As you can see, 1% is lost in flooring values</strong></p> <p>I need logic in a way that whatever the values are for each fruit, total should get to 100%. <strong>Above one is SAMPLE DATA, number of tree for each fruit, and number of fruits can increase or decrease.</strong></p>
php
[2]
2,892,429
2,892,430
jQuery Selection Child of UL. Looking for a better method
<p>I have a div element which contains UL and UL contains the LI items. One of the LI item has an ID of stocknumber. I need to select that li. </p> <p>Here is my code which works fine I am just looking for a better implementation. </p> <pre><code>$(".block").children("ul").children("#stocknumber") // gets me the li and it works!! </code></pre> <p><strong>UPDATE 1:</strong> </p> <p>Please note that ids are not unique! </p> <p>Here is what I came up with: </p> <pre><code>$(".block").children("ul").find("#stocknumber") </code></pre>
jquery
[5]
3,869,985
3,869,986
Shedule UI update
<p>My app contains an activity which UI has to be updated due to server show schedule. What is the best approach for updating UI in this situation. </p> <p>So far, I've come up with AlarmManager and Service but I'm not sure it's a good practice. Any other suggestions ? I've seen some relevant methods in Handler but I'm not how to use them regarding the uptime parameter.</p> <p>Alarm</p> <pre><code> Intent intent = new Intent(getActivity(), OnAirUpdateAlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(getActivity(), 0, intent, 0); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.add(Calendar.SECOND, 10); AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); </code></pre> <p>Receiver (checks whether the running activity is one the needs to updated)</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { ActivityManager am = (ActivityManager) context .getSystemService(Activity.ACTIVITY_SERVICE); List&lt;ActivityManager.RunningTaskInfo&gt; taskInfo = am.getRunningTasks(1); String name = taskInfo.get(0).topActivity.getShortClassName(); if (name.equals(".activity.handset.HandsetMainActivity")) { Intent notificationIntent = new Intent(context, HandsetMainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra( context.getResources().getString( R.string.extras_main_activity_on_new_intent), HandsetMainActivity.UPDATE_PLAYER_FRAGMENT_UI); context.startActivity(notificationIntent); } } </code></pre> <p>And if it is - requests fragments UI update. Again not sure if this is the best solution.</p> <p>Thanks for your suggestions.</p>
android
[4]
3,376,018
3,376,019
Checking data "exists" in array?
<p>I have an small array of data which i want to check if my values im checking against exist in the array together.</p> <p>This is how the data looks like from my console.log(astar);</p> <p><a href="http://i.imgur.com/PqzG7.jpg" rel="nofollow">http://i.imgur.com/PqzG7.jpg</a></p> <p>My attempt was:</p> <pre><code> console.log(astar); // display array info for (i=0; i &lt; 50; i++){ for (j=0; j &lt; 50; j++){ if( i in astar &amp;&amp; j in astar[i] ){ abposx = getx(i); abposy = gety(j); ctx.fillStyle = "#000"; ctx.fillRect (abposx,abposy,10,10); } </code></pre> <p>The idea is the "inner arrays" which have [0][1] positions im trying to see if "any" of them have [0] == i and [1] == j if so = true.</p> <p>How should i alter it to work correctly &amp; most efficiently - so that it will draw when it is found in the arrays </p>
javascript
[3]
3,988,466
3,988,467
how to call an broadcast receiver from an activity?
<p>I have a broadcast class that blocks the incoming call. I want to call that broadcast receiver from the activity ? Can any one help me fix this. I appreciate your help. 1. Class A extends activity will call Class B that extends BroadcastReceiver, now I want to block calls , only based on certain requirements, which are checked in Class A, if true then call the Class B (or block the call in short)</p>
android
[4]
3,304,048
3,304,049
Only Text from Items of ListView are clickable
<p>We have a ListView with dynamic content and we can only click on the text, and not the whole item (that means a short text means a small touch area)</p> <p>Our ListView:<br> <code> ListView lv = getListView();<br> lv.setTextFilterEnabled(true);<br> lv.setOnItemClickListener(this); </code></p> <p>What do we have to do to make the whole Item clickable and not only its text</p>
android
[4]
4,421,227
4,421,228
JSON stringify and decode JS/PHP
<p>I have a problem with sending an object in PHP. I stringify the object before sending it to the PHP file.</p> <p>The PHP file then uses json_decode. But the decode shows a blank variable.</p> <p>The object which i console.log shows this as its structure:</p> <p><img src="http://i.stack.imgur.com/Qf8gt.jpg" alt="enter image description here"></p> <p>Its then sent to PHP with this :</p> <pre><code> console.log(my_Obj); var as = JSON.stringify(my_Obj); call_data('add.php?&amp;as='+as, nxtFunc); </code></pre> <p>Now in the PHP file i have this which handles the situation:</p> <pre><code> $path = json_decode($_GET['as']); echo $_GET['as'].'&lt;br/&gt;'; print_r($path); die; </code></pre> <p>The result is:</p> <pre><code>[null,null,{\"8\":[null,null,null,null,null,null,[],[],[],[],[]],\"9\": [null,null,null,null,null,null,null,null,null,null,[]],\"10\": [null,null,null,null,null,null,null,null,null,null,[],[]],\"11\": [null,null,null,null,null,null,null,null,null,null,null,[]]}] &lt;br/&gt; </code></pre> <p>My XHR request url in Chrome shows:</p> <pre><code>add.php?as=[null,null,{%228%22:[null,null,null,null,null,null,[],[],[],[],[]],%229%22:[null,null,null,null,null,null,null,null,null,null,[]],%2210%22:[null,null,null,null,null,null,null,null,null,null,[],[]],%2211%22:[null,null,null,null,null,null,null,null,null,null,null,[]]}] </code></pre> <p>Notice the print_r shows nothing. Should i not be using stringify ?</p>
javascript
[3]
5,820,764
5,820,765
What is the accuracy of scheduleAtFixedRate?
<p>we need to keep an eye on the pc clock from a Java program. For this, we schedule a Runnable using scheduleAtFixedRate() every 500 ms. We call System.currentTimeMillis() from this every time. If we see that the there is a bigger difference then 500 ms +- a certain allowed delta, then we assume the clock has changed (then we need to do some other stuff).</p> <p>Would this be a correct way of doing things? Tests on Linux show that a 50 ms delta is enough during normal operation. On windows, we have to increase it too 100 ms, otherwise, it is thinking the time has changed on every check we do.</p> <p>Any other ideas on how to do this?</p>
java
[1]
1,292,762
1,292,763
Storing collection of HTML elements in variable for later use
<p>Here is a jQuery issue that I come across and always have to resolve using methods I'm not proud of.</p> <p>I'm attempting to store a collection of elements for later assessment. The problem is that every time I try to access and apply any function to it, the error console reports the it is not a function. I'm convinced that I have a misunderstand of how jQuery works. Nonetheless, I'd like to be pointed in the right direction. Here is the code I am using:</p> <pre><code>var products = $('ul.products'); var productLists = [] $.each(products, function (i) { productLists[i] = products[i].children('li'); console.log(productLists[i]); }); </code></pre> <p>and here is the error I get:</p> <pre><code>Uncaught TypeError: Property 'children' of object #&lt;HTMLUListElement&gt; is not a function </code></pre>
jquery
[5]
6,001,591
6,001,592
How do I change the color of javascript text?
<p>So I have some JavaScript that creates separate text.</p> <p>When I call it, to make the typing text, I do something like:</p> <pre><code>&lt;center&gt;&lt;p id="w00t"&gt;&lt;font color="white"&gt;text here&lt;/font&gt;&lt;/p&gt;&lt;/center&gt; &lt;script type="text/javascript"&gt; new TypingText(document.getElementById("w00t"), 50, function(i){ var ar = new Array("\\", "|", "/", "-"); return " " + ar[i.length % ar.length]; }); //Type out examples: TypingText.runAll(); &lt;/script&gt; </code></pre> <p>But, the background of my webpage is black, and it prints the line ending array:</p> <pre><code>new Array("\\", "|", "/", "-"); return " " + ar[i.length % ar.length]; }); </code></pre> <p>as black.</p> <p>How would I make it white?</p>
javascript
[3]
147,562
147,563
jquery each not staying contained
<p>I have a problem with .each(), i'm trying to iterate over multiple span#obj and use the information from the selection list name=instance_type as a data variable in name=instance_input. </p> <p>I have it working for a single iteration but if i remove the 'return false' from the .each() the data variable becomes filled with the value of the last name=instance_type.</p> <pre><code>$( "span#obj" ).each(function(){ self = this; $("[name='instance_input']",this).autocomplete({ source: function( request, response ) { $.ajax({ url: "json_lookup_call.php", dataType: "json", data: { dataClass : $("[name='instance_type'] :selected",self).val(), maxRows: 12, name_startsWith: request.term }, success: function( data ) { response( $.map( data.results, function( item ) { return { label: item.reference + (item.name ? " - " + item.name : ""), value: item.reference } })); } }); }, minLength: 3 }); return false; }); </code></pre>
jquery
[5]
423,997
423,998
android popup window with webpage in it
<p>how to create an android popup window with webpage in it.</p>
android
[4]
2,782,281
2,782,282
c# regex.ismatch using a variable
<p>I have the following code which works fine but i need to replace the site address with a variable...</p> <pre><code>string url = HttpContext.Current.Request.Url.AbsoluteUri; // Get the URL bool match = Regex.IsMatch(url, @"(^|\s)http://www.mywebsite.co.uk/index.aspx(\s|$)"); </code></pre> <p>I have tried the following but it doesn't work, any ideas???</p> <pre><code>string url = HttpContext.Current.Request.Url.AbsoluteUri; // Get the URL string myurl = "http://www.mywebsite.co.uk/index.aspx"; bool match = Regex.IsMatch(url, @"(^|\s)"+myurl+"(\s|$)"); </code></pre>
c#
[0]
738,923
738,924
How can convert a datetime to double?
<p>How can convert a datetime to double?</p>
c#
[0]
2,995,448
2,995,449
Algorithm used by C# MACTripleDES.ComputeHash()
<p>can any one provide me with references on how this function is internally implemented.</p>
c#
[0]
495,185
495,186
Help solving t_echo php error while using echo do_shortcode
<p>I am using the Orbit Slider plugin successfully on my site. The plugin supports its own categories. I would like to embed the slider within my page.php template but allow each page to have it's own slider based on the category.</p> <p>Inside my page.php I have this:</p> <p><code>&lt;?php echo do_shortcode('[orbit-slider category="page"]'); ?&gt;</code></p> <p>the category "page" is just the name of a category I created. It will display only slides that come from category.</p> <p>Instead of hard-coding the category, I wanted to use custom fields so that on each individual page my client can specify a category to be shown. I have tried something like this but it's causing an internal server error:</p> <p><code>&lt;?php echo do_shortcode('[orbit-slider category="' echo get_post_meta($post-&gt;ID, "slide-category", true);'"]'); ?&gt;</code></p> <blockquote>[09-Feb-2012 20:05:08] PHP Parse error: syntax error, unexpected T_ECHO in /public_html/wp-content/themes/techmd960/page.php on line 21 </blockquote> <p>Can someone point out what I am doing wrong? I figure it has to do with the quotes (double and single) but can't figure it out.</p> <p>Essentially I just want to output the custom field "slide-category" as the value for category="" in the shortcode.</p>
php
[2]
144,170
144,171
undefined function when function is present
<p>I have a PHP class that looks like this:</p> <pre><code>class userAuthentication { public static function Authenticate() { if (isset($_COOKIE['email'])) { verify($someVar, getPass($_COOKIE['email']); } } public static function getPass($email) { } public static function verify() { } } </code></pre> <p>At times (I can't pin-point exactly when), I get a fatal error :</p> <pre><code>Call to undefined function getPass() </code></pre> <p>The error is thrown at the line where I call the function in the above code sample. Why is this happening when the function clearly exists.</p>
php
[2]
3,105,086
3,105,087
php session with intervening html page
<p>I have a php page that store a session variable. One of the link is a .html page, with link back to some php pages. When I travel back to php page, would the session variable still be accessible? </p> <p>Sorry if the answer to this would be obvious since I am not familiar with sessioning. Maybe the session is recorded in the server?</p>
php
[2]
4,249,980
4,249,981
Refactoring basic javascript
<p>I have the following code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { //div1 toggle function runEffect(){ var options = {}; //run the effect $("#div1_toggle").toggle("blind",options,350); }; $("#div1").click(function() { runEffect(); return false; }); }); &lt;/script&gt; </code></pre> <p>Imagine the above code literally duplicated for a number of divs named div1, div2, div3, etc.</p> <p>This is horrendously bad, and I would like to rewrite the code such that it applies to a div of <i>any</i> name to toggle a div of (equal name + _toggle).</p> <p>Bonus: how could I still allow some of these divs to incorporate a different toggle speed (i.e. the 350ms specified above) while reducing redundancy?</p>
javascript
[3]
367,763
367,764
Differentiate click vs mousedown/mouseup
<p>I've read several answers on stackoverflow pertaining to this situation, but none of the solutions are working. </p> <p>I'm trying to do different things based upon whether a user clicks an element, or holds the mouse down on that element using jQuery.</p> <p>Is it possible to accomplish this?</p>
jquery
[5]
3,583,339
3,583,340
iphone MVC game design question
<p>I've got a question about the Model View Controller (MVC) design pattern for iphone games.</p> <p>Let's say I have a simple game that uses a ViewController. So this view controller has an associated window/view and takes player inputs of buttons sliders, etc.. on this view.</p> <p>Now I also have a subview of the ViewController's main window/view and I actually do some animation of various polygons in this subview. I also want to take touch events in this subview.</p> <p>My question is, in the subview, I've got all the user touch code and animation code as the player's touch input affects the animation directly changing rotation etc.. There's a lot of variables in my subview class. Am I violating the MVC design? Should I delegate this stuff to another class or the view controller?</p> <p>Many thanks </p>
iphone
[8]
105,822
105,823
In app billing - handling IN_APP_NOTIFY
<p>I'm implementing in-app billing for android and I had a question about handling the IN_APP_NOTIFY intent. Is there a way to determine what original request triggered this intent? As an example, if I send multiple requests to the Market service, how would my BroadcastReceiver know which request triggered the intent? </p> <p>Thanks</p> <p>Shravan</p>
android
[4]
1,883,359
1,883,360
How to intercept a centre-button press
<p>I have an app in which it is essential that I execute some code when the user presses the centre button on an android device. I already process the user pressing the right hand button (the back button) via <code>onKeyDown(int keyCode, KeyEvent event) / if (keyCode == KeyEvent.KEYCODE_BACK)</code> so I had assumed that pressing the centre button would be processed in a similar manner. But upon further investigation, it appears that onKeyDown is not called. So my question is; how to I intercept a centre-button press?</p> <p>P.S. Much to my embarrassment, I'm not even sure what the centre button is called!</p>
android
[4]
3,897,921
3,897,922
how to make a csv file from database in php?
<p>i have a database table where i have store different information and i want to make a csv file from it how can i do this?</p>
php
[2]
3,880,514
3,880,515
check for existing record
<pre><code>class Catalog { bool BookCopy; public: string BookTitle; Catalog() { BookCopy = false; } Catalog(string Title, bool Copy) { BookTitle = Title; BookCopy = Copy; } void SetTitle(string Title) {BookTitle = Title; } void SetBookCopy(bool Copy) {BookCopy = Copy; } string GetTitle() { return BookTitle; } bool GetCopy() { return BookCopy; } }; class BookList { vector&lt;Catalog&gt; List; vector&lt;Catalog&gt;::iterator Transit; public: void Fill(); void Show(); }; void BookList::Fill() //Create book record { string Title; bool Copy; Catalog Buffer; cout &lt;&lt; "Enter book information, Stop To quit" &lt;&lt; endl; cout &lt;&lt; "-------------------------- " &lt;&lt; endl; while(true) { cout &lt;&lt; "Title: "; getline(cin, Title); if(Title == "Stop") break; for(Transit = List.begin() ; Transit != List.end() ; Transit++ ) { if(Transit-&gt;GetTitle() == Title) { Copy = true; } else Copy = false; } </code></pre> <p>I want to check if an identical title exists when making a new record. If it exists then to assign 1 to Copy otherwise leave it as 0. When I make a record with an identical title 1 does not get assigned to copy.</p>
c++
[6]
354,773
354,774
In app purchase is not working under android 2.3.6
<p>In my app I have integrated in app billing system and its working properly in the devices of 2.3.6 and above, but when I test it on 2.3.3 and 2.2.1 then in app billing is not triggered. I have used the following code to test in a button click listener:</p> <pre><code>val = billingService.requestPurchase("android.test.purchased", payloadContents); </code></pre> <p>Is there any documentation that in which version should it run or any solution of it?</p>
android
[4]
4,334,374
4,334,375
In what way is my array index an 'Illegal string offset'?
<p>When "future-proofing" code by testing it on PHP 5.4, I get a warning I don't understand.</p> <pre><code>function __clone() { $this-&gt;changed = TRUE; foreach ($this-&gt;conditions as $key =&gt; $condition) { if ( $condition['field'] instanceOf QueryConditionInterface) { $this-&gt;conditions[$key]['field'] = clone($condition['field']); } } } </code></pre> <p>I broke out <code>$condition['field']</code> into its own row to reduce the amount of code to focus on. About that specific line, PHP has this to say</p> <blockquote> <p>Warning: Illegal string offset <code>'field'</code> in <code>DatabaseCondition-&gt;__clone()</code></p> </blockquote> <p>And I just can't see how 'field', is an illegal string offset. I'm guessing that I'm just missing something obvious, but if the community can't find a problem, I'll file a bug report.</p> <p>I interpret the warning as "<em>Under no circumstances is 'field' a valid key</em>". This error would have made sense if I had tried to us for example an array as a key.</p>
php
[2]
5,797,920
5,797,921
javascript confirmation box
<p>In javascript,guide me to display a confirm box with button such as "Yes" and "No" instead of "Ok" and "Cancel".</p> <p>thanks in advance...</p>
javascript
[3]
1,760,939
1,760,940
Self inflating ListView
<p>I've got a listview and it's adapter, which accepts a list of object data. Is it possible to extend the adapter or the listview itself to start track position, namely implement OnScrollListener. So far I've tried implementing adapter as OnScrollListener and extentding ListView with further implementation as OnScrollListener.</p> <p>My ultimate goal is to create an endless listview.</p> <p>Is it possible? Or the only way to do it is to use ListActivity ?</p>
android
[4]
1,583,640
1,583,641
How to add view-based template to Xcode 4.2/iOS 5 SDK
<p>I have OS X Lion and installed Xcode 4.2_and the iOS 5 SDK beta for lion.</p> <p>Currently I don't have View-based and Navigation-based templates. Is it possible to add them somehow?</p> <p>Thanks in advance. </p>
iphone
[8]
5,616,493
5,616,494
Sending messages fail when bulding a simle chat room
<p>I try the tutorial on net to build chat room.</p> <p>First I create a database in MYSQL called chatroom and buld a datasheet called chat with three columns:chtime, nick, words.</p> <p>Then I write four PHP files, login.php, main.php, display.php, speak.php but encounting problem about display and speak. My speak doesn't work and I just pop up a new window without any words.</p> <p>I don't know where is the problem?</p> <p>I have tried to fix it serveral days but in vain. Please tell me where is my error! Thx.</p> <p>The following is my code:</p> <p>Login.php <a href="http://codepad.org/WIfr3quz" rel="nofollow">http://codepad.org/WIfr3quz</a></p> <p>Main.php <a href="http://codepad.org/b9pXuNl0" rel="nofollow">http://codepad.org/b9pXuNl0</a></p> <p>Display.php <a href="http://codepad.org/o7pf5G57" rel="nofollow">http://codepad.org/o7pf5G57</a></p> <p>Speak.php <a href="http://codepad.org/wFDEMrNk" rel="nofollow">http://codepad.org/wFDEMrNk</a></p>
php
[2]
754,142
754,143
getText from all TextView which created by user
<p>This is my Add button code which will get the text from <code>AutoCompleteTextView</code> and list into <code>ListView</code> on each click of Add button. I am so confusing about getting text from all <code>TextView</code> which created by user.</p> <p>Because I need to compare the user inputs in all <code>TextView</code>with symptoms column in database to diagnose the disease. Hope you guys can help me =)</p> <pre><code>private OnClickListener onClick() { return new OnClickListener() { @Override public void onClick(View v) { mLayout.addView(createNewTextView(mEditText.getText().toString())); } }; } private TextView createNewTextView(String text) { final LayoutParams lparams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final TextView textView = new TextView(this); textView.setLayoutParams(lparams); //textView.setText("Symptom: " + text); textView.setText(text); return textView; } </code></pre>
android
[4]
4,784,663
4,784,664
Steps in list question, Python beginner
<p>The following code include the last number.</p> <pre><code>&gt;&gt;&gt; numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] &gt;&gt;&gt; numbers[::3] [1, 4, 7, 10] </code></pre> <p>Why does not includet the last number 2, like 10, 8, 6, 4, 2?</p> <pre><code>&gt;&gt;&gt; numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] &gt;&gt;&gt; numbers[:1:-2] [10, 8, 6, 4] </code></pre>
python
[7]
2,888,163
2,888,164
without extends of class activity how to getget email id's from contacts and get phone no from contacts?
<p>hi all how to implement coding for get email id's from contacts and get phone no from contacts show me the way to overcome from this problem note: class doesn't have extends Activity and oncreate() method also so kindly help me to go forward </p>
android
[4]
5,383,313
5,383,314
python. get size of an object
<p>I need to know size of objects in my python program. I have <code>for</code> loop in which I need to know size of objects. If I use <code>sys.getsizeof</code> then memory does not free instantly and I cannot see actual size. Is there way to do it?</p> <p>My objects are json and string. In the worst case I can save them to file and look at file sizes. But how can I look at file size from python code?</p> <p><strong>Edit</strong>: size of serialised objects is more important for me. so second part of the question is essential. </p> <p>Thanks.</p>
python
[7]
551,025
551,026
Iterate through an array in PHP
<p>I'm very new to PHP but I have to make something quickly.</p> <pre><code> $fql = "SELECT uid, name, pic_square, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"; $response = $facebook-&gt;api(array( 'method' =&gt; 'fql.query', 'query' =&gt;$fql, )); $allUsers = $mapper-&gt;getAll(); </code></pre> <p>So I've got $response and, for example, <code>$response[0]["name"]</code> returns the name of the first user and <code>$response[0]["id"]</code> returns the id of the first user.</p> <p>Then I've got the $allUsers array in which I've got all of the users ids. For <code>$allUsers[0]-&gt;id</code> returns the id of the first user.</p> <p>Ok, now as the result I would like to filter the $response array and have in it only users whose id is present in $allUsers array. It may be new array, for example $filteredResponse.</p> <p>Thank you very much for the help, it's really just an issue of me not really knowing the syntax</p> <p>I wrote sth like this:</p> <pre><code>$filteredResult = array(); foreach ($response as &amp;$userfb) { foreach($allUsers as &amp;$userdb){ if($userfb["id"] == $userdb-&gt;id){ array_push($filteredResult, $userfb); break 1; } } } </code></pre> <p>Is this correct ?</p>
php
[2]
5,359,214
5,359,215
How to create a jQuery function to return a bool?
<p>How can I create a jQuery function like </p> <pre><code>$.MyFunction(/*optional parameter*/)? </code></pre> <p>which will return a bool?</p> <p><strong>note:</strong></p> <p>I've tried this: </p> <pre><code>jQuery.fn.isValidRequest = function (options) { return true; } // I'm contending with Prototype, so I have to use this jQuery(document).ready(function ($) { // and jQuery 1.2.6, supplied by the client - long story $('a').livequery('click', function () { alert($.isValidRequest("blah")); return false; }); }); </code></pre> <p>but it crashes on the alert() with </p> <pre><code>Microsoft JScript runtime error: Object doesn't support this property or method </code></pre> <p><strong>This is what worked in the end:</strong></p> <pre><code>jQuery.isValidRequest = function (options) { return true; } </code></pre>
jquery
[5]
3,252,188
3,252,189
Javascript strings to object
<p>I have two strings, one a key and one a value, which I would like to turn into an object and concatenate in a loop. For example:</p> <pre><code>var data = {}; // loop starts here var a_key = 'element'; var a_val = 'value'; var a_obj = // somehow this equals { "element":"value" } data = data.concat(a_obj); // loop ends here </code></pre> <p>I'm just not sure how to create an object from those two strings! Any help appreciated</p>
javascript
[3]
5,235,322
5,235,323
Killing Clickonce application using javascript
<p>i have a webpage that runs clickonce application on button click,my question is Is it possible to stop clickonce application(publish on web/available online only!) using javascript?</p>
javascript
[3]
5,461,144
5,461,145
Display each XML attribute separately
<p>Basically, I have a small issue trying to display each attibute seperetly when I play it, it seems to display all the attributes in title. I thought you could sort of take the same approach as you do with arrays by writing something like</p> <pre><code>listView1.Items.Add(items[0]); </code></pre> <p>I am completly new to this so i apoligize if the question sounds noobish.</p> <p>xml file:</p> <pre><code>&lt;books&gt; &lt;type&gt; &lt;price&gt;2.50&lt;/price&gt; &lt;title&gt;Harry&lt;/title&gt; &lt;/type&gt; &lt;type&gt; &lt;price&gt;2.70&lt;/price&gt; &lt;title&gt;bob&lt;/title&gt; &lt;/type&gt; &lt;/books&gt; </code></pre> <p>Code:</p> <pre><code>XmlTextReader reader = new XmlTextReader("XMLfile1.xml"); XmlNodeType type; while(reader.Read()) { type = reader.NodeType; if (type == XmlNodeType.Element) { if (reader.Name == "title") { reader.Read(); listView1.Items.Add(reader.Value); } } } reader.Close(); </code></pre>
c#
[0]
2,297,517
2,297,518
Include php files only when needed at runtime
<p>I have some PHP code which looks roughly like this</p> <pre><code>require_once 'cache.php'; require_once 'generator.php'; if (cache_dirty ('foo')) { cache_update ('foo', generate_foo ()); } print cache_read ('foo'); </code></pre> <p>My problem is that <code>generator.php</code> includes a whole mass of libraries and I don't want to load/parse it unless <code>cache_dirty</code> actually returns <code>false</code> at runtime.</p> <p>I know there are PHP precompilers which can help but for now I need a quick fix. Is this possible?</p>
php
[2]
1,949,618
1,949,619
How to loop through :eq for an unknown range using jquery?
<p>How to loop through a jquery each loop using filter :eq for an unknown range?</p> <p>for example, I would like to loop through the following:</p> <pre><code>$("#list li:eq("+ i +")").each(function(i) { i++; }); </code></pre> <p>This code does not work</p>
jquery
[5]
1,142,324
1,142,325
jQuery: changing the available options in a list based on the selected option
<pre><code>&lt;select id="studentinst" size="6"&gt; &lt;option value="1"&gt;First Installment&lt;/option&gt; &lt;option value="2"&gt;Second Installment&lt;/option&gt; &lt;option value="3"&gt;Third Installment&lt;/option&gt; &lt;option value="4"&gt;Fourth Installment&lt;/option&gt; &lt;option value="5"&gt;Fifth Installment&lt;/option&gt; &lt;option value="6"&gt;Sixth Installment&lt;/option&gt; &lt;/select&gt; </code></pre> <p>If I select 4, it should only display the first 4 options and the rest should be hidden. Desired output:</p> <pre><code> First Installment Second Installment Third Installment Fourth Installment </code></pre> <p>How can I achieve this using jQuery?</p> <p>see sample <a href="http://jsfiddle.net/PQ7GF/9/" rel="nofollow">link</a> check this link... for loop doesn't work over here</p>
jquery
[5]
4,666,202
4,666,203
is animation allowed in an onClick() function
<p>I tried using the following code in .java(main activity):</p> <pre><code>final ImageView diskView1 = (ImageView) findViewById(R.id.can); diskView1.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ System.out.println("Clicked."); AnimationSet canMov; RotateAnimation canRotate; TranslateAnimation canTrans; canMov = new AnimationSet(true); canRotate = new RotateAnimation(0,1360, Animation.RELATIVE_TO_SELF,0.5f , Animation.RELATIVE_TO_SELF,0.5f ); canRotate.setStartOffset(50); canRotate.setDuration(20000); canMov.addAnimation(canRotate); canTrans = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.35f); canTrans.setDuration(20000); canMov.addAnimation(canTrans); canMov.setRepeatCount(0); canMov.setRepeatMode(Animation.REVERSE); diskView1.setAnimation(canMov); } }); </code></pre> <p>I am able to get the message 'clicked' in LogCat, but the animation after that does not respond to the click. However, without the use of onClick(), I get the full animation of the can. I need the animation to start only after I click the can. What am i doing wrong?</p>
android
[4]
5,544,189
5,544,190
JavaScript Date Validation Function
<p>Can anyone explain how does the foll JS function validate date which needs to be of the form mm/dd/yyyy.</p> <pre><code>&lt;script type="text/javascript"&gt; function checkdate(input){ var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity var returnval=false if (!validformat.test(input.value)) alert("Invalid Date Format. Please correct and submit again.") else{ //Detailed check for valid date ranges var monthfield=input.value.split("/")[0] var dayfield=input.value.split("/")[1] var yearfield=input.value.split("/")[2] var dayobj = new Date(yearfield, monthfield-1, dayfield) if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) alert("Invalid Day, Month, or Year range detected. Please correct and submit again.") else returnval=true } if (returnval==false) input.select() return returnval } &lt;/script&gt; </code></pre>
javascript
[3]
2,242,945
2,242,946
how to dynamically call a function in c#
<p>i have method:</p> <pre><code> add(int x,int y) </code></pre> <p>and i also have: </p> <pre><code>int a=5; int b=6; string s="add"; </code></pre> <p>is it possible to call add(a,b) using the string s? how can i do this in c#?</p>
c#
[0]
89,570
89,571
formated text in outlook
<p>I am creating a small script using JavaScript and HTML. I am asking users to enter some information in text boxes and once they click submit, Outlook email will open with the body of the email populated with some of the info they put in the text boxes. I want to be able to format the text (change font, change colors...) so that when it opens in Outlook the formated text is displayed. Here is an example, not all the info is there. What I want to show is that when the <code>window.location="MAILTO:"</code> is executed it opens up an email with the body of the email populated with text that is stored in <code>var</code> <code>body1</code>. I am unable to format that text.</p> <pre><code>var body1 = "We have provisioned your new smart card for logical access."+ "%0A%0A" + "When you receive the smart card insert it in the card reader and use the randomly assigned PIN below for access:" + "%0A%0A" + "PIN: " + document.forms[0].body.value + "%0A%0A" + "To change the PIN number go to start - All programs - ActiveIdentity - ActiveClient- PIN change tool." + "%0A%0A" + "If you are unable to change the PIN, please contact SPOC at 1-877-600-7762."+"%0A%0A"+ text; window.location = "MAILTO:" + document.forms[0].mail.value +"?subject= SmartCard PIN" +"&amp;body=" + body1; </code></pre>
javascript
[3]
432,241
432,242
Simple way to get which image was clicked when running same function
<p>I'm making a card game for android. You select your first card by clicking image1, second card by clicking image2, etc. These images run the same function in java, but how can I pass a variable to get that they clicked image1, image2, or image3? I'd like to avoid having 3 functions that are the exact same aside from one variable. Thanks for any input.</p>
android
[4]
1,983,304
1,983,305
Change , to . on input/tab
<p>I'm making a form but for the sake of consistency I would like to change every <code>,</code> to an <code>.</code></p> <p>Is this possible with JavaScript, and if so how can I do this?</p>
javascript
[3]
519,062
519,063
Application on iPhone Startup
<p>Hey how can i make my application start on the iPhone startup ? Thank you for explaining ....</p>
iphone
[8]
1,678,105
1,678,106
FreqTable with random values(#C)
<p>I would like to make a frequency table with random numbers. So i have created a array that generates 11 random values between 0 and 9999.</p> <pre><code> public void FillArrayRandom(int[] T) { Random Rndint = new Random(); for (int i=0; i &lt; T.Length; i++) { T[i] = Rndint.Next(0, 9999); } }/*FillArrayRandom*/ </code></pre> <p>The result i want is something alike this:(bar height up to 21) So this will be a constant.</p> <pre><code> * * * * * * (the highest value will have the largest row/bar) * * * * 0 1 2 3 .....(index value's) 931 6669 10 8899 .... (up to 11 random values) </code></pre> <p>My question is how do i exactly caculate the frequency between those 11 random values? The bars should have a relative relation with each other depending on there frequency. I would only like to use 1 single array in my program (for the generated values).</p> <p>F = (F * 21?) / ...? Really no clue how to obtain the proper results.</p> <p>If a frequency is >=21 write * If a frequency is >=20 write * If a frequency is >=19 write * , and so on until i reach 1. (and the full table is displayed </p> <p>Basicly i would like to print the table line per line with consolewrite(line).</p> <p>etc...</p> <p>Regards.</p>
c#
[0]
290,444
290,445
PHP "<<<TEXT some content TEXT" Meaning
<p>Good morning,</p> <p>I encountered the following code and wondered what the &lt;&lt;&lt;'SCRIPT is ?</p> <pre><code>$options = &lt;&lt;&lt;SCRIPT &lt;script type="text/javascript"&gt; var options = {$encoded}; &lt;/script&gt; SCRIPT; </code></pre> <p>could someone give me a link to the php documentation related to this ?</p> <p>I would have like to google it but i can t find a proper manner to look for <code>&lt;&lt;&lt;</code>, thus i come to you.</p> <p>thank you.</p>
php
[2]
4,201,913
4,201,914
How can I add a slide effct to this div's changer
<p>Please help add slide effect when changing divs (I found example code here):</p> <pre><code>$(function () { var counter = 0, divs = $('#update1, #update2, #update3'); function showDiv () { divs.hide() .filter(function (index) { return index == counter % 3; }) .show('fast'); counter++; }; showDiv(); setInterval(function () { showDiv(); }, 10 * 1000); }); </code></pre>
jquery
[5]
1,918,130
1,918,131
Equivalent in C# of "Block values" in other languages
<p>In some languages, almost everything can be used as a value. For example, some languages let you treat a block of code as a unit which can return a value.</p> <p>In Scheme, a block of code wrapped in a <code>let</code> can return a value:</p> <pre><code>(define val (let () (define a 10) (define b 20) (define c (+ a b)) c)) </code></pre> <p>Perl 5 also supports blocks as values:</p> <pre><code>my $val = do { my $a = 100; my $b = 200; my $c = $a + $b; $c; }; </code></pre> <p>The closest approximation to block values I could come up with in C# was to use a lambda that is cast and immediately called:</p> <pre><code>var val = ((Func&lt;int&gt;)(() =&gt; { var a = 10; var b = 20; var c = a + b; return c; }))(); </code></pre> <p>That's not too bad and is in fact exactly what is happening semantically with Scheme; the <code>let</code> is transformed to a <code>lambda</code> which is applied. It's at this point that I wouldn't mind macros in C# to clean up the syntactic clutter.</p> <p>Is there an another way to get "block values" in C#?</p>
c#
[0]
2,029,583
2,029,584
How can I do something like a FlowLayout in Android?
<p>How can I do something like a <code>FlowLayout</code> in Android? </p>
android
[4]
1,415,529
1,415,530
Getting Error in CreateTableCommand.ExecuteNonQuery();
<p>This is the query in which i m getting error</p> <pre><code>CreateTableCommand.CommandText = "BACKUP DATABASE Test" + "TO DISK = 'C:\backup\t1.bak'" + "WITH " + "NOFORMAT, " + "COMPRESSION," + "NOINIT, " + "NAME = N't1-Full Database Backup'," + "SKIP, " + "STATS = 10;"; </code></pre> <p>and the error is "Incorrect syntax near 'DISK'." but if i run run that query ms sql server 2008 its work fine but when i try to use that in my C# application it gave error pls help me out</p>
c#
[0]
4,439,606
4,439,607
Know the name of the form in JavaScript
<p>I have a button called "Next" that exists in a couple of asp.net pages. Actually it is in a User Control. When "Next" is clicked it calls a function <code>CheckServicesAndStates</code> in JavaScript. I want to know the page that has initiated this "Next" button click.</p> <p>Can anyone tell me how is this possible?</p>
javascript
[3]