Daily Archives

Articles indexed Monday June 7 2010

Page 11/113 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • PHP real time chat with ajax polling

    - by xRobot
    I need to create a chat similar to facebook chat. I am thinking to use ajax polling ( to send request every 2-3 seconds ). Is this a good approach ? Or I need to use other server side languages like erlang and server-comet ?

    Read the article

  • Can you cast an object to one that implements an interface? (JAVA)

    - by DDP
    Can you cast an object to one that implements an interface? Right now, I'm building a GUI, and I don't want to rewrite the Confirm/Cancel code (A confirmation pop-up) over and over again. So, what I'm trying to do is write a class that gets passed the class it's used in and tells the class whether or not the user pressed Confirm or Cancel. The class always implements a certain interface. Code: class ConfirmFrame extends JFrame implements ActionListener { JButton confirm = new JButton("Confirm"); JButton cancel = new JButton("Cancel"); Object o; public ConfirmFrame(Object o) { // Irrelevant code here add(confirm); add(cancel); this.o = (/*What goes here?*/)o; } public void actionPerformed( ActionEvent evt) { o.actionPerformed(evt); } } I realize that I'm probably over-complicating things, but now that I've run across this, I really want to know if you can cast an object to another object that implements a certain interface.

    Read the article

  • jQuery draggable leaving cloned html behind

    - by Alex Crooks
    I am using jQuery UI; Draggable http://jqueryui.com/demos/draggable invoked like this: $(document).ready(function(){ $("#side_bar").sortable({ revert: true }); $(".draggable").draggable({ containment: 'parent', hascroll: true, handle: 'div.box_header', scrollSensitivity: 100, scrollSpeed: 100, axis: 'y', connectToSortable: '#side_bar', helper: 'clone', opacity: 0.35 }); }); You can see the html structure on http://www.sarsclan.co.uk (right side bar area). It seems to create a transparant clone as your dragging, but when you drop it puts the draggable div in the right place, but leaves the original div in it's place and just appends the dom with a clone of that original div in its new place.

    Read the article

  • android: consume key press, bypassing framework processing

    - by user360024
    What I want android to do: when user presses a single key, have the view respond, but do so without opening a text area and displaying the character associated with the key that was pressed, and without requiring that the Enter key be pressed, and without requiring that the user press Esc to make the text area go away. For example, when user presses "u" (and doesn't press Enter), that means "undo the last action", so the controller and model immediately undo the last action, then the view does an invalidate() and user sees that their last action has been undone. In other words the "u" key press should be silently processed, such that the only visual result is that user's last action has been undone. I've implemented OnKeyListener and provided an onKey() method: the class: public class MyGameView extends View implements OnKeyListener{ in the constructor: //2010jun06, phj: With onKey(), helps let this View consume key presses // before the framework gets a chance to consume the key press. setOnKeyListener((View.OnKeyListener)this); the onKey() method: public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_R) { Log.d("BWA", "In onKey received keycode associated with R."); } return true; // meaning the event (key press) has been consumed, so // the framework should not handle this event. } but when user presses "u" key on the emulator keypad, a textarea is opened at the bottom of the screen, the "u" charater is displayed there, and the onKey() method doesn't execute until user presses the Enter key. Is there a way to make android do what I want? Thanks,

    Read the article

  • Get the entire string of a jquery DOM object

    - by Scozzard
    Hi, I have had a bit of a look around and am having some difficulty solving a wee issue I am having. I basically have a string of HTML, I convert that to a JQuery DOM object so that I can easily remove all elements that have a certain class using JQuery's .remove(). I.e., var radHtml = editor.get_html(); var jqDom = $(radHtml); $(".thickbox", jqDom).remove(); editor.set_html(jqDom.html()); The only problem is that .html() only gets the first element, not the entire DOM. In reference to my code I am basically wanting radHhtml - elements with class "thickbox" (returned as string). I was wondering if there was an easy way to do this - have some html and remove all elements (in this case divs) that have a certain class (but leaving their contents). JQuery doesnt have to used, but I would like to. Any help would be much appreicated. Thanks.

    Read the article

  • The way cores, processes, and threads work exactly?

    - by unknownthreat
    I need a bit of an advice for understanding how this whole procedure work exactly. If I am incorrect in any part described below, please correct me. In a single core CPU, it runs each process in the OS, jumping around from one process to another to utilize the best of itself. A process can also have many threads, in which the CPU core runs through these threads when it is running on the respective process. Now, on a multiple core CPU, Do the cores run in every process together, or can the cores run separately in different processes at one particular point of time? For instance, you have program A running two threads, can a duo core CPU run both threads of this program? I think the answer should be yes if we are using something like OpenMP. But while the cores are running in this OpenMP-embedded process, can one of the core simply switch to other process? For programs that are created for single core, when running at 100%, why the CPU utilization of each core are distributed? (ex. A duo core CPU of 80% and 20%. The utilization percentage of all cores always add up to 100% for this case.) Do the cores try help each other run each thread of each process in some ways? Frankly, I'm not sure how this works exactly. Any advice is appreciated.

    Read the article

  • don't wanna lose data on Android after uninstalling

    - by soclose
    Hi, Now I make a trial application. I'd like to store IMEI and other info in Android permanently. And I don't want to lose them after uninstalling it. I tested with shared preference but it deletes after un-installation. SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("silentMode", true); // Commit the edits! editor.commit(); let me know where to store.

    Read the article

  • Counting entries in a list of dictionaries: for loop vs. list comprehension with map(itemgetter)

    - by Dennis Williamson
    In a Python program I'm writing I've compared using a for loop and increment variables versus list comprehension with map(itemgetter) and len() when counting entries in dictionaries which are in a list. It takes the same time using a each method. Am I doing something wrong or is there a better approach? Here is a greatly simplified and shortened data structure: list = [ {'key1': True, 'dontcare': False, 'ignoreme': False, 'key2': True, 'filenotfound': 'biscuits and gravy'}, {'key1': False, 'dontcare': False, 'ignoreme': False, 'key2': True, 'filenotfound': 'peaches and cream'}, {'key1': True, 'dontcare': False, 'ignoreme': False, 'key2': False, 'filenotfound': 'Abbott and Costello'}, {'key1': False, 'dontcare': False, 'ignoreme': True, 'key2': False, 'filenotfound': 'over and under'}, {'key1': True, 'dontcare': True, 'ignoreme': False, 'key2': True, 'filenotfound': 'Scotch and... well... neat, thanks'} ] Here is the for loop version: #!/usr/bin/env python # Python 2.6 # count the entries where key1 is True # keep a separate count for the subset that also have key2 True key1 = key2 = 0 for dictionary in list: if dictionary["key1"]: key1 += 1 if dictionary["key2"]: key2 += 1 print "Counts: key1: " + str(key1) + ", subset key2: " + str(key2) Output for the data above: Counts: key1: 3, subset key2: 2 Here is the other, perhaps more Pythonic, version: #!/usr/bin/env python # Python 2.6 # count the entries where key1 is True # keep a separate count for the subset that also have key2 True from operator import itemgetter KEY1 = 0 KEY2 = 1 getentries = itemgetter("key1", "key2") entries = map(getentries, list) key1 = len([x for x in entries if x[KEY1]]) key2 = len([x for x in entries if x[KEY1] and x[KEY2]]) print "Counts: key1: " + str(key1) + ", subset key2: " + str(key2) Output for the data above (same as before): Counts: key1: 3, subset key2: 2 I'm a tiny bit surprised these take the same amount of time. I wonder if there's something faster. I'm sure I'm overlooking something simple. One alternative I've considered is loading the data into a database and doing SQL queries, but the data doesn't need to persist and I'd have to profile the overhead of the data transfer, etc., and a database may not always be available. I have no control over the original form of the data. The code above is not going for style points.

    Read the article

  • Register Schema Master in Active Directory

    In order to view the complete schema in AD, I have to register the schmmgmt.dll and then open a snap in in MMC, the steps can be summarized as: Go to CMD> Windows System Folder > System32 folder Type in "regsvr32 schmmgmt.dll" Open MMC > File > Add/Remove Snap-In > Active Directory Schema Then I can browser all available attributes in this AD Schema  ...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Can't pass a single parameter to lambda function in MVVM Light Toolkit's RelayCommand

    - by Dave
    I don't know if there's a difference between Josh Smith's and Laurent Bugnion's implementations of RelayCommand or not, but everywhere I've looked, it sounds like the Execute portion of RelayCommand can take 0 or 1 parameters. I've only been able to get it to work with 0. When I try something like: public class Test { public RelayCommand MyCommand { get; set; } public Test() { MyCommand = new RelayCommand((param) => SomeFunc(param)); } private void SomeFunc( object param) { } } I get the error: Delegate 'System.Action' does not take '1' arguments. Just to make sure I am not insane, I went to the definition of RelayCommand to make sure I didn't have some rogue implementation in my solution somewhere, but sure enough, it was just Action, and not Action<. What on earth am I missing here?

    Read the article

  • Overloading stream insertion without violating information hiding?

    - by Chris
    I'm using yaml-cpp for a project. I want to overload the << and >> operators for some classes, but I'm having an issue grappling with how to "properly" do this. Take the Note class, for example. It's fairly boring: class Note { public: // constructors Note( void ); ~Note( void ); // public accessor methods void number( const unsigned long& number ) { _number = number; } unsigned long number( void ) const { return _number; } void author( const unsigned long& author ) { _author = author; } unsigned long author( void ) const { return _author; } void subject( const std::string& subject ) { _subject = subject; } std::string subject( void ) const { return _subject; } void body( const std::string& body ) { _body = body; } std::string body( void ) const { return _body; } private: unsigned long _number; unsigned long _author; std::string _subject; std::string _body; }; The << operator is easy sauce. In the .h: YAML::Emitter& operator << ( YAML::Emitter& out, const Note& v ); And in the .cpp: YAML::Emitter& operator << ( YAML::Emitter& out, const Note& v ) { out << v.number() << v.author() << v.subject() << v.body(); return out; } No sweat. Then I go to declare the >> operator. In the .h: void operator >> ( const YAML::Node& node, Note& note ); But in the .cpp I get: void operator >> ( const YAML::Node& node, Note& note ) { node[0] >> ? node[1] >> ? node[2] >> ? node[3] >> ? return; } If I write things like node[0] >> v._number; then I would need to change the CV-qualifier to make all of the Note fields public (which defeats everything I was taught (by professors, books, and experience))) about data hiding. I feel like doing node[0] >> temp0; v.number( temp0 ); all over the place is not only tedious, error-prone, and ugly, but rather wasteful (what with the extra copies). Then I got wise: I attempted to move these two operators into the Note class itself, and declare them as friends, but the compiler (GCC 4.4) didn't like that: src/note.h:44: error: ‘YAML::Emitter& Note::operator<<(YAML::Emitter&, const Note&)’ must take exactly one argument src/note.h:45: error: ‘void Note::operator(const YAML::Node&, Note&)’ must take exactly one argument Question: How do I "properly" overload the >> operator for a class Without violating the information hiding principle? Without excessive copying?

    Read the article

  • How to open android calculator buit-in-application

    - by Jobayer
    Hello Developers Thanks to every on to support android development forum. I want to make a application where when I click a button in my application then open android built-in Calculator application. That means I want to call calculator apk file from my application. Is it possible? Advanced thanks to reply

    Read the article

  • AJAX is reloading page on a SharePoint site (SharePoint 2007 AJAX-enabled)

    - by Josh
    I have an AJAX-enabled SharePoint 2007 site. I have also created a user control that has an interactive ajax form. It obviuosly works like a charm locally, but I am trying to get it working on the SharePoint site. The problem is that once I load up the user control on to an aspx page inside SharePoint, the form (which has ajax), causes the page to reload every time a postback occurs. Can someone help point me in the direction of debugging this? - I really need to eliminate the page refreshes and have the ajax work correctly in SharePoint. I read that the ScriptManager has to be in the SharePoint masterpage, but that did not work either... Page still reloads everytime. Thanks.

    Read the article

  • Getting session authenticity token via ajax (rails, jquery)

    - by ming yeow
    Hi folks, I wish to authenticate a user without having the page reloaded, and having the user submit a given form. However, the problem that I immediately run into here is that the authenticity token typically gets set when the page is reloaded. I need the authenticity token for the form submission, but i do not have it yet because the page is yet to reload. I figure this cannot be that rare - anyone has any idea on how to resolve this? 1 idea could be getting rails to pass back the authenticity token after authentication, but i do not know how to access it from the controller 1) not logined user sees form 2) not logined user types in message and submit 3) facebox asking for authentication 4) after authentication, submit form automatically without refreshing 5) //but authenticity token is needed for form submission, which is not there yet

    Read the article

  • need help in site classification

    - by goh
    hi guys, I have to crawl the contents of several blogs. The problem is that I need to classify whether the blogs the authors are from a specific school and is talking about the school's stuff. May i know what's the best approach in doing the crawling or how should i go about the classification?

    Read the article

  • AVD Error: No compatible targets were found. Do you wish to add a new Android Virtual Device?

    - by cdonner
    I must be missing something. Help! My manifest contains: <manifest ...> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="7" android:maxSdkVersion="10" /> <application ... I have all API packages installed (through 7 - Android 2.1). Whenever I try to run or debug my app in the emulator, reglardless of which version I start, I get the message in the subject line and I have to click on Cancel in order to continue. After that, the device chooser appears: and I can select a device and the app starts up fine in the Emulator. What do the red Xs mean next to the target? When my Nexus One is cradled, I do not get the warning that there is no compatible device. I can live with the extra click, but I am concerned that my up does not properly register the target API level and that this will cause problems once uploaded to the market.

    Read the article

  • How to connect remote EJB module from application client

    - by Zeck
    Hi guys, I have a EJB module in remote Glassfish server and application client in my computer. I want to connect from the application client to the remote EJB. Here is the my EJB interface: @Remote public interface BookEJBRemote { public String getTitle(); } Here is the my ejb: @Stateless public class BookEJB implements BookEJBRemote { @Override public String getTitle() { return "Twenty Thousand Leagues Under the Sea"; } } I have several questions : Can I use Dependency Injection in the remote application client to connect to the ejb? If so what can i do to achieve this. Do i need to configure in the sun-ejb-jar.xml and sun-application-client.xml? In other words, if i use DI like @EJB MyEJBRemote ejb; How application client container know what ejb to be injected? Where should i specify the information? How can i run the application client? I tried to run package-appclient in the glassfish server to get appclient.jar and copy it to my computer. Then i type appclient.jar -client myAppClient.jar . It didn't work. How do i point the target server? if i cannot use DI in the client then i guess i have to use JNDI lookup. Do i need to configure jndi name in sun-ejb-jar.xml or in the sun-application-client.xml? No matter how i try i never manage to run application client ? Can you guys put some working example? And thank you for every advises and examples?

    Read the article

  • Closed Source Java Applications

    - by Paul
    I am taking programming courses and we have been discussing Open Source and having a bit of an argument over the confusion. Just because Java is Open Source, the licensing on developed applications starts at the developer, correct? Someone is arguing about the use of code from a complete program just because "Java is Open Source". If I write a Java application, what are the limitations on how I can distribute it or how someone else can use it? Assume here that I DO NOT want someone having access to my source. Thanks

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >