Daily Archives

Articles indexed Thursday April 8 2010

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

  • Why can't I declare C# methods virtual and static?

    - by Luke
    I have a helper class that is just a bunch of static methods and would like to subclass the helper class. Some behavior is unique depending on the subclass so I would like to call a virtual method from the base class, but since all the methods are static I can't create a plain virtual method (need object reference in order to access virtual method). Is there any way around this? I guess I could use a singleton.. HelperClass.Instance.HelperMethod() isn't so much worse than HelperClass.HelperMethod(). Brownie points for anyone that can point out some languages that support virtual static methods. Edit: OK yeah I'm crazy. Google search results had me thinking I wasn't for a bit there.

    Read the article

  • url link in bibtex

    - by Tim
    Hi, I was wondering how to make a url link appear in Bibliography? For example, @misc{libsvm, abstract = {LIBSVM is an implbmentation of Support vector machine (SVM).}, author = {Chang, Chih-Chung}, keywords = {svm}, posted-at = {2010-04-08 00:05:04}, priority = {2}, title = {LIBSVM}, url = "http://www.csie.ntu.edu.tw/~cjlin/libsvm/", year = {2008} } will appear in Bibliography as [2] Chih-Chung Chang. Libsvm, 2008. But I hope the link "http://www.csie.ntu.edu.tw/~cjlin/libsvm/" could appear and the "Libsvm" could be all capital "LIBSVM". Honestly, I have no idea how a link should appear in Bibliography. What I think might be not professional. Please advise me how to put it in a professional way. Thanks and regards!

    Read the article

  • bibtex and label/ref

    - by Tim
    Hi, I was wondering how I can add \label into bibtex so that when I cite in my document and I can also \ref to it by clicking it and jumping to the Bibliography at the end? for example: @article{greenwade93, author = "George D. Greenwade", title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})", year = "1993", journal = "TUGBoat", volume = "14", number = "3", pages = "342--351" } Thanks and regards

    Read the article

  • Bad File descriptor

    - by Luke
    Does anyone see a problem with this, its not working saying bad file descriptor not sure why? pipe(pipefd[0]); if ((opid = fork()) == 0) { dup2(pipefd[0][1],1);/*send to output*/ close(pipefd[0][0]); close(pipefd[0][1]); execlp("ls","ls","-al",NULL); } if((cpid = fork())==0){ dup2(pipefd[0][1],0);/*read from input*/ close(pipefd[0][0]); close(pipefd[1][1]); execlp("grep","grep",".bak",NULL); } close(pipefd[0][0]); close(pipefd[0][1]);

    Read the article

  • C#: Inheritence, Overriding, and Hiding

    - by Rosarch
    I'm having difficulty with an architectural decision for my C# XNA game. The basic entity in the world, such as a tree, zombie, or the player, is represented as a GameObject. Each GameObject is composed of at least a GameObjectController, GameObjectModel, and GameObjectView. These three are enough for simple entities, like inanimate trees or rocks. However, as I try to keep the functionality as factored out as possible, the inheritance begins to feel unwieldy. Syntactically, I'm not even sure how best to accomplish my goals. Here is the GameObjectController: public class GameObjectController { protected GameObjectModel model; protected GameObjectView view; public GameObjectController(GameObjectManager gameObjectManager) { this.gameObjectManager = gameObjectManager; model = new GameObjectModel(this); view = new GameObjectView(this); } public GameObjectManager GameObjectManager { get { return gameObjectManager; } } public virtual GameObjectView View { get { return view; } } public virtual GameObjectModel Model { get { return model; } } public virtual void Update(long tick) { } } I want to specify that each subclass of GameObjectController will have accessible at least a GameObjectView and GameObjectModel. If subclasses are fine using those classes, but perhaps are overriding for a more sophisticated Update() method, I don't want them to have to duplicate the code to produce those dependencies. So, the GameObjectController constructor sets those objects up. However, some objects do want to override the model and view. This is where the trouble comes in. Some objects need to fight, so they are CombatantGameObjects: public class CombatantGameObject : GameObjectController { protected new readonly CombatantGameModel model; public new virtual CombatantGameModel Model { get { return model; } } protected readonly CombatEngine combatEngine; public CombatantGameObject(GameObjectManager gameObjectManager, CombatEngine combatEngine) : base(gameObjectManager) { model = new CombatantGameModel(this); this.combatEngine = combatEngine; } public override void Update(long tick) { if (model.Health <= 0) { gameObjectManager.RemoveFromWorld(this); } base.Update(tick); } } Still pretty simple. Is my use of new to hide instance variables correct? Note that I'm assigning CombatantObjectController.model here, even though GameObjectController.Model was already set. And, combatants don't need any special view functionality, so they leave GameObjectController.View alone. Then I get down to the PlayerController, at which a bug is found. public class PlayerController : CombatantGameObject { private readonly IInputReader inputReader; private new readonly PlayerModel model; public new PlayerModel Model { get { return model; } } private float lastInventoryIndexAt; private float lastThrowAt; public PlayerController(GameObjectManager gameObjectManager, IInputReader inputReader, CombatEngine combatEngine) : base(gameObjectManager, combatEngine) { this.inputReader = inputReader; model = new PlayerModel(this); Model.Health = Constants.PLAYER_HEALTH; } public override void Update(long tick) { if (Model.Health <= 0) { gameObjectManager.RemoveFromWorld(this); for (int i = 0; i < 10; i++) { Debug.WriteLine("YOU DEAD SON!!!"); } return; } UpdateFromInput(tick); // .... } } The first time that this line is executed, I get a null reference exception: model.Body.ApplyImpulse(movementImpulse, model.Position); model.Position looks at model.Body, which is null. This is a function that initializes GameObjects before they are deployed into the world: public void Initialize(GameObjectController controller, IDictionary<string, string> data, WorldState worldState) { controller.View.read(data); controller.View.createSpriteAnimations(data, _assets); controller.Model.read(data); SetUpPhysics(controller, worldState, controller.Model.BoundingCircleRadius, Single.Parse(data["x"]), Single.Parse(data["y"]), bool.Parse(data["isBullet"])); } Every object is passed as a GameObjectController. Does that mean that if the object is really a PlayerController, controller.Model will refer to the base's GameObjectModel and not the PlayerController's overriden PlayerObjectModel?

    Read the article

  • How do you clean Core Data generated models and code from a project?

    - by Hazmit
    I'm having an extremely annoying problem with Core Data in the iPhone SDK. I would say in general Core Data for the most part appears easy to use and nice to implement. I have a sqlite database that is being used as a read only reference to pull data elements out for an iPhone app. It would seem there are really mysterious issues relating to what seems to be migration of the database to the most recent versions of my schema. Why can't you just clean out your stored objects and models and let a project redo all of it when you compile next? You would think if you setup a stored object model there would be a way to just reset it and recompile. I've tried what feels like a thousand 'tips' that have been the results of hours of google searches and documentation prowling to figure out how to do this. My most recent error during compile time is below. 2010-04-07 18:23:51.891 PE[1962:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'PElement'' All of this code has been working in the simulator and is only causing me troubles now because I made a change to the schema. I also have the database options for automatically migrating set as below. NSMutableDictionary *optionsDictionary = [NSMutableDictionary dictionary]; [optionsDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption]; [optionsDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSInferMappingModelAutomaticallyOption];

    Read the article

  • Context Free Language Question (Pumping Lemma)

    - by Maixy
    I know this isn't directly related to programming, but I was wondering if anyone know how to apply the pumping lemma to the following proof: Show that L={(a^n)(b^n)(c^m) : n!=m} is not a context free language I'm pretty confident with applying pumping lemmas, but this one is really irking me. What do you think?

    Read the article

  • How to connect an existing strongly-typed data set to a different server at run time?

    - by Kiril
    I am coding a simple space empire management game in Visual C# 2008, which relies on connecting to a remote SQL server database to get/store data. I would like the user to be able to connect to a user-specified SQL server from the login screen(he specifies IP address, port, database name, ID, password and presses "connect" button). However, I found out that the Dataset connection string property is read only and cannot be changed. Is there any way to guide the wizard-generated DataSet to a user-specified server at run time?

    Read the article

  • Loop through all subclasses in an Android view?

    - by Slapout
    I’m working on a game for Android. To help implement it, my idea is to create a subclass of a view. I would then insert several instances of this class as children of the main view. Each instance would handle detecting when it was pressed (via OnTouchListener). The problem I’m having now is how do I loop through all these sub-views so I can read their statuses and process them? (I.e. when they all reach a certain state something should happen). Or is there a better way to have several objects on the screen that respond to touch and whose status I can check?

    Read the article

  • C++ template class error with operator ==

    - by Tommy
    Error: error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const entry' (or there is no acceptable conversion) The function: template <class T, int maxSize> int indexList<T, maxSize>::search(const T& target) const { for (int i = 0; i < maxSize; i++) if (elements[i] == target) //ERROR??? return i; // target found at position i // target not found return -1; } indexList.h indexList.cpp Is this suppose to be an overloaded operator? Being a template class I am not sure I understand the error? Solution- The overload function in the class now declared const: //Operators bool entry::operator == (const entry& dE) const <-- { return (name ==dE.name); }

    Read the article

  • Trying to Create a ToolBar with an ImageList, not working.

    - by blaquee
    Im trying to get my toolbar to work, with an imagelist. The images are png's and are individual So i was adding them in the ImageList in succession. But it wasnt working, Here is the code to add the Image to the ImageList HIMAGELIST CreateToolBarImages( HINSTANCE hInst) { HIMAGELIST v_ImageList = NULL; //IMAGE_LIST v_Img; HICON hIcon; HBITMAP hBit; COLORMAP cMap; COLORREF fromColor = RGB( 0,0,0 ); InitCommonControls(); v_ImageList = ImageList_Create( 32,32, ILC_MASK, 1,1 ); cMap.from = fromColor; cMap.to = ::GetSysColor ( COLOR_BTNFACE ); hBit = CreateMappedBitmap( hInst, IDB_CONSOLE, 0, &cMap, 1 ); //hBit = LoadBitmap( hInst, MAKEINTRESOURCE(IDB_CONSOLE) ); consoleImg = ImageList_Add( v_ImageList, hBit, 0 ); if( consoleImg == -1 ) return NULL; DeleteObject( hBit ); Then i create The ToolBar, but it fails at the Image function. HWND CreateToolBarButton( HWND hWndParent ) { const int ImageID = 0; const int numB = 1; COLORREF iColor; HWND hToolBar = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_CHILD |TBSTYLE_LIST |TBSTYLE_FLAT | WS_VISIBLE, 0,0,0,0, hWndParent, NULL, g_hInst, NULL ); if( hToolBar == NULL ) return NULL; HIMAGELIST ImgList = CreateToolBarImages ( g_hInst); if( ImgList == NULL ) MessageBox( hWndParent, L"No Tool Images", L"BOB", MB_OK ); return NULL; Is there something im missing? or not doing?

    Read the article

  • SQLAuthority News Author Visit Review TechMela Nepal March 29-30, 2010

    I was very fortunate to attend TechMela at Kathmandu, Nepal on 29th and 30th of March 2010. I would like to thank Allen Bailochan Tuladhar from Microsoft MDP Nepal for inviting me. Allen is a person with seemingly infinite energy and unlimited passion for Microsoft Technology. If you get an opportunity to spend just one [...]...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

  • Attempts at NIC teaming on Server 2008 R2 with PRO/1000 MT

    - by Klaus
    I have a Dell PowerEdge 1850 server and a gigabit switch that supports nic teaming (and was configured to do so). The server has a total of four Intel PRO/1000 MT ports, which also support teaming. But.. for some reason Intel does not actually have a version of the drivers/ProSet that will work for these cards on 2008 R2. You have to use the built-in drivers that come with 2008 R2, which do not support the additional features. According to their website, they have no plans to change this. Strangely enough, I experimented with various drivers in an attempt to force it to work. At one point, the teaming was working, but there were side effects (such as the DNS server refusing to start). So now I am back to running just one of the cards, (very) frustrated about the whole situation. I have looked all over to see if there is some way around this, but have not had any success. I know I can probably just get a new network adapter for it, but with the good deal I got, that would cost more than the server! :) While staying with 2008 R2, does anyone know of any possible alternatives? Thanks!

    Read the article

  • DNS Name lookup (was SSH) Not Working After Snow Leopard Upgrade

    - by petercardona
    I think this started with the Snow Leopard update. Cleaned out the .ssh directory, still having the issue. ~: uname -a Darwin california-example-com.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386 ~: ssh -V OpenSSH_5.2p1, OpenSSL 0.9.8k 25 Mar 2009 ~: ls -l ~/.ssh ~: nslookup nevada Server: 10.94.62.3 Address: 10.94.62.3#53 Name: nevada.example.com Address: 10.94.62.3 ~: ssh nevada ssh: Could not resolve hostname nevada: nodename nor servname provided, or not known

    Read the article

  • Tool to annotate pictures (screenshots) for documentation purposes?

    - by René Nyffenegger
    Long time ago, I saw someone use a software (on Windows) that was specifically created to annotate pictures. It made it simple to add arrows, boxes, circles in "outstanding" colors to the image. Unfortunatly, I don't remember what program that was. Now, I have to document a GUI and I'd like to use this software in order to annotate screenshots of the software so that I can show the order of flow and dependencies between various aspects of the GUI. I'd be very happy if someone could point me into the right direction.

    Read the article

  • Intel Xeon 5600 (Westmere-EP) and 7500 (Nehalem-EX)

    - by jchang
    Intel Xeon 5600 (Westmere-EP) and 7500 (Nehalem-EX) Performance Intel launched the Xeon 5600 series (Westmere-EP, 32nm) six-core processors on 16 March 2010 without any TPC benchmark results. In the performance world, no results almost always mean bad or not good results. Yet there is every reason to believe that the Xeon 5600 series with six-cores (X models only) will performance exactly as expected for a 50% increase in the number of cores at the same frequency (as the 5500) with no system level...(read more)

    Read the article

  • RoR associations through or not through?

    - by showFocus
    I have four models that are related to one another, the way I have it setup at the moment is I have to select a county, region and country when entering a new city. class Country < ActiveRecord::Base has_many :regions has_many :counties has_many :cities end class Region < ActiveRecord::Base has_one :country has_many :counties has_many :cities end class County < ActiveRecord::Base has_one :country has_one :region has_many :cities end class City < ActiveRecord::Base has_one :country has_one :region has_one :county end Would it be better to use the :through symbol in the association? So I could say the city: has_one :country, :through => :region Not sure if this is correct, I have read how :through works but I'm not sure if this is the best solution. I am a newbie and while I'm not struggling with the syntax and how things work, it would be good to get opinions on best practices and the way things should be done from some rails wizards! Thanks in advance.

    Read the article

  • Python: load variables in a dict into namespace

    - by celil
    I want to use a bunch of local variables defined in a function, outside of the function, so I am passing x=locals() as a return value. How can I load all the variables defined in that dictionary into the namespace outside the function, so that instead of accessing the value using x['variable'], I could simply use variable.

    Read the article

  • C++. What is a subprogram and method?

    - by xbonez
    I have a CPP HW to be done. One question is: 1) Write a subprogram (not a method) void promptForMovie(Movie & myMovie) that ..... 2) Write a method void output(ostream & out); that .... My question is what exactly is a subprogram and a method? Which one of them means a function, and what does the other mean? Thank you

    Read the article

  • C++ syntax issue

    - by Doug
    It's late and I can't figure out what is wrong with my syntax. I have asked other people and they can't find the syntax error either so I came here on a friend's advice. template <typename TT> bool PuzzleSolver<TT>::solve ( const Clock &pz ) { possibConfigs_.push( pz.getInitial() ); vector< Configuration<TT> > next_; //error is on next line map< Configuration<TT> ,Configuration<TT> >::iterator found; while ( !possibConfigs_.empty() && possibConfigs_.front() != pz.getGoal() ) { Configuration<TT> cfg = possibConfigs_.front(); possibConfigs_.pop(); next_ = pz.getNext( cfg ); for ( int i = 0; i < next_.size(); i++ ) { found = seenConfigs_.find( next_[i] ); if ( found != seenConfigs_.end() ) { possibConfigs_.push( next_[i] ); seenConfigs_.insert( make_pair( next_[i], cfg ) ); } } } } What is wrong? Thanks for any help.

    Read the article

  • Easy to get a test file into JUnit

    - by Benju
    Can somebody suggest an easy way to get a reference to a file as a String/InputStream/File/etc type object in a junit test class? Obviously I could paste the file (xml in this case) in as a giant String or read it in as a file but is there a shortcut specific to Junit like this? public class MyTestClass{ @Resource(path="something.xml") File myTestFile; @Test public void toSomeTest(){ ... } }

    Read the article

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