Search Results

Search found 996 results on 40 pages for 'compound eye'.

Page 24/40 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • How do I simplify a 2D game grid for level management while keeping its by-pixel features?

    - by Eric Thoma
    (I cross-posted this from StackOverflow as this seems to be a more appropriate forum. I've looked around a little here and I did not find an answer, so I hope this is not a recurring question.) This is a question dealing with 2D world design. I am playing around by creating a 2D bird's eye view shooter game, and I am looking to make the game sleek and advanced. I hope to be able to write physics so projectiles have momentum and knock-down properties. I am immediately running into the problem of world design. I need a way to have level files that store everything there is about a game. This is easiest by just having a grid of objects. But there are thin-walls and other objects that don't seem to fit into a traditional cell of a grid. I want to be able to fit all these together so I can streamline level design; so I don't have to put in the exact pixel-specific start and end of a wall. There doesn't seem to be an obvious translation from level file to game without forcing myself into a pacman-life scenario, meaning a scenario where the game feels boxy and discrete. There is a contrast between the smoothly (relatively) moving characters and finite jumps in a grid. I would appreciate an answer that would describe implementation options or point me to resources that do. I would also appreciate references to sites that teach game design. The language I am using is Java (although I would love to use C or C++, but I can never find convenient resources in those languages). Thank you for any answers. Please leave any questions in the space below; I will be able to answer them later tonight (28th Nov).

    Read the article

  • I have an "amoeba" game mechanic. Any idea on how to implement it?

    - by Jason
    Outside of a tetris clone, a crappy 2D top-down shooter, and some messing around with stuff like Unity and Flixel, I realize that I have yet to complete a single, polished, bells-and-whistles game. I want to change this, and I have an idea for my next project. The idea is that you're an amoeba. Amoebas have these eye-like cores (or something like that, I don't know biology), and you have two of 'em. You control one with WASD and the other with IJKL. There has to be a constant radius of stuff around each of the cores: And the area of the amoeba has to stay constant. So if you move a core in one direction, you increase the amoeba's area, but that increase is compensated by a decrease somewhere else: Aaaaaand I'd like to implement a vagination mechanic. You absorb things by engulfing them, like a boss. Maybe even an extra core, or a needle that pops you and causes all your inner stuff to start gushing out: But here's the problem: I don't know how to make this. However, I would like some ideas on how to implement it. Should I explore physics libraries like Box2D? Or maybe something involving fluid physics? Any help would be much appreciated. P.S. Feel free to steal this idea. I have plenty of ideas. If you do, please tell me how you made it so I can try it myself.

    Read the article

  • Unable to create suitable graphics device?

    - by kraze
    I've been following the Eye of the Dragon tutorial, which is basicly a guide to making a 2D RPG game, obviously. I recently finished the tutorial about making pop up screens in the menu and changed the screen to load as a full screen. Whenever I try and load the game it just goes black and my mouse sits there. I cannot change out of it other then with CtrlAltDel. Once i do that it says No suitable graphics card found, unable to create graphics device. I read somewhere about XNA not allowing more then one screen when any one of them is full screen. but it wasnt very informative. Anyone have any ideas whats going on and/or how to fix this? Just incase if this helps this is the code for the graphics device: public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = 900; graphics.PreferredBackBufferHeight = 768; graphics.IsFullScreen = true; this.Window.Title = "Eyes of the Dragon"; Content.RootDirectory = "Content"; }

    Read the article

  • The Oracle Architects Training: 40 training sessions for our EMEA partners to build their Oracle Applications and Technical skills

    - by Richard Lefebvre
    There is a lot more to Oracle technology than meets the eye. Sure, you already belong to a small circle of our most experienced and committed partners. But are you making the best use possible of our technology solutions? Put it to the test. Join the “Oracle Partner Architects Training”. It is aimed at providing your experts, architects and consultants with in-depth architectural knowledge about Oracle technology. Here is your chance to learn from the best. Seasoned speakers, exclusive content and no product marketing. Oracle technology beyond the obvious. Mark your calendar The Oracle Partner Architects Training is an online training program. Sign up for the live Webex sessions (scheduled from January 2013 till April 2013) or watch replays as they become available. Feel free to follow training sessions at your own pace. Also, last year’s sessions are still very accurate and very available on architects.oraevents.eu NOTE: Looking to get your consultants Oracle certified? One more reason to join the Oracle Partner Architects Training. It is the fast track to getting their expertise validated with an Oracle certificate.

    Read the article

  • Unable to start Ubuntu 12.04. The system is running in low-graphics

    - by kaleidoscpicsoul
    I am a newbie to Ubuntu. I installed Ubuntu 12.04 using a USB Stick and it was running all fine for a few weeks and this error popped up. According to one of my friend, the best way was to re-install Ubuntu. Being from a non unix background i thought the same too and after the second install it happened again, but only this time was much quicker, in 3 days. I don't want to re-install Ubuntu every time this happens. I am a complete newbie to Linux which means that i am really bad at using terminal. I know there are other people who fixed this issue using this very same forum, but unfortunately the answers provided are too complex for me to understand. Please let me know how to do this. Things I want to let you know: I would need help step by step if that is alright with you. After i get the error i get the options and i click exit to console login I get the following message in a black screen (which i think is a command line sort of thing): * Stopping save kernel messages [OK] apache2: Could not reliably determine the server's fully qualified domain name,using 127.0.1.1 for ServerName [OK] * Starting web server apache2 and a blinking cursor. So basically it looks like a dead end for my non unixy eye. And one final thing is before this issue had happened i had tried configuring Python to Apache2. For that i had uninstalled and installed LAMP server several time and edited the configuration files too. I don't know if this really is a concern, but I don't know.. I have a USB with Ubuntu 12.04 in it so i can install it anytime. (But i want to know what the issue is rather than running away) . I migrated to Ubuntu from Windows and i have no plans to go back. I think that's from my side. Please let me know if there are any questions.

    Read the article

  • Is there supposed to be a Windows Network folder in the file manager?

    - by Cindy
    I pulled my hard drive out of my computer and started with a bootable usb version of Ubuntu, which I am using that at this point. At first boot, I see that there is a Windows folder when browsing network. Since there is no operating system present, besides the usb that I boot from, should there be a Windows network folder? Original question First of all I just want to say, I wish I had tried Ubuntu a couple years ago when I first heard about it, but I was like a lot of the population and went with the "easy way" and stuck with Windows because I didn't want to take the time to learn something new. Well, about 3 months ago I realized someone had hacked into my computer, and then found they had hacked my facebook account so I decided I had better do a complete credit check. I found student loans (totalling about 30,000 so far) had recently showed up on my credit report. I think it's going to be a long, long road to recovery now but I'm hoping Ubuntu will be a start and definitely an eye opener. My relationship with Windows is over. I had 3 antivirus programs running, none were protecting me like I thought they were. Turned out a free program that I downloaded was the only one that could detect and clean the virus, but by then it was too late. Anyhow, my question is, I pulled my hard drive out of my computer and started with a bootable usb version of Ubuntu, which I am using that at this point. At first boot, I see that there is a Windows folder when browsing network. Since there is no operating system present, besides the usb that I boot from, should there be a Windows network folder? I am using a local ISP (and won't be much longer because I am very paranoid at this point) and I want to make sure all is ok before I put my new hard drive in and install Ubuntu. Any help would be appreciated. Also, I want to thank Ubuntu and the community for giving people an alternative.

    Read the article

  • Creating movement path displays in a top-down 2d RTS

    - by nihohit
    My game is a top-down 2d RTS coded in C# using SFML's libraries. I want that during unit selection, a unit will display it's movement path on the map. Currently, after the path is computed as a list of directions ({left, up,down, down, down, left}, as an example), it's sent to the graphical component to create it's UI equivalent, and here I'm having some problems. current, these I've checked three ways to do it: compute the size of the image (in the example above it'll be a 3*2 rectangle) and create an invisible rectangle, and then go over the directions list and mark each spot with a visible point, so as to get a continous line. This system is slightly problematic because of the amount of large images that I need to save, but mostly because I have a lot of fine detail onscreen, and a continous line obstructs the view. again, compute the size of the image, but now create several (let's say 4) invisible images of that size, and then instead of a single continous line I'll switch between the four images, in each will appear only a fourth of the spots, in a way which creates a path animation. This is nicer on the eye, but here the memory demands, and the amount of time needed to compute each such image-loop is significant. Just create a list of single markers, each on a different spot on the path. This is very quick & easy on memory, but too sparse. Is there a simple or resource-light system to create path-animations?

    Read the article

  • Recommended display/background brightness ratio and UI color schemes [duplicate]

    - by user1306322
    This question already has an answer here: Colour scheme for editor - guidelines or medical reccomendations 3 answers I'm a professional programmer, which means I spend a lot of time staring at various displays. Recently I've been having some problems with my eyes, so I went to talk to several doctors, which all gave me different recommendations as to how bright the background of the room should be in comparison to the display's brightness. It was very confusing, as some of them even agreed with counter-arguments of others, which made it all even less clear. So I'd like to ask the professional programmers, as people who actually have some experience with that. Some of the doctors said that looking at a monitor is like looking at a book, so the brightness ratios should be approximately the same. Others said that background should be as bright as the display itself, because then there is no brightness difference at the edges, and that's what may cause eye fatigue. From my own experience, I can say that reading a book isn't the same as writing or debugging a program, where you have to pay close attention to each symbol, and in books most words are easily recognizable without focusing too hard on them. Also, books are black on white and I myself use the default (dark text, white bg) color scheme for my IDE, but I've seen some programmers use mid-bright text on very dark background color schemes. So I'd like to ask what are the recommended display/background brightness ratios for programming? I'm not sure this site is the right one for this kind of questions, so if you know a better one, please comment.

    Read the article

  • Overlapping text on top menu in Unity 12.04

    - by mercury
    So I'm new to Linux but am basically blown away by Ubuntu 12.04 and could definitely see this becoming my main desktop over time One small annoyance for me is a tendency for the global menu on the top bar to partially over-write the text description of the active window in the top panel. e.g. I focus on the "Ubuntu Software Centre" window which writes out that label in the leftmost corner of the top menu bar. If I then move the cursor up to the top menu bar to access the "file menu", this will partially overwrite the window name leaving just "Ubuntu" visible. This is a little slice of ugliness I don't want to see every day! Much easier on the eye for me would be to display the active window name at the centre of the top panel, using some of that free space and then have the global menu stay where it is, just to the right of the app launcher. I've found a solution to disable the global menu but I would prefer to keep it and instead move (or disable) the active window name in the top panel. Any way to do this?

    Read the article

  • VB6 ImageList Frm Code Generation

    - by DAC
    Note: This is probably a shot in the dark, and its purely out of curiosity that I'm asking. When using the ImageList control from the Microsoft Common Control lib (mscomctl.ocx) I have found that VB6 generates FRM code that doesn't resolve to real property/method names and I am curious as to how the resolution is made. An example of the generated FRM code is given below with an ImageList containing 3 images: Begin MSComctlLib.ImageList ImageList1 BackColor = -2147483643 ImageWidth = 100 ImageHeight = 45 MaskColor = 12632256 BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} NumListImages = 3 BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Form1.frx":0054 Key = "" EndProperty BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Form1.frx":3562 Key = "" EndProperty BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "Form1.frx":6A70 Key = "" EndProperty EndProperty End From my experience, a BeginProperty tag typically means a compound property (an object) is being assigned to, such as the Font object of most controls, for example: Begin VB.Form Form1 Caption = "Form1" ClientHeight = 10950 ClientLeft = 60 ClientTop = 450 ClientWidth = 7215 BeginProperty Font Name = "MS Serif" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = -1 'True Strikethrough = 0 'False EndProperty End Which can be easily seen to resolve to VB.Form.Font.<Property Name>. With ImageList, there is no property called Images. The GUID associated with property Images indicates type ListImages which implements interface IImages. This type makes sense, as the ImageList control has a property called ListImages which is of type IImages. Secondly, properties ListImage1, ListImage2 and ListImage3 don't exist on type IImages, but the GUID associated with these properties indicates type ListImage which implements interface IImage. This type also makes sense, as IImages is in fact a collection of IImage. What doesn't make sense to me is how VB6 makes these associations. How does VB6 know to make the association between the name Images - ListImages purely because of an associated type (provided by the GUID) - perhaps because it's the only property of that type? Secondly, how does it resolve ListImage1, ListImage2 and ListImage3 into additions to the collection IImages, and does it use the Add method? Or perhaps the ControlDefault property? Perhaps VB6 has specific knowledge of this control and no logical resolution exists?

    Read the article

  • VS2008 EF and non crud SP usage.

    - by SteveO
    Using an edmx version of EF. My returned data is a join between tables that has a COMPOUND filter on the primary table. In essence this query is going to return a SEGMENT of Law codes and descriptions that a user can tie to a Sex Offender report. I have a complex SP because Linq2SQL cannot pass in a between statement, or at least that is how I understand the error. The Code itself is broken up by '-' marks. 39-13-504 "Aggravated Sexual Battery" User wants to have a query with 4 parmas 39, 13, 500, 599. Get all codes from Title 39 and Chapter 13 with parts between 500 and 599. I have the SP in place to do the work, is there are way to consume the SP within the EF? I find many blogs about SPs with CRUD operations as their use of an SP. That doesn't fit this need at all. I do not have a single table but a join to the "prior selections" table that maps the key for the code. Any pointers on how to get a READ with an SP? TIA

    Read the article

  • Help with JPQL query

    - by Robert
    I have to query a Message that is in a provided list of Groups and has not been Deactivated by the current user. Here is some pseudo code to illustrate the properties and entities: class Message { private int messageId; private String messageText; } class Group { private String groupId; private int messageId; } class Deactivated { private String userId; private int messageId; } Here is an idea of what I need to query for, it's the last AND clause that I don't know how to do (I made up the compound NOT IN expression). Filtering the deactivated messages by userId can result in multiple messageIds, how can I check if that subset of rows does not contain the messageId? SELECT msg FROM Message msg, Group group, Deactivated unactive WHERE group.messageId = msg.messageId AND (group.groupId = 'groupA' OR group.groupId = 'groupB' OR ...) AND ('someUserId', msg.messageId) NOT IN (unactive.userId, unactive.messageId) I don't know the number of groupIds ahead of time -- I receive them as a Collection<String> so I'll need to traverse them and add them to the JPQL dynamically.

    Read the article

  • Don't Understand Sql Server Error

    - by Jonathan Wood
    I have a table of users (User), and need to create a new table to track which users have referred other users. So, basically, I'm creating a many-to-many relation between rows in the same table. So I'm trying to create table UserReferrals with the columns UserId and UserReferredId. I made both columns a compound primary key. And both columns are foreign keys that link to User.UserID. Since deleting a user should also delete the relationship, I set both foreign keys to cascade deletes. When the user is deleted, any related rows in UserReferrals should also delete. But this gives me the message: 'User' table saved successfully 'UserReferrals' table Unable to create relationship 'FK_UserReferrals_User'. Introducing FOREIGN KEY constraint 'FK_UserReferrals_User' on table 'UserReferrals' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors. I don't get this error. A cascading delete only deletes the row with the foreign key, right? So how can it cause "cycling cascade paths"? Thanks for any tips.

    Read the article

  • User roles - why not store in session?

    - by Phil
    I'm porting an ASP.NET application to MVC and need to store two items relating to an authenitcated user: a list of roles and a list of visible item IDs, to determine what the user can or cannot see. We've used WSE with a web service in the past and this made things unbelievably complex and impossible to debug properly. Now we're ditching the web service I was looking foward to drastically simplifying the solution simply to store these things in the session. A colleague suggested using the roles and membership providers but on looking into this I've found a number of problems: a) It suffers from similar but different problems to WSE in that it has to be used in a very constrained way maing it tricky even to write tests; b) The only caching option for the RolesProvider is based on cookies which we've rejected on security grounds; c) It introduces no end of complications and extra unwanted baggage; All we want to do, in a nutshell, is store two string variables in a user's session or something equivalent in a secure way and refer to them when we need to. What seems to be a ten minute job has so far taken several days of investigation and to compound the problem we have now discovered that session IDs can apparently be faked, see http://blogs.sans.org/appsecstreetfighter/2009/06/14/session-attacks-and-aspnet-part-1/ I'm left thinking there is no easy way to do this very simple job, but I find that impossible to believe. Could anyone: a) provide simple information on how to make ASP.NET MVC sessions secure as I always believed they were? b) suggest another simple way to store these two string variables for a logged in user's roles etc. without having to replace one complex nightmare with another as described above? Thank you.

    Read the article

  • Sorting by dates (including nil) with NSFetchedResultsController

    - by glorifiedHacker
    In my NSFetchedResultsController, I set a sortDescriptor that sorts based on the date property of my managed objects. The problem that I have encountered (along with several others according to Google) is that nil values are sorted at the earliest end rather than the latest end of the date spectrum. I want my list to be sorted earliest, earlier, now, later, latest, nil. As I understand it, this sorting is done at the database level in SQLite and so I cannot construct my own compare: method to provide the sorting I want. I don't want to manually sort in memory, because I would have to give up all of the benefits of NSFetchedResultsController. I can't do compound sorting because the sectionNameKeyPaths are tightly coupled to the date ranges. I could write a routine that redirects indexPath requests so that section 0 in the results controller gets mapped to the last section of the tableView, but I fear that would add a lot of overhead, severely increase the complexity of my code, and be very, very error-prone. The latest idea that I am considering is to map all nil dates to the furthest future date that NSDate supports. My left brain hates this idea, as it feels more like a hack. It will also take a bit of work to implement, since checking for nil factors heavily into how I process dates in my app. I don't want to go this route without first checking for better options. Can anyone think of a better way to get around this problem?

    Read the article

  • Accessing children with a given name via jdom

    - by Christian
    I want to access the children with skos:Concept. getChildren("skos:Concept") and getChildren("Concept") both give me an empty list what should I use instead?. My example Data: <owl:AnnotationProperty rdf:about="&dc;identifier"/> <owl:ObjectProperty rdf:about="&skos;narrower"/> <skos:Concept rdf:about="#concept:0_acetylpantolactone:4253501"> <skos:prefLabel xml:lang="" >0-acetylpantolactone</skos:prefLabel> <skos:hiddenLabel xml:lang="" >2(3H)-Furanone, 3-(acetyloxy)dihydro-4,4-dimethyl-, (R)-</skos:hiddenLabel> <dc:identifier rdf:resource="urn:CHID:028227363"/> <dc:identifier rdf:resource="urn:MESH:C014305"/> </skos:Concept> <skos:Concept rdf:about="#concept:1012S:4202655"> <skos:prefLabel xml:lang="">1012S</skos:prefLabel> <skos:hiddenLabel xml:lang="" >C19-H16-Cl2-N6-O</skos:hiddenLabel> <skos:hiddenLabel xml:lang="">Compound 1012S</skos:hiddenLabel> <dc:identifier rdf:resource="urn:CAS:95211_91_9"/> <dc:identifier rdf:resource="urn:CHID:095211919"/> </skos:Concept>

    Read the article

  • Why is graphviz drawing two arrows, and using a weird order?

    - by dmd
    Why is graphviz drawing two arrows from uncap_spike to peel, and why is it drawing peel to the right of hang? I want uncap_spike - peel - hang - spike, in that order, with one edge between each. digraph hangers { compound=true fontname="Gill Sans" node [fontname="Gill Sans" shape=box fillcolor=white style="rounded, filled"] edge [fontname="Gill Sans"] subgraph cluster_prep { style="filled" label=Prep gather [shape=Mrecord label="{gather | EtOH swab\nvented tubing}"] uncap_bottle [label="uncap bottle"] uncap_spike [label="uncap spike"] swab [shape=Mrecord label="{swab EtOH | wait 30 seconds for sterility}"] gather -> uncap_bottle -> swab -> uncap_spike {rank=same gather uncap_bottle swab uncap_spike} } subgraph cluster_hang { style=filled label=Hang {rank=same peel hang} } {rank=same uncap_spike -> peel -> hang -> spike -> prime} hang -> rip [color=firebrick] rip [label="eyelet\nripped" style="filled" shape=octagon regular fontcolor=white fontsize=10 width=.5 fixedsize color=firebrick fillcolor=firebrick ] swab -> not_sterile [color=firebrick] not_sterile [label="not\nsterile" style="filled" shape=octagon regular fontcolor=white fontsize=10 width=.5 fixedsize color=firebrick fillcolor=firebrick ] }

    Read the article

  • Hibernate: Check if object exists/changed

    - by swalkner
    Assuming I have an object Person with long id String firstName String lastName String address Then I'm generating a Person-object somewhere in my application. Now I'd like to check if the person exists in the database (= firstname/lastname-combination is in the database). If not = insert it. If yes, check, if the address is the same. If not = update the address. Of course, I can do some requests (first, try to load object with firstname/lastname), then (if existing), compare the address. But isn't there a simpler, cleaner approach? If got several different classes and do not like to have so many queries. I'd like to use annotations as if to say: firstname/lastname = they're the primary key. Check for them if the object exists. address is the parameter you have to compare if it stayed the same or not. Does Hibernate/JPA (or another framework) support something like that? pseude-code: if (database.containsObject(person)) { //containing according to compound keys if (database.containsChangedObject(person)) { database.updateObject(person); } } else { database.insertObject(person); }

    Read the article

  • Is this the right way to organize my database tables?

    - by Moss
    So I'm making a website that allows users to build contact lists. So their are users, the users have lists, and the lists have contacts. It seems to me that I need 3 tables for this but I just want to make sure. There would be a User table of course, and then a "List of Lists" table that has the username, and listname, as primary key along with whatever other info we want to attach to the lists as a whole. Finally, for lack of a better word, the List table which would again have the username/listname p.k., then the contact ID and notes and such that the user attaches to that contact on that specific list. I hope that is a clear explanation. For some reason I feel unsure about this arrangement. For one thing if the website becomes popular the List table could swell to billions of rows. And it also feels a little weird that everybody's list info is all jumbled up in the same table. I suppose I could create separate tables for each user and even for each list but that seems like a bad idea for other reasons. My db explanation assumes I can use foreign keys on my tables which at the moment isn't actually an option. If I can't get InnoDB tables enabled I will probably use ID's for the lists instead of depending on a compound key. Maybe I should do this anyway?

    Read the article

  • C/C++ Control Structure Limitations?

    - by STingRaySC
    I have heard of a limitation in VC++ (not sure which version) on the number of nested if statements (somewhere in the ballpark of 300). The code was of the form: if (a) ... else if (b) ... else if (c) ... ... I was surprised to find out there is a limit to this sort of thing, and that the limit is so small. I'm not looking for comments about coding practice and why to avoid this sort of thing altogether. Here's a list of things that I'd imagine could have some limitation: Number of functions in a scope (global, class, or namespace). Number of expressions in a single statement (e.g., compound conditionals). Number of cases in a switch. Number of parameters to a function. Number of classes in a single hierarchy (either inheritance or containment). What other control structures/language features have limits such as this? Do the language standards say anything about these limits (perhaps minimum requirements for an implementation)? Has anyone run into a particular language limitation like this with a particular compiler/implementation? EDIT: Please note that the above form of if statements is indeed "nested." It is equivalent to: if (a) { //... } else { if (b) { //... } else { if (c) { //... } else { //... } } }

    Read the article

  • `DesignMode` in subcontrols is not set correctly?

    - by affan
    I have a compound control contains nested controls. The problem i am facing is that control read properties from a global setting class which is static and intern read from setting file. To stop individual control from accessing configuration in design mode i added check in each control. If(!DesignMode){ ... //Initialize properties e.g. prop = AppConfig.GetProperty("prop1"); } The problem is that individual control work fine when open in VS. But when i open top control containing nested control i get error by VS designer. The error is that in a nested control DesignMode=false for some reason. I also created a test app and created a simple control within another control to test if there is a problem with VS but it seem to work correctly for any depth of controls. I dont even know how to debug this. For now i comment out the property initializing code and build it and then open designer and there uncomment it and build it again to run it. Did anyone came across this problem or is there any way to fix it.

    Read the article

  • C# wrapper for objects

    - by Haggai
    I'm looking for a way to create a generic wrapper for any object. The wrapper object will behave just like the class it wraps, but will be able to have more properties, variable, methods etc., for e.g. object counting, caching etc. Say the wrapper class be called Wrapper, and the class to be wrapped be called Square and has the constructor Square(double edge_len) and the properties/methods EdgeLength and Area, I would like to use it as follows: Wrapper<Square> mySquare = new Wrapper<Square>(2.5); /* or */ new Square(2.5); Console.Write("Edge {0} -> Area {1}", mySquare.EdgeLength, mySquare.Area); Obviously I can create such a wrapper class for each class I want to wrap, but I'm looking for a general solution, i.e. Wrapper<T> which can handle both primitive and compound types (although in my current situation I would be happy with just wrapping my own classes). Suggestions? Thanks.

    Read the article

  • Page URL and database organization.

    - by shurik2533
    I want that its name would be the page address. For example, if page has heading "Some Page", than its address should be http://somesite/some_page/. "some_page"-name generated by system automatically. "some_page" - is the unique identifier of page. The problem in that the user in the future can enter a name which already exists that will cause an error. It is necessary to find an optimum variant of the decision of a problem for great volumes of the data. I have solved a problem as follows: The page identifier in a database is the name of page and a suffix which is by default equal to zero. At page addition there is a check on existence. If such page does not exist, the suffix is equal 0 and its name is "some_page", if page is exist, than - search for the maximum number of a suffix and suffix=suffix+1 and page name become "some_page_1". For this I create in a database the compound key from fields "suffix" and "pageName": Table Pages suffix|pageName |pageTitle 0 |some_page |Some Page 1 |some_page |Some Page 0 |other_page|Other Page Addition of pages occurs through stored procedure: CREATE PROCEDURE addPage (pageNameVal VARCHAR(100), pageTitleVal VARCHAR(100)) BEGIN DECLARE v INT DEFAULT 0; SELECT MAX(suffix) FROM pages WHERE pageName=pageNameVal INTO v; IF v >= 0 THEN SET v = v + 1; ELSE SET v = 0; END IF; INSERT INTO pages (suffix, pageName) VALUES (pageNameVal, v, pageTitleVal); END; Whether there are more the best decisions?

    Read the article

  • 2-column table with two foreign keys. Performance/design question.

    - by Emanuel
    Hello everyone! I recently ran into a quite complex problem and after looking around a lot I couldn't find a solution to it. I've found answers to my questions many times before on stackoverflow.com, so I decided to post here. So I'm making a user/group managment system for a web-based project, and I'm storing all related data into a postgreSQL database. This system relies on three tables: USERS GROUPS GROUP_USERS The two first tables simply define all the users and all the groups on the site, and the last table, GROUP_USERS, stores the groups every user is part of. It only has two columns: USER_ID GROUP_ID Since every user can be a member of several groups, I decided to make a separate table for this purpose, rather than storing a comma separated column in the USERS-table. Now, both columns are foreign keys, and I want to make them both primary keys as well, this since each combination of USER_ID and GROUP_ID has to be unique, and if I give them the constraint UNIQUE pgAdmin tells me that each table should have at least one Primary key. But now I am stuck with what seems to be a lot of indexes and relations to a very small table only containing numbers. In the end, I want this table to be as fast as possible, even if containing tens of thousands of rows. Size on disk shouldn't be a problem since its just all numbers anyway, but it feels quite stupid to have a full-sized index refering to a smaller table. Should I stick with my current solution, store comma-separated values in a column in the USERS-table or is there any other solution I should be aware of. PS. I don't want to use an array-column, even if they are supported by postgreSQL. I want to be as generic as possible so I can switch database later on, if necessary. EDIT: I other words, will using a compound primary key and two foreign keys in one table with only two columns have a negative impact on performance rather than the opposite due to the size of the generated index? Thank you!

    Read the article

  • JQuery quiz app - use <id> tag to toggle variable on/off

    - by hairyllama
    Hi, I am writing a jquery phonegap quiz app and have a number of categories from which a user can select via checkbox. Relevant questions belonging to those categories are then returned. However, I have two huge switch statements to change the relevant variables from 0 to 1 if the checkbox for that category is selected and vice versa (this info is used to build a compound db query). The value of the variable behind the checkbox is only ever 0 or 1, so is there a better way to do this? My HTML is: <h2>Categories</h2> <ul class="rounded"> <li>Cardiology<span class="toggle"><input type="checkbox" id="cardiology" /></span></li> <li>Respiratory<span class="toggle"><input type="checkbox" id="respiratory" /></span></li> <li>Gastrointestinal<span class="toggle"><input type="checkbox" id="gastrointestinal" /></span></li> <li>Neurology<span class="toggle"><input type="checkbox" id="neurology" /></span></li> </ul> My Javascript is along the lines of: var toggle_cardiology = 0; var toggle_respiratory = 0; var toggle_gastrointestinal = 0; var toggle_neurology = 0; $(function() { $('input[type="checkbox"]').bind('click',function() { if($(this).is(':checked')) { switch (this.id) { case "cardiology": toggle_cardiology = 1; break; case "respiratory": toggle_respiratory = 1; break; case "gastrointestinal": toggle_gastrointestinal = 1; break; case "neurology": toggle_neurology = 1; break; etc. (which is cumbersome with 10+ categories plus an else statement with a switch to change them back) I'm thinking of something along the lines of concatenating the HTML id tag onto the "toggle_" prefix - in pseudocode: if (toggle_ + this.id == 1){ toggle_ + this.id == 0} if (toggle_ + this.id == 0){ toggle_ + this.id == 1} Thanks, Nick.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >