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
3,374,567
3,374,568
jQuery $(window).resize not firing within jQuery plugin
<p>I've created a custom jQuery plugin and having issues getting the window resize function to fire within the plugin. Broke it down to the basics of what I got, can't figure out why it's not firing:</p> <pre><code>;(function ( $, window, document, undefined ) { $.fn.test = function(options) { $(window).resize(function() { alert('sdsd'); }); }; })(jQuery); $(function() { $('.element').test(); }); </code></pre>
jquery
[5]
531,087
531,088
How to Display Database Data in TextBox?
<p>I'm trying to display data from database in ASP.Net TextBox. But ASP.Net Textbox doesn't have DataSource and DataSourceID. I used ADO.Net Disconnect Approach to connect and retrieve data from MSSQL 2008 database. So how can I do that problem?</p>
asp.net
[9]
715,581
715,582
How does INRIX traffic monitoring work?
<p>How does INRIX traffic monitoring work?</p> <p>How would I develop a Java application that uses Inrix?</p>
java
[1]
354,479
354,480
Python: Write 1,000,000 ints to file
<p>What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer...</p> <p>Edit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied in rare case). You can use any writing method you know, but the resulting file should have minimum size.</p>
python
[7]
4,276,623
4,276,624
programmatically finding the size of float
<p>Disclaimer: this question may not have practical value, it's more of a puzzle/curiosity question.</p> <p>In Java I can write the following code to programmatically find the size of int:</p> <pre><code>public static void main(String[] args) { int x = 1; int count = 1; while((x = x &lt;&lt; 1) != 0) { count++; System.out.println("x: " + x + ", " + count); } System.out.println("size: " + count); } </code></pre> <p>Is there a similar way to programmatically find the size of Java's float?</p>
java
[1]
1,595,267
1,595,268
Redesigning an ASP.NET website
<p>My company's website is a kind of complex Visual Studio project that utilizes lots of custom libraries it has created. The site is an ASP.NET site with a Master page and such. I have been tasked with redesigning it; we have found and purchased an HTML template that we want to use, so the task seemed to be applying the CSS from this purchased template to the website... which I found out today is very difficult and just wouldn't work. Can't just switch the CSS sheet in the master page and be able to work it out from there.</p> <p>Making the simple text pages is simple, just copy and paste into the new markup. But we have a lot of code behind, javascript, etc in our pages and I'm not really sure where to start, if not just start from scratch. I read this topic <a href="http://stackoverflow.com/questions/8977285/best-practice-css-to-refacing-redesigning-a-large-website">Best Practice CSS to refacing/redesigning a large website</a>, which kind of suggests to start from scratch... But it seems like I will need to use the code in the current project in some way, which brings the master page back and the whole problem... Should I really rewrite every line of code?</p> <p>Can you give some tips or reference some links for me to get started?</p> <p>Thanks.</p>
asp.net
[9]
839,664
839,665
Hosting a web service for an iPhone App
<p>I need to write a fairly simple Delivery Tracking application. The device needs to know information about the 'matters' such as status (delivered/awaiting delivery), type (for delivery/for pickup), address, payment accepted etc.</p> <p>The iPhone part of the app seems very simple but in terms of hosting some kind of web service is the part I am unsure about.</p> <p>Does Apple have some kind of service or recommending way of handling this?</p> <p>The web service would need to store all the information about the matters and receive updates from the device when matters are delivered and then there is a possibility that new matters could be sent out manually from the depot.</p> <p>These are the parts I am unsure about - any ideas? </p>
iphone
[8]
2,040,452
2,040,453
How to attach other supporting setup file into my application during making setup file?
<p>i want to attach .net frame work setup file into my setup file and more other so that my application will run in other PC? what is the solution for this ?</p>
c#
[0]
2,255,386
2,255,387
JAVA: Read char from String to a certain char
<p>Is there a method or way to read and keep reading chars from a string, putting them in a new string until there is a certain char. Keep reading from &lt; to > but no further. Thankx</p>
java
[1]
2,801,535
2,801,536
Using HttpPost to get data from local server
<p>I used following code in java class of android. Everything works except it wont send any request. Answer is always null. </p> <pre><code> public class WebviewActivity extends Activity { /** Called when the activity is first created. */ EditText et; Editable ur; TextView tx;HttpResponse response;String x; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tx=(TextView)findViewById(R.id.textView1); et=(EditText)findViewById(R.id.editText1); Button button = (Button)findViewById(R.id.button1); button.setOnClickListener(send); } private OnClickListener send = new OnClickListener() { public void onClick(View v) { ur=et.getText(); postData(); tx.setText("ans:"+x); }}; public void postData() { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://localhost/name.php"); try { // Add your data List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1); nameValuePairs.add(new BasicNameValuePair("name", ur.toString())); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request response = httpclient.execute(httppost); Log.d("myapp", "response " + response.getEntity()); x= EntityUtils.toString(response.getEntity()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>and in php i used following code</p> <pre><code> &lt;?php $name=$_POST["name"]; echo $name; ?&gt; </code></pre> <p>Any idea how it make it work?</p>
android
[4]
3,261,497
3,261,498
How to address instance of anonymous class from inner anonymous class?
<p>I have a code that contains anonymous class in another anonymous class and I need to address instance of outer anonymous class from inner anonymous class. Here is the code:</p> <pre><code>editTemplateButton.setAction(new AbstractAction("Edit...", GUIUtils.EDIT_ELEMENT_ICON) { { setEnabled(false); // disabled at start templatesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { setEnabled(!templatesList.isSelectionEmpty()); // depends on selection } }); } @Override public void actionPerformed(ActionEvent e) { //todo } }); </code></pre> <p>So, I call <code>setEnabled()</code> of implementation of <code>AbstractAction</code> inside implementation of <code>ListSelectionListener</code>. Now it's called ok. But I want to put implementation of <code>ListSelectionListener</code> to variable and use it twice for different actions. How can I call <code>setEnabled()</code> properly? Please don't forget that outer <code>JFrame</code> contains this code is also have <code>setEnabled()</code> method and I don't want to call it instead of right one.</p> <p>Thanks in advance for your answer.</p> <p><strong>UPDATE:</strong> I can't use construction like <code>AbstractAction.this.setEnabled(!templatesList.isSelectionEmpty());</code> because compiler reports error.</p>
java
[1]
2,570,538
2,570,539
How to add a hidden value to DataGridView TextBox? (C#)
<p>I am working with an existing GridView and I want to know if there is a way I can have a different value and display for the TextBoxColumn, similar to a ComboBoxColumn (displaymember, valuemember). </p> <pre><code>private System.Windows.Forms.DataGridViewTextBoxColumn PATH; this.PATH.DataPropertyName = "Path"; this.PATH.HeaderText = "PATH"; this.PATH.Name = "Path"; this.PATH.ReadOnly = true; this.PATH.Width = 186; </code></pre> <p>Right now I have a hidden column with the ID but I am wondering if there is a better solution.</p> <p>ETA: I have put PATH.DataPropertyName = "PathId" (the hidden value I want to use for update) and this.PATH.Name = "Path" (The string value I want displayed) </p> <p>The Name value is still returned when I get the value of the column. </p> <p>this.mySampleGridView.Rows[i].Cells["Path"].Value</p>
c#
[0]
4,182,599
4,182,600
PHP- pages that contain session variables must be linked?
<p>i have a php snippet saying: if this session variable is this, change the header location to this.</p> <p>the session variables arent working, however.</p> <p>must the pages be linked?</p> <pre><code>$query = mysql_query("SELECT * FROM `username` WHERE `password` = '$pword' AND `username` = '$uname'"); $exsists = 0; WHILE($rows = mysql_fetch_array($query)){ $exsists = 1; break; } if ($exsists){ $_SESSION['usern23']=$uname; $_SESSION['logged']=1; header('Location: logged2.php'); } </code></pre> <p>$_SESSION['usern'] wont show up on logged2.php</p>
php
[2]
1,581,227
1,581,228
Is it possible to write Android app without an SDK?
<p>Just wondering, since Android apps are Java programs, would it be possible to write one entirely from scratch without using an SDK? If no, then why not?</p>
android
[4]
3,775,027
3,775,028
rerun javascript on callback
<p>I have a page which shows a map (PolyMap - polymaps.org) within a Devexpress CallbackPanel. When the page initially loads, the map loads just fine, but when a callback is performed within the CallbackPanel, the map does not load. I think that I have narrowed it down to the fact that the javascript is not being reinitialized on the callback, and I know that I need to handle this through the CallbackPanel-EndCallback event.</p> <p>What I don't know, is how to actually accomplish this in my JS function. I am REALLY new to javascript, and I know how to call specific functions from another function, but I run a complex series of functions within a separate javascript file to load the map using the following tag at the bottom of the page:</p> <pre><code>&lt;script type="text/javascript" src="../js/PolyMaps/DiseaseMap.js" id="MapLoad"&gt;&lt;/script&gt; </code></pre> <p>I would really like to avoid having to completely re-write everything into the EndCallback function, and I know that this has to be a really simple answer, but how do I reinitialize the entire script within another javascript function? i.e.</p> <pre><code>Function ReRun() { //Re-Initialize MapLoad Script } </code></pre>
javascript
[3]
5,003,621
5,003,622
javascript date query
<p>i'm try to point so dots on a graph and label them with a date... its working but having problems converting date string. the script i'm using is below. x is the time stamp but when used i get NaN values when replaced with 1268956800000 for example it works fine.</p> <p>i can see where i'm going wrong i think x is not a value when called? but javascript is not a strong point please help</p> <pre><code> if (item) { if (previousPoint != item.datapoint) { previousPoint = item.datapoint; $("#tooltip").remove(); var x = item.datapoint[0].toFixed(0), y = item.datapoint[1].toFixed(0); d = new Date(x); curr_date = d.getDate(); curr_month = d.getMonth(); curr_year = d.getFullYear(); showTooltip(item.pageX, item.pageY, item.series.label + " qty " + y + curr_date + " / " + curr_month + " / " + curr_year); } } </code></pre>
javascript
[3]
4,417,180
4,417,181
iPhone: How to Disable UIWebView Selection
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6676369/how-to-disable-copy-and-paste-in-uiwebview">How to disable Copy and Paste in UIWebView</a> </p> </blockquote> <p>Any suggestions how to remove page items highlight on WebView..Like when you tap on text, text area become grey and menu with "copy, select, paste" appears...Can I disable that thing ? Thanks in advance.</p>
iphone
[8]
98,774
98,775
Handling Orientation changes with Context and AlertDialog/AsyncTask
<p>I have an activity that loads an AlertDialog like this.</p> <pre><code> progressDialog = new ProgressDialog( MyActivity.this ); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage("Doing Something"); progressDialog.setCancelable(false); progressDialog.show(); </code></pre> <p>I also have another class that extends AsyncTask</p> <pre><code> private class MyBackgroundTask extends AsyncTask&lt;Void, Void, Boolean&gt; { @Override protected Boolean doInBackground(Void... params) { ...do stuff } @Override protected void onPostExecute(Boolean result) { progressDialog.dismiss(); } @Override protected void onProgressUpdate(Void... values) { } } </code></pre> <p>If the orientation of the screen changes I get an error about trying to attach to a view that does not exist. This is because the Activity has been destroyed and the context has gone away.</p> <p>So I added this to onDestroy() and it fixed it.</p> <pre><code> @Override public void onDestroy() { if(progressDialog!=null) if(progressDialog.isShowing()) progressDialog.cancel(); if(background!=null) background.cancel(true); } </code></pre> <p>But this means that I always have to keep a reference to the Dialog and AsyncTask</p> <p>So I cant do this for example:</p> <pre><code>new MyAsyncTask().execute(); </code></pre> <p>In case the orientation changes, equally I can't do this:</p> <pre><code> new AlertDialog.Builder(this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle( "some title" ) .setMessage("some message") .setPositiveButton(R.string.ok, null) .show(); </code></pre> <p>This does not seem right to me and there must be a better way, I know you can use getApplicationContext() but in some situations this is not viable.</p> <p>How do I manage this properly?</p>
android
[4]
5,574,645
5,574,646
How to generate avi video from images?
<p>I need to create a video from text input. I have successfully generated image from text input.</p> <p>Now i need to generate a video of avi format from the above created image.</p> <p>How can i do this?</p>
java
[1]
445,837
445,838
Monitoring Android activity life-cycle callbacks
<p>I want to be able to launch an arbitrary app from a program (e.g. by executing the command "am start ", then have the program be notified in some way when the life-cycle callbacks (e.g. onStart, onStop) in the app's activity are called.</p> <p>The problem is that I can not rely on having the app's source code, so can not modify it to add code to the app's implementations of those callbacks.</p> <p>Is there any way to do this without modifying the Android activity manager, or writing a custom activity manager?</p>
android
[4]
2,307,377
2,307,378
CakePHP Undefined index when looking for query string
<p>I get an error saying <code>'Undefined index: redirect'</code> </p> <p>with this code:</p> <pre><code> $came_from_site = $_GET['redirect']; if($came_from_site != "true") { echo 'USER TYPED IN URL MANUALLY'; } </code></pre> <p>The error happens when the query string doesn't exist.... So I guess I need to check if a) it exists and then if it does b) check that it's value is true</p> <p>Can anyone help?</p> <p>Thanks</p>
php
[2]
3,267,403
3,267,404
Count number of times a character appears in a url using PHP
<p>I want to count the number of times "/" appears in this url</p> <p>Here is my code</p> <pre><code>$url = "http://www.google.com/images/srpr/nav_logo14.png"; $url_arr = eregi(".",$url); echo count($url_arr); </code></pre> <p>It displays on "1"</p>
php
[2]
1,928,766
1,928,767
JQUERY get the first item from an array
<pre><code>$("canvas[name=myCanvas]").index(0).width( $(window).width() ); $("canvas[name=myCanvas]").index(0).height( $(window).height() ); </code></pre> <p>Hello I have three canvas on a page. How can I set up only the first canvas width and height? And how can I access the third?</p> <p>Tried: </p> <pre><code>$("canvas[name=myCanvas]").index(0) </code></pre> <p>and</p> <pre><code>$("canvas[name=myCanvas]")[0] </code></pre> <p>not worked</p>
jquery
[5]
2,913,890
2,913,891
jQuery cleaning up two strings (compare string1 to string2 and remove items not uniq)
<p>How do I remove the oldItems from the newItems string? (remove Blue and Green) newItems is generated from jQuery autocomplete and I would like to remove already selected items from the select list.</p> <pre><code>newItems = Blue \n Red \n Black \n Yellow \n Green \n oldItems = Blue,Yellow,Orange,Green </code></pre> <p>Best regards. Asbjørn Morell.</p>
jquery
[5]
2,627,754
2,627,755
jquery load function problem
<p>i have a select box like that</p> <pre><code>&lt;select name="sehirler_post" id="sehirler_post"&gt; </code></pre> <p>i am getting values via jquery. i know two different ways to get values. first one is :</p> <pre><code>var sehirler_post = jQuery('select#sehirler_post').attr('value'); </code></pre> <p>second one is:</p> <pre><code>jQuery('#sehirler_post ').val() </code></pre> <p>and finally here is my problem, i have something like this:</p> <pre><code>jQuery("#okay").load("ajax_post_category.php?okay="+id+""); </code></pre> <p>i would like to use selectbox value instead of id (okay="+id+"). so, i must change +id+ part with select box value. however i can not do it.. i tried to do like that:</p> <pre><code>jQuery("#okay").load("ajax_post_category.php?okay="+jQuery('#sehirler_post').val()+""); </code></pre> <p>it did not work. there must be a way, so i can use selectbox value instead of id in my load function. if anyone helps me, ill be so glad.</p> <p>regards</p>
jquery
[5]
5,888,460
5,888,461
How to convert a javascript Object into an actual file in order to upload with HTML5
<p>I have a javascript object with a huge amount of data in it, including several large base64 encoded strings.</p> <p>We are currently sending the data to the server via a simple ajax POST but since the data is so large the wait time for the user is unacceptable.</p> <p>For this reason we wish to harness the new html5 file upload features and actually measure the progress as the data is uploaded to the server so that the user is provided with constant feedback during this lengthy process.</p> <p>In order to use this feature this large array will have to be sent as an actual file rather than as a huge object sent as url params.</p> <p>Is there any way to either:</p> <p>A. Convert this object into an actual text file and send it that way.</p> <p>or</p> <p>B. Hook into the html5 progress api and actually measure the progress of this standard ajax POST.</p> <p>Thanks in advance.</p>
javascript
[3]
4,216,949
4,216,950
Storing NSObjects in file
<p>I have huge array with NSobjects. While storing to file iPad is getting memory issues. I want to store each object in file one by one and again read it back. Any suggestions?</p>
iphone
[8]
915,018
915,019
What are the things Java got right?
<p>What are the things that Java (the language and platform) got categorically right? In other words, what things are more recent programming languages preserving and carrying forward? </p> <p>Some easy answer are: garbage collection, a VM, lack of pointers, classloaders, reflection(?) </p> <p>What about language based answers? </p> <p>Please don't list <a href="http://stackoverflow.com/questions/457884/what-are-the-things-java-got-wrong">the things Java did wrong</a>, just right. </p>
java
[1]
4,348,531
4,348,532
PHP sessions using cross domain form processor
<p>I have a download page on my site. In order to reach it you have to fill out a form, unfortunately due to legacy coding beyond my control the form is processed via a script on another domain (where our crm lives).</p> <p>I am having trouble passing the session value that is added when you successfully submit the form to the download page. Again, the user fills out a form, form is processed and the session value added and they should be returned to the download page. </p> <p>The download page should be inacessible in any other situation. Don't want people bypassing the form and going straight to the download. </p> <p>processor script code</p> <pre><code>&lt;?PHP session_start(); //lots of database stuff //successful insertion to database if (($row = mysql_fetch_assoc($result))) { $redirect .= '?sessionid=xvyXXXXX'; header("Location: http://" . $redirect); } ?&gt; </code></pre> <p>software download page code</p> <pre><code>&lt;?php $code = $_GET['sessionid']; if(strcmp( $code , 'xvyXXXXX' ) != 0) { header("Location: http://kinetick.com/V3/download-registration.php"); } else { header("Location: http://kinetick.com/V3/download-software.php"); } ?&gt; </code></pre> <p>I can't get this to work. Is there another way taking into account the processor script is on another domain? currently when I remove the if/else and put a print its showing an empty array. Need some help big time! thx all</p>
php
[2]
655,890
655,891
How to read line (from a file) and then append + print in python?
<pre><code>for line in file: print line </code></pre> <p>In the code above when I change it to:</p> <pre><code>for line in file: print line + " just a string" </code></pre> <p>This only appends "just a string" to the last line</p> <p>PS: Python newbie</p>
python
[7]
5,671,337
5,671,338
Bidirectional implicit casting?
<p>From what I understand I can have a type <code>Foo</code> automatically cast itself to an int when it is passed to a method expecting an int. Can I also do the other direction? i.e. have an int implicitly cast itself to <code>Foo</code> and have this <em>definition also be in foo</em>?</p> <p>My understanding may be incorrect.</p>
c#
[0]
259,797
259,798
Are these clauses identical?
<p>I'm looking at a javascript that my colleague wrote and I think that it looks like it does the same in both clauses:</p> <pre><code>function doSubmitOversikt(action, command, status) { var checked = document.getElementById("klarbox").checked; if(status &amp;&amp; !checked) { if (confirm("Ärendet är satt som Klar (formell handläggning första delen klar). Vill du verkligen ångra detta? Att ångra kan innebära att ärendet behöver arras om i CICS.")) { document.actionForm.action.value = action; document.actionForm.actionCommand.value = command; document.actionForm.submit(); disableAll(); } } else { document.actionForm.action.value = action; document.actionForm.actionCommand.value = command; document.actionForm.submit(); disableAll(); } } </code></pre> <p>What will be the difference between the above code and to unconditionally do</p> <pre><code> document.actionForm.action.value = action; document.actionForm.actionCommand.value = command; document.actionForm.submit(); disableAll(); </code></pre> <p>?</p>
javascript
[3]
4,661,953
4,661,954
How to iterate through the built-in types in C#?
<p>I want to iterate through the built-in types (bool, char, sbyte, byte, short, ushort, etc) in c#.</p> <p>How to do that?</p> <pre><code>foreach(var x in GetBuiltInTypes()) { //do something on x } </code></pre>
c#
[0]
2,053,225
2,053,226
How do I extend a class with c# extension methods?
<p>Can extension methods be applied to the class?</p> <p>For example, extend DateTime to include a Tomorrow() method that could be invoked like:</p> <pre><code>DateTime.Tomorrow(); </code></pre> <p>I know I can use </p> <pre><code>static DateTime Tomorrow(this Datetime value) { //... } </code></pre> <p>Or</p> <pre><code>public static MyClass { public static Tomorrow() { //... } } </code></pre> <p>for a similar result, but how can I extend DateTime so that I could invoke DateTime.Tomorrow?</p>
c#
[0]
1,539,823
1,539,824
java - automatically printing stack traces for uncaught exceptions
<p>Is there a way to have java print a stack trace to console for all uncaught exceptions like in many IDEs, other than overwriting the uncaught exception handler in the thread/threadgroup?</p>
java
[1]
633,819
633,820
Product ids in inAppPurchasing of Android
<p>I am working in an android app, which has an inappPurchasing implementation <a href="http://developer.android.com/guide/market/billing/billing_integrate.html" rel="nofollow">http://developer.android.com/guide/market/billing/billing_integrate.html</a>. </p> <p>I have tested with reserved product ids and now I'm going to test with my own product ids. I have a test account, I have saved my app in the Android market and published its one product and tested. Its goes perfect. I want to know that I have more than 60 products in which more than one have same price. Should I use different ids for every products or one id for all products of the same price?</p> <p>And one more thing: Can we see productIds published in the market in the purchasing process or is it hidden from the user?</p>
android
[4]
1,611,601
1,611,602
The remote server returned an error: (401) Unauthorized
<p>I'm trying to get the access token from the windows live connect api by using this code</p> <p>string requestUrl = "https://consent.live.com/AccessToken.aspx";</p> <pre><code> // Request the access token. string postData = string.Format("{0}?wrap_client_id={1}&amp;wrap_client_secret={2}&amp;wrap_callback={3}&amp;wrap_verification_code={4}&amp;idtype={5}", requestUrl, "000000004C039809", "l4VJekL1vFL1iFVmcP5qLkWv9ukY4mdl", "http://ewshops.com", "dac5d71d-d640-30d1-ebed-3576b132b3ec", "cid"); byte[] postDataEncoded = System.Text.Encoding.UTF8.GetBytes(postData); WebRequest req = HttpWebRequest.Create(requestUrl); req.Method = "POST"; // req. req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = postDataEncoded.Length; Stream requestStream = req.GetRequestStream(); requestStream.Write(postDataEncoded, 0, postDataEncoded.Length); WebResponse res = req.GetResponse(); string responseBody = null; using (StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8)) { responseBody = sr.ReadToEnd(); } // Process FORM POST. NameValueCollection responseCollection = System.Web.HttpUtility.ParseQueryString(responseBody); return responseCollection["wrap_access_token"]; </code></pre> <p>but I've recieved the following error</p> <p>The remote server returned an error: (401) Unauthorized.</p>
c#
[0]
3,536,524
3,536,525
importing SQLiteWrapper gives error
<p>i am trying to import the SQLiteWrapper but it gives an error...i am not quite sure why... and also cant import these packages </p> <pre><code>import android.provider.Telephony.Sms; import android.provider.Telephony.Threads; import android.provider.Telephony.Sms.Inbox; import android.provider.Telephony.Sms.Intents; import android.provider.Telephony.Sms.Outbox; import com.google.android.mms.MmsException; import android.database.sqlite.SqliteWrapper </code></pre> <p>; can anyone help i am developing in eclipse on android 2.2 and running code on emulator...</p>
android
[4]
1,673,251
1,673,252
How to determine a web visitor's country of origin?
<p>How to determine a web visitor's country of origin?</p>
php
[2]
4,747,228
4,747,229
Language selection using images in PHP
<p>I have found an open source PHP script that uses a select menu to choose the language.</p> <p>In the code session makes use of a loop to fill in the select menu, as above...</p> <pre><code>$la = 0; foreach($trans['languages'] as $short=&gt;$langname) { $params['LANGSEL'][$la]['LANG_SHORT'] = $short; $params['LANGSEL'][$la]['LANG_LONG'] = $langname; $la++; } </code></pre> <p>In the php template creates the select menu like that...</p> <pre><code>&lt;td&gt;&lt;select class="select" name="lang"&gt;&lt;#FOR LANGSEL#&gt; &lt;option value="&lt;#LANG_SHORT#&gt;"&gt;&lt;#LANG_LONG#&gt;&lt;/option&gt; &lt;#/FOR LANGSEL#&gt;&lt;/select&gt;&lt;/td&gt; </code></pre> <p>So this code works fine but i find it kinda ugly so i am trying to make an image input instead So i thought something like that would work..</p> <pre><code>&lt;input type="image" name="lang" value="http://localhost/index.php?lang=en" src=" &lt;#IMAGES_DIRECTORY#&gt;/english.png"&gt;&lt;/td&gt; &lt;input type="image" name="lang" value="http://localhost/index.php?lang=it" src=" &lt;#IMAGES_DIRECTORY#&gt;/italian.png"&gt;&lt;/td&gt; </code></pre> <p>But nothing changes, the page always shows up in italian that is the default language.. Thanks in advance from a newbie that is struggling to learn some html and php.</p>
php
[2]
3,247,377
3,247,378
How can I find out what enums are defined by a class?
<p>I know I can get the public static members of a class by doing something like:</p> <p><code>obj.getClass().getFields()</code></p> <p>but this doesn't get me the enums. I'd like to be able to get them from the Class object returned by the getClass method. Any ideas?</p>
java
[1]
4,952,470
4,952,471
PHP: Call to a member function GetUserCollection() on a non-object
<p>Apologies for posting this question - I know they have been asked and answered several times (i.e. <a href="http://stackoverflow.com/questions/1787561/call-to-a-member-function-on-a-non-object">Call to a member function on a non-object</a>, etc), but non of the suggested solutions seem to work for me. This is what I have:</p> <pre><code>class Common { private $model; public function _construct() { $this-&gt;model = Model::GetInstance(); //$this-&gt;model-&gt;GetUserCollection(); } public function validateusername($username) { $userlist = $this-&gt;model-&gt;GetUserCollection(); $result = true; if ($username == false) { $this-&gt;error = "Please enter username."; $result = false; } } } // This is my DB model class Model { private static $instance = null; private $conn = false; private function __construct() { if (!$this-&gt;connect()) { print "Unable to connect to database!"; exit; } } public function connect() { if ($this-&gt;conn == false) { $this-&gt;conn = mysql_connect(DBHOST, DBUSER, DBPASS); if ($this-&gt;conn) { if (!mysql_select_db(DBNAME, $this-&gt;conn)) { print "DB Connection Error!"; exit; } } } return $this-&gt;conn; } public function GetUserCollection() { return UserCollection::GetInstance(); // return new UserCollection(); } public static function GetInstance() { if (!self::$instance) { self::$instance = new Model(); } return self::$instance; } } </code></pre> <p>Why is it exactly this line : <strong>$userlist = $this->model->GetUserCollection();</strong> which is throwing me an error even though I am returning a new instance of it in the in the model Thanks in advance, JJ.</p>
php
[2]
794,721
794,722
any simple jquery <table> paginators
<p>I'm looking for a jquery plugin so I can paginate my html tables (the content of which is generated by a jsp c:forEach). But so far I haven't found anything that worked.</p> <p>The plugin doesn't need to be fancy, in fact something like the first example on <a href="http://dl.dropbox.com/u/4151695/html/pajinate-0.2/examples/example1.html" rel="nofollow">http://dl.dropbox.com/u/4151695/html/pajinate-0.2/examples/example1.html</a> would do fine.</p> <p>I'm still very new to jquery so I don't have the knowledge yet to write one myself.</p> <p>So does anyone have any pointers where I could find one?</p>
jquery
[5]
3,131,327
3,131,328
Beginning iphone development
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1081678/beginning-os-x-iphone-development-reference-texts">Beginning OS X &amp; iPhone Development: Reference texts</a> </p> </blockquote> <p>I am struggling with beginning iphone development using Objective-C. What are the best resources I can use for learning iphone development from scratch ?</p> <p><strong>Update</strong>: Sorry for the dup question. </p> <p>After reading the other threads, I've decided to purchase <a href="http://www.bit.ly/HeadFirstiPhone" rel="nofollow">Head First iPhone Development: A Learner's Guide to Creating Objective-C Applications for the iPhone</a> </p> <p>This book seems to be the best choice for beginning iphone development, and was recommended by most of the experts here.</p> <p>Thanks! </p>
iphone
[8]
3,770,098
3,770,099
PHP: How can I access / use a method within its own class?
<p>I am trying to figure out how to use a method within its own class. example:</p> <pre><code>class demoClass { function demoFunction1() { //function code here } function demoFunction2() { //call previously declared method demoFunction1(); } } </code></pre> <p>The only way that I have found to be working is when I create a new intsnace of the class within the method, and then call it. Example:</p> <pre><code>class demoClass { function demoFunction1() { //function code here } function demoFunction2() { $thisClassInstance = new demoClass(); //call previously declared method $thisClassInstance-&gt;demoFunction1(); } } </code></pre> <p>but that does not feel right... or is that the way? any help?</p> <p>thanks</p>
php
[2]
2,165,441
2,165,442
Programmatical ViewState
<p>View state can store the page value at the time of post back (Sending and Receiving information from Server) of your page. View State stored the value of page controls as a string which is hashed and encoded in some hashing and encoding technology. We can see it in the page.</p> <p>My Question : We can also declare the programmatically View state in the code behind , during the round trip ,where is it maintain in the page life cycle, can we see in the page?</p>
asp.net
[9]
929,156
929,157
c++ calculations
<p>I'm trying to do a simple calculation in C++ I know I can do this but it slipped my mind.</p> <pre><code>45 + x(.25) = 70 </code></pre> <p>How do I solve for <code>x</code> in code.</p> <p>If it helps this equation should be x = 100 as in .25 of 100 will result in 70.</p> <p>Tips: I'm trying to avoid the <code>&lt;cmath&gt;</code> include at all costs.</p>
c++
[6]
4,449,951
4,449,952
Allow only certain websites to access a PHP page
<p>I am trying to make a basic API for my website so certain other websites that I approve of can show content from my site. I have a PHP script on my server that the other websites can access to pull content in XML format. How can I make sure that only certain websites can access this php page on my server?</p>
php
[2]
3,093,905
3,093,906
Extending an object ( nesting )
<p>In a section object, I have a <code>CategoryId</code> - like a foreign key. Now, I would like to copy each section into the matching category object.</p> <p>Source:</p> <pre><code>var sections = [{title:"FirstSection", CategoryId : 1}, {title:"SecondSection", CategoryId : 1}, {title:"ThirdSection", CategoryId : 2}]; var categories = [{title:"Cat1", Id : 1}, {title:"Cat2", Id : 2}]; </code></pre> <p>The result would look like this:</p> <pre><code>categories = [{title:"Cat1", Id : 1, sections : [{title:"FirstSection", CategoryId : 1}, {title:"SecondSection", CategoryId : 1}] }, {title:"Cat2", Id : 1, sections: [{title:"ThirdSection", CategoryId : 2}] }]; </code></pre> <p>All sections with <code>CategoryId = 1</code> are now in a sections array of the category with Id = 1.</p> <p>Maybe I am searching for the wrong keywords, but I can not find a solution for this. </p>
javascript
[3]
1,482,074
1,482,075
Android image comparison by pixel
<p>I am trying to Math any random image which is captured by my camera. I want to do comparision between them and I want to give rating of that out of 10.</p> <p>I am using this but it is not working:</p> <pre><code> bMap1 = BitmapFactory.decodeFile("/sdcard/mahendra.jpeg"); bMap2 = BitmapFactory.decodeFile("/sdcard/google.jpg"); System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+bMap1+"and"+bMap2); //image.setImageBitmap(bMap); BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.ARGB_8888; opt.inSampleSize = 5; int intColor1 = 0; int intColor2 = 0; for (int x = 0; x &lt; bMap1.getWidth(); x++) { for (int y = 0; y &lt; bMap1.getHeight(); y++) { intColor1 = bMap1.getPixel(x, y); intColor2 = bMap2.getPixel(x, y); //System.out.print(" ("+ x + ","+ y +") c:" + intColor1); } String resultString = String.valueOf(intColor1); } //now calculate percentage difference double razlika = (((double)intColor1 - intColor2)/intColor2)*100; System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+razlika); if(razlika&lt;100) { System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;Rating of your image is 1 out of 10"); } </code></pre>
android
[4]
4,855,715
4,855,716
ASP.NET site maintenance tip
<p>I am planning to shift my site from one host to other. Any best practices to follow while moving the site?</p> <ul> <li>my site is always accessed using both <code>http://mysomesite.com</code> and <code>http://www.mysomesite.com</code>. I have not set redirection from <code>http</code> to <code>http://www</code>. Should I be doing it now?</li> </ul> <p>When the nameservers are updated, how do I inform the users? Any way in ASP.NET to put the site in maintenance mode?</p> <p>UPDATE: I meant to ask should I redirect <code>http://mysomesite.com</code> to <code>http://www.somesite.com</code> or is it OK to leave it like that. </p>
asp.net
[9]
1,342,694
1,342,695
Variable declaration warning in VS2008
<p>The following code in VS2008 gives me a "variable is already defined" warning:</p> <pre><code>if (someVar) { var a = 1; } else { var a = 2; } </code></pre> <p>The warning is given on the second <code>var a = ...</code>. To cure this warning I have done:</p> <pre><code>var a; if (someVar) { a = 1; } else { a = 2; } </code></pre> <p>But is this the correct way to do it?</p> <p>Thanks,</p> <p>AJ</p>
javascript
[3]
1,182,173
1,182,174
SearchView as part of the AlertDialog
<p>[This is posted on Android Developer's forum as well]</p> <p>I am trying to place the search widget [<code>SearchView</code> basically] in the title part of an <code>AlertDialog</code>. Is that allowed, i.e. will it work? The idea is to have the user enter a search word and when he/she presses the <kbd>Enter</kbd> key on the keyboard, to use the search word entered to search through an array of strings and display the result as a <code>listView</code> in the same <code>AlertDialog</code>'s body portion. The following is the piece of relevant code.</p> <pre><code>AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainActivity.this); RelativeLayout titleLayout = new RelativeLayout(this); SearchView sv = new SearchView(this); titleLayout.addView(sv); dialogBuilder.setCustomTitle(titleLayout); </code></pre> <p>When I run this code, I see the search widget in the title alright. The Virtual/Soft keyboard pops up when I click inside the search box - but I am unable to type in it because the <code>AlertDialog</code> disappears as soon as I click anywhere outside of it (as it should). I am wondering if the keyboard is associated with the activity that is launching the <code>AlertDialog</code> instead of being in the context of the <code>AlertDialog</code> itself.</p> <p>Any ideas?</p> <p>TIA.</p>
android
[4]
772,262
772,263
I need help designing a long running job processing server
<p>I'm about to propose a new architecture for several pieces of the system I'm working on; it's going to entail getting a lot of number crunching and data translation jobs off of tomcat, and on a more fitting platform and I need a little advice.</p> <p>First, the way this system is currently setup: There is an AS400 and a PostgreSQL database; some of those tables need to be synchronized at various points in the year. An administration application running on Tomcat6 would have a button, "Synchronize" and the struts action class will spawn a new thread to run the job. The job can take anywhere from 15 seconds to 4 days (this is the maximum time we have experienced so far).</p> <p>I do not like this design. Tomcat is a web server, not a job processing server.</p> <p>So, the solution I have in mind is to take one of our unused servers and put Jboss 7 on it. then have a simple interface on that job processing server (e.g. web, JMS) that would listen for triggers. when someone clicks on the "synchronize" button on the web page, the job server is sent the signal telling it what job to fire, what parameters are included and to start processing the job.</p> <p>Years ago I designed a similar concept in job processing where I had a JMS queue that would listen for jobs to come in. when a certain task was added to the queue the system would fire off and run that task. But on that system the jobs would never take more than 5 or 6 seconds, not several days so I'm not sure that JMS Queues would be the best fit here. I looked at Quartz but thats more of a recurring task scheduling system. Although I know I can code around that and make it work, I'm still wondering if thats the best tech for the problem.</p> <p>Do you have any suggestion?</p>
java
[1]
3,409,263
3,409,264
Undefined index: msg in C:\xampp\htdocs\admin\login.php on line 16
<p>I am getting an undefined index error for this line:</p> <pre><code>$msg = $_GET['msg']; </code></pre>
php
[2]
2,640,195
2,640,196
wallpaper crop function
<p>If I try and use an image from my gallery to be my homescreen wallpaper, I have to first crop the image. The crop screen that appears has two buttons (as well as save + cancel) which allows to choose between only a full screen image or whether or not you would like to be able to scroll the wallpaper (i.e. the width is double the screen size).</p> <p>I was wondering if it was possible to use this cropping function elsewhere. For example, I am making a live wallpaper and would like the user to be able to choose a custom background image. I would like to use this crop function to get the image the correct size and aspect ratio.</p>
android
[4]
1,350,662
1,350,663
Compare two hashsets?
<p>I have two hashsets like this:</p> <pre><code>HashSet&lt;string&gt; log1 = new HashSet&lt;string&gt;(File.ReadLines("log1.txt")); HashSet&lt;string&gt; log2 = searcher(term); </code></pre> <p>How would I compare the two?</p> <p>I want to make sure that <code>log2</code> does not contain any entries from <code>log1</code>. In other words, I want to remove all(if any), items that <code>log1</code> has inside <code>log2</code>.</p>
c#
[0]
1,438,027
1,438,028
how to add and remove css class
<p>how to remove CSS default class</p> <p>This is my div </p> <pre><code>&lt;div id="messageContainer"&gt; </code></pre> <p>This is my css class</p> <pre><code>#messageContainer{ height:26px; color:#FFFFFF; BACKGROUND-COLOR: #6af; VERTICAL-ALIGN: middle; TEXT-ALIGN: center; PADDING-TOP:6px; } </code></pre> <p>I want to remove default class and new css class</p> <p>Please help;</p>
jquery
[5]
354,261
354,262
Using Geocoder to show user's location Address
<p>I have this method to show the user's latitude and longitude on a map activity:</p> <pre><code>public void animateMap(Location location){ double lat = location.getLatitude(); double lng = location.getLongitude(); Toast.makeText(MyMapActivity.this, "Sie sind an\n" + lat + "\n" + lng, Toast.LENGTH_SHORT) .show(); GeoPoint point = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mapController.animateTo(point, new Message()); mapOverlay.setPointToDraw(point); } </code></pre> <p>How to implement the Geocoder on my method? So the Toast will display the location's address instead of the coordinates</p>
android
[4]
1,052,474
1,052,475
How do I validate favicons using Javascript?
<p>In a previous post on <a href="http://stackoverflow.com/questions/7034333/adding-favicons-with-generic-option">SO</a> I asked how to display favicons with a generic option for favicons that do not exist. </p> <pre><code>&lt;img src="example.com/favicon.ico"; alt=""/&gt; </code></pre> <p>This code was posted:</p> <pre><code>var img = document.getElementsByTagName('img')[0], favicon = new Image; favicon.src = 'http://example.com/favicon.ico' favicon.onerror = function() { img.src = 'http://url-on-local-server.com/favicon.ico'; } </code></pre> <p>However I do not understand the need for "new Image", why can't I just use the existing image like this?</p> <pre><code>var img = document.getElementsByTagName('img')[0], img.src = 'http://example.com/favicon.ico' img.onerror = function() { img.src = 'http://url-on-local-server.com/favicon.ico'; } </code></pre>
javascript
[3]
3,445,033
3,445,034
Merge datatables but ignore duplicated rows
<p>I have the following code, its a custom people picker for sharepoint 2010.</p> <p>It searches by username, but also by the person name. Because its a contains search, if I try with part of my username:</p> <p>cia</p> <p>It shows my duplicated rows because that matches the username but also the person name.</p> <p>this is my code:<br> I cant use LINQ</p> <pre><code> protected override int IssueQuery(string search, string groupName, int pageIndex, int pageSize) { try { // Find any user that has a matching name var table = ADHelper.ExecuteNameQuery(RootPath, search); // 20249: Search by username, method was already done, but it was not being called. var table2 = ADHelper.ExecutesAMAccountNameQuery(search); table2.Merge(table,); PickerDialog.Results = table2; </code></pre>
c#
[0]
2,371,322
2,371,323
How to get a substring from a large string?
<p>I have a large string in the form of a query, like for example: "SELECT column_name1, column_name2, column_name3, column_name4 FROM table1 JOIN table2 ON table1.field1 = table2.field1" (the original query will have about 30 column names from joins of about 6-8 tables)</p> <p>Now I just want the column names from this string. How can I achieve that?</p> <p>Thank you in advance.</p>
c#
[0]
5,455,475
5,455,476
Comparison method violates its general contract(arraylist comprasion)
<p>I asked before <a href="http://stackoverflow.com/questions/16429431/compare-arraylists-of-chars-alphabetically">compare arraylists of chars alphabetically</a> how to compare arraylists of chars alphabetically. Now I decided to implement it. </p> <p>Here is my comprasion method</p> <pre><code>@Override public int compareTo(Word o) { int left = this.count(); int right = o.count(); if (left == right){ if (this.length() &gt; o.length()){ try{ for(int i = 0; i &lt; this.length(); i++){ if (this.get(i).compareTo(o.get(i)) &lt; 0) return 1; } }catch(IndexOutOfBoundsException e){ return -1; } } else { try{ for(int i = 0; i &lt; o.length(); i++){ if (this.get(i).compareTo(o.get(i)) &lt; 0) return -1; } }catch(IndexOutOfBoundsException e){ return 1; } } } else return (left &gt; right)?1:-1; return 0; } </code></pre> <p>I check whether <code>this.count</code> is equal to <code>o.count</code> and if not I begin to compare every element of arraylists. But if it is not equal then I compare <code>left</code> and <code>right</code>.</p> <p>But I don't understand why it throws such exception. Where is the problem?</p> <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.ComparableTimSort.mergeHi(Unknown Source) at java.util.ComparableTimSort.mergeAt(Unknown Source) at java.util.ComparableTimSort.mergeCollapse(Unknown Source) at java.util.ComparableTimSort.sort(Unknown Source) at java.util.ComparableTimSort.sort(Unknown Source) at java.util.Arrays.sort(Unknown Source) at java.util.Collections.sort(Unknown Source) at task.Main.main(Main.java:69) </code></pre> <p><code>Main.java: 69</code> is where <code>Collections.sort</code> invoked`.</p>
java
[1]
153,101
153,102
twitter connectivity via iphone application
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3642129/send-images-to-twitter-through-code">Send images to twitter through code</a> </p> </blockquote> <p>I have to upload text and image on twitter via my iphone application. I couldnt find sample code or any other link to do this task. please,any one having solution on that. give me suggestion. or sample code.</p>
iphone
[8]
4,797,851
4,797,852
Read file and then jump to end
<p>I want to read the text file and after that get the offset to which file is read.I tried the following program but the thing is i dont want to use RandomAccessFile,how can i do that.</p> <pre><code>RandomAccessFile access = null; try { access = new RandomAccessFile(file, "r"); if (file.length() &lt; addFileLen) { access.seek(file.length()); } else { access.seek(addFileLen); } } catch (Exception e) { e.printStackTrace(); } String line = null; try { while ((line = access.readLine()) != null) { System.out.println(line); addFileLen = file.length(); } </code></pre>
java
[1]
2,626,437
2,626,438
how to read characters from a string for android
<p>how can i read characters from a string variable until a special character has reached, for example a '/'.it should be read from begining. and how to send this string to another activity from onItemClickListener() method</p>
android
[4]
19,951
19,952
Using Activity of Project2 in Project1
<p>Project1 : its an android project without an activity Project2: its an android project with a sigle Hello world Activity.</p> <p>I created a jar of project2 with the name Project2.jar and added it as a reference library in project1 and i am trying to see the hello world activity when i run project1.</p> <p>while creating the jar for project2 i added only the src folder, and i registered the hello world activity of project2 in the manifest file of project1.</p> <p>the error being: "Uncaught handler: thread main exiting due to uncaught exception" "java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example1.project1/com.example2.Project2}: java.lang.ClassNotFoundException: com.example2.Project2 in loader dalvik.system.PathClassLoader@437356c8"</p> <p>Need Assistance on this.</p>
android
[4]
478,113
478,114
From which library to include inline List creation?
<p>I find myself re-implementing List creation method. But I'm sure that it is already implemented in some widely used library (if not in java itself). So my question is: Which useful library to include, to get functionality of following code:</p> <pre><code>public static &lt;T&gt; List&lt;T&gt; buildList(T... args) { ArrayList&lt;T&gt; list = new ArrayList&lt;T&gt;(); for (T arg : args) { list.add(arg); } return list; } </code></pre> <p>EDIT: Already found what i was looking for: <a href="http://code.google.com/p/google-collections/" rel="nofollow">http://code.google.com/p/google-collections/</a> I just import statically:</p> <pre><code>import static com.google.common.collect.Lists.newArrayList; </code></pre> <p>and use:</p> <pre><code>methodThatTakesArray(newArrayList("fst", "snd", "lst)); </code></pre>
java
[1]
5,225,334
5,225,335
How to prevent my app from running in the background on the iPhone
<p>Is there any way to cause an app to quit instead of going to background when the home button is pressed? For security reasons, it would be better if the app did not run in background but actually closed when home is pushed. This is <em>not</em> for users' security, but rather for company data on the app, so it is not a user's choice. I could not find any way to quit other than forcing an exit, which Apple discourages.</p>
iphone
[8]
155,249
155,250
unexpected EOF while parsing
<pre><code>while True: no=input() if no=='': break else: split_change(no) </code></pre> <p>This gives EOF error, how to check for EOF while getting input from std input ?</p>
python
[7]
3,637,880
3,637,881
Array: Storing Objects or References
<p>As a Java developer I have the following C++ question.</p> <p>If I have objects of type A and I want to store a collection of them in an array, then should I just store pointers to the objects or is it better to store the object itself?</p> <p>In my opinion it is better to store pointers because: 1) One can easily remove an object, by setting its pointer to null 2) One saves space.</p>
c++
[6]
656,063
656,064
displaying message in PyQt4
<p>I am developing an application using PyQt4 .</p> <p>Currently I am in need of a message box ie if I am on a current screen and user presses a function the callback function should display message whether by a message box or any other way you can suggest ......However when the user cancels it the flow should go to the current screen.</p> <p>Please help ....</p> <p>Thanks a lot.. </p>
python
[7]
4,801,270
4,801,271
How to know if a mobile or a device have hardware support for USB accessory mode?
<p>I am trying to build a project which connect android with arduino using Android Open Accessory Development Kit But i found that i could use this Platform with android devices that have hardware support for USB accessory mode.My question is How to know if my mobile or a device have hardware support for USB accessory mode? Many Thanks in advance.</p>
android
[4]
17,389
17,390
Current milliseconds, from long to int
<p>I currently have the following code:</p> <pre><code>public static int currentTimeMillis() { long millisLong = System.currentTimeMillis(); while ( millisLong &gt; Integer.MAX_VALUE ) { millisLong -= Integer.MAX_VALUE; } return (int)millisLong; } </code></pre> <p>which returns the current time in an <code>int</code> format (not exactly, but it can be used for time differences). For very good reasons, I can't use <code>long</code>. </p> <p>Yes, I am just interested in the difference between two calls, and this approach works well. But it just looks wrong. I know that. And inefficient. I know. So my questions is, how can I improve it?</p> <p>I need a function that returns an <code>int</code> such that:</p> <pre><code>int x1 = currentTimeMillis(); //my function long y1 = System.currentTimeMillis(); ..... int x2 = currentTimeMillis(); long y2 = System.currentTimeMillis(); // here, x2 - x1 must be equal to y2 - y1 </code></pre> <p>EDIT:</p> <p>FYI, I want to do this for benchmarking. I'm running tests on multiple threads in parallel, the stop event is triggered by an external component. I'm also serializing the data in a way that only supports <code>int</code>, and the object I'm serializing can not have <code>long</code> members. </p>
java
[1]
1,747,158
1,747,159
Can the bin2hex value two different strings be the same?
<p>I am using bin2hex to create unique id's for my users as an Identifier and I don't want to connect to MySQL for checking repetition .</p>
php
[2]
1,167,207
1,167,208
How to load GhostScript (gs64dll.dll) 64 bit dll in ASP.net 2010 application (It gives error with error code: HRESULT: 0x8007000B)
<p>To do this I have created c# wrapper and put gs64dll.dll in bin folder still it gives the same error.</p>
c#
[0]
2,951,926
2,951,927
jQuery, REAL :not operator equivalent?
<p>this code line select all the children inputs inside any div who his class name is not "id" and "quantity" ::</p> <pre><code>$("div.item &gt; div:not(.id,.quantity) &gt; :input").live("keydown",function(event) {}); </code></pre> <p><strong>what is the code line to do the opposite?</strong>, something like ::</p> <pre><code>$("div.item &gt; div:filter(.id,.quantity) &gt; :input").live("keydown",function(event) {}); </code></pre> <p>( of course <code>:filter</code> is not a valid jQuery selector )</p>
jquery
[5]
1,993,496
1,993,497
Android Keystore Rebuild? is it possible
<p>Actually, I have lost my keystore of some of my apps. But I know the exact information which was into that keystore, I used same info written in .txt file for every keystore.</p> <p>Is there any way to restore, rebuild by using the info were into that keystore?</p> <p>Any ways to recover keystore?</p> <p>You help will highly be appreciated. </p>
android
[4]
4,799,897
4,799,898
Finished Software Upload on Web
<p>I have finished a software application which i have made using Python only. I have used py2exe and created .exe format for distribution . Now I am stuck . I have no idea where can I upload my software for people to download it for free . This is a windows GUI App . I want to provide the software for free (but not the source code).Everywhere I go , i am asked to make a developer licence and provide company details etc (which i can't give)...And then charges per month with pay-per-download schemes.I don need any of all these . So please tell me any website (or if blogs can work), to which i can upload my software and it can be searched and downloaded by people for free. </p> <p>In advance , Thank you guys.</p>
python
[7]
3,464,739
3,464,740
Do all header("Location: member.php?id=$username") have to be the first thing in a script? (PHP)
<p>I know in the Manuel it says that the header has to be the first thing in a script, but how come I see some codes where <strong>header("Location: member.php?id=$username")</strong> is in a if-statement?</p> <p>Ex:</p> <pre><code>//a bunch of codes above if($result!="0"){ // authenication correct lets login $_SESSION["password"] = $password;; $_SESSION["username"] = $username; header("Location: member.php?id=$username"); } else { echo "Wrong username or password. Please try again!"; } </code></pre> <p>But when I do this, it sometimes would/won't throw an error. How do I allow the header (); to be used in a script without any errors? I want to redirect the user back to the login if they click "no" and to the homepage if they click "yes".</p>
php
[2]
4,971,930
4,971,931
Using AVAudioPlayer and MPMoviePlayerController simultaneously
<p>I need to use <strong>AVAudioPlayer</strong> and <strong>MPMoviePlayerController</strong> simultaneously i.e play a movie while the background loop is playing is it possible.<br> My bg music loop stops working when a movie starts playing , so I tried to stop the bg music loop and start the movie and when movie stops, start playing the bg loop again but this is also is not working.</p>
iphone
[8]
517,691
517,692
How to Show contact photo in my application?
<p>I want to show image of contacts(form contact list) in my application. How to do it? </p>
android
[4]
5,371,392
5,371,393
Any issues with using += on a string
<p>As the title suggests, is there any reason I shouldn't do the following to append something on to the end of a string:</p> <pre><code>string someString = "test"; someString += "Test"; </code></pre>
c#
[0]
1,442,648
1,442,649
How to access element in object?
<p>For example i have:</p> <pre><code>var my_ul = jQuery('&lt;ul/&gt;'); jQuery('&lt;li/&gt;').appendTo(my_ul); jQuery('&lt;li/&gt;').appendTo(my_ul); jQuery('&lt;li/&gt;').appendTo(my_ul); jQuery('&lt;li/&gt;').appendTo(my_ul); </code></pre> <p>Is it possible to access last li in ul?</p>
jquery
[5]
3,448,688
3,448,689
Is it possible for the main function to be a friend of a class?
<p>I know that this is detrimental to data hiding but theoretically is this allowed ?</p>
c++
[6]
1,039,607
1,039,608
java mac address different than iwconfig
<p>I have function for read MAC address in java:</p> <blockquote> <pre><code> for(Enumeration&lt;NetworkInterface&gt; enm = NetworkInterface.getNetworkInterfaces(); enm.hasMoreElements();){ NetworkInterface network = (NetworkInterface) enm.nextElement(); if(null != network.getHardwareAddress()){ System.out.print(network.getDisplayName()); byte[] mac = network.getHardwareAddress(); StringBuilder sb = new StringBuilder(18); for (byte b : mac) { if (sb.length() &gt; 0) sb.append(':'); sb.append(String.format("%02x", b &amp; 0xff)); } System.out.print(sb.toString()); return null; } } </code></pre> </blockquote> <p>This result: wlan0: 00:25:d3:9c:ad:7a But when I do: iwconfig, I reveive: 00:0D:F3:0D:DD:DC for wlan0</p> <p>Question, why ?</p> <p>EDIT: I am sorry for question, When I run ifconfig (not iwconfig) it responds:</p> <blockquote> <p>wlan0 Link encap:Ethernet HWaddr 00:25:d3:9c:ad:7a<br> inet addr:192.168.50.100 Bcast:192.168.50.255 Mask:255.255.255.0 inet6 addr: fe80::225:d3ff:fe9c:ad7a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2417546 errors:0 dropped:0 overruns:0 frame:0 TX packets:1608679 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3099222889 (3.0 GB) TX bytes:183978636 (183.9 MB)</p> </blockquote> <p>So it's okay, thank you anyway.</p>
java
[1]
3,171,461
3,171,462
android and camera flash
<p>I want to write application which will be used camera flash. I want the light to blink. For now I have this code:</p> <pre><code>void ledon() { cam = Camera.open(); Parameters params = cam.getParameters(); params.setFlashMode(Parameters.FLASH_MODE_ON); cam.setParameters(params); cam.startPreview(); cam.autoFocus(new AutoFocusCallback() { public void onAutoFocus(boolean success, Camera camera) { } }); } </code></pre> <p>this part:</p> <pre><code> cam.autoFocus(new AutoFocusCallback() { public void onAutoFocus(boolean success, Camera camera) { } }); </code></pre> <p>I dont know why its necessary but it wont work without it.</p> <p>This code turn on led and turn off automaticly for about 2 seconds. I want to led will turn on e.g. for 5 sec then 3 sec led off and then again on for 4 seconds. How I can manually set periods of time in which led will be on and off. Is this possible? Thanks for any help.</p> <p>PS. I have samsung galaxy ace.</p>
android
[4]
4,399,612
4,399,613
Arrays / vectors c++ pushing?
<p>I need to create a keyed array that I can push data to.</p> <p>I need to store id and time, and on an event push a new id and time to the array.</p> <p>After a look around, many people have suggested vectors.</p> <p>I'm not sure how I would implement it though, having two keys, and how to push to them?</p> <p>If anyone could help?</p>
c++
[6]
3,406,374
3,406,375
How do you replace content without losing focus?
<p>For example:</p> <pre><code>&lt;input type="text" name="test" onChange="document.formname.test.value=.document.formname.test.value.replace('something','something else')" /&gt; </code></pre> <p>The replace function works but it loses focus on every change</p> <p>How do you make it not lose focus?</p> <p>What I'm trying to do is make it so that certain text is immediately replaced with new text when its typed but you can continue typing</p>
javascript
[3]
736,373
736,374
gnu c++ floating number precision
<p>I have simple question about floating number,</p> <pre><code>double temp; std::cout.precision(std::numeric_limits&lt;double&gt;::digits10); temp = 12345678901234567890.1234567890; std::cout &lt;&lt; (temp &lt; std::numeric_limits&lt;double&gt;::max()) &lt;&lt; std::endl; std::cout &lt;&lt; std::fixed &lt;&lt; std::endl; std::cout &lt;&lt; temp &lt;&lt; std::endl; </code></pre> <p>However, the output I get is this,</p> <pre><code>1 12345678901234567168.000000000000000 </code></pre> <p>The value of temp is still within the range of double, however, the value is completely different. I am wondering what have I done wrong here?</p> <p>Thanks.</p>
c++
[6]
1,414,315
1,414,316
How can I set using of "WHSUserPermission" class?
<p>How can I set using of "WHSUserPermission" class? I don't find microsoft.homeserver.sdk.interop.v1.dll</p>
c#
[0]
5,456,702
5,456,703
What are jQuery valHooks?
<p>After reading about <code>valHooks</code> in a <a href="http://bugs.jquery.com/ticket/9319">jQuery defect</a> and more recently seen in a <a href="http://jsfiddle.net/bV5fu/1/">fiddle</a> I searched the jQuery documentation and Google but I can't find anything other than a short example in the <a href="http://blog.jquery.com/2011/05/03/jquery-16-released/">jQuery 1.6 release post</a>. Please can someone explain what <code>valHooks</code> are and why they are useful?</p>
jquery
[5]
3,549,567
3,549,568
Daemon process which accepts arguments and returns results
<p>This is the scenario.</p> <p>Run a python script in background. Call this script using perl with arguments and returns a result to stdout. </p> <p>How do I write this python script ? </p> <p>Basically the question is how do I pass arguments to a running program ? Is this possible (via threads/subprocess/etc/., ) ? else how do I approach this problem ?</p>
python
[7]
3,374,152
3,374,153
Java: How many times is arr.length called in a for-loop?
<p>If <code>arr</code> is an array of size 10, in the following code block, how many times is <code>arr.length</code> accessed?</p> <pre><code>for (int i = 0; i &lt; arr.length; ++i); </code></pre> <p>Once? Or every time it loops?</p> <p>Thanks everyone! Here's what I ended up doing:</p> <pre><code>final int len = arr.length; for (int i = 0; i &lt; len; ++i); </code></pre>
java
[1]
2,005,142
2,005,143
javascript select input event
<p>I'm trying to create a select input from javascript and bind a function to when a user changes an option. So far I have:</p> <pre><code> var filter = document.createElement("select"); filter.name = "selectName"; filter.change = function() { alert("CHANGED"); } var pos = 0 for (i in filters){ var splitted = i.split('.'); var display = splitted[splitted.length - 2]; filter.options[pos] = new Option(display, i); pos++; } </code></pre> <p>But nothing happens on selecting something else. What is wrong with this code. Also, how can I get the new selected value in the function ? Something like:</p> <pre><code> alert(this.value + "has been selected") </code></pre>
javascript
[3]
317,999
318,000
jQuery button same function with link
<p>the jQuery is</p> <pre><code>$(function() { // videoThumb is a css class found in the foreach list class="videoThumb". ytvideo is the holder ID set as div ID $(".videoThumb4").on('click').ytplaylist({ holderId: 'ytvideo4', html5: true, playerWidth: '520', autoPlay: false, sliding: false, listsliding: true, social: true, autoHide: false, playfirst: 0, playOnLoad: false, modestbranding: true, showInfo: false }); }); </code></pre> <p>the main clickable link is this</p> <pre><code>&lt;a class="videoThumb4" href="http://www.youtube.com/watch?v=' . $yValue['videoid'] . '"&gt; ' . $yValue['description'] . ' &lt;/a&gt; </code></pre> <p>then i want this link to be like a button which is below. with same value and function. is this correct the button is</p> <pre><code>&lt;input class="videoThumb4" onclick="ytplaylist();" type="button" name="previewSel" value="Preview" id="previewbut"&gt; </code></pre> <p>the sample link was <a href="http://cocopop12.site11.com/search/" rel="nofollow">YT</a></p>
jquery
[5]
4,441,636
4,441,637
Installation of 3rd party package in Python
<p>How can i Install the 3rd party package in python.? I have setup.py file in 3rd party package. </p> <p>I need to know steps involved and how to do? Where to write the commands and how to actually do it.</p>
python
[7]
4,299,763
4,299,764
PHP Adding 2 decimal points numbers (money) gives wrong results in total amount
<p>I have an customer invoice table in my MySQL database with a DECIMAL(10,2) field called price.</p> <p>When fetching these values in php and calculating a sum amount, </p> <p>ex: in the script </p> <pre><code>$totalAmount = 0; // initialised them to while(records){ $amount = $inv_amount - ($pay_amount + $onamount); //float i guess. 2.22, 14.22 $totalAmount = $totalAmount + $amount; //float i guess. 2.22, 14.22 ..etc } </code></pre> <p>when <code>echo $totalAmount;</code> it has a slight error in the final amount 0.01 however when dealing which large datasets around 20,000 this error becomes very considerable such as 200+</p> <p>what is the safest way to do this when dealing with prices and such with these numbers in PHP? Or will I end up with potential rounding errors and things like that which are common when working with floating point data types?</p> <p>is using </p> <pre><code>round number_format </code></pre> <p>is the most suitable solution for this type of a financial application ?</p>
php
[2]
1,650,581
1,650,582
Invalid file destination in Java?
<pre><code> Scanner user = new Scanner(System.in); String word; System.out.println("Location of file: "); word = user.nextLine(); FileReader fileOpen = new FileReader(word); BufferedReader fileRead = new BufferedReader(fileOpen); </code></pre> <p>How can I do an error check if the user enters a wrong file destination? </p> <p>I get:</p> <pre><code> java.io.FileNotFoundException: </code></pre> <p>when a invalid file destination is entered. </p> <p>I want the program to say something like </p> <pre><code>System.out.println("Invalid directory"); </code></pre> <p>I get errors for the methods isDirectory() and exists() telling me they don't exist for the type String when I try:</p> <pre><code>if (word.exists()) { //do blah blah } else { //Print error } </code></pre>
java
[1]
1,840,736
1,840,737
How to concatenate two array objects using jquery without adding duplicates
<p>I have two array objects :</p> <pre><code> var arr1 =[{product_id: 2, name: 'stack'}, {product_id: 3, name: 'overflow'}]; var arr2 = [{product_id: 2, name: 'popo'},{product_id: 6, name: 'foo'}]; </code></pre> <p>I do jquery like follows:</p> <pre><code>$.each(arr1 , function(){ var productId = this.product_id; $.each(arr2 , function(productId){ if(this.product_id != productId){ arr2.push(this); } }); }); </code></pre> <p>at the end </p> <p>arr2 must look like</p> <pre><code> var arr2 = [{product_id: 2, name: 'stack'}, {product_id: 3, name: 'overflow'}, {product_id: 6, name: 'foo'}] </code></pre> <p>am i doing correct jquery coding..?</p>
jquery
[5]