Search Results

Search found 313 results on 13 pages for 'logically'.

Page 6/13 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Set value in controller using nested resource

    - by vectran
    I have two models, product and order. Product - cost - id Order - cost - product_id Each time someone places an order, it captures the product_id through a radio button value in the "new order" form. In the controller when creating the new order it needs to set order.cost to order.product.cost. Logically I thought the code should be something like this: def create ... @order.cost == @order.product.cost ... end However I can't seem to make it work at all, hence me asking the question here. Any help is answering (or naming) the question would be greatly appreciated.

    Read the article

  • What is the most stupid coded solution you have read/improved/witnessed?

    - by Rigo Vides
    And for stupid I mean Illogical, non-effective, complex(the bad way), ugly code style. I will start: We had a requirement there when we needed to hide certain objects given the press of a button. So this framework we were using at the time provided a way to tag objects and retrieve all the objects with a certain tag in a complete iterable collection. So I presented the most logically solution given these conditions to my partner: Me: you know, tag all the objects we needed to hide with the same tag, then call the function to get them all, iterate trough them and make them hidden. Partner: I don't know, that is hardcoding for me... Me: So what do you suggest? 20 mins later... Partner: I don't know... let's put a tag to all the objects to be hidden like this, 1, 2, 3, 4, 5, 6, 7 (and so for each object to be hidden), Then we make a for from 1 to n (where n was the number of objects to hide) and we hide them all there!

    Read the article

  • memory alignment issues with union

    - by confucius
    Hi all, Is there guarantee, that memory for this object will be properly aligned if we create this object of this type in stack? union my_union { int value; char bytes[4]; }; If we create char bytes[4] in stack and then try to cast it to integer there might be alignment problem. We can avoid that problem by creating it in heap, however, is there such guarantee for union objects? Logically there should be, but I would like to confirm. Thanks.

    Read the article

  • Can anyone tell me what the authors mean on this line?

    - by Anirudh Goel
    i was going through this link: FAT16 Basics to Assemble Clusters. I have read the structures involved in defining a directory entry in FAT. Now when giving the example for a FAT16 File, it says the data cluster is 0x03 for the example file MyFile.txt. Which means if we logically compute the Data Cluster we will be able to reach to the first node which happens to be cluster no 3. But what I fail to understand is what the author is trying to say in the next line where it says What we can see in the File Allocation Table at this moment? How suddenly we reach to the File Allocation Table? Weren't we already there when we were going through the information of Myfile.txt? I couldn't find any reason how suddenly the author jumped to an offset location of 00000200 and is identifying the emptiness of the clusters. It will be great if someone can help me understand. Thanks

    Read the article

  • Javascript function, on web page close

    - by AXheladini
    Hello there, I have an problem that i can not solve. The problem is this way: When i close my page on some browser i want an message box to appear and to ask me if I really want to close the page or not. logically: click on x (close tab on web browser) and than the box appears with two buttons yes and now, if i click yes the page will be closed if i click no the page will not close. I know there must be some javascript or ajax code but i can not configure it by my self.

    Read the article

  • Basic Login Script using php and mysql inquiry

    - by Matt
    Attempting to write a check for a login script to see if the username is available. Would the best way to write this query be to check if isset(!_POST[]) for both values (nick and pass) then connect to database WHERE the mysql database for the usernick requested return the user id if the usernick exists evaluate if isset($id) to see if the user name is taken and use that to continue to creating an entry Does this logically sound like a method to check for login without using excessive code sorry for not posting the code, it is on another computer and this computer is locked down by my administrator at work... Also, is there another way to evaluate if a value exists in the database? For instance, instead of setting $id to the return value of the mysql database can i just ping the mysql database for the information and have it return a Boolean result so I am not putting out any user information. Thanks, Matt

    Read the article

  • When does a MySQL Query actually execute in PHP?

    - by MJB
    This sounds like a really simple question, but I am new to PHP. If I have a statement like this: $r =& $db->query("insert into table (col1, col2) values (10, 20)"); Do I have to still execute it, or does it get executed when I reference it? I have another case where I have a select query, which seems logically to run only when I call fetchrow, but the code I am presented with (to fix) does not call execute or fetch.I would have expected it to, so I cannot tell if it is just that I don't get it, or that the missing execute statement is the problem. It also does not insert the record, but it does not throw an error I can find. Also, I am a little confused by the =& notation. I looked it up on google, and found a few mentions of it, but I am still not clear on it. Thanks.

    Read the article

  • Double pointer const-correctness warnings in C

    - by Michael Koval
    You can obviously cast a pointer to non-const data to a a pointer of the same type to const data: int *x = NULL; int const *y = x; Adding additional const qualifiers to match the additional indirection should logically work the same way: int * *x = NULL; int *const *y = x; /* okay */ int const *const *z = y; /* warning */ Compiling this with GCC or Clang with the -Wall flag, however, results in the following warning: test.c:4:23: warning: initializing 'int const *const *' with an expression of type 'int *const *' discards qualifiers in nested pointer types int const *const *z = y; /* warning */ ^ ~ Why does adding an additional const qualifier "discard qualifiers in nested pointer types"?

    Read the article

  • Haskell Syntax: Parse Error On Input

    - by NuNu
    As part of a mini-haskell compiler that I'm writing, I have a function named app. What I want this function to do is take in these arguments epp (App e1 e2). The first step would be to evaluate e1 recursively (epp e1) and check if the output would be an error. If not then evaluate e2 and then call another function eppVals to evaluate the outputs of the calls on e1 and e2 which I defined as v1 and v2 respectively. epp (App e1 e2) | epp e1 /= Error = eppVals v1 v2 | otherwise = Error where v1 = epp e1 v2 = epp e2 <- parse error on input `=' Logically I believe what I have written so far works but I'm getting a parse error on input = where I stated above. Any idea why? My second try epp :: Exp -> Error Val epp (App e1 e2) = (eppVals v1 v2) where v1 = (epp e1) v2 = (epp e2) But now throws Couldn't match expected type Val with actual type Error Val

    Read the article

  • Dynamically determining table name given field name in SQL server

    - by Salman A
    Strange situation: I am trying to remove some hard coding from my code. There is a situation where I have a field, lets say "CityID", and using this information, I want to find out which table contains a primary key called CityID. Logically, you'd say that it's probably a table called "City" but it's not... that table is called "Cities". There are some other inconsistencies in database naming hence I can never be sure if removing the string "ID" and finding out the plural will be sufficient. Note: Once I figure out that CityID refers to a table called Cities, I will perform a join to replace CityID with city name on the fly. I will appreciate if someonw can also tell me how to find out the first varchar field in a table given its name.

    Read the article

  • HTML form requirements specification

    - by Peder
    I am building a framework that will validate forms both client-side (javascript) and server-side based on a form requirements specification written in json. The purpose is to get rid of logically equivalent code on the server and client to make the code more maintainable, faster to write, and less buggy. The specification format may look something like: { '&lt;field_name>' : ['&lt;validation_function>', 'req', ['&lt;requirement>', &lt;param>], ...], ... } ( the requirement list is ordered so that the user can get most basic error messages first, the 'req' requirement must come first if it exists and means that the field is required) e.g.) { 'name' : ['string', 'req', ['min',6], ['max',150], ['match', /^[\sa-z0-9ÅÄÖåäö&]$/i], ['not_match', /^tmp_/]], 'email' : ['email', 'req'], 'email_confirm' : ['same_as', 'email'], 'password' : ['string', 'req', ['min', 6], ['max', 64], ['match', /^[a-z0-9\!@#\$%^&*_+.]$/i] ], } Does anyone know of a similar technology? I think the Rails validation framework solves the problem on the wrong level because I have found that forms often operate on more than one model.

    Read the article

  • Optimising (My)SQL Query

    - by Simon
    I usually use ORM instead of SQL and I am slightly out of touch on the different JOINs... SELECT `order_invoice`.*, `client`.*, `order_product`.*, SUM(product.cost) as net FROM `order_invoice` LEFT JOIN `client` ON order_invoice.client_id = client.client_id LEFT JOIN `order_product` ON order_invoice.invoice_id = order_product.invoice_id LEFT JOIN `product` ON order_product.product_id = product.product_id WHERE (order_invoice.date_created >= '2009-01-01') AND (order_invoice.date_created <= '2009-02-01') GROUP BY `order_invoice`.`invoice_id` The tables/ columns are logically names... it's an shop type application... the query works... it's just very very slow... I use the Zend Framework and would usually use Zend_Db_Table_Row::find(Parent|Dependent)Row(set)('TableClass') but I have to make lots of joins and I thought it'll improve performance by doing it all in one query instead of hundreds... Can I improve the above query by using more appropriate JOINs or a different implementation? Many thanks.

    Read the article

  • VWD Express won't let me add one table!

    - by user530809
    Sorry if this question is too trivial but I really haven't found any related questions and I am shaking too much to think logically. I spent like few hours waiting for SQL Server to finally install (you know, it's Microsoft) and now when I want to add new table to database it says "this feature is not supported by Microsoft Visual Web Developer Express". How could this happen? I mean, what's the point of even letting me use this if I can't even add one table to database, and I won't even know about it until I actually need to do it? Are they really serious or is it just some mistake? Is there any way to get around this problem? I need to create just one simple project with one small table in database but it won't let me, but I can't believe they could actually have nerves to make express edition without such a trivial function, so maybe I just made something wrong and there's actually some way to add this table? Sorry for being so whiny but I'm just fed up with this environment.

    Read the article

  • What effect does static const have on a namespace member

    - by user144182
    namespace MyNamespace { static const double GasConstant = 1.987; Class MyClass { // constructors, methods, etc. }; }; I previously had GasConstant declared within the MyClass declaration (and had a separate definition in the source file since C++ does not support const initialization of non-integral types). I however need to access it from other files and also logically it seems like it should reside at the namespace level. My questions is, what effect does static const have in this case? Clearly const means I can't assign a new value to GasConstant, but what does a static member at the namespace mean. Is this similar to filescope static effect, where the member is not accessible outside of the unit?

    Read the article

  • MVC4 link automatically redirected to default INDEX page/action even if defined action name with controller

    - by Raj Tamakuwala
    i am creating web mobile application in mvc4. My problem is when I click on particular link in my application,it works well, but sometimes it automatically redirected to INDEX page that is set as default page in global.asax as routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); Now I don't know why its automatically redirected to INDEX page,even if I have already defined controller and action name where it show redirected as, <a href='@(Url.Action( "ActivityWall", "Home"))' > </a> logically it should redirect to "ActivityWall" page,which it does.but sometime only it goes to INDEX page.then when I clear my cookie problem will again solved but after some time it again start redirecting to INDEX page. I also posted question related to cookies issue yesterday,but I think that is nit main issue. can someone help please ?

    Read the article

  • How is the ">" operator implemented (on 32 bit integers)?

    - by Ron Klein
    Let's say that the environment is x86. How do compilers compile the "" operator on 32 bit integers. Logically, I mean. Without any knowledge of Assembly. Let's say that the high level language code is: int32 x, y; x = 123; y = 456; bool z; z = x > y; What does the compiler do for evaluating the expression x > y? Does it perform something like (assuming that x and y are positive integers): w = sign_of(x - y); if (w == 0) // expression is 'false' else if (w == 1) // expression is 'true' else // expression is 'false' Is there any reference for such information?

    Read the article

  • zsh for loop exclusion

    - by ABach
    This is somewhat of a simple question, but for the life of me, I cannot figure out how to exclude something from a zsh for loop. For instance, let's say we have this: for $package in /home/user/settings/* do # do stuff done Let's say that in /home/user/settings/, there is a particular directory ("os") that I want to ignore. Logically, I tried the following variations: for $package in /home/user/settings/^os (works w/ "ls", but not with a foor loop) for $package in /home/user/settings/*^os for $package in /home/user/settings/^os* ...but none of those seem to work. Could someone steer my syntax in the right direction?

    Read the article

  • P/Invoke or C++/CLI for wrapping a C library

    - by Ian G
    Have a moderate size (40-odd function) C API that needs to be called from a C# project. The functions logically break up to form a few classes that will be API presented to the rest of the project. Are there any objective reasons to prefer P/Invoke or C++/CLI for the interoperability underneath that API, in terms of robustness, maintainability, deployment, ...? The issues I could think of that might be, but aren't problematic are: C++/CLI will require an separate assembly, the P/Invoke classes can be in the main assembly. (We've already got multiple assemblies and there'll be the C dlls anyway so not a major issue). Performance doesn't seem differ noticeable between the two methods. Issues that I'm not sure about are: My feeling is C++/CLI will be easier to debug if there's inter-op problem, is this true? Language familiarity enough people know C# and C++ but knowledge of details of C++/CLI are rarer here. Anything else?

    Read the article

  • How to generate a report of IIS settings for easy perusal?

    - by Bryan
    Hello, I'm looking for a way to (hopefully) create a text file which lists all the settings in IIS for.. Virtual Directories Web sites Which framework is used on a certain website/directory directory of hosted files etc. Basically I want to do some investigation on some of our servers to figure out where certain projects are located, without digging through right clicking and looking for the directory name manually, etc, for every domain we host. The reasoning is that I often need to find access to files/projects I haven't worked on before, but historically, we don't have a strong naming scheme, so you can't just look where something "logically" would be - so, generating a list would be very helpful. Something like this would be awesome, but I'm looking for any tips at all Domainname1.com framework: ASP.NET 1.1 directory: c:\inetpub\wwwroot\domainname1.com Applications hosted at this domain: etc, etc. Plain text, XLS, XML.. anything other than right clicking through the whole list! Thanks!

    Read the article

  • OAuth 2.0: Can a user-agent client avoid forwarding fragments?

    - by Bosh
    In the OAuth 2.0 draft specification, user-agent clients receive authorization in the form of a bearer token via redirection (from an authentication server) to a URL such as HTTP/1.1 302 Found Location: http://example.com/rd#access_token=FJQbwq9&expires_in=3600 According to Section 3.5.2 it is then the user-agent's job to GET the URL in question, but "The user-agent SHALL NOT include the fragment component with the request." In other words, as a result of the example redirection above, the user-agent should GET /rd HTTP/1.1 Host: example.com without passing #access_token to the server. My question: what user agents behave this way? I thought redirection in Firefox, for example, would (logically) include the fragment in the GET request. Am I just wrong about this, or does the OAuth 2.0 specification rely on non-standard user-agent behavior?

    Read the article

  • Searching a 2D array for a range of values in java

    - by Paige O
    I have a 2^n size int array and I want to check if an element exists that is greater than 0. If the element exists, I want to divide the array by 4 and check if the coordinates of the found element are in the 1st, 2nd, 3rd or 4th quadrant of the array. For example, logically if the element exists in the first quadrant it would look something like this: If array[][] 0 && the row of that coordinate is in the range 0-(grid.length/2-1) && the column of that coordinate is in the range 0-(grid.length/2-1) then do something. I'm really not sure how to check the row and column index of the found element and store those coordinates to use in my if statement. Help!

    Read the article

  • Editing a TreeView node doesn't change the TreeNode Key

    - by Blitzz
    I have a TreeView with user-editable nodes. I like to use the node caption as key to my tree node : + Root |+ Node1 ||- SubNode1 ||- SubNode2 |+ Node2 ||- SubNode3 ||- SubNode4 So I can reach a node like this: MyTreeView.Nodes["Root"].Nodes["Node2"].Nodes["SubNode3"] The problem is that, as I allow the user to rename any node, I would need also to change the key of my node in its parent in the AfterLabelEdit handler... which seems (logically) not to be done automatically. Unfortunately, Nodes["blabla"] is readonly, Nodes.Add(string Key, TreeNode Node) doesn't exist, and I can't find a way to do this without throwing (sooner or later) a bad exception. Any idea ?

    Read the article

  • Logical value of an assignment in C

    - by Andy Shulman
    while (curr_data[1] != (unsigned int)NULL && ((curr_ptr = (void*)curr_data[1]) || 1)) Two part question. What will (curr_ptr = (void*)curr_data[1]) evaluate to, logically. TRUE? Also, I know its rather hack-ish, but is the while statement legal C? I would have to go through great contortions to put the assignment elsewhere in the code, so I'd be really nice if I could leave it there, but if it's so egregious that it makes everyone's eyeballs burst into flames, I'll change it.

    Read the article

  • has_many relation doesn't seems right or logical, some thing like belongs_to_many looks right

    - by Vijendra
    My situation is like this. Company has many users and users may belongs to many companies. And current implementation is something like below. class Company has_many :employments has_many :users, :through = :employments end class Employment belongs_to :company belongs_to :user end class User has_many :employments has_many :companies, :through = :employments #This doesn't looks correct end User has many companies doesn't looks logically meaningful.It must be some thing like belongs_to_many companies. Do I need to use has_and_belongs_to_many? But that also will gives the same meaning. Can some one please suggest the right way for representing these relationships?

    Read the article

  • SQL Server JOIN with optional NULL values

    - by Paul McLoughlin
    Imagine that we have two tables as follows: Trades ( TradeRef INT NOT NULL, TradeStatus INT NOT NULL, Broker INT NOT NULL, Country VARCHAR(3) NOT NULL ) CTMBroker ( Broker INT NOT NULL, Country VARCHAR(3) NULL ) (These have been simplified for the purpose of this example). Now, if we wish to join these two tables on the Broker column, and if a country exists in the CTMBroker table on the Country, we have the following two choices: SELECT T.TradeRef,T.TradeStatus FROM Trades AS T JOIN CTMBroker AS B ON B.Broker=T.Broker AND ISNULL(B.Country, T.Country) = T.Country or SELECT T.TradeRef,T.TradeStatus FROM Trades AS T JOIN CTMBroker AS B ON B.Broker=T.Broker AND (B.COUNTRY=T.Country OR B.Country IS NULL) These are both logically equivalent, however in this specific circumstance for our database (SQL Server 2008, SP1) two different execution plans are produced for these two queries with the second version significantly outperforming the first version in terms of both time and logical reads. My question really is as follows: as a general rule would (2) be preferred to (1), or does this just happen to be exploiting some particular idiosyncracy of the optimiser in 2008 SP1 (that could therefore change with future versions of SQL Server).

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >