Search Results

Search found 2348 results on 94 pages for 'cat pants'.

Page 9/94 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • mySQL experts - need help with 'intersect'

    - by MTCreations
    I know that mySQL 5.x does not support INTERSECT, but that seems to be what I need. Table A: Products (p_id) Table B: Prod_cats (cat_id) - category info (name, description, etc) Table C: prod_2cats (p_id, cat_id) - many to many prod_2cats holds the many (1 or more) categories that have been assigned to Products (A). Doing a query/filter lookup, (user interactive) and need to be able to select across multiple categories the products that meet ALL the criteria. Ex: - 80 products assigned to Category X - 50 products assigned to Category Y - but only 10 products (intersect) are assigned to BOTH cat X AND cat Y This sql works for one category: SELECT * FROM products WHERE p_show='Y' AND p_id IN ( SELECT p_id FROM prods_2cats AS PC WHERE PC.cat_id =" . $cat_id ." <-$cat_id is sanitized var passed from query form . I can't seem to find the means to say ' give me the intersect of cat A and cat B' and get back the subset (10 records, from my example) Help!

    Read the article

  • Compute the Length of Largest substring that starts and ends with the same substring

    - by Deepak
    Hi People, Below is the Problem Statement: PS: Given a string and a non-empty substring sub, compute recursively the largest substring which starts and ends with sub and return its length. Examples: strDist("catcowcat", "cat") ? 9 strDist("catcowcat", "cow") ? 3 strDist("cccatcowcatxx", "cat") ? 9 Below is my Code: (Without recursion)//since i found it hard to implement with recursion. public int strDist(String str, String sub){ int idx = 0; int max; if (str.isEmpty()) max = 0; else max=1; while ((idx = str.indexOf(sub, idx)) != -1){ int previous=str.indexOf(sub, idx); max = Math.max(max,previous); idx++; } return max; } Its working for few as shown below but returns FAIL for others. Expected This Run strDist("catcowcat", "cat") ? 9 6 FAIL strDist("catcowcat", "cow") ? 3 3 OK strDist("cccatcowcatxx", "cat") ? 9 8 FAIL strDist("abccatcowcatcatxyz", "cat") ? 12 12 OK strDist("xyx", "x") ? 3 2 FAIL strDist("xyx", "y") ? 1 1 OK strDist("xyx", "z") ? 0 1 FAIL strDist("z", "z") ? 1 1 OK strDist("x", "z") ? 0 1 FAIL strDist("", "z") ? 0 0 OK strDist("hiHellohihihi", "hi") ? 13 11 FAIL strDist("hiHellohihihi", "hih") ? 5 9 FAIL strDist("hiHellohihihi", "o") ? 1 6 FAIL strDist("hiHellohihihi", "ll") ? 2 4 FAIL Could you let me whats wrong with the code and how to return the largest substring that begins and ends with sub with its respective length.

    Read the article

  • getting proxies of the correct type in nhibernate

    - by Nir
    I have a problem with uninitialized proxies in nhibernate The Domain Model Let's say I have two parallel class hierarchies: Animal, Dog, Cat and AnimalOwner, DogOwner, CatOwner where Dog and Cat both inherit from Animal and DogOwner and CatOwner both inherit from AnimalOwner. AnimalOwner has a reference of type Animal called OwnedAnimal. Here are the classes in the example: public abstract class Animal { // some properties } public class Dog : Animal { // some more properties } public class Cat : Animal { // some more properties } public class AnimalOwner { public virtual Animal OwnedAnimal {get;set;} // more properties... } public class DogOwner : AnimalOwner { // even more properties } public class CatOwner : AnimalOwner { // even more properties } The classes have proper nhibernate mapping, all properties are persistent and everything that can be lazy loaded is lazy loaded. The application business logic only let you to set a Dog in a DogOwner and a Cat in a CatOwner. The Problem I have code like this: public void ProcessDogOwner(DogOwner owner) { Dog dog = (Dog)owner.OwnedAnimal; .... } This method can be called by many diffrent methods, in most cases the dog is already in memory and everything is ok, but rarely the dog isn't already in memory - in this case I get an nhibernate "uninitialized proxy" but the cast throws an exception because nhibernate genrates a proxy for Animal and not for Dog. I understand that this is how nhibernate works, but I need to know the type without loading the object - or, more correctly I need the uninitialized proxy to be a proxy of Cat or Dog and not a proxy of Animal. Constraints I can't change the domain model, the model is handed to me by another department, I tried to get them to change the model and failed. The actual model is much more complicated then the example and the classes have many references between them, using eager loading or adding joins to the queries is out of the question for performance reasons. I have full control of the source code, the hbm mapping and the database schema and I can change them any way I want (as long as I don't change the relationships between the model classes). I have many methods like the one in the example and I don't want to modify all of them. Thanks, Nir

    Read the article

  • Using a dictionary file with sed

    - by Winston
    I have a blacklist.txt file that contains keywords I want to remove using sed. Here's what the blacklist.txt file contain winston@linux ] $ cat blacklist.txt obscure keywords here ... And here's what I have so far, but currently doesn't work. blacklist=$(cat blacklist.txt); output="filtered_file.txt" for i in $blacklist; do cat $input | sed 's/$i//g' >> $output done

    Read the article

  • Clean URLs mod_rewrite & wildcard subdomains

    - by Søren Zet
    I got this url http://domain.com/blogs/directory-param with this rule RewriteBase /blogs/directory/ RewriteRule ^/blogs/directory-([A-Za-z0-9-]+)$ /blogs/directory/index.php?cat=$1 [L] so I get /blogs/directory/index.php?cat=param now my problem is the following: I use wildcards subdomains so every *.domain.com is mapped to domain.com/blogs/ for example soeren.domain.com is mapped to domain.com/blogs and so on... My problem now is I want a rule for soeren.domain.com/directory-param which points to domain.com/blogs/directory?index.php?cat=param Do you have any ideas?

    Read the article

  • efficient list mapping in python

    - by Joey
    Hi everyone, I have the following input: input = [(dog, dog, cat, mouse), (cat, ruby, python, mouse)] and trying to have the following output: outputlist = [[0, 0, 1, 2], [1, 3, 4, 2]] outputmapping = {0:dog, 1:cat, 2:mouse, 3:ruby, 4:python, 5:mouse} Any tips on how to handle given with scalability in mind (var input can get really large).

    Read the article

  • Database model for saving random boolean expressions

    - by zarko.susnjar
    I have expressions like this: (cat OR cats OR kitten OR kitty) AND (dog OR dogs) NOT (pigeon OR firefly) Anyone having idea how to make tables to save those? Before I got request for usage of brackets, I limited usage of operators to avoid ambiguous situations. So only ANDs and NOTs or only ORs and saved those in this manner: operators id | name 1 | AND 2 | OR 3 | NOT keywords id | keyword 1 | cat 2 | dog 3 | firefly expressions id | operator | keywordId 1 | 0 | 1 1 | 1 | 2 1 | 3 | 3 which was: cat AND dog NOT firefly But now, I'm really puzzled...

    Read the article

  • Whats the point of lazy-seq in clojure?

    - by dbyrne
    I am looking through some example Fibonacci sequence clojure code: (def fibs (lazy-cat [1 2] (map + fibs (rest fibs)))) I generally understand what is going on, but don't quite understand the point of lazy-cat. I know that lazy-cat is a macro that is translating to something like this: (def fibs (concat (lazy-seq [1 2]) (lazy-seq (map + fibs (rest fibs))))) What exactly is lazy-seq accomplishing? It would still be evaluated lazily even without lazy-seq? Is this strictly for caching purposes?

    Read the article

  • How to install Imagick on Mac OS with XAMPP

    - by Cat
    I'm having some trouble installing Imagick on a Mac. I have XAMPP installed and when I run 'sudo pecl install imagick', I get this error: checking ImageMagick MagickWand API configuration program... configure: error: not found. Please provide a path to MagickWand-config or Wand-config program. ERROR: `/private/tmp/pear/temp/imagick/configure --with-imagick="/Applications/XAMPP/xamppfiles/bin"' failed The error above shows up when I input /Applications/XAMPP/xamppfiles/bin after Please provide the prefix of Imagemagick installation [autodetect] Do I need to install some other library before running the Imagick install command?

    Read the article

  • Is this a variation of the traveling salesman problem?

    - by Ville Koskinen
    I'm interested in a function of two word lists, which would return an order agnostic edit distance between them. That is, the arguments would be two lists of (let's say space delimited) words and return value would be the minimum sum of the edit (or Levenshtein) distances of the words in the lists. Distance between "cat rat bat" and "rat bat cat" would be 0. Distance between "cat rat bat" and "fat had bad" would be the same as distance between "rat bat cat" and "had fat bad", 4. In the case the number of words in the lists are not the same, the shorter list would be padded with 0-length words. My intuition (which hasn't been nurtured with computer science classes) does not find any other solution than to use brute force: |had|fat|bad| a solution ---+---+---+---+ +---+---+---+ cat| 2 | 1 | 2 | | | 1 | | ---+---+---+---+ +---+---+---+ rat| 2 | 1 | 2 | | 3 | | | ---+---+---+---+ +---+---+---+ bat| 2 | 1 | 1 | | | | 4 | ---+---+---+---+ +---+---+---+ Starting from the first row, pick a column and go to the next rows without ever revisiting a column you have already visited. Do this over and over again until you've tried all combinations. To me this sounds a bit like the traveling salesman problem. Is it, and how would you solve my particular problem?

    Read the article

  • Drupal: Whow to forward argument to block-exposed-filters results?

    - by Vlad Socaciu
    I have a typical views page displaying nodes, with a taxonomy tid receiveid as an argument through the url: cat/% Now I want to further narow the results with an exposed filter by a cck field. All goes well and for tid=10 (for instance), the filtered page url is cat/10?field_no_people_value=5 Now, when I expose the filter in a block, the argument, tid, goes away and I get cat/all?field_no_people_value=5 . Obviously, filtering by tid doesn't happen anymore. How should I get around this?

    Read the article

  • My SQL query is only returning I need the parent aswell

    - by sico87
    My sql query is only returning the children of the parent I need it to return the parent as well, public function getNav($cat,$subcat){ //gets all sub categories for a specific category if(!$this->checkValue($cat)) return false; //checks data $query = false; if($cat=='NULL'){ $sql = "SELECT itemID, title, parent, url, description, image FROM p_cat WHERE deleted = 0 AND parent is NULL ORDER BY position;"; $query = $this->db->query($sql) or die($this->db->error); }else{ //die($cat); $sql = "SET @parent = (SELECT c.itemID FROM p_cat c WHERE url = '".$this->sql($cat)."' AND deleted = 0); SELECT c1.itemID, c1.title, c1.parent, c1.url, c1.description, c1.image, (SELECT c2.url FROM p_cat c2 WHERE c2.itemID = c1.parent LIMIT 1) as parentUrl FROM p_cat c1 WHERE c1.deleted = 0 AND c1.parent = @parent ORDER BY c1.position;"; $query = $this->db->multi_query($sql) or die($this->db->error); $this->db->store_result(); $this->db->next_result(); $query = $this->db->store_result(); } return $query; }

    Read the article

  • How to display two ObservableCollections as a single list in WPF?

    - by nareshbhatia
    I have two ObservableCollections, say ObservableCollection<Cat> and ObservableCollections<Dog>. Cat and Dog both derive from class Pet. I want to display a list of all Pets. How do I do this? I prefer not want create a new ObservableCollection<Pet> by adding items from the two source lists because this list will become stale as more Cats and Dogs are added to the source lists. I can think of two approaches: 1) Create a "Decorator" ObservableCollection that keeps the two source collections as members and iterates over them every time. 2) Create an ObservableCollection<Pet> that does have the combined elements of the two source collections, but is also dependent on the source collections. Thus if a Cat is added to the Cat collection, this collection is notified and it adds the new Cat to itself. Is there a standard way to solve this issue? I don't want to reinvent the wheel!

    Read the article

  • Java: Finding objects in collections.

    - by Jake
    This problem occurs over and over. I have some complicated object, such as a Cat, which has many properties, such as age, favorite cat food, and so forth. A bunch of Cats are stored in a Java Collection, and I need to find all the Cats that are aged 3, or those whose favorite cat food is Whiskas. Surely, I can write a custom method that finds those Cats with a specific property, but this gets cumbersome with many properties; is there some generic way of doing this?

    Read the article

  • How to perform a non-polymorphic HQL query in Hibernate?

    - by Eli Acherkan
    Hi all, I'm using Hibernate 3.1.1, and in particular, I'm using HQL queries. According to the documentation, Hibernate's queries are polymorphic: A query like: from Cat as cat returns instances not only of Cat, but also of subclasses like DomesticCat. How can I query for instances of Cat, but not of any of its subclasses? I'd like to be able to do it without having to explicitly mention each subclass. I'm aware of the following options, and don't find them satisfactory: Manually filtering the instances after the query, OR: Manually adding a WHERE clause on the discriminator column. It would make sense for Hibernate to allow the user to decide whether a query should be polymorphic or not, but I can't find such an option. Thanks in advance!

    Read the article

  • Drupal - Selected Node Highlighting in Views

    - by fighella
    Drupal Question: Does anyone have a method of using Views and highlighting a selected/current node. So for example: I have a list of articles under a heading: 2009 Articles Dog Training Cat Cleaning Snake Wrangling The 3 articles are made from the view (ie: latest articles from 2009)... as the user makes new articles, they are automatically added into this view by title. I now need to find a way, that if a user clicks on say CAT CLEANING.... and the cat cleaning article appears, the CAT CLEANING in the view becomes bold (or some CSS indication it's the current article.) I know this is pretty easy with MENU's, But I don't want to force a user to add new articles into a menu. Thanks alot, JD

    Read the article

  • Problem with NHibernate and saving.

    - by Vilx-
    When I do this: Cat x = Session.Load<Cat>(123); x.Name = "fritz"; Session.Flush(); NHibernate detects the change and UPDATEs the DB. But, when I do this: Cat x = new Cat(); Session.Save(x); x.Name = "fritz"; Session.Flush(); I get NULL for name, because that's what was there when I called Session.Save(). Why doesn't NHibernate detect the changes - or better yet, take the values for the INSERT statement at the time of Flush()?

    Read the article

  • Inherit all methods of object (including "constructor"), but modify some of them.

    - by Kirzilla
    Hello, Let's imagine that we have object Animal $.Animal = function(options) { this.defaults = { name : null } this.options = $.extend(this.defaults, options); } $.Animal.prototype.saySomething = function() { alert("I'm animal!"); } Now I'd like to create Cat object. It is absolutely similar to $.Annimal, but method saySomething() will look like this one... $.Cat.prototype.saySomething = function() { alert("I'm cat!"); } How can I inherit from Animal to create new object Cat and redefine saySomething() method? Thank you.

    Read the article

  • C++ - Breaking code implementation into different parts

    - by Kotti
    Hi! The question plot (a bit abstract, but answering this question will help me in my real app): So, I have some abstract superclass for objects that can be rendered on the screen. Let's call it IRenderable. struct IRenderable { // (...) virtual void Render(RenderingInterface& ri) = 0; virtual ~IRenderable() { } }; And suppose I also have some other objects that derive from IRenderable, e.g. Cat and Dog. So far so good. I add some Cat and Dog specific methods, like SeekForWhiskas(...) and Bark(...). After that I add specific Render(...) method for them, so my code looks this way: class Cat : public IRenderable { public: void SeekForWhiskas(...) { // Implementation could be here or moved // to a source file (depends on me wanting // to inline it or not) } virtual void Render(...) { // Here comes the rendering routine, that // is specific for cats SomehowDrawAppropriateCat(...); } }; class Dog : public IRenderable { public: void Bark(...) { // Same as for 'SeekForWhiskas(...)' } virtual void Render(...) { // Here comes the rendering routine, that // is specific for dogs DrawMadDog(...); } }; And then somewhere else I can do drawing the way that an appropriate rendering routine is called: IRenderable* dog = new Dog(); dog->Render(...); My question is about logical wrapping of such kind of code. I want to break apart the code, that corresponds to rendering of the current object and it's own methods (Render and Bark in this example), so that my class implementation doesn't turn into a mess (imagine that I have 10 methods like Bark and of course my Render method doesn't fit in their company and would be hard to find). Two ways of making what I want to (as far as I know) are: Making appropriate routines that look like RenderCat(Cat& cat, RenderInterface* ri), joining them to render namespace and then the functions inside a class would look like virtual void Render(...) { RenderCat(*this, ...); }, but this is plain stupid, because I'll lose access to Cat's private members and friending these functions looks like a total design disaster. Using visitor pattern, but this would also mean I have to rebuild my app's design and looks like an inadequate way to make my code complicated from the very beginning. Any brilliant ideas? :)

    Read the article

  • Right way to return proxy model instance from a base model instance in Django ?

    - by sotangochips
    Say I have models: class Animal(models.Model): type = models.CharField(max_length=255) class Dog(Animal): def make_sound(self): print "Woof!" class Meta: proxy = True class Cat(Animal): def make_sound(self): print "Meow!" class Meta: proxy = True Let's say I want to do: animals = Animal.objects.all() for animal in animals: animal.make_sound() I want to get back a series of Woofs and Meows. Clearly, I could just define a make_sound in the original model that forks based on animal_type, but then every time I add a new animal type (imagine they're in different apps), I'd have to go in and edit that make_sound function. I'd rather just define proxy models and have them define the behavior themselves. From what I can tell, there's no way of returning mixed Cat or Dog instances, but I figured maybe I could define a "get_proxy_model" method on the main class that returns a cat or a dog model. Surely you could do this, and pass something like the primary key and then just do Cat.objects.get(pk = passed_in_primary_key). But that'd mean doing an extra query for data you already have which seems redundant. Is there any way to turn an animal into a cat or a dog instance in an efficient way? What's the right way to do what I want to achieve?

    Read the article

  • "Directly accessing" return values without referencing

    - by undocumented feature
    Look at this ruby example: puts ["Dog","Cat","Gates"].1 This will output Cat as ruby allows me to directly access the "anonymous" array created. If I try this in PHP, however: echo array("Dog","Cat,"Gates")[1] This won't work. What is this called, not only concerning arrays but all functions? Where else is it possible? Feel free to change the question title when you know how this "feature" is called.

    Read the article

  • Is running multiple databases on login going to make my Mac really slow?

    - by Walrus the Cat
    Sometime ago, I installed Postgres, and the Launch agent that causes it to run when I log in. Just now, I did the same thing for Mongo. I was just about to do it for Couch. I don't remember if I ever did it for MySQL, but I probably did. Mongo and Couch are just 'when I have time to look into it' sort of things, but I don't want to have to remember to start them when I do. I have a 2.4 Ghz processor and 8 GB ram. Is this sort of behavior going to significantly impact my computer's performance? Should I be scrambling to uninstall all but the database I'm currently using, or can I install all the things and run them all the time? Thanks

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >