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,252,234
4,252,235
Synchronized methods and locks
<p>When a thread invokes a synchronized method, it automatically acquires the intrinsic lock for that method's object and releases it when the method returns but what happens when a static synchronized method is invoked because a static method is associated with a class not an object?</p>
java
[1]
4,405,740
4,405,741
Creating a Alert Dialog after the animation ends in onAnimationEnd method
<p>I want to create a Alert Dialog after the animation ends. I used AlertDialog.Builder in onAnimationEnd method but i did'nt get any alert.So, please help me out with this.</p> <p>The Code looks something like this</p> <p>onAnimationEnd () { // Code Here }</p>
android
[4]
2,854,142
2,854,143
Method contains default parameter value
<p>I want to define a function in c# with 2 parameters and they have their default values , like</p> <pre><code> public T AccessEntity(string Id = null, string File = null) { return (from e in ServiceContext.CreateQuery&lt;T&gt;(TableName) where e.RowKey == Id || e.File == File select e).FirstOrDefault(); } </code></pre> <p>Now with this function user can search their record by file or id but if user try to search the record by file then how we can map the first argument to second formal parameter without passing any dummy value as a first argument.</p> <p>I do not want this : <code>invokingobj.AccessEntity(null, "name of file");</code></p> <p>Is this possible ?</p>
c#
[0]
1,638,586
1,638,587
Opening Browser in Android
<p>I tried to open link in a browser in JavaScriptInterface but it seems it didn't work. What the problem with the code below:</p> <pre><code>import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; public class JavaScriptInterface extends Activity{ Context mContext; JavaScriptInterface(Context c) { mContext = c; } public void openLink(){ Uri uri = Uri.parse("http://www.google.com"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } } </code></pre> <p>I already have the required permission:</p> <pre><code>&lt;uses-permission android:name="android.permission.INTERNET" /&gt; </code></pre>
android
[4]
1,289,296
1,289,297
No XML or code generated after creating a new Android Project
<p>No XML file (the default Main.xml) is generated after I create a new Android Project.</p> <p>I am using eclipse 4.2, ADT 20.0.3. ADT and SDK have been successfully installed, I think.</p> <p>When I create a new project, after choosing BlankActivity and leaving out all the details for the activity in their default state and click <em>Finish</em> as described here: <a href="http://developer.android.com/training/basics/firstapp/creating-project.html" rel="nofollow">Creating an Android Project</a>, but the project wizard does <em>not</em> disappear though a project without any XML or any code has been generated.</p>
android
[4]
1,751,926
1,751,927
PHP Caching, Storing cache in multiple directories
<p>We have a number of client sites still at GoDaddy, and they're complicated sites, so it will take some time for us to get around to migrating them. Ultimately, they'll end up in a dedicated environment, but for now, we're stuck with GoDaddy's shared hosting scenario.</p> <p>I want to setup output buffer PHP caching in static files, and have it clear maybe every 3-4 hours. What I've seen online for accomplishing this seems to throw all the cache files into a single big directory.</p> <p>GoDaddy has a policy (something we're battling now on another issue) where they don't allow more than 1,024 files in a single directory, because it degrades performance for the shared environment. I don't dispute that fact, but I'm hoping there may be a clever solution for PHP caching where we have a nested caching structure of sorts.</p> <p>Any ideas?</p>
php
[2]
3,179,484
3,179,485
Pointer to class holding array of pointers to another class
<p>I have three classes one is for drawing a <code>tilemap</code> to the screen, one contains the ships that have been initialized, and the last ones are the ships.</p> <p>The problem: I need the <code>tilemap</code> class to be able to see every ships location, so that it knows whether to draw water, or a ship based on x y grid coordinates.</p> <p>to do this I have used this: <code>pShipsContained-&gt;aContainer[0]-&gt;fGetCoordX()</code></p> <p>Which will build, but then freezes practically every thing on my pc.</p> <p>is there a better way to do this?</p> <p>using c++</p>
c++
[6]
5,918,463
5,918,464
How can i upload file in remote machine(LAN) using java
<p>How can i upload file in remote machine(LAN) using java program.I want to connect remote machine in LAN and upload file from my local machine to remote machine.So please tell me how can i do this.</p>
java
[1]
2,059,360
2,059,361
Android app doesnt work on version 4.0 +
<p>I have made an app that works on version 1.6 and above but once I updated my phone to 4.0.4 it gives me the following error, unfortunately, test has stopped and it wont run at all. Any reason as to why this might have happened? maybe I need to change something on the coding to make it work on the new version? package com.droidnova.android;</p> <pre><code>import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MotionEvent; public class SplashScreen extends Activity { protected boolean _active = true; protected int _splashTime = 5000; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); // thread for displaying the SplashScreen Thread splashTread = new Thread() { @Override public void run() { try { int waited = 0; while(_active &amp;&amp; (waited &lt; _splashTime)) { sleep(100); if(_active) { waited += 100; } } } catch(InterruptedException e) { // do nothing } finally { finish(); startActivity(new Intent("com.droidnova.android.splashscreen.MyApp")); stop(); } } }; splashTread.start(); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { _active = false; } return true; } </code></pre> <p>}</p>
android
[4]
1,155,130
1,155,131
Any mean to filter dataview with a custom function?
<p>I tried to filter dataview with a custom function but it isn't recognized. Is it possible ? If yes any article ?</p>
c#
[0]
2,114,743
2,114,744
how does the first part of this work?
<p>I have this snippet of <a href="http://jsfiddle.net/gL2kY/" rel="nofollow">jquery</a> and i want to know how it works....i understand the keypup but what i dont understand is the data ..what is it doing and </p> <p>here is the parts i dont understand</p> <pre><code>$('p span').each(function(){ $(this).data('factor',$(this).text()); }) </code></pre> <p>and </p> <pre><code>$('p span').each(function(){ $(this).text(function(){ return $(this).data('factor') * factor; }); }) </code></pre> <p>seems like they are looping but for what</p>
jquery
[5]
3,343,330
3,343,331
jQuery : selecting an element whose content is exactly such and such
<p>I want to select all A elements whose content is exactly "^" (these are return to top links). How to do that ?</p>
jquery
[5]
4,545,324
4,545,325
getting the error" No provisioned iPhone OS device is connected" for iphone
<p>what this error mean, when i am installing the app on device,i am getting this error. how can i solve this error. </p>
iphone
[8]
3,895,286
3,895,287
jQuery syntax help - filmstrip gallery code
<p>I'm trying to make a simple gallery and can't figure out what is wrong with my jQuery syntax.</p> <p>When the user clicks a thumbnail (one of the first three list items), I want to <code>clone()</code> the image and caption, and paste it into <code>li.expand</code> (the full-size image).</p> <p>The first two lines of my jQuery function are working (i.e. the "selected" class) but the last two lines don't seem to be doing anything. Am I using <code>$(this)</code> wrong?</p> <p><strong>HTML</strong></p> <pre><code>&lt;ul class="gallery2"&gt; &lt;li&gt; &lt;img src="img/1.jpg" /&gt; &lt;p&gt;Caption 1&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;img src="img/2.jpg" /&gt; &lt;p&gt;Caption 2&lt;/p&gt; &lt;/li&gt; &lt;li&gt; &lt;img src="img/3.jpg" /&gt; &lt;p&gt;Caption 3&lt;/p&gt; &lt;/li&gt; &lt;li class="expand"&gt; &lt;!-- This space will be filled with whatever thumbnail is selected --&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p><strong>jQuery</strong></p> <pre><code>$(".gallery2 li").click(function () { $(".gallery2 li").removeClass("selected"); $(this).addClass("selected"); $(".gallery2 li.expand").html().remove(); $(this).html().clone().appendTo(".gallery2 li.expand"); }); </code></pre>
jquery
[5]
1,990,262
1,990,263
Setting tab title textsize (android)
<p>Im trying to set tab title textsize in android.. </p> <p>Basically so I can see the text in all 4 tabs and I was searching up another question and they said to use custom theme but its not working for me for some reason. </p> <p>This is the code I'm using:</p> <p>Manifest </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mychecklist" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@styles/kustom" &gt; &lt;activity android:name="MyActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>styles.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="kustom" parent="@android:style/TextAppearance.Medium"&gt; &lt;item name="android:layout_width"&gt;fill_parent&lt;/item&gt; &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt; &lt;item name="android:textColor"&gt;#00FF00&lt;/item&gt; &lt;item name="android:typeface"&gt;monospace&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <hr> <p>Please help guys:)</p>
android
[4]
1,041,234
1,041,235
create image file on server
<p>I'm trying to use the facebook api to get the app user's profile pic and then save it on the server. I'm getting the image just fine, but creating a new image file and saving it in the correct folder seems to be a problem. I tried using the fopen and file_put_contents functions, but apparently they require that a file be created before hand. How can I save the fb user's image on the server? My code is as follows.</p> <pre><code>$facebook = new Facebook(array( 'appId' =&gt; '12345', 'secret' =&gt; '12345', 'cookie' =&gt; true )); $access_token = $facebook-&gt;getAccessToken(); if($access_token != "") { $user = $facebook-&gt;getUser(); if($user != 0) { $user_profile = $facebook-&gt;api('/me'); $fb_id = $user_profile['id']; $fb_first_name = $user_profile['first_name']; $fb_last_name = $user_profile['last_name']; $fb_email = $user_profile['email']; $img = file_get_contents('https://graph.facebook.com/'.$fb_id.'/picture?type=large'); $file = '/img/profile_pics/large/'; rename($img, "".$file."".$img.""); } </code></pre> <p>Any suggestions?</p> <p>Thanks,</p> <p>Lance</p>
php
[2]
1,863,416
1,863,417
How to customize the Android Ringtone Picker Dialog?
<p>I show a dialog for selecting one of the ring tones with the following code:</p> <pre><code> Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,"My customised Title"); Uri uri = ContentUris.withAppendedId( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, 1l); // Don't show 'Silent' intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri); startActivityForResult(intent, 123); </code></pre> <p>It open a ringtone select dialog like below.</p> <p>Now, Here you can see the fonts are too large, <code>i want to make it small</code>, so how can i do it ? How can i make it small. </p> <p><img src="http://i.stack.imgur.com/0Uf8D.png" alt="enter image description here"></p>
android
[4]
3,739,182
3,739,183
Function Return writing style in Java
<p>Is this :</p> <pre><code>String function() { return someString; } </code></pre> <p>Any different than this ?</p> <pre><code>String function() { return(someString); } </code></pre> <p>Its the return I'm interested in. I see the 2nd style less frequently, is it just convention or is the return in parenthesis actually doing something different?</p>
java
[1]
884,400
884,401
PHP removing backslash from code submitted through $_POST
<p>I have a code editor block and and submitting code like the following:</p> <pre><code>$something = "&lt;a href=\"somepage.html\"&gt;Link&lt;/a&gt;"; </code></pre> <p>However, when I submit it the string that gets output is missing the backslash escape characters and I get:</p> <pre><code>$something = "&lt;a href="somepage.html"&gt;Link&lt;/a&gt;"; </code></pre> <p>...which obviously isn't correct. I've figured out that it has to do with magic_quotes_gpc and when turned "On" works properly. My goal is for the application to be able to be installed easily on multiple hosts and I'd like to avoid having to turn on magic_quotes_gpc on every instance.</p>
php
[2]
4,183,403
4,183,404
My classes and functions - is there a better way?
<p>Just been looking at the way I am structuring my classes and wondering it there is a better way.</p> <p>I have forms which pass the information through to the process class. This class just forwards everything onto my main class which then does the work. When the work is done, it then passes the information through to the database class to carry out the sql.</p> <p>If in the main class there is an error, the error goes back to the process class. The process class sets a session variable true is the error is there.</p> <p>It then goes to the referrer which is the original page and on that page I have code which leaves an error message if the session variable is present.</p> <p>I know this possibly isn't the best way to explain things, but does it sound like a reasonable way to do things?</p> <p>I am just trying to improve the way I write classes! Thanks</p>
php
[2]
4,374,147
4,374,148
Runtime populated enum-like class
<p>I have many objects using few classes (means elements visual categorization like in html+css). Classes are not known at compile-time and they are used in conditions many times.</p> <p>To improve performance I've got one solution:</p> <pre><code>public class ElementClass { private static final Map&lt;String, ElementClass&gt; classes = new HashMap&lt;&gt;(); public final String name; public final String lowerName; public ElementClass(String name, String lowerName) { this.name = name; this.lowerName = lowerName; } public static ElementClass get(String name) { String lower = name.toLowerCase(); ElementClass c = classes.get(lower); if (c == null) { c = new ElementClass(name, lower); classes.put(lower, c); } return c; } } </code></pre> <p>The method <code>get</code> is used very less than comparison of <code>ElementClass</code> variables. It is in parsing configurations and for some <code>static</code> variables. I'm not sure if this is the best way to go, because I'm Java beginner.</p> <p>The examples usage of <code>ElementClass</code>:</p> <pre><code>// contains element styles based on it's class Map&lt;ElementClass,ElementStyle&gt; styles; void exampleFunction() { ElementClass c = ElementClass.get("special"); for( Element e : elements ) { if( e.cls == c ) doSomethingSpecial(); } } </code></pre>
java
[1]
4,222,092
4,222,093
Suggest closest matching 'correct' number from an array if, if statement returns false
<p>To simplify this question, I'm looking for php to suggest the nearest triangular number from an array to the number that has returned false.</p> <p>For example if the value of the original number is 54 (which is not triangular), I'd like php to select the nearest two variables from an array that would fit this: 55 is and so is 45. Then echo them as suggestions. How can I achieve this?</p> <p>To give some background information, here is my current code:</p> <pre><code>&lt;?php $x = 54; $area = $x * 8; $ans1 = sqrt(1 + $area) -1; $ans2 = sqrt(1 + $area) +1; $answer1 = $ans1 / 2; $answer2 = -$ans2 / 2; $answer3 = $answer1 + $answer2; if ( is_numeric( $answer2 ) &amp;&amp; strpos( $answer2, '.' ) === false ){ echo "$x is Triangular &lt;br /&gt; &lt;br /&gt;"; if ($answer2 &gt; $answer1) {echo "Total number of glasses per side: ".$answer2."&lt;br /&gt;";} if ($answer2 &lt; $answer1) {echo "Total number of glasses per side: ".$answer1."&lt;br /&gt;";} } else { echo "$x is not Triangular &lt;br /&gt; &lt;br /&gt;";} ?&gt; </code></pre>
php
[2]
776,498
776,499
Array values not being changed by method
<p>not a js expert so this might be a stupid question but...</p> <p>Why does the log show that the array has changed? I was expecting the array still to be a [0,0] since the method is invoked after the console.log. Also, if I try to replace the whole array like this: </p> <pre><code>this.my_array = [1,0]; </code></pre> <p>the log will still show [0,0], which is something that makes more sense to me. What's going on?</p> <pre><code>function Y() { this.my_array = [0,0]; this.changeIt = function() { this.my_array[0] = 1; }; } var z = new Y; console.log(z.my_array); z.changeIt(); </code></pre> <p>​</p>
javascript
[3]
2,537,089
2,537,090
Why onRestoreInstanceState() never gets called
<p>I am trying to save data in my activity and than restore it. I save data in on onSaveInstanceState() and then I try to restore the data in onRestoreInstanceState().</p> <p>I setup breakpoint, the method onSaveInstanceState() get called. But onRestoreInstanceState() or onCreate() never did.</p> <p>Here is my steps: 1. start my activity. 2. press 'Home' button on the phone. onSaveInstanceState() get called. 3. Click the icon in the launcher and launch my activity again. </p> <p>At this time, only onRestart() get called. But not onRestoreInstanceState() or onCreate() </p> <p>Does anyone know why?</p>
android
[4]
660,100
660,101
Warning message with virtual event
<p>I want to use virtual event &amp; override it in derive class. Following is the code snippet, I get a warning message while declaring the virtual event.</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication6 { class Program { static void Main(string[] args) { DeriveClass obj = new DeriveClass(); obj.myEvent += new EventHandler(obj_myEvent); obj.MyFunction(); Console.ReadLine(); } static void obj_myEvent(object sender, EventArgs e) { Console.WriteLine("Event fired....."); } } public abstract class BaseClass { // I get warning on this line - Warning 1 The event 'ConsoleApplication6.BaseClass.myEvent' is never used Program.cs public virtual event EventHandler myEvent; } public class DeriveClass : BaseClass { public override event EventHandler myEvent; public void MyFunction() { if (myEvent != null) { myEvent(this, null); } } } } </code></pre> <p>Can anybody please tell me how to resolve this warning?</p> <p>Atul Sureka</p>
c#
[0]
4,971,077
4,971,078
Changing colors on static image
<p>Is there a way to change the color of each state on a static image of the USA? My goal is to use state health rankings to color code a map of the USA, to show the overall 'healthiness' of each state. At first I thought I could just change the opacity of each state, but all the states are combined in one image. Then I thought of narrowing it down by coordinates, but that seems really messy and wouldn't be the same on different screen sizes. Is there any way I can do this?</p>
android
[4]
2,829,835
2,829,836
Launching app in background in iPhone
<p>Is there a way that I can use the url scheme approach to launch an application in the background or if it is already running in the background invoke it without it (the callee) coming to the foreground? I heard that this can be done in iOS 4.2 but don't see it when I use </p> <p>[[UIApplication sharedApplication] openURL:url];</p> <p>to open the application. Thanks, N.</p>
iphone
[8]
3,612,570
3,612,571
How can i present efficiently 10000 record list in single html file
<p>I have single html file that contains 10000 list items that needs to be in single html file order by categories for example ordered by the ABC not all of them needs to be shown.<br> each time only 500 ( so the other are hidden ) .<br> what way or method can efficiently rearrange me the list in this way ?<br> java script ? css? </p> <p>its all in client side , no server side.</p>
javascript
[3]
3,158,123
3,158,124
Removing elements from an object with changing indexes
<p>I am having trouble deleting rules from the stylesheet object due to ever changing indexes.</p> <p>I have this function:</p> <pre><code>function delete_styles(delete_array){ console.log(delete_array); // ["0,0", "0,1", "0,2", "0,6", "0,7", "0,8", "0,9", "0,10", "0,14", "0,15", "0,16"] for(var i in delete_array){ var pair = delete_array[i].split(','); var p1 = parseInt(pair[0]); var p2 = parseInt(pair[1]); document.styleSheets[p1].deleteRule(p2); } } </code></pre> <p>However, as soon as I delete <code>(0,0)</code>, the index <code>(0,1)</code> is invalid because it becomes <code>(0,0)</code>!</p> <p>I can't just use a counter and take a way an incrementing amount each time because there may be larger gaps in the CSS rules.</p> <p>Any help on the logic here?</p>
javascript
[3]
3,864,348
3,864,349
Java Set of Bytes
<p>Hello Can anyone help me to know how can I have a "Set" of Bytes in Java? Thank you</p>
java
[1]
2,363,060
2,363,061
What is the simplest way to automatically reconnect with the same port after the connection is reset? - Java
<p>I'm going through the tutorial <a href="http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html" rel="nofollow">Knock Knock Server and Client from Oracle</a>. I'm testing it on a single computer, and I'd like to add functionality that will automatically reconnect (ideally without losing 'progress' in the joke) on the same port. </p> <p>I'm a bit muddled because I've been seeing what happens when I use TCPView to close the connection (I think this is the simplest way to simulate the client losing connection to the server on a single computer), but the SocketException seems to arise in the KnockKnockProtocol class. What's the most basic way to tell the program to just try and reconnect the Client with the same port. I don't really know how to make an SSCCE that's simpler than Oracle's example, linked above.</p> <p>I'm having trouble working out what I should be looking into here.</p>
java
[1]
454,463
454,464
Dynamically add ImageView to TableRow
<p>I have a TableLayout in my XML, and I'd like to dynamically add a TableRow with an ImageView to that TableLayout. What I have so far is this:</p> <pre><code>TableRow tr = new TableRow(this); ImageView imgView = new ImageView(this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); imgView.setLayoutParams(lp); imgView.setImageDrawable(getResources().getDrawable(R.drawable.icon_test)); tr.addView(imgView); tlCollection.addView(tr); </code></pre> <p>What am I doing wrong? If I want to add a Textview to the same TableRow, it works, but adding an ImageView doesn't work.. </p> <p>The code for adding a TextView:</p> <pre><code>TextView myTextView = new TextView(this); myTextView.setLayoutParams(new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT,TableRow.LayoutParams.WRAP_CONTENT)); myTextView.setText("Test"); tr.addView(myTextView); </code></pre> <p>Any idea?</p>
android
[4]
3,177,940
3,177,941
How to avoid Fatal error: Allowed memory size of 83886080 bytes exhausted
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3887692/error-allowed-memory-size-of-67108864-bytes-exhausted">Error: Allowed memory size of 67108864 bytes exhausted</a> </p> </blockquote> <p>I have a (multiple) file upload form on my website, and it works, but if I upload too much files (depends on file size I guess) I get that error. I know I can edit the memory_limit property in php.ini, but is their a way I can free up that memory with php?</p> <p>I'm uploading some images, then they are resized and cropped to two images, and then saved in a directory and in a database.</p> <p>Thanks</p>
php
[2]
2,559,595
2,559,596
Inheritance Object method in IE
<p>I've defined method fadeIn for Object</p> <pre><code> Object.prototype.fadeIn = function(d, callback) { //some code here }; .... var b = documentGetElementById('b1'); // &lt;div id="b1"&gt;&lt;/div&gt; b.fadeIn(); </code></pre> <p>It works in FF, Opera, Chrome, but IE reports "Object doesn't support this property or method" when I try launch fadeIn. Why IE doesn't inherit my methods from Object and how to fix it?</p>
javascript
[3]
5,851,061
5,851,062
Application Error:while retriving messages from MSMQ to application
<p>I am getting following error. This is related to HUB. I mean i am trying to retrive messages from MSMQ to application. But i am getting following error in that application log.</p> <p>Timestamp: 7/27/2012 12:35:26 PM<br> Message: Publish exception<br> Category: Service, Service<br> Priority: 5<br> EventId: 0<br> Severity: Error<br> Machine: AMHS-DB1<br> Application Domain: AllscriptsHubConnectivityService.exe<br> Process Id: 3160<br> Process Name: D:\HLTHPNT\sbin\Hub\AllscriptsHubConnectivityService.exe<br> Win32 Thread Id: 9636<br> Extended Properties: Exception message - System.NullReferenceException: Object reference not set to an instance of an object.<br> at Allscripts.ProEHR.Portal.Handlers.PortalRegistrationProcessed.BuildHubMessage(ProEHRMessage aMessage) in C:\HealthMatics\ProEHRHub\Main\Applications\Handlers\PatientAccountHandlers\PortalRegistrationProcessed.cs:line 97<br> at Allscripts.ProEHR.EventBusHarness.HubMessageManager.&lt;>c_<em>DisplayClass8.b</em>_6(ProEHRMessage m) in C:\HealthMatics\ProEHRHub\Main\Applications\Allscripts.ProEHR.EventBusHarness\HubMessageManager.cs:line 133<br> at Allscripts.ProEHR.Messaging.Core.ProMessageRouter.Publish[TMessage](TMessage message) in C:\HealthMatics\ProEHRHub\Main\Applications\Allscripts.ProEHR.Messaging.Core\ProMessageRouter.cs:line 243 </p>
asp.net
[9]
4,186,135
4,186,136
how do I replace certain characters in a string?
<p>Suppose I have a string like this</p> <pre><code>SOMETHING [1000137c] SOMETHING = John Rogers III [SOMETHING] SOMETHING ELSE </code></pre> <p>and I need to turn it into this</p> <pre><code>SOMETHING [1000137c] SOMETHING = John_Rogers_III [SOMETHING] SOMETHING ELSE </code></pre> <p>Therefor I need to replace spaces with "_" between words after "[1000137c] SOMETHING = " and before " [". How can I do that in php?</p> <p>Thanks!</p>
php
[2]
5,588,388
5,588,389
jQuery watermark not working
<p>I am trying to use jQuery watermark and it's not working.</p> <pre><code> $(function () { var watermark = "Enter Phone Number"; watermark.fontcolor = $(this).col if ($("#txtPhone").val() == "") { $("#txtPhone").val(watermark); } $("#txtPhone").focus(function () { if (this.value == watermark) { this.value = ""; } }).blur(function () { if (this.value == "") { this.value = watermark; } }); }); </code></pre> <p>The page is a contentPlaceHolder.</p> <p>Anything wrong with this?</p>
jquery
[5]
4,102,430
4,102,431
Reducing recursive calls on pow recursion method?
<p>Had a question on how to reduce the amount of recursive calls on a self implementation of the pow method. Here is what I wrote, can this be improved?</p> <pre><code>public static int pow(double a, int b) { boolean isNegative = false; if(b &lt; 0) { isNegative = true; } if(b == 0) { return 1; } else if(b == 1) { return (isNegative ? (1 / b) : b); } return (isNegative ? ((1 / b) * (1 / b) * pow(a, b + 2)) : (b * b * pow(a, b - 2))); } </code></pre>
java
[1]
5,970,028
5,970,029
Searching for string withing string in JS issue
<p>i am using HTML5 and indexOf gives me an error, so what else can i use to search for the word "correct" in a string: <code>a001_new_quiz_multiple_choice_new_mc4_correct.html</code> which is in a variable called <code>value1</code></p> <pre><code>function SetAPIValue(key1, value1) { // alert("action is " + key1 + " and data is " + value1); console.log(value1); var str = "wrong"; var n = str.search(value1); if (n &gt; 0) alert("found"); } </code></pre> <p>the error i get: 0x800a01b6 - Microsoft JScript runtime error: Object doesn't support property or method 'indexOf'</p>
javascript
[3]
2,922,334
2,922,335
Android: why is my OnKeyListener() not called?
<p>I defined an EditText-field and I want to be informed when the user edits that fields. So I thought: simple - I add an OnKeyListener and so I did. But even though the text field gets edited (and even displays the entered/modified text) I don't get any callback, i.e. the LOG-output doesn't show up. </p> <pre><code> TextView text = new TextView(this); text.setText(...); ... text.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { TextView tv = (TextView)v; CharSequence val = tv.getText(); Log.v(TAG, "value: " + val); // ... rest omitted for brevity } }); </code></pre> <p>Any idea, why that callback is never called?</p> <p>Michael</p> <p>PS.: Sigh! Android is really full of oddities! It seems that almost nothing I touched so far worked immediatly as one would expect. And - believe it or not - I have LOTS of experience with GUIs, esp. in Java (AWT, Swing, SWT, you name it...) But Android is a really tough beast!</p>
android
[4]
5,055,078
5,055,079
Update GUI controls from a background thread of another class
<p>I am creating an windows based application which download the data from server. I am using background thread which is created on different class to perform these download operation.And I want to continuously show the download status on rich textbox i.e on main thread.But i am unable to do this,get an Cross-thread operation not valid. Please help me to resolve this problem.</p> <p>method on Form1.cs</p> <pre><code>public void UpdateRichText(string Text) { SetRichText(Text); } public delegate void SetRichTextTextDelegate(string text); public void SetRichText(object number) { if (InvokeRequired) { this.BeginInvoke(new SetRichTextTextDelegate(SetRichText),text); return; } richTextBox1.Text += number.ToString() + "\n"; } private void button3_Click_1(object sender, EventArgs e) { demo d = new demo(); d.display(); } </code></pre> <p>methods on demo.cs</p> <pre><code> Form1 f = new Form1(); public void display() { Thread t = new Thread(new ThreadStart(call)); t.Start(); } public void call() { //when i call this method every time if(InvokeRequired) is false. f.UpdateRichText("Called from Thread"); } </code></pre>
c#
[0]
5,411,330
5,411,331
Can any body access the database files stored in application's data folder in android?
<p>I am using the SQLite database to store data in my application. Can the databases I created for use in my application be accessed by others or any outside application?</p>
android
[4]
3,384,681
3,384,682
Can't get out of the loop when I type nothing or press cancel
<p>I can't seem to get out of the loop when I type nothing in the input or I press cancel. Is there a way out?</p> <pre><code> While (last == '?'){ input = (int)(Math.random()*2); if (number == 1){ answer = "Nice"; } if (number == 2){ answer = "Okay"; } System.out.println("The answer: " + answer); input = JOptionPane.showInputDialog(null, "Ask a question. (Remember the?)"); if (input != null &amp;&amp; input.length() &gt; 0){ last = input.charAt(input.length() - 1); } } </code></pre>
java
[1]
801,746
801,747
Error opening a file with date/time stamp in its name
<p>I want to create a file with date and time stamp appended to the file name using Python. When I am doing this, I am getting the error while opening the file.</p> <pre><code>today = datetime.datetime.today().strftime("%m-%d-%Y_%H:%M:%S") file = "text" + today open(file,'w') </code></pre> <p>It reports error for invalid file name.</p>
python
[7]
2,565,261
2,565,262
Refresh rate for GPS - what's acceptable?
<p>I'm trying to figure out a refresh rate to use for my GPS location listener to get around a bug on the HTC Hero where the GPS icon won't remove itself off the notification bar.</p> <p><a href="http://groups.google.com/group/android-developers/browse%5Fthread/thread/e687b3bfa9146f31/7fa59b0108bbdf89?lnk=gst&amp;q=gps#7fa59b0108bbdf89" rel="nofollow">http://groups.google.com/group/android-developers/browse%5Fthread/thread/e687b3bfa9146f31/7fa59b0108bbdf89?lnk=gst&amp;q=gps#7fa59b0108bbdf89</a></p> <p>Does anyone here have any suggestions? For my app, I'd normally run with a refresh rate of 5 minutes. But when I close the app, and de-register my listeners, the GPS icon sometimes still stays on the notification bar. Does anyone have an HTC Hero and can confirm this?</p> <p>The link above suggests that using a refresh rate of under 35 seconds fixes the problem, but not sure if that's true.</p> <p>Thanks</p>
android
[4]
3,701,863
3,701,864
Grab the content of a div,which is inside another div
<p>I am doing an application where I want to grab the content of div,which is inside a div.In my application I want to grab the content of <code>&lt;li&gt;&lt;/li&gt;,</code>which is inside <code>&lt;ul class="snippet-list"&gt;&lt;/ul&gt;</code>.The ul class is inside <code>&lt;div data-analyticsid="related"&gt;&lt;/div&gt;</code>.Is there any regular expression like preg_match to grab the data.</p> <p>Thanks in advance...</p>
php
[2]
5,849,170
5,849,171
Stop application from running in background?
<p>How to stop application from running in background in android? I want my application to start fresh everytime it loads. How to do it programatically.</p>
android
[4]
4,264,126
4,264,127
C++ delete storage space in a different function from where it was allocated
<p>Will I get undefined behavior if I delete a storage space in a different function from where the space was originally allocated?</p> <pre><code>typedef struct { unsigned int Data1; unsigned int Data2; unsigned int Data3; }TData; void CreateStorage(void) { TData *TempData = new TData; DeleteStorage((unsigned char*)TempData); } void DeleteStorage(unsigned char *StorageToDelete) { delete (TData*)StorageToDelete; } </code></pre>
c++
[6]
4,475,432
4,475,433
How a developer from countries not listed in the "android app selling countries list" sell their apps?
<p>I am from Pakistan and my country is not included in the "Android App selling Countries list". I want to sell the apps on Android Market. </p> <p>Is there any way I can sell my apps. </p>
android
[4]
38,883
38,884
even and odd number of clicks count in jquery
<p>I have four divs in my html page something like this: the working fiddle implementation is here: <a href="http://jsfiddle.net/GxaCK/3/" rel="nofollow">http://jsfiddle.net/GxaCK/3/</a></p> <pre><code> &lt;div class="first"&gt; &lt;p&gt; First &lt;/p&gt; &lt;/div&gt; &lt;div class="second"&gt; &lt;p&gt; Second &lt;/p&gt; &lt;/div&gt; &lt;div class="third"&gt; &lt;p&gt; Third &lt;/p&gt; &lt;/div&gt; &lt;div class="fourth"&gt; &lt;p&gt; Fourth &lt;/p&gt; &lt;/div&gt; </code></pre> <p>and then the jquery like this:</p> <pre><code>$(function() { var firstCnt = 0, secondCnt = 0, thirdCnt = 0, fourthCnt = 0; $(".first").live("click", function(){ firstCnt += 1; $(".first p").text(firstCnt); }); $(".second").live("click", function(){ secondCnt += 1; $(".second p").text(secondCnt); }); }); </code></pre> <p>now given this, i can do firstCnt%2 to get if the div was clicked for even or the odd number of times. </p> <p>I have the following doubt: 1. is this a goodway of implementation, in a project? 2. is there anything like even odd selector for clicks as well, <a href="http://www.w3.org/Style/Examples/007/evenodd.en.html" rel="nofollow">as exists in css3</a></p>
jquery
[5]
4,054,796
4,054,797
jQuery - shuffling two absolutely positioned elements
<p>I have a container called three. It has the two divs inside as 'one' and 'two'. I would just like to shuffle their absolute positions. Is it possible? If so, is there any built-in function with <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow">jQuery</a>?</p> <p>This is my try, but it does not work properly:</p> <h3>HTML:</h3> <pre><code>&lt;div id='three'&gt; &lt;div id="one"&gt;1&lt;/div&gt; &lt;div id="two"&gt;2&lt;/div&gt; &lt;/div&gt; </code></pre> <h3>Code:</h3> <pre><code>var clone1 = $('#one').clone(); var colone2 = $('#two').clone(); var clone1X = $('#two').position().left var clone1Y = $('#two').position().top; var clone2X = $('#one').position().left; var clone2Y = $('#one').position().top; $('div &gt; div').remove(); $('div').append($(colone2).css({left:clone1X,top:clone1Y})).append($(clone1).css({left:clone2X,top:clone2Y})); </code></pre> <p>But does not work as I expected.</p>
jquery
[5]
2,192,113
2,192,114
How do I display only match keyword in array
<p>This is my array output</p> <pre><code>Array ( [0] =&gt; Array ( [tweet_text] =&gt; Fedora 16 "Verne" released! http://t.co/lECbdzE0 #Fedora #Linux ) [1] =&gt; Array ( [tweet_text] =&gt; Ubuntu 11.10 "Oneiric Ocelot" released! #Ubuntu #Linux ) ) </code></pre> <p>Example to find <code>Ubuntu</code> keyword. From the current array how do I filter to show only</p> <pre><code>Array ( [1] =&gt; Array ( [tweet_text] =&gt; Ubuntu 11.10 "Oneiric Ocelot" released! #Ubuntu #Linux ) ) </code></pre> <p>The code</p> <pre><code>$keywords = array('Ubuntu'); foreach ($keywords as &amp;$keyword) { $keyword = preg_quote($keyword); } $regex = "/(" . implode('|', $keywords) . ")/"; $check = preg_match($regex, $anArray); if($check == 1) { // here I want to display only Ubuntu } </code></pre> <p>Let me know</p>
php
[2]
4,335,669
4,335,670
how to fix a bottom relative layout when soft keyboard comes?
<p>When i write something on the edit text in my app ,the soft keyboard comes in along with a bottom relative layout..I want to fix the bottom relative layout position fixed.Any help will be greatly appreciated..</p>
android
[4]
2,579,561
2,579,562
simple php pagination
<p>I have rows of data coming from database, I would like to have simple pagination, is there any simple code or tutorials pls help.</p>
php
[2]
3,220,319
3,220,320
Android: Make a button not visible
<p>How can I remove a button in android, or make it invisible. </p>
android
[4]
3,280,333
3,280,334
Eclipse issue - Launch error: Failed to connect to remote VM. Connection timed out
<p>I get the message "Launch error: Failed to connect to remote VM. Connection timed out." each time i debug my application on read device. </p> <p>I added to the AndroidManifest the </p> <p> and android:debuggable="true" </p> <p>But still this is not helping. </p> <p>When i reset the Eclipse ( close it and open it again ) this problem sometimes solved. </p> <p>Its really hard to work in this way - </p> <p>How can i solve this problem ? ? ?</p>
android
[4]
2,132,817
2,132,818
ImageDownloader example?
<p>I'm looking at an image cache / downloader for android, I see there's something called ImageDownloader from the sdk examples, also part of this blog post from the team:</p> <p><a href="http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html" rel="nofollow">http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html</a></p> <p>but also see this one which seems to be a more up-to-date version:</p> <p><a href="http://code.google.com/p/android-imagedownloader/source/browse/trunk/src/com/example/android/imagedownloader/ImageAdapter.java?r=3" rel="nofollow">http://code.google.com/p/android-imagedownloader/source/browse/trunk/src/com/example/android/imagedownloader/ImageAdapter.java?r=3</a></p> <p>I'm not sure which we should be using, I'm guessing the one hosted at the google code project?</p> <p>Thanks</p>
android
[4]
2,667,629
2,667,630
Application interfering with OS processes
<p>I am new to android. I have created a simple application that starts a service to register an SMS broadcast receiver. The application works fine but I keep getting alerts that different process are not responding. The associated buttons are to "Force Close" or "Wait". The particular process varies. For example, "com.android.inputmethod.latin". Other times it mught the "mms" process.</p> <p>I get these alerts under the 2.1 or 2.1-update1 platform but I do not however under the 2.2 platform.</p>
android
[4]
1,443,275
1,443,276
php expression question
<pre><code>function createHash($string) { $check1 = $this-&gt;stringToNumber($string, 0x1505, 0x21); $check2 = $this-&gt;stringToNumber($string, 0, 0x1003F); $factor = 4; $halfFactor = $factor/2; $check1 &gt;&gt;= $halfFactor; $check1 = (($check1 &gt;&gt; $factor) &amp; 0x3FFFFC0 ) | ($check1 &amp; 0x3F); $check1 = (($check1 &gt;&gt; $factor) &amp; 0x3FFC00 ) | ($check1 &amp; 0x3FF); $check1 = (($check1 &gt;&gt; $factor) &amp; 0x3C000 ) | ($check1 &amp; 0x3FFF); $calc1 = (((($check1 &amp; 0x3C0) &lt;&lt; $factor) | ($check1 &amp; 0x3C)) &lt;&lt; $halfFactor ) | ($check2 &amp; 0xF0F ); $calc2 = (((($check1 &amp; 0xFFFFC000) &lt;&lt; $factor) | ($check1 &amp; 0x3C00)) &lt;&lt; 0xA) | ($check2 &amp; 0xF0F0000 ); return ($calc1 | $calc2); } </code></pre> <p><strong>>>=</strong> what does this expression stand for? it looks very strange to me. I couldn't find any questions on google.</p>
php
[2]
3,752,617
3,752,618
How to pass a dynamically generated ID to Jquery
<p>I'm using a nice <a href="http://www.planitworks.nl/en/jeegoocontext" rel="nofollow">Jquery context menu</a> which returns the ID of my element in the form </p> <pre><code>$(context).attr('id') </code></pre> <p>and not in the form</p> <pre><code>$(this).attr('id') </code></pre> <p>due to the fact that I'm using one single context menu for a large number of elements where each element has its unique ID. The context menu works perfectly as it executes the commands relative to the clicked element identified by its unique ID.</p> <p>I use the context menu to write data to a MySQl db via $.get and this works too.</p> <p>But now I would like to use the data I get back from $.get and use it with the .replaceWith method to change some text without refreshing the page:</p> <pre><code>$.get("jq_get_go.php", { parameter2: $(this).attr('menuCommand'), id: $(context).attr('id') }, function(data) { $(".ci_saremo").xxxxx.replaceWith('&lt;li class="Like ci_saremo" id="' + $(context).attr('id') + '"&gt;&lt;a href=""&gt;' + data + '&lt;/a&gt;&lt;/li&gt;'); } ); </code></pre> <p>I don't understand what should I replace the xxxxx with to get the ID of my element that I know I have here</p> <pre><code>$(context).attr('id') </code></pre> <p>Of course if I omit xxxxx and leave</p> <pre><code>$(".ci_saremo").replaceWith('&lt;li class="Like ci_saremo" id="' + $(context).attr('id') + '"&gt;&lt;a href=""&gt;' + data + '&lt;/a&gt;&lt;/li&gt;'); </code></pre> <p>every ".ci_saremo" text will be replaced. So I need to identify it by its ID. Basically, I don't understand how to chain/insert <code>$(context).attr('id')</code> in the above string.</p>
jquery
[5]
2,918,156
2,918,157
Where to set User Control event handlers?
<p>Where in the page life cycle is it most appropriate to set event handler delegates for events raised by custom User Controls?</p> <p>I have a <code>ReportFilter</code> user control that raises an <code>ApplyFilterClicked</code> event. Currently I am just using <code>Page_Load</code> to assign a handler method.</p> <pre><code>reportFilter.ApplyFilterClicked += reportFilter_ApplyFilterClicked; </code></pre>
asp.net
[9]
2,490,269
2,490,270
hi all , i have a query regrding to playing wave file from raw directory from res > raw
<p>i have a query regrding to playing wave file from raw directory from res > raw, i have written a code on button click event here is my code </p> <pre><code>public void buttonOnclick(View v) { try { MediaPlayer mMediaPlayer = new MediaPlayer(); mMediaPlayer = MediaPlayer.create(this, R.raw.sc1malf); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mMediaPlayer.setLooping(true); mMediaPlayer.start(); } catch(Exception e) { } } </code></pre> <p>but this code is not working on samsung android mobile ,any one correct this code</p>
android
[4]
3,662,049
3,662,050
C# string parsing problem
<p>I have a file thats exported with a ton of lines. I want to be able to parse the file into a neat order that I can easily use.</p> <p>I have a sample string here:</p> <pre><code>&lt;a href="http://www.foxnews.com/us/2010/07/28/cemetery-allows-father-war-veteran-fly-flag-grave/?test=latestnews"&gt;deal reached on cemetery flags&lt;/a&gt; | &lt;a href="#" onclick="foxgrabplayer('4295654','','grave insult to grieving family');return false;"&gt;&lt;img src="/i/redes/icon-video.gif"&gt;&lt;/a&gt;&lt;br&gt; - &lt;a href="http://www.foxnews.com/politics/2010/07/27/obama-missing-historic-boy-scout-jamboree-fundraisers-view-taping/"&gt;obama skips out on scouts for 'the view'&lt;/a&gt;&lt;br&gt; - &lt;strong class="em"&gt;you decide: &lt;/strong&gt;&lt;a href="http://www.foxnews.com/opinion/2010/07/27/decide-right-obama-miss-boy-scout-jamboree/"&gt;right call?&lt;/a&gt;&lt;/li&gt;" </code></pre> <p>All of that is 1 line. I'd want it to output like the following:</p> <pre><code>http://www.foxnews.com/us/2010/07/28/cemetery-allows-father-war-veteran-fly-flag-grave|Deal reached on cemetery flags http://www.foxnews.com/politics/2010/07/27/obama-missing-historic-boy-scout-jamboree-fundraisers-view-taping|obama skips out on scouts for 'the view </code></pre> <p>sort of www|description for every href in the line. Hope this makes sense!</p>
c#
[0]
2,326,207
2,326,208
changes in jquery 1.4.2 breaking the code?
<p>I had this code on a page using jquery 1.3, but now in jquery 1.4.2 it's breaking with syntax error/uncrecognized expression:</p> <pre> $(document).ready(function(){ $("span[@name^=charge]").click(function(){ $("#" + $(this).attr("name")).show(); $(this).hide(); }); }); </pre> <p>How do I fix that?</p>
jquery
[5]
874,155
874,156
Problems changing properties on a control using the controls name
<p>This should work.. I think..</p> <pre><code>string ctrlName = "btnSomeButton" + someIndexValue; this.Controls[ctrlName].Text = "Some value"; </code></pre> <p>I get 'Object reference not set to an instance of an object.', the control does exist on the form. I've tried casting it.</p> <p>Solution:</p> <pre><code>string ctrlName = "btnSomeButton" + someIndexValue; Control[] ctrl = this.Controls.Find(ctrlName, True); Button btn = (Button)ctrl[0]; btn.Text = "Some Value"; </code></pre> <p>Thank you.</p>
c#
[0]
2,960,758
2,960,759
Lazy loading images on ListView not getting refreshed
<p>I was just including this code into my <a href="https://github.com/thest1/LazyList" rel="nofollow">project</a> from <a href="http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview/3068012#3068012">an answer to Stack Overflow question <em>How do I do a lazy load of images in ListView</em></a>.</p> <p>I read all about it in <em><a href="http://stackoverflow.com/questions/541966/android-how-do-i-do-a-lazy-load-of-images-in-listview">How do I do a lazy load of images in ListView</a></em>.</p> <p>I added successfully into my project and images seem fine BUT they show up ONLY when I scroll up/down, I mean, when the list refreshes itself. So, If I do not do nothing (scroll) I keep seeing my default image and no the already downloaded image. </p> <p>Any ideas?</p>
android
[4]
808,149
808,150
Can I have XML Defination in this way
<p>HI </p> <p>Can i have a xml defination like below</p> <pre><code>&lt;add key="FirstName" ServerType="FirstName" Mandatory="Yes" length="3" DataType="String"/&gt; </code></pre> <p>if yes how can i read this in my dot net c# code i use dotnet 2.0 frame work Please help me with the code</p>
c#
[0]
3,315,885
3,315,886
Multiplying 2d array in java
<p>I have declared an array that i would like to multiply the value of the first column by value of the second column of each row and create a grand sum of these products. I have tried the code listing below, what am i missing</p> <pre><code>public class Arrays { public static void(String[] args) { int array_x[][]={{9,8},{2,17},{49,4},{13,119},{2,19},{11,47},{3,73}}; int sum = 0; for (int i = 0; i &lt; array_x.length; i++) { for (int j = 0; j &lt; array_x.length; j++) { array_x[i][j] = i * j; System.out.println("\n" + array_x[i][j]) } } } } </code></pre> <p>The output should be something like 9*8=72 2*17=34 etc then sum the whole results as 72+34+....</p>
java
[1]
762,352
762,353
How to create a simple First Person Dungeon Crawler
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/54223/how-do-i-get-started-in-game-development">How do I get started in game development?</a> </p> </blockquote> <p>I am an amateur programmer trying to make my first game. I've been trying to create an 'old-school' first person dungeon crawler in the spirit of Dungeon Master, Ultima and all the early AD&amp;D games like Curse of the Azure Bonds. I loved all of those games! I even looked up the 1st FPS called Maze Wars (how about that!) created in 1974 which would be an ideal first project that I could expand upon.</p> <p>I am learning to program in Python, but I do not have a Comp Sci. degree. I would like to know the actual math (Linear Algebra?) and techniques that you have to use in order to create the above games, specifically the simple 3d first person perspective. Any books or websites to recommend?</p>
python
[7]
2,271,548
2,271,549
Overloaded virtual function call resolution
<p>Please consider the following code: </p> <pre><code>class Abase{}; class A1:public Abase{}; class A2:public A1{}; //etc class Bbase{ public: virtual void f(Abase* a); virtual void f(A1* a); virtual void f(A2* a); }; class B1:public Bbase{ public: void f(A1* a); }; class B2:public Bbase{ public: void f(A2* a); }; int main(){ A1* a1=new A1(); A2* a2=new A2(); Bbase* b1=new B1(); Bbase* b2=new B2(); b1-&gt;f(a1); // calls B1::f(A1*), ok b2-&gt;f(a2); // calls B2::f(A2*), ok b2-&gt;f(a1); // calls Bbase::f(A1*), ok b1-&gt;f(a2); // calls Bbase::f(A2*), no- want B1::f(A1*)! } </code></pre> <p>I'm interested to know why C++ chooses to resolve the function call on the last line by upcasting the <code>this</code> pointer of the object to the base class, rather than upcasting the argument of <code>f()</code>? Is there any way that I can get the behaviour I want?</p>
c++
[6]
4,903,737
4,903,738
What's the best way to do "application settings" in Android?
<p>I'd like to store some application settings (like the URL of an API, and some settings for testing) for an Android application.</p> <p>I mostly work as a <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET</a> developer, so I'm used to using the file <code>app.config</code> for this purpose. What's a good way to do it in Android?</p>
android
[4]
4,935,447
4,935,448
Handle orientation from Portrait to Landscape mode for Checkbox
<p>I am using the Checkbox on a layout xml .</p> <pre><code>&lt;CheckBox android:id="@+id/chkbox" android:checked="false" android:button="@drawable/ic_uncheck_img"&gt; </code></pre> <p>The Checkbox is by default set to "false" &amp; a image is added for unchecked button.</p> <pre><code>private CheckBox mCheck= null; public void onCreate(Bundle savedInstanceState) { mCheck= (CheckBox) findViewById(R.id.chkbox); mCheck.setChecked(false); mCheck.setButtonDrawable(R.drawable.ic_uncheck_img); } public void onClick(View view) { if (view.getId() == R.id.chkbox) { if (mCheck.isChecked()) mCheck.setButtonDrawable(R.drawable.ic_check_img); else mCheck.setButtonDrawable(R.drawable.ic_uncheck_img); } </code></pre> <p>Within the onClick() , when the user clicks on the Checkbox , the image changes from uncheck to check . User does that on the portrait mode.</p> <p>When the user changes orientation to the landscape mode of the device, the check disappears &amp; the uncheck image is displayed . The state of the Checkbox is not maintained when the orientation changes from portrait to landscape.</p> <p>Kindly provide your inputs on how to maintain the state of the Checkbox even if the orientation changes.</p> <p>Thanks in advance.</p> <p>Warm Regards,</p> <p>CB</p>
android
[4]
4,687,315
4,687,316
Change image with if statement
<p>When the program loads, there's already and image for a place holder</p> <pre><code>ImageIcon icon = new ImageIcon(Path + "Hangman1.jpg"); JLabel label = new JLabel(); label.setIcon(icon); </code></pre> <p>Now i know how to write an if statement that prints out the body part</p> <pre><code>if (guesses &gt;= 1) System.out.print("HEAD "); if (guesses &gt;= 2) System.out.print("BODY "); if (guesses &gt;= 3) System.out.print("LEFT ARM "); if (guesses &gt;= 4) System.out.print("RIGHT ARM "); if (guesses &gt;= 5) System.out.print("LEFT LEG "); if (guesses &gt;= 6) System.out.print("RIGHT LEG "); </code></pre> <p>But instead of using a normal System.out.print i want to call up my images (want the image to change)</p>
java
[1]
1,530,323
1,530,324
Android Keyevent injection requires system permissions
<p>hi i am using key event injection using window manager but when i tested this application it gives me error </p> <pre><code> 04-12 18:19:35.794: WARN/WindowManager(58): Permission denied: injecting key event from pid 6290 uid 10039 to window Window{45034880 com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 10020 04-12 18:19:35.794: WARN/System.err(6290): java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission 04-12 18:19:35.854: DEBUG/PhoneData(6290): 04-12 18:19:36.048: WARN/System.err(6290): at android.os.Parcel.readException(Parcel.java:1247) 04-12 18:19:36.048: WARN/System.err(6290): at android.os.Parcel.readException(Parcel.java:1235) </code></pre> <p>I also give the inject event permission is there any way to give a application system permissions.</p>
android
[4]
1,966,325
1,966,326
Convert select dropdown into list for printing
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7336437/how-to-convert-select-dropdown-into-an-unordered-list-using-jquery">How to convert &lt;select&gt; dropdown into an unordered list using jquery?</a> </p> </blockquote> <p>I want to convert all select dropdowns into ul lists for printing. </p> <pre><code>&lt;select&gt; &lt;option&gt;Item 1&lt;/option&gt; &lt;option&gt;Item 2&lt;/option&gt; &lt;option&gt;Item 3&lt;/option&gt; &lt;/select&gt; </code></pre> <p>into:</p> <pre><code>&lt;ul&gt; &lt;li&gt;Item 1&lt;/li&gt; &lt;li&gt;Item 2&lt;/li&gt; &lt;li&gt;Item 3&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Why does this only show?: </p> <pre><code>&lt;ul&gt;&lt;/ul&gt; </code></pre> <p>jquery:</p> <pre><code>$('select').parent().append('&lt;ul&gt;&lt;/ul&gt;'); $('select option').each(function(){ $('&lt;ul&gt;').append('&lt;li&gt;'+$(this).text()+'&lt;/li&gt;'); }); $('select').remove(); </code></pre> <p>edit: removed select ID. I want to step through each and not just one particular select.</p>
jquery
[5]
1,327,546
1,327,547
Android MVC and Inner class
<p>I learn the android for one year,But now I am so confused about how to use MVC in android apps,I can't deal with UI、Activity、network,I often use inner class to avoid the communication between classes,but it looks like mess, encapsulation is so bad.so who can help me to figure out how to use android mvc,and inner class is good or bad,when to use it</p>
android
[4]
1,145,894
1,145,895
How to disable all links before load jQuery?
<p>I need a pure Javascript code to disable all links while loading the page, avoiding to click them and redirecting to other page when its using a <a href="http://defunkt.io/facebox/" rel="nofollow">Facebox</a>.</p> <p>Can be something that I place in a <code>&lt;script&gt;</code> tag in the <code>&lt;head&gt;</code>.</p> <p>Any suggestions?</p> <p><strong>EDIT:</strong></p> <p>Ok, I get that in <code>head</code> doesn't work. But in <code>body</code> ending work properly. That's why I asked for suggestions. :)</p>
javascript
[3]
3,595,219
3,595,220
Radio button array with cloned row
<p>I have a form where a row get's clowned if a user clicks "add row". My problem is with the radio buttons, the name of the radio group stays the same and I need to get them unique for each cloned row. This is how I have it at the moment.</p> <pre><code> &lt;input type="radio" name="chronic_l_duration[]" value="Chronic" /&gt; &lt;input type="radio" name="chronic_l_duration[]" value="Limited duration" /&gt; </code></pre> <p>What I would like is something like this:</p> <pre><code>&lt;input type="radio" name="chronic_l_duration[1]" value="Chronic" /&gt; &lt;input type="radio" name="chronic_l_duration[1]" value="Limited duration" /&gt; </code></pre> <p>end when a other row gets added it goes to:</p> <pre><code> &lt;input type="radio" name="chronic_l_duration[2]" value="Chronic" /&gt; &lt;input type="radio" name="chronic_l_duration[2]" value="Limited duration" /&gt; </code></pre> <p>Javascript I use to clone a row:</p> <pre><code> $(document).ready(function(){ var clonedRow = $('.row').clone().html(); var appendRow = '&lt;tr class = "row"&gt;' + clonedRow + '&lt;/tr&gt;'; $('#btnAddMore').click(function(){ $('.employmentHistoryForm tr:last').after(appendRow); }); $('.deleteThisRow').live('click',function(){ var rowLength = $('.row').length; if(rowLength &gt; 1){ deleteRow(this); }else{ $('.employmentHistoryForm tr:last').after(appendRow); deleteRow(this); } }); function deleteRow(currentNode){ $(currentNode).parent().parent().remove(); } }); </code></pre> <p>So each time the row get's cloned the radio button has a unique value.</p> <p>Is there maybe a way I can do this?</p>
javascript
[3]
3,366,007
3,366,008
How to get First Day and last day of the week of a date
<p>I am using DatePickerDialog to show the calender. I want to access First day and last day of the week of the date selected.</p> <p>Here is what I have tried</p> <pre><code> this.tv_date.setText( new StringBuilder() // Month is 0 based so add 1 .append(mDay).append("-") .append(monthName).append("-") .append(mYear).append("")); tv_date.setHighlightColor(Color.CYAN); String str=mDay+"-"+mMonth+"-"+mYear; SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy"); sdf.format(""+str); //here I am getting exception Calendar cal=Calendar.getInstance(); int s= cal.getFirstDayOfWeek(); Toast.makeText(getApplicationContext(), "first day of the week : "+s, 1).show(); </code></pre> <p>But I am getting "IllegalArguementException". Please help me </p> <p>Thanks</p>
android
[4]
789,268
789,269
how to view an alert dialog box even when android phone is rotated
<p>I am creating an application in which an alert dialog box pops up when i click on a button.Now when the phone is rotated this view gets disappears.<strong>Can anyone help me to retain this alert view even if phone is rotated?</strong></p>
android
[4]
5,220,039
5,220,040
how to get table object using cssclass selector?
<p>I have an HTML page with lot of tables. Among that I have a table with the following format</p> <pre><code>&lt;table&gt;&lt;tr&gt;&lt;td class="myclass"&gt;..&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td class="myclass"&gt;..&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; </code></pre> <p>How can I get the object of this table using the class selector in jquery?</p>
jquery
[5]
5,781,751
5,781,752
How to convert variable name to string in JavaScript?
<p>I am new to stackoverflow but I found it pretty helpful several times. Now I have my own question: Is there a way to convert variable names to strings in javascript? To be more specific:</p> <pre><code>var a = 1, b = 2, c = 'hello'; var array = [a, b, c]; </code></pre> <p>Now at some point as I go through the array, I need to get variable names (instead of their values) as strings - that would be 'a' or 'b' or 'c'. And I really need it to be a string so it is writeable. How can I do that?</p> <p>Thank you</p> <p>jirkap</p>
javascript
[3]
4,894,091
4,894,092
Keyboard covers up part of edittext
<p>I have a numberpicker but my keyboard is not showing up like I want.</p> <p>Screen: </p> <p><img src="http://i.stack.imgur.com/I80X5.png" alt="enter image description here"> </p> <p>As you can see, the keyboard covers part of the edittext.</p> <p>How can I fix this <strong>without using a scrollview</strong>? </p> <p>I've already tried setting android:windowSoftInputMode="adjustPan" or "adjustResize".</p> <p>When I use scrollview I get the following problem : <a href="http://stackoverflow.com/questions/12669308/screen-shifts-a-bit-when-change-focus-to-next-edittext">Screen shifts a bit when change focus to next edittext</a></p> <p>Thx :)</p>
android
[4]
5,983,876
5,983,877
jQuery animate bottom div
<p>I try to move a specific <code>div</code> using jQuery <code>animate</code>. However, It does not work for div, but it works for <code>img</code>. Here's my code (it doesn't work):</p> <pre><code>&lt;body&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#clickme').hover(function() { $('#lol').animate({ bottom: '+=100', left: '+=100' }, 5000, function() { // Animation complete. }); }); }); &lt;/script&gt; &lt;div id="clickme"&gt; Click here &lt;/div&gt; &lt;div id="lol" style="width: 500px; border: 1px solid #000; display: block;"&gt;aaaaaa&lt;/div&gt; &lt;/body&gt; </code></pre> <p>But this one, will work:</p> <pre><code>&lt;body&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#clickme').hover(function() { $('#book').animate({ bottom: '+=100', left: '+=100' }, 5000, function() { // Animation complete. }); }); }); &lt;/script&gt; &lt;div id="clickme"&gt; Click here &lt;/div&gt; &lt;img id="book" src="http://img.labnol.org/images/2008/03/firefox-google-logo.jpg" alt="" width="266" height="113" style="position: relative; left: 10px;" /&gt; &lt;/body&gt; </code></pre>
jquery
[5]
1,105,702
1,105,703
how to create a popup window in C#.net
<p>I have two different applications on different system.If a button pressed in one application i keep its record in Database and according to the record I want to popup a window in second application that notifying that Button is pressed in first application.</p> <p>How could I do this? Is it feasible?</p>
c#
[0]
2,999,671
2,999,672
array_key_exists works properly when method is called direct, but not when through another method
<p>I'm having some trouble in finding out why the code extract below does not do what I expect. When passing a setting string immediately to <code>settingIsProtected</code> the function returns correctly if a setting is protected (has leading underscore in the data array). But when the method is called through <code>getAll</code> if never gets past the first if statement.</p> <p>Thoughts much appreciated, thanks!</p> <pre><code>&lt;?php class Config { private static $data = array( 'foo' =&gt; 'bar', '_baz' =&gt; 'qux' ); public static function getAll($filterProtected = TRUE) { if ($filterProtected == TRUE) { $filtered = array(); foreach (self::$data as $key =&gt; $value) { if (self::settingIsProtected($key) == TRUE) { $filtered[$key] = $value; } } return $filtered; } else { return self::$data; } } public static function settingIsProtected($key) { if (array_key_exists($key, self::$data)) { return FALSE; } else if (array_key_exists('_' . $key, self::$data)) { return TRUE; } else { return NULL; } } } var_dump(Config::settingIsProtected('foo')); // prints false var_dump(Config::settingIsProtected('baz')); // prints true var_dump(Config::getAll(FALSE)); // prints an array with foo and _baz var_dump(Config::getAll(TRUE)); // prints empty array ?&gt; </code></pre>
php
[2]
2,881,663
2,881,664
Android GLSurfaceView as subview
<p>I'm very new to an Android platform and currently trying figure out why things work this way:</p> <p>If I create <code>GLSurfaceView</code> and add it using the <code>setContentView</code> or <code>addContentView</code> to an activity everything works fine (<code>Renderer.onDrawFrame</code> is called as expected). However if I add my <code>GLSurfaceView</code> to another <code>ViewGroup</code> (which is then added using <code>setContentView</code>) nothing is rendered.</p> <p>So what is the difference between <code>addView</code> and <code>addContentView</code> ?</p> <p>In the end I need to create a custom view with OpenGL rendering in background and some controls on top.</p> <p>Also what is the point of separating View and ViewGroup? Why not to join them (like it is done in CocoaTouch) ?</p>
android
[4]
4,319,816
4,319,817
What to replace a UIButton to improve frame rate?
<p>I created a minesweeper clone game and I made a 30 x 30 grid of cells. Now in my initialize design, I planned to use UIButton for each cell so that I can use its touchDown and touchUpInside. But my problem is using UIButton makes the game slow in zooming and especially in loading or adding each cell(900 pcs) in a UIView.</p> <p>Now I'm planning to use images instead of UIButton and I heard about CALayer for easy animation. Can you suggest how can I use this CALayer for my implementation or replacement of UIButton?</p> <p>Thanks.</p>
iphone
[8]
5,407,289
5,407,290
asp.net dropdown list control - dropdown list selected index change event not fired
<p>i have only one item in dropdownlist, so the selected index changed event is not fired. can someone help me in this? Thanks</p>
asp.net
[9]
626,098
626,099
The distance Calculation from two places
<p>I have latitude and longitude of two places. Can i calculate the distance between them in android.? </p> <p>Regards Aneesh </p>
android
[4]
3,409,431
3,409,432
How to delete images from a folder using PHP Script
<p>We need to delete images created in linux file system. in a path <code>/home/user/img/</code> (All images)</p> <p>We have tried using <code>unlink()</code> but it is taking lot of time to delete it. Can someone help us how to delete images using linux commands must be passed with php script. I think <code>rm</code> command can do quickly but i am confused how to use</p> <p>Our script:</p> <pre><code>$locationIMG_p="/home/user/img/"; $location_p="/home/user/img/"; $opend=opendir($locationIMG_p); while(false!==($rf=readdir($opend))) { unlink($locationIMG_p.$rf); } closedir($opend); </code></pre>
php
[2]
2,029,997
2,029,998
Automatically saving doc file after 20 secs
<p>i am doing a php program which requires doc file to be saved after every 10 secs.msword should not ask the path to be saved. actually i have written a program which opens a doc file. the file should be auto saved to the exact location from where the file is opened.</p>
php
[2]
4,195,873
4,195,874
javascript load image to div onclick
<p>I want to display image user click from image link in a for loop to a div. </p> <p>my for loop is as follows.</p> <pre><code>&lt;a href='' name=my_image[i] onclick='disp_image('link_image_url')'id=my_image[i] class='popup-open'&gt;&lt;img src=my_image[i] width='80' height='65'&gt;&lt;/a&gt;; </code></pre> <p>and my javascript function </p> <pre><code>&lt;script language=\"javascript\"&gt; function disp_image(url){ document.getElementById('image').innerHTML ="&lt;img src=url width='100' height='105'&gt;"; ;} &lt;/script&gt; &lt;/script&gt; </code></pre> <p>However it is not being load in my div content </p> <pre><code>&lt;div id="image"&gt;&lt;/div&gt; </code></pre> <p>can someone has an idea how can i display selected image in a div content dynamically</p>
javascript
[3]
3,233,414
3,233,415
conversion - ASCII hex to float in c++
<p>I have a string containing, for example "3F800000".</p> <p>This is a hexadecimal representation of the float 1.0 Only I can't seem to find any convenient way of making this conversion in C++. Suggestions?</p>
c++
[6]
715,879
715,880
Basic If/Else if in C++
<p>I've just started learning C++ - and I have a Quick Question.</p> <p>Using if/else if statements for more than one variable at a time. How do I have them separated?</p> <p>Ex. </p> <pre><code>float a, b, c, d, e; if (a &gt; 0 &amp;&amp; b &gt; 0) cout &lt;&lt; "blah blah"; else if (a &gt; 0) cout &lt;&lt; "blah blah a"; else if (b &gt; 0) cout &lt;&lt; "blah blah b"; if (c &gt; 0 &amp;&amp; d &gt; 0) cout &lt;&lt; "wowww"; else if (c &gt; 0) cout &lt;&lt; woww c"; else if (d &gt; 0) cout &lt;&lt; wowww d"; </code></pre> <p>It errors, at the <code>else if (c&gt;0)</code>.</p> <p>How do I separate the two clauses?</p>
c++
[6]
3,016,241
3,016,242
asp control vs html control
<p>Im new to web programming and i've started with asp.net 2.0,i would like to know what are the differences on using an html control than an asp control,and i'd like to know too how the attribute runat = "sever" works.</p>
asp.net
[9]
1,129,678
1,129,679
Parsing File to Get List of Names in C#
<p>I'm parsing my <code>/etc/passwd</code> file, which looks like this:</p> <pre><code>root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync </code></pre> <p>I want my program to return the following:</p> <pre><code>root bin daemon ... sync </code></pre> <p>My current code is this:</p> <pre><code>Regex expression = new Regex(@"^\w*"); foreach (Match myMatch in expression.Matches(txt)) { txtout.Text = myMatch.ToString(); } </code></pre> <p>But, I'm only returning <code>root</code> with this code. How can I return every line?</p>
c#
[0]
3,455,234
3,455,235
Why should compilation fail for this code?
<p>Another SCJP question. I think the output is K=7, but the book's answer is "compilation fails". I just don't see anything wrong with the code.</p> <pre><code>1. class RevQOne{ 2. public static void main(String [] args) { 3. boolean i = true; 4. boolean j = false; 5. short k = 10; 6. if((k == 10) &amp;&amp; (j = true))k--; 7. if((i = false) || ( k == 9)) 8. k--; 9. k--; 10. System.out.println("k=" + k); 11. } 12. } </code></pre> <p>PS: Both the silly = signs in lines 6 and 7, and the if with missing braces in 7, are intentional. The question is meant to test my knowledge of how those things act when misused, I suppose.</p>
java
[1]
2,444,987
2,444,988
Event is not firing while redirect from one page to another
<p>In my home page i have a search button and its working perfectly but when i redirect to any page of my websites and come back to home page the search button is not working... this the event binding code for search button</p> <pre><code>$("#search_top_form").delegate("#search_button", "click", function(e) {       e.stopPropagation();    wrapperConsole('click search');    alert("event trigger");                                        submitSearchForm(); $("#search_top_form").undelegate(); }); </code></pre>
jquery
[5]
2,452,492
2,452,493
event handlers in javascript
<p>I'm looking to build two functions:</p> <pre><code>var MyObject = new Object(); MyObject.MyProperty = 1; function ListenToChange() { here I want to listen to changes in MyProperty1 and do something when it changes } function ThrowEvent () { here I change the value of MyProperty every 5 seconds setTimeOut('ThrowEvent', 5000); } </code></pre> <p>I looked at the addEventListener property but it looks like it works for DOM objects. I thought of using the ThrowEvent function to change the value of a hidden div and listen for the changes in the value of the hidden with $('#HiddenDiv').change() but I'm wondering if there's a better way to do it with the addEventListener.</p> <p>Thanks for your help.</p>
javascript
[3]