Daily Archives

Articles indexed Thursday June 3 2010

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

  • Rails, destroy if blank

    - by Joseph Silvashy
    This might sound odd, but is there a 'Rails way' to have a model destroyed if a certain attribute is blank? Say I have a model like tags with just a name attribute or something, if the user edits the tag and deletes all the text out of the name field in the form I'd like the model to just be deleted. I'm aware of the reject_if method, but that doesn't seem to work.

    Read the article

  • Open Id XRDS Discovery

    - by Asciant
    I am working with Open Id, just playing around making a class to interact / auth Open Id's on my site (in PHP). I know there are a few other Libraries (like RPX), but I want to use my own (its good to keep help better understand the protocol and whether its right for me). The question I have relates to the Open Id discovery sequence. Basically I have reached the point where I am looking at using the XRDS doc to get the local identity (openid.identity) from the claimed identity (openid.claimed_id). My question is, do I have to make a cURL request to get the XRDS Location (X-XRDS-location) and then make another cURL request to get the actual XRDS doc?? It seems like with a DUMB request I only make one cURL request and get the Open Id Server, but have to make two to use the XRDS Smart method. Just doesn't seem right, can anyone else give me some info.

    Read the article

  • Kohana 3 - custom route

    - by pigfox
    I'm trying to create a custom route like:search/result/city/p1/state/p2/zip/p3/min/p4/max/p5/bed/p6/bath/p7/cats/p8/dogs/p9/parking/p10 Where search is the controller and result the action p1-p10 are variables.

    Read the article

  • How to post non-latin1 data to non-UTF8 site using perl?

    - by ZyX
    I want to post russian text on a CP1251 site using LWP::UserAgent and get following results: $text="??????? ?????"; FIELD_NAME => $text # result: ??? ?'???'???'?????????????? ?'?'?????????'???'?' $text=Encode::decode_utf8($text); FIELD_NAME => $text # result: ? ???????????? ?'???????' FIELD_NAME => Encode::encode("cp1251", $text) # result: ?????+?+?????? ???????+?? FIELD_NAME => URI::Escape::uri_escape_utf8($text) # result: D0%a0%d1%83%d1%81%d1%81%d0%ba%d0%b8%d0%b9%20%d1%82%d0%b5%d0%ba%d1%81%d1%82 How can I do this? Content-Type must be x-www-form-urlencoded. You can find similar form here, but there you can just escape any non-latin character using &#...; form, trying to escape it in FIELD_NAME results in 10561091108910891 10901077108210891 (every &, # and ; stripped out of the string).

    Read the article

  • Browser Detection

    - by Jrgns
    What's the best / simplest / most accurate way to detect the browser of a user? Ease of extendability and implementation is a plus. The less technologies used, the better. The solution can be server side, client side, or both. The results should eventually end up at the server, though. The solution can be framework agnostic. The solution will only be used for reporting purposes.

    Read the article

  • Silverlight: After adding table no datacontext classes are available for the new DomainService class

    - by Gabriel
    I'm using a Silverlight 4 WCF RIA Services demo application that uses LinqToSql, that works well. I add a new database table, move the new table to the LinqToSql designer and build the project I add a new DomainService class I get a dialog with the only option to create an empty DomainService and no DataContext classes are available. What am I missed? Thanks in advance Gabriel

    Read the article

  • Java - Is Set.contains() broken on OpenJDK 6?

    - by Peter
    Hey, I've come across a really strange problem. I have written a simple Deck class which represents a standard 52 card deck of playing cards. The class has a method missingCards() which returns the set of all cards which have been drawn from the deck. If I try and compare two identical sets of missing cards using .equals() I'm told they are different, and if I check to see if a set contains an element that I know is there using .contains() I am returned false. Here is my test code: public void testMissingCards() { Deck deck = new Deck(true); Set<Card> drawnCards = new HashSet<Card>(); drawnCards.add(deck.draw()); drawnCards.add(deck.draw()); drawnCards.add(deck.draw()); Set<Card> missingCards = deck.missingCards(); System.out.println(drawnCards); System.out.println(missingCards); Card c1 = null; for (Card c : drawnCards){ c1 = c; } System.out.println("C1 is "+c1); for (Card c : missingCards){ System.out.println("C is "+c); System.out.println("Does c1.equal(c) "+c1.equals(c)); System.out.println("Does c.equal(c1) "+c.equals(c1)); } System.out.println("Is c1 in missingCards "+missingCards.contains(c1)); assertEquals("Deck confirm missing cards",drawnCards,missingCards); } (Edit: Just for clarity I added the two loops after I noticed the test failing. The first loop pulls out a card from drawnCards and then this card is checked against every card in missingCards - it always matches one, so that card must be contained in missingCards. However, missingCards.contains() fails) And here is an example of it's output: [5C, 2C, 2H] [2C, 5C, 2H] C1 is 2H C is 2C Does c1.equal(c) false Does c.equal(c1) false C is 5C Does c1.equal(c) false Does c.equal(c1) false C is 2H Does c1.equal(c) true Does c.equal(c1) true Is c1 in missingCards false I am completely sure that the implementation of .equals on my card class is correct and, as you can see from the output it does work! What is going on here? Cheers, Pete

    Read the article

  • Linked list example using threads

    - by Carl_1789
    I have read the following code of using CRITICAL_SECTION when working with multiple threads to grow a linked list. what would be the main() part which uses two threads to add to linked list? #include <windows.h> typedef struct _Node { struct _Node *next; int data; } Node; typedef struct _List { Node *head; CRITICAL_SECTION critical_sec; } List; List *CreateList() { List *pList = (List*)malloc(sizeof(pList)); pList->head = NULL; InitializeCriticalSection(&pList->critical_sec); return pList; } void AddHead(List *pList, Node *node) { EnterCriticalSection(&pList->critical_sec); node->next = pList->head; pList->head = node; LeaveCriticalSection(&pList->critical_sec); } void Insert(List *pList, Node *afterNode, Node *newNode) { EnterCriticalSection(&pList->critical_sec); if (afterNode == NULL) { AddHead(pList, newNode); } else { newNode->next = afterNode->next; afterNode->next = newNode; } LeaveCriticalSection(&pList->critical_sec); } Node *Next(List *pList, Node *node) { Node* next; EnterCriticalSection(&pList->critical_sec); next = node->next; LeaveCriticalSection(&pList->critical_sec); return next; }

    Read the article

  • Need to override drawrect if your UIView is merely a container?

    - by Greg Maletic
    According to Apple's docs, "Subclasses need not override -[UIView drawRect:] if the subclass is a container for other views." I have a custom UIView subclass that is indeed merely a container for other views. Yet the contained views aren't getting drawn. Here's the pertinent code that sets up the custom UIView subclass: - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Consists of both an "on" light and an "off" light. We flick between the two depending upon our state. self.onLight = [[[LoyaltyCardNumberView alloc] initWithFrame:frame] autorelease]; self.onLight.backgroundColor = [UIColor clearColor]; self.onLight.on = YES; [self addSubview:self.onLight]; self.offLight = [[[LoyaltyCardNumberView alloc] initWithFrame:frame] autorelease]; self.offLight.backgroundColor = [UIColor clearColor]; self.offLight.on = NO; [self addSubview:self.offLight]; self.on = NO; } return self; } When I run the code that displays this custom UIView, nothing shows up. But when I add a drawRect method... - (void)drawRect:(CGRect)rect { [self.onLight drawRect:rect]; [self.offLight drawRect:rect]; } ...the subviews display. (Clearly, this isn't the right way to be doing this, not only because it's contrary to what the docs say, but because it -always- displays both subviews, completely ignoring some other code in my UIView that sets the hidden property of one of the views, it ignores the z-ordering, etc.) Anyway, the main question: why don't my subviews display when I'm not overriding drawRect:? Thanks!

    Read the article

  • Windows running service as "system" when log on as is "user"

    - by danspants
    I have an apache service that is running as "SYSTEM", however the log on as settings are configured to run as my user account. The windows task manager claims that I am the user name associated with the service when it's running, however I had the apache service call a python script which indicates that the user is "SYSTEM. Any ideas on how to fix this? I've reinstalled 3 times and once with a newer version.

    Read the article

  • vmware - ACE, Workstation - how to manage remoe clients??

    - by tom smith
    Hi. Exploring Vmware products/services and have a few questions. As I understand VM, you can use VMWare Workstation to create a VM of a target machine/box/OS. Let's call this VM, "foo". If I have 100 client PCs in my dept, and I want to install the VM (foo) on each client, and also manage the remote VM instances of (foo). How can I accompish this? Let's assume that the client machines are running Windows7, and have the vmplayer app installed on the box. I'm looking to do the following kinds of actions regarding the remote client machines: -Update the foo VM/image with new updated copies -Make sure that every VM "foo" has the same user, but a unique passwd -Monitor the traffic/status of each client VM "foo" oin each client -Start/Stop each client VN "foo" from the master console -Etc... Can this be accomplished? How would I do it, what services/products would I need? I've tried toalking to a few of the pre-sales guys in VMWare, and got nowhere, other than telling me to email my questions!! Looking at google shed more insight, but I still have questions. So, if you have detailed VMWare understanding, pointers to consultants, or resellers who can help, all pointers are greatly appreciated. Thanks -tom

    Read the article

  • Font Book does not Install all Fonts

    - by waiwai933
    My Mac decided to delete all but 19 fonts, which is fairly annoying. It didn't really delete them, as in I still have the original files in the /Library/Fonts folder, but they've disappeared from Font Book, so I can't use them. Now, Apple says that you can select a folder to install all fonts in that folder, but when I try that, the spinning wheel (not the beach ball) comes up in the lower right hand corner for a few seconds and then leaves, without installing any fonts. The same thing happens if I use the + sign in the menu bar, select multiple, or if I try validating and then installing (actually, that installs one font). Is there any way to mass-install these fonts or will I have to install them one by one? Comp info: Mac OS X 10.5.8 running Font Book 2.1 (123).

    Read the article

  • Mapping composite foreign keys in a many-many relationship, with overlapping components.

    - by Kirk Broadhurst
    I have a Page table and a View table. There is a many-many relationship between these two via a PageView table. Unfortunately all of these tables need to have composite keys (for business reasons). Page has a primary key of (PageCode, Version), View has a primary key of (ViewCode, Version). PageView obviously enough has PageCode, ViewCode, and Version. The FK to Page is (PageCode, Version) and the FK to View is (ViewCode, Version) Makes sense and works, but when I try to map this in Entity framework I get Error 3021: Problem in mapping fragments...: Each of the following columns in table PageView is mapped to multiple conceptual side properties: PageView.Version is mapped to (PageView_Association.View.Version, PageView_Association.Page.Version) So clearly enough, EF is having a complain about the Version column being a common component of the two foreign keys. Obviously I could create a PageVersion and ViewVersion column in the join table, but that kind of defeats the point of the constraint, i.e. the Page and View must have the same Version value. Has anyone encountered this, and is there anything I can do get around it? Thanks!

    Read the article

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