Search Results

Search found 24731 results on 990 pages for 'corner case'.

Page 31/990 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • "Special case" records for foreign key constraints

    - by keithjgrant
    Let's say I have a mysql table, called foo with a foreign key option_id constrained to the option table. When I create a foo record, the user may or may not have selected an option, and 'no option' is a viable selection. What is the best way to differentiate between 'null' (i.e. the user hasn't made a selection yet) and 'no option' (i.e. the user selected 'no option')? Right now, my plan is to insert a special record into the option table. Let's say that winds up with an id of 227 (this table already has a number of records at this point, so '1' isn't available). I have no need to access this record at a database level, and it would act as nothing more than a placeholder that the foreign key in the foo table can reference. So do I just hard-code '227' in my codebase when I'm creating 'foo' records where the user has selected 'no option'? The hard-coded id seems sloppy, and leaves room for error as the code is maintained down the road, but I'm not really sure of another approach.

    Read the article

  • How to roll back changes in gridview in case of incorrect input

    - by Mustafa A. Jabbar
    Hi, I have a DataGridView that is bound to a list of object. It has some columns that the user can edit. There are certain inputs that are not allowed for a row as a whole. How can I roll back if the user enters invalid inputs in some cell. I tried using the RowValidating event handler but it was not called after cell value has been changed. Even when I implemet CellValueChanged, I still cannot roll back the changes. Any idea how to accomplish this

    Read the article

  • Auto enter pass phrase in case of Python ssl Client/Server

    - by rauch
    I need to create Client/Server application to send files from clients to Server. I use simple ssl sockets for that and authenticate with certificates. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ssl_sock = ssl.wrap_socket(ms, keyfile=".../newCA/my_client.key", certfile=".../newCA/my_client.crt", server_side=0, cert_reqs=ssl.CERT_REQUIRED, ca_certs=".../newCA/CA/my-ca.crt" ) ssl_sock.connect((HOST, MPORT)) And Server side: msock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.ssl_sock = ssl.wrap_socket(msock, keyfile=".../newCA/my_server.key", certfile=".../newCA/my_server.crt", server_side=1, cert_reqs=ssl.CERT_REQUIRED, ca_certs=".../newCA/CA/my-ca.crt" ) self.ssl_sock.bind(('', self.PORT)) self.ssl_sock.listen(self.QUEUE_MAX) The problem is the following: when client tries to connect to Server, it requires Enter the pass phrase for private key for Both: for Server-side and Client-side. In Java we need to set System Property: javax.net.ssl.keyStorePassword="" and it has to be used automatically, But how is it been used in Python? I can't enter pass phrase all time the client connects.

    Read the article

  • Unit testing, mocking - simple case: Service - Repository

    - by rafek
    Consider a following chunk of service: public class ProductService : IProductService { private IProductRepository _productRepository; // Some initlization stuff public Product GetProduct(int id) { try { return _productRepository.GetProduct(id); } catch (Exception e) { // log, wrap then throw } } } Let's consider a simple unit test: [Test] public void GetProduct_return_the_same_product_as_getProduct_on_productRepository() { var product = EntityGenerator.Product(); _productRepositoryMock.Setup(pr => pr.GetProduct(product.Id)).Returns(product); Product returnedProduct = _productService.GetProduct(product.Id); Assert.AreEqual(product, returnedProduct); _productRepositoryMock.VerifyAll(); } At first it seems that this test is ok. But let's change our service method a little bit: public Product GetProduct(int id) { try { var product = _productRepository.GetProduct(id); product.Owner = "totallyDifferentOwner"; return product; } catch (Exception e) { // log, wrap then throw } } How to rewrite a given test that it'd pass with the first service method and fail with a second one? How do you handle this kind of simple scenarios? HINT: A given test is bad coz product and returnedProduct is actually the same reference.

    Read the article

  • The case of the sneaky backslash - Regex

    - by Shane Cusson
    I'm missing something very obvious here, but I just cant see it. I've got: string input = @"999\abc.txt"; string pattern = @"\\(.*)"; string output = Regex.Match(input,pattern).ToString(); Console.WriteLine(output); My result is: \abc.txt I don't want the slash and cant figure out why it's sneaking into the output. I tried flipping the pattern, and the slash winds up in the output again: string pattern = @"^(.*)\\"; and get: 999\ Strange. The result is fine in Osherove's Regulator. Any thoughts? Thanks.

    Read the article

  • How to create a generic list in this wierd case in c#

    - by Marc Bettex
    Hello, In my program, I have a class A which is extended by B, C and many more classes. I have a method GetInstance() which returns a instance of B or C (or of one of the other child), but I don't know which one, so the return type of the method is A. In the method CreateGenericList(), I have a variable v of type A, which is in fact either a B, a C or another child type and I want to create a generic list of the proper type, i.e. List<B> if v is a B or List<C> if v is a C, ... Currently I do it by using reflection, which works, but this is extremely slow. I wanted to know if there is another way to to it, which doesn't use reflection. Here is an example of the code of my problem: class A { } class B : A { } class C : A { } // More childs of A. class Program { static A GetInstance() { // returns an instance of B or C } static void CreateGenericList() { A v = Program.GetInstance(); IList genericList = // Here I want an instance of List<B> or List<C> or ... depending of the real type of v, not a List<A>. } } I tried the following hack. I call the following method, hoping the type inferencer will guess the type of model, but it doesn't work and return a List<A>. I believe that because c# is statically typed, T is resolved as A and not as the real type of model at runtime. static List<T> CreateGenericListFromModel<T>(T model) where T : A { return new List<T> (); } Does anybody have a solution to that problem that doesn't use reflection or that it is impossible to solve that problem without reflection? Thank you very much, Marc

    Read the article

  • Use case for output buffering as the correct solution to "headers already sent"

    - by kemp
    I see (not just on this site) a lot of question from inexperienced PHP programmers about the infamous "headers already sent... output started at" error, and many people suggest using ouput buffering as a solution. In my experience I have never found a situation where that error wasn't caused by a flow in the program's logic. Are there cases where output buffering is actually the correct solution?

    Read the article

  • 302 vs 301 redirect in this specific case

    - by Binder
    We have a website that displays information in a location based manner, i.e. it detects the IP of the visiting user and redirects him/her to an appropriate landing page; for e.g. a user coming from 'Egypt' will be redirected to http://www.mysite.com/egypt/cairo and a user visting from dubai will be redirected to http://www.mysite.com/uae/dubai, so on and so forth and we cater to multiple locations in the middle-east. Now, we have been advised by our SEO consultant that we should put a 301 (permanent redirect) on http://www.mysite.com to point to http://www.mysite.com/ksa/riyadh I would like to know the negative implications that this would have on Google indexing or otherwise, as I fundamentally disagree with this suggestion and believe that in a siutation like this a 302 redirect would be more appropriate.

    Read the article

  • jQuery DataLink - Does DataLink solve my use case?

    - by AnApprentice
    Hello, I recently heard of the jQuery datalink plugin and wondered if I should be using if for the following: I have a an inbox in my app that consists of the following: Inbox (index) - List of Items (list of mails) Inbox (show) Item Viewer (1 mail) Inbox Unread Counter The challenge I'm having now is a user can mark a mail as read/unread in either view which makes keeping the counter accurate challenging. Can datalink help with this? If so how? Also, I read that datalink requires forms is that true? Or can I bind the links to anything like 0 and anytime a mailitem changes from read to unread it would automatically update? Thanks

    Read the article

  • JQuery class selectors like $(.someClass) are case sensitive?

    - by Justin Grant
    Given this HTML: <div class="OpenIDSelector">some text</div> Why does this JQuery selector match it on some browsers and some pages, but not on others? $('.OpenIdSelector) NOTE: I ran into this problem and solved it myself, but it was annoying and I didn't find it on StackOverflow already, so I'm posting it as a Q&A pair so someone else won't waste an hour like I did.

    Read the article

  • Best database (mysql) structure for this case:

    - by robert
    we have three types of data (tables): Book (id,name,author...) ( about 3 million of rows) Category (id,name) ( about 2000 rows) Location (id,name) ( about 10000 rows) A Book must have at least 1 type of Category (up to 3) AND a Book must have only one Location. I need to correlate this data to get this query faster: Select Books where Category = 'cat_id' AND Location = 'loc_id' Select Books where match(name) against ('name of book') AND Location = 'loc_id' Please I need some help. Thanks

    Read the article

  • Is MySQL Replication Appropriate in this case?

    - by MJB
    I have a series of databases, each of which is basically standalone. It initially seemed like I needed a replication solution, but the more I researched it, the more it felt like replication was overkill and not useful anyway. I have not done MySQL replication before, so I have been reading up on the online docs, googling, and searching SO for relevant questions, but I can't find a scenario quite like mine. Here is a brief description of my issue: The various databases almost never have a live connection to each other. They need to be able to "sync" by copying files to a thumb drive and then moving them to the proper destination. It is OK for the data to not match exactly, but they should have the same parent-child relationships. That is, if a generated key differs between databases, no big deal. But the visible data must match. Timing is not critical. Updates can be done a week later, or even a month later, as long as they are done eventually. Updates cannot be guaranteed to be in the proper order, or in any order for that matter. They will be in order from each database; just not between databases. Rather than a set of master-slave relationships, it is more like a central database (R/W) and multiple remote databases (also R/W). I won't know how many remote databases I have until they are created. And the central DB won't know that a database exists until data arrives from it. (To me, this implies I cannot use the method of giving each its own unique identity range to guarantee uniqueness in the central database.) It appears to me that the bottom line is that I don't want "replication" so much as I want "awareness". I want the central database to know what happened in the remote databases, but there is no time requirement. I want the remote databases to be aware of the central database, but they don't need to know about each other. WTH is my question? It is this: Does this scenario sound like any of the typical replication scenarios, or does it sound like I have to roll my own? Perhaps #7 above is the only one that matters, and given that requirement, out-of-the-box replication is impossible. EDIT: I realize that this question might be more suited to ServerFault. I also searched there and found no answers to my questions. And based on the replication questions I did find both on SO and SF, it seemed that the decision was 50-50 over where to put my question. Sorry if I guessed wrong.

    Read the article

  • how free of memory happen in this case???

    - by Riyaz
    #include <stdio.h> void func(int arr[],int xNumOfElem) { int j; for(j=0; j<xNumOfElem; j++) { arr[j] = j + arr[j]; printf("%d\t",arr[j]); } printf("\n"); } int main() { int *a,k; a = (int*) malloc(sizeof(int)*10); for(k = 0; k<10; k++) { a[k] = k; printf("%d\t",a[k]); } printf("\n"); func(a,10); //Func call free(a); } Inside the the function "func" who will allocate/deallocate memory for dynamic array "arr". arr is an function argument.

    Read the article

  • SOAP VS REST PRAGMATIC CASE STUDIES ?

    - by asksuperuser
    I'm not satisfied with the answers given by the SOAP vs REST questions notably here: http://stackoverflow.com/questions/106546/performance-of-soap-vs-xml-rpc-or-rest because it's just general philosophical answers and not pragmatic answers with some study cases. Nobody can give precise cases of when soap would be more suitable than rest, especially as for performance point of view ? For example let's say I have a flash client for a financiall simulation wizard calling legacy code. Should I use SOAP or REST ? Why ?

    Read the article

  • Will creating index help in this case

    - by The King
    I'm still a learning user of SQL-SERVER2005. Here is my table structure CREATE TABLE [dbo].[Trn_PostingGroups]( [ControlGroup] [char](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [PracticeCode] [char](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [ScanDate] [smalldatetime] NULL, [DepositDate] [smalldatetime] NULL, [NameOfFile] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [DepositValue] [decimal](11, 2) NULL, [RecordStatus] [char](1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, CONSTRAINT [PK_Trn_PostingGroups_1] PRIMARY KEY CLUSTERED ( [ControlGroup] ASC, [PracticeCode] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] Scenario 1 : Suppose I have a query like this... Select * from Trn_PostingGroups where PracticeCode = 'ABC' Will indexing on Practice Code seperately help me in making my query faster?? Scenario 2 : Select * from Trn_PostingGroups where ControlGroup = 12701 and PracticeCode = 'ABC' and NameOfFile = 'FileName1' Will indexing on NameOfFile seperately help me in making my query faster ??

    Read the article

  • Spring MVC simple case

    - by coure2011
    Trying to understand a sample code... I am returning a modelview successfully from my AthuenticationController like this modelAndView = new ModelAndView("redirect:/home/"); .... return modelAndView; and my browser url is changed to /home/ but its showing a 404 page I have a HomePageController and it has methods @RequestMapping(method = RequestMethod.GET) public String loadHome and @RequestMapping(method = RequestMethod.GET, value = "/main") public String reloadHome but System.out.println("Message") is not executing in any of the above methods. When authenticated I want to load a home.jsp page? It is in WEB-INF/jsp/...

    Read the article

  • case-insensitive matching in xpath?

    - by Ethan
    For example, for the xml below <CATALOG> <CD title="Empire Burlesque"/> <CD title="empire burlesque"/> <CD title="EMPIRE BURLESQUE"/> <CD title="EmPiRe BuRLeSQuE"/> <CD title="Others"/> <CATALOG> How to match the first 4 records with xpath like //CD[@title='empire burlesque']. Is there xpath function to do this? Other solutions like PHP function are also accepted.

    Read the article

  • Object reference case study

    - by Skogen
    When person 1 become partner with person 3, person 2 should no longer have person 1 as partner. How should I solve this? public class Person { private String name; private Person partner; public Person(String name){ this.name = name; } public void setPartner(Person partner){ this.partner = partner; partner.partner = this; } public static void main(String[] args) { Person one = new Person("1"); Person two = new Person("2"); Person three = new Person("3"); Person four = new Person("4"); one.setPartner(two); three.setPartner(four); one.setPartner(three); //Person two is still partner with person 1 }

    Read the article

  • method implementation for this case in Java

    - by Thomas
    Hello, I just saw a code snippet like this: private static class DefaultErrorHandler<RT> implements ErrorHandler<RT> { public RT handle(Object[] params, Throwable e) { return Exceptions.throwUncheckedException(e); } Now I am wondering what the static method "throwUncheckedException (Throwable e)" would return exactly and how it might be implemented regarding the generics. Can anybody give me an example ?

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >