Search Results

Search found 777 results on 32 pages for 'mr spock'.

Page 18/32 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • How do I find the "concrete class" of a django model baseclass

    - by Mr Shark
    I'm trying to find the actual class of a django-model object, when using model-inheritance. Some code to describe the problem: class Base(models.model): def basemethod(self): ... class Child_1(Base): pass class Child_2(Base): pass If I create various objects of the two Child classes and the create a queryset containing them all: Child_1().save() Child_2().save() (o1, o2) = Base.objects.all() I want to determine if the object is of type Child_1 or Child_2 in basemethod, I can get to the child object via o1.child_1 and o2.child_2 but that reconquers knowledge about the childclasses in the baseclass. I have come up with the following code: def concrete_instance(self): instance = None for subclass in self._meta.get_all_related_objects(): acc_name = subclass.get_accessor_name() try: instance = self.__getattribute__(acc_name) return instance except Exception, e: pass But it feels brittle and I'm not sure of what happens when if I inherit in more levels.

    Read the article

  • Temporary storage for keeping data between program iterations?

    - by mr.b
    I am working on an application that works like this: It fetches data from many sources, resulting in pool of about 500,000-1,500,000 records (depends on time/day) Data is parsed Part of data is processed in a way to compare it to pre-existing data (read from database), calculations are made, and stored in database. Resulting dataset that has to be stored in database is, however, much smaller in size (compared to original data set), and ranges from 5,000-50,000 records. This process almost always updates existing data, perhaps adds few more records. Then, data from step 2 should be kept somehow, somewhere, so that next time data is fetched, there is a data set which can be used to perform calculations, without touching pre-existing data in database. I should point out that this data can be lost, it's not irreplaceable (key information can be read from database if needed), but it would speed up the process next time. Application components can (and will be) run off different computers (in the same network), so storage has to be reachable from multiple hosts. I have considered using memcached, but I'm not quite sure should I do so, because one record is usually no smaller than 200 bytes, and if I have 1,500,000 records, I guess that it would amount to over 300 MB of memcached cache... But that doesn't seem scalable to me - what if data was 5x that amount? If it were to consume 1-2 GB of cache only to keep data in between iterations (which could easily happen)? So, the question is: which temporary storage mechanism would be most suitable for this kind of processing? I haven't considered using mysql temporary tables, as I'm not sure if they can persist between sessions, and be used by other hosts in network... Any other suggestion? Something I should consider?

    Read the article

  • Is there a SQL Server error numbers C# wrapper anyone knows of?

    - by Mr Grok
    I really want to do something useful when a PK violation occurs but I hate trapping error numbers... they just don't read right without comments (they're certainly not self documenting). I know I can find all the potential error numbers at SQL Server books online but I really want to be able to pass the error number to some helper class or look it up against a Dictionary of some sort rather than have non-descript err numbers everywhere. Has anyone got / seen any code anywhere that encapsulates the SQL Server Error numbers in this way as I don't want to re-invent the wheel (or I'm lazy maybe).

    Read the article

  • Generic FSM for game in C++ ?

    - by Mr.Gando
    Hello, I was wondering if there's a way I could code some kind of "generic" FSM for a game with C++?. My game has a component oriented design, so I use a FSM Component. my Finite State Machine (FSM) Component, looks more or less this way. class gecFSM : public gecBehaviour { public: //Constructors gecFSM() { state = kEntityState_walk; } gecFSM(kEntityState s) { state = s; } //Interface void setRule(kEntityState initialState, int inputAction, kEntityState resultingState); void performAction(int action); private: kEntityState fsmTable[MAX_STATES][MAX_ACTIONS]; }; I would love to hear your opinions/ideas or suggestions about how to make this FSM component, generic. With generic I mean: 1) Creating the fsmTable from an xml file is really easy, I mean it's just a bunch of integers that can be loaded to create an MAX_STATESxMAX_ACTION matrix. void gecFSM::setRule(kEntityState initialState, int inputAction, kEntityState resultingState) { fsmTable[initialState][inputAction] = resultingState; } 2) But what about the "perform Action" method ? void gecFSM::performAction(int action) { switch( smTable[ ownerEntity->getState() ][ action ] ) { case WALK: /*Walk action*/ break; case STAND: /*Stand action*/ break; case JUMP: /*Jump action*/ break; case RUN: /*Run action*/ break; } } What if I wanted to make the "actions" and the switch generic? This in order to avoid creating a different FSM component class for each GameEntity? (gecFSMZombie, gecFSMDryad, gecFSMBoss etc ?). That would allow me to go "Data Driven" and construct my generic FSM's from files for example. What do you people suggest?

    Read the article

  • String replaceAll method (Java)

    - by Mr CooL
    I have following problem, Code: String a="Yeahh, I have no a idea what's happening now!"; System.out.println(a); a=a.replaceAll("a", ""); System.out.println(a); Before removing 'a', result: Yeahh, I have no a idea what's happening now! Actual Result: After removing 'a', result: Yehh, I hve no ide wht's hppening now! Desired Result: Yeahh, I have no idea what's happening now! Anyone can gimme some advices to achieve my desired result?

    Read the article

  • XSLT line counter - is it that hard?

    - by Mr AH
    I have cheated every time I've needed to do a line count in XSLT by using JScript, but in this case I can't do that. I simply want to write out a line counter throughout an output file. This basic example has a simple solution: <xsl:for-each select="Records/Record"> <xsl:value-of select="position()"/> </xsl:for-each> Output would be: 1 2 3 4 etc... But what if the structure is more complex with nested foreach's : <xsl:for-each select="Records/Record"> <xsl:value-of select="position()"/> <xsl:for-each select="Records/Record"> <xsl:value-of select="position()"/> </xsl:for-each> </xsl:for-each> Here, the inner foreach would just reset the counter (so you get 1, 1, 2, 3, 2, 1, 2, 3, 1, 2 etc). Does anyone know how I can output the position in the file (ie. a line count)?

    Read the article

  • fesetround with MSVC x64

    - by mr grumpy
    I'm porting some code to Windows (sigh) and need to use fesetround. MSVC doesn't support C99, so for x86 I copied an implementation from MinGW and hacked it about: //__asm__ volatile ("fnstcw %0;": "=m" (_cw)); __asm { fnstcw _cw } _cw &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO); _cw |= mode; //__asm__ volatile ("fldcw %0;" : : "m" (_cw)); __asm { fldcw _cw } if (has_sse) { unsigned int _mxcsr; //__asm__ volatile ("stmxcsr %0" : "=m" (_mxcsr)); __asm { stmxcsr _mxcsr } _mxcsr &= ~ 0x6000; _mxcsr |= (mode << __MXCSR_ROUND_FLAG_SHIFT); //__asm__ volatile ("ldmxcsr %0" : : "m" (_mxcsr)); __asm { ldmxcsr _mxcsr } } The commented lines are the originals for gcc; uncommented for msvc. This appears to work. However the x64 cl.exe doesn't support inline asm, so I'm stuck. Is there some code out there I can "borrow" for this? (I've spent hours with Google). Or will I have to go on a 2 week detour to learn some assembly and figure out how to get/use MASM? Any advice is appreciated. Thank you.

    Read the article

  • Alternative approach to OpenGL View on top of Camera

    - by Mr. Roland
    Hi, the traditional way of doing a camera preview background with OpenGL on the front is to take two SurfaceViews(one for the camera another for OpenGL) and stack them on top of each other. The problem is that stacking SurfaceViews is discouraged: http://groups.google.com/group/android-developers/browse_thread/thread/4850fe5c314a3dc6 So what alternatives are there? I was considering the following: Subclass GlSurfaceView, and then call set the Camera preview onto the holder of this subclass: Camera.setPreviewDisplay(mHolder); Don't use GLSurfaceView, instead create your own SurfaceView subclass where you display the Camera preview onto the holder and also draw your openGL. This would require to use OpenGL without GLSurfaceView, has anyone done this before? I'm not sure if this even is possible or makes sense, since it implies displaying the camera preview onto the holder of the surface and at the same time drawing OpenGL on the same surface. Is there any other sensible alternative to solving the problem without using two SurfaceViews? Thanks!

    Read the article

  • Android x86 porting, unable to make it work

    - by Mr G
    I'm kind of new to the whole porting issue and I got to it because of the slowness in the emulator provided with the Android SDK. I downloaded the android-x86-3.2-RC2-eeepc and android-x86-3.2-RC2-tegav2 ISO-es (from this site) and tried them on the VirtualBox but have no internet connection on the eeepc version and the tegev2 wont event start. I tried the VirtualBoxHowTo but got nothing, on both Windows and Linux platforms. the only thing I managed to understand is that to use this on a VM you need to build it for VM. Can anyone help me on this? P.S.: I need the HoneyComb version (3.2) and the pc I have is a AMD 6 core on and Asus Crosshair Extreme motherboard, Windows 7 or Ubunutu 11.10. (both OS are 64bit)

    Read the article

  • Query notation for the sitecore 'source' field in template builder

    - by M.R.
    I am trying to set the the source field of a template using the query notation (or xpath - whichever works), but none of them seems to be working. My content tree is a multisite content tree: France --Page 1 ----Page1A -------Page1AA --Page 2 --Page 3 --METADATA ----Regions US --Page 1 ----Page1A -------Page1AA --Page 2 --Page 3 --METADATA ----Regions Each site has its own METADATA folder, and I want it so that when adding a page inside each of the main country nodes, I want the values to reflect whatever is in the METADATA of that site. I have two different fields for now - a droplink and a treelistex field. So I thought I can just get the parent item that is a country site, and get the metadata folder for that. When I put the following query in both the fields, I get different results: query:./ancestor::*[@@templatename='CountryHome']/METADATA/Regions/* For the droplink field, I get only the first Region (one item) For the treelistex field, I get the entire content tree I then tried to modify the query a little bit and took the 'query' notation out ./ancestor::*[@@templatename='CountryHome']/METADATA/Regions/* If I go to the developer center/xpath builder, and set the context node to any item underneath the main country site, it returns me exactly what I need, but when I put this in the source, I get the entire content tree in both the cases. Help!

    Read the article

  • WPF C# Hide TabControl Items on Application Startup

    - by mr justinator
    I've created a start page that loads when the application is run but it is also showing my tabcontrol (two tabitems for editing & diagraming). How do I hide my tabcontrol items on startup and only show it when a user selects file - new? Many thanks! Xaml: <TabControl Height="Auto" Name="tabControl1" Width="Auto"> <TabItem Header="Diagram" Name="DiagramTab"></TabItem> <TabItem Header="Rulebase" Name="RuleTab" > <Grid> <TextBox Height="Auto" Name="RuleText" Width="Auto" Text="" AcceptsTab="True" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" GotFocus="FocusChanged" KeyDown="ContentChanged" HorizontalScrollBarVisibility="Visible" /> </Grid> </TabItem> </TabControl> Here's my file - new menu item: private void ProcessNewCommand() { if (dataChanged) { string sf = SaveFirst(); if (sf != "Cancel") { ClearState(); } } else { ClearState(); } }

    Read the article

  • Get image data for Direct3d rendering stream

    - by Mr Bell
    I would like to get at the raw image data, as in a pointed to a byte array or something like that, of the image output from a direct3d app without actually rendering it to the monitor. I need to do this so that I can render direct3d as a directshow source filter Visual studio 2008 c++

    Read the article

  • How to get webcam video stream bytes in c++

    - by Mr Bell
    I am targeting windows machines. I need to get access to the pointer to the byte array describing the individual streaming frames from an attached usb webcam. I saw the playcap directshow sample from the windows sdk, but I dont see how to get to raw data, frankly, I don't understand how the video actually gets to the window. Since I don't really need anything other than the video capture I would prefer not to use opencv. Visual Studio 2008 c++

    Read the article

  • Is there a methode to linarize a Document?

    - by M.R.
    A webservice response with a message which is not linarized. This produces a problem, when trying to access a (as an example) the root element with getSOAPBody().getFirstChlid(). In a linarized document this call would return the first element inside the the body. If the message is not properly formated, you may get the the line break between the soap body and the first element. The problem should be easy to solve with a recursive method, but I was wondering, if there is a method for it? Like normalize etc. Edit: XML Response: ... XMLSchema-instance"><soapenv:Body> <wst:RequestSecurityTokenResponse xmlns:wst="http://schemas.xmlsoap.org/ws/200/02/trust">... JAVA CODE: final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder db = factory.newDocumentBuilder(); Document result = db.newDocument(); //messResult is the response result.appendChild(result.importNode(messResult.getSOAPBody().getFirstChild(),true)); Error Log: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.

    Read the article

  • Targetting x86 vs AnyCPU when building for 64 bit window OSes

    - by Mr Roys
    I have an existing C# application written for .NET 2.0 and targetting AnyCPU at the moment. It currently references some third party .NET DLLs which I don't have the source for (and I'm not sure if they were built for x86, x64 or AnyCPU). If I want to run my application specifically on a 64 bit Windows OS, which platform should I target in order for my app to run without errors? My understanding at the moment is to target: x86: If at least one third party .NET dll is built for x86 or use p/Invoke to interface with Win32 DLLs. Application will run in 32 bit mode on both 32 bit and 64 bit OSes. x64: If all third party .NET dlls are already built for x64 or AnyCPU. Application will only run in 64 bit OSes. AnyCPU: If all third party .NET dlls are already built for AnyCPU. Application will run in 32 bit mode on 32 bit OSes and 64 bit on 64 bit OSes. Also, am I right to believe that while targetting AnyCPU will generate no errors when building a application referencing third party x86 .NET DLLs, the application will throw a runtime exception when it tries to load these DLLs when it runs on a 64 bit OS. Hence, as long as one of my third party DLLs is doing p/Invoke or are x86, I can only target x86 for this application?

    Read the article

  • How can i tell jaxb / Maven to genereate multiple schema packages?

    - by M.R.
    Example: </plugin> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.7.1</version> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <schemaDirectory>src/main/resources/dir1</schemaDirectory> <schemaIncludes> <include>schema1.xsd</include> </schemaIncludes> <generatePackage>schema1.package</generatePackage> </configuration> </plugin> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.7.1</version> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <schemaDirectory>src/main/resources/dir2</schemaDirectory> <schemaIncludes> <include>schema2.xsd</include> </schemaIncludes> <generatePackage>schema2.package</generatePackage> </configuration> </plugin> </plugins> What happened: Maven executes the the first plugin. Then deletes the target folder and creates the second package, which then is visible. I tried to set target/somedir1 for the first configuration and target/somedir2 for the second configuration. But the behavior does not not change? Any ideas? I do not want to generate the packages directly in the src/main/java folder, because these packages are genereated and should not be mixed with manual created classes.

    Read the article

  • Core Data confusion: fetch without tableview.

    - by Mr. McPepperNuts
    I have completed and reproduced Core Data tutorials using a tableview to display contents. However, I want to access an Entity through a fetch on a view without a tableview. I used the following fetch code, but the count returned is always 0. The data exists when the database is opened using SQLite tools. NSManagedObject *entryObj; XYZDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; NSManagedObjectContext *managedObjectContext = appDelegate.managedObjectContext; NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Quote" inManagedObjectContext:managedObjectContext]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"id" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [request setEntity: entity]; NSArray *results = [managedObjectContext executeFetchRequest:request error:nil]; if (results == nil) { NSLog(@"No results found"); entryObj = nil; }else { NSLog(@"results %d", [results count]); } [request release]; [sortDescriptors release]; count returned is always 0; it should be 5. Can anyone point me to a reference or tutorial regarding creating a controller not to be used with a tableview.

    Read the article

  • interactive lua: command line arguments

    - by mr calendar
    I wish to do lua prog.lua arg1 arg2 from the command line Inside prog.lua, I want to say, for instance print (arg1, arg2, '\n') Lua doesn't seem to have argv[1] etc and the methods I've seen for dealing with command line arguments seem to be immature and / or cumbersome. Am I missing something?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >