Search Results

Search found 3788 results on 152 pages for 'pure equal'.

Page 16/152 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • 2D Tile Based Collision Detection

    - by MrPlosion1243
    There are a lot of topics about this and it seems each one addresses a different problem, this topic does the same. I was looking into tile collision detection and found this where David Gouveia explains a great way to get around the person's problem by separating the two axis. So I implemented the solution and it all worked perfectly from all the testes I through at it. Then I implemented more advanced platforming physics and the collision detection broke down. Unfortunately I have not been able to get it to work again which is where you guys come in :)! I will present the code first: public void Update(GameTime gameTime) { if(Input.GetKeyDown(Keys.A)) { velocity.X -= moveAcceleration; } else if(Input.GetKeyDown(Keys.D)) { velocity.X += moveAcceleration; } if(Input.GetKeyDown(Keys.Space)) { if((onGround && isPressable) || (!onGround && airTime <= maxAirTime && isPressable)) { onGround = false; airTime += (float)gameTime.ElapsedGameTime.TotalSeconds; velocity.Y = initialJumpVelocity * (1.0f - (float)Math.Pow(airTime / maxAirTime, Math.PI)); } } else if(Input.GetKeyReleased(Keys.Space)) { isPressable = false; } if(onGround) { velocity.X *= groundDrag; velocity.Y = 0.0f; } else { velocity.X *= airDrag; velocity.Y += gravityAcceleration; } velocity.Y = MathHelper.Clamp(velocity.Y, -maxFallSpeed, maxFallSpeed); velocity.X = MathHelper.Clamp(velocity.X, -maxMoveSpeed, maxMoveSpeed); position += velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; position = new Vector2((float)Math.Round(position.X), (float)Math.Round(position.Y)); if(Math.Round(velocity.X) != 0.0f) { HandleCollisions2(Direction.Horizontal); } if(Math.Round(velocity.Y) != 0.0f) { HandleCollisions2(Direction.Vertical); } } private void HandleCollisions2(Direction direction) { int topTile = (int)Math.Floor((float)Bounds.Top / Tile.PixelTileSize); int bottomTile = (int)Math.Ceiling((float)Bounds.Bottom / Tile.PixelTileSize) - 1; int leftTile = (int)Math.Floor((float)Bounds.Left / Tile.PixelTileSize); int rightTile = (int)Math.Ceiling((float)Bounds.Right / Tile.PixelTileSize) - 1; for(int x = leftTile; x <= rightTile; x++) { for(int y = topTile; y <= bottomTile; y++) { Rectangle tileBounds = new Rectangle(x * Tile.PixelTileSize, y * Tile.PixelTileSize, Tile.PixelTileSize, Tile.PixelTileSize); Vector2 depth; if(Tile.IsSolid(x, y) && Intersects(tileBounds, direction, out depth)) { if(direction == Direction.Horizontal) { position.X += depth.X; } else { onGround = true; isPressable = true; airTime = 0.0f; position.Y += depth.Y; } } } } } From the code you can see when velocity.X is not equal to zero the HandleCollisions() Method is called along the horizontal axis and likewise for the vertical axis. When velocity.X is not equal to zero and velocity.Y is equal to zero it works fine. When velocity.Y is not equal to zero and velocity.X is equal to zero everything also works fine. However when both axis are not equal to zero that's when it doesn't work and I don't know why. I basically teleport to the left side of a tile when both axis are not equal to zero and there is a air block next to me. Hopefully someone can see the problem with this because I sure don't as far as I'm aware nothing has even changed from what I'm doing to what the linked post's solution is doing. Thanks.

    Read the article

  • Comparing two collections for equality

    - by Crossbrowser
    I would like to compare two collections (in C#), but I'm not sure of the best way to implement this efficiently. I've read the other thread about Enumerable.SequenceEqual, but it's not exactly what I'm looking for. In my case, two collections would be equal if they both contain the same items (no matter the order). Example: collection1 = {1, 2, 3, 4}; collection2 = {2, 4, 1, 3}; collection1 == collection2; // true What I usually do is to loop through each item of one collection and see if it exists in the other collection, then loop through each item of the other collection and see if it exists in the first collection. (I start by comparing the lengths). if (collection1.Count != collection2.Count) return false; // the collections are not equal foreach (Item item in collection1) { if (!collection2.Contains(item)) return false; // the collections are not equal } foreach (Item item in collection2) { if (!collection1.Contains(item)) return false; // the collections are not equal } return true; // the collections are equal However, this is not entirely correct, and it's probably not the most efficient way to do compare two collections for equality. An example I can think of that would be wrong is: collection1 = {1, 2, 3, 3, 4} collection2 = {1, 2, 2, 3, 4} Which would be equal with my implementation. Should I just count the number of times each item is found and make sure the counts are equal in both collections? The examples are in some sort of C# (let's call it pseudo-C#), but give your answer in whatever language you wish, it does not matter. Note: I used integers in the examples for simplicity, but I want to be able to use reference-type objects too (they do not behave correctly as keys because only the reference of the object is compared, not the content).

    Read the article

  • C++ non-member functions for nested template classes

    - by beldaz
    I have been writing several class templates that contain nested iterator classes, for which an equality comparison is required. As I believe is fairly typical, the comparison is performed with a non-member (and non-friend) operator== function. In doing so, my compiler (I'm using Mingw32 GCC 4.4 with flags -O3 -g -Wall) fails to find the function and I have run out of possible reasons. In the rather large block of code below there are three classes: a Base class, a Composed class that holds a Base object, and a Nested class identical to the Composed class except that it is nested within an Outer class. Non-member operator== functions are supplied for each. These classes are in templated and untemplated forms (in their own respective namespaces), with the latter equivalent to the former specialised for unsigned integers. In main, two identical objects for each class are compared. For the untemplated case there is no problem, but for the templated case the compiler fails to find operator==. What's going on? #include <iostream> namespace templated { template<typename T> class Base { T t_; public: explicit Base(const T& t) : t_(t) {} bool equal(const Base& x) const { return x.t_==t_; } }; template<typename T> bool operator==(const Base<T> &x, const Base<T> &y) { return x.equal(y); } template<typename T> class Composed { typedef Base<T> Base_; Base_ base_; public: explicit Composed(const T& t) : base_(t) {} bool equal(const Composed& x) const {return x.base_==base_;} }; template<typename T> bool operator==(const Composed<T> &x, const Composed<T> &y) { return x.equal(y); } template<typename T> class Outer { public: class Nested { typedef Base<T> Base_; Base_ base_; public: explicit Nested(const T& t) : base_(t) {} bool equal(const Nested& x) const {return x.base_==base_;} }; }; template<typename T> bool operator==(const typename Outer<T>::Nested &x, const typename Outer<T>::Nested &y) { return x.equal(y); } } // namespace templated namespace untemplated { class Base { unsigned int t_; public: explicit Base(const unsigned int& t) : t_(t) {} bool equal(const Base& x) const { return x.t_==t_; } }; bool operator==(const Base &x, const Base &y) { return x.equal(y); } class Composed { typedef Base Base_; Base_ base_; public: explicit Composed(const unsigned int& t) : base_(t) {} bool equal(const Composed& x) const {return x.base_==base_;} }; bool operator==(const Composed &x, const Composed &y) { return x.equal(y); } class Outer { public: class Nested { typedef Base Base_; Base_ base_; public: explicit Nested(const unsigned int& t) : base_(t) {} bool equal(const Nested& x) const {return x.base_==base_;} }; }; bool operator==(const Outer::Nested &x, const Outer::Nested &y) { return x.equal(y); } } // namespace untemplated int main() { using std::cout; unsigned int testVal=3; { // No templates first typedef untemplated::Base Base_t; Base_t a(testVal); Base_t b(testVal); cout << "a=b=" << testVal << "\n"; cout << "a==b ? " << (a==b ? "TRUE" : "FALSE") << "\n"; typedef untemplated::Composed Composed_t; Composed_t c(testVal); Composed_t d(testVal); cout << "c=d=" << testVal << "\n"; cout << "c==d ? " << (c==d ? "TRUE" : "FALSE") << "\n"; typedef untemplated::Outer::Nested Nested_t; Nested_t e(testVal); Nested_t f(testVal); cout << "e=f=" << testVal << "\n"; cout << "e==f ? " << (e==f ? "TRUE" : "FALSE") << "\n"; } { // Now with templates typedef templated::Base<unsigned int> Base_t; Base_t a(testVal); Base_t b(testVal); cout << "a=b=" << testVal << "\n"; cout << "a==b ? " << (a==b ? "TRUE" : "FALSE") << "\n"; typedef templated::Composed<unsigned int> Composed_t; Composed_t c(testVal); Composed_t d(testVal); cout << "c=d=" << testVal << "\n"; cout << "d==c ? " << (c==d ? "TRUE" : "FALSE") << "\n"; typedef templated::Outer<unsigned int>::Nested Nested_t; Nested_t e(testVal); Nested_t f(testVal); cout << "e=f=" << testVal << "\n"; cout << "e==f ? " << (e==f ? "TRUE" : "FALSE") << "\n"; // Above line causes compiler error: // error: no match for 'operator==' in 'e == f' } cout << std::endl; return 0; }

    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

  • Backtracking infinite loop

    - by Greenhorn
    This is Exercise 28.1.2 from HtDP. I've successfully implemented the neighbors function and all test cases pass. (define Graph (list (list 'A (list 'B 'E)) (list 'B (list 'E 'F)) (list 'C (list 'D)) (list 'D empty) (list 'E (list 'C 'F)) (list 'F (list 'D 'G)) (list 'G empty))) (define (first-line n alist) (cond [(symbol=? (first alist) n) alist] [else empty])) ;; returns empty if node is not in graph (define (neighbors n g) (cond [(empty? g) empty] [(cons? (first g)) (cond [(symbol=? (first (first g)) n) (first-line n (first g))] [else (neighbors n (rest g))])])) ; test cases (equal? (neighbors 'A Graph) (list 'A (list 'B 'E))) (equal? (neighbors 'B Graph) (list 'B (list 'E 'F))) (equal? (neighbors 'C Graph) (list 'C (list 'D))) (equal? (neighbors 'D Graph) (list 'D empty)) (equal? (neighbors 'E Graph) (list 'E (list 'C 'F))) (equal? (neighbors 'F Graph) (list 'F (list 'D 'G))) (equal? (neighbors 'G Graph) (list 'G empty)) (equal? (neighbors 'H Graph) empty) The problem comes when I copy-paste the code from Figure 77 of the text. It is supposed to determine whether a destination node is reachable from an origin node. However it appears that the code goes into an infinite loop except for the most trivial case where the origin and destination nodes are the same. ;; find-route : node node graph -> (listof node) or false ;; to create a path from origination to destination in G ;; if there is no path, the function produces false (define (find-route origination destination G) (cond [(symbol=? origination destination) (list destination)] [else (local ((define possible-route (find-route/list (neighbors origination G) destination G))) (cond [(boolean? possible-route) false] [else (cons origination possible-route)]))])) ;; find-route/list : (listof node) node graph -> (listof node) or false ;; to create a path from some node on lo-Os to D ;; if there is no path, the function produces false (define (find-route/list lo-Os D G) (cond [(empty? lo-Os) false] [else (local ((define possible-route (find-route (first lo-Os) D G))) (cond [(boolean? possible-route) (find-route/list (rest lo-Os) D G)] [else possible-route]))])) Does the problem lie in my code? Thank you.

    Read the article

  • Combining multiple condition in single case statement in Sql Server

    - by swetha
    According to the following description i have to frame a case ...End statement in Sql server ,help me to frame a complex case..End statement to fulfil the following condition. if PAT_ENT.SCR_DT is not null and PAT_ENTRY.ELIGIBILITY is null then display display 'Favor' if PAT_ENT.SCR_DT is not null and PAT_ENTRY.EL is equal to No, display 'Error' if PAT_ENTRY.EL is Yes and DS.DES is equal to null or OFF, display 'Active' if DS.DES is equal to N, display 'Early Term' if DS.DES is equal to Y, display 'Complete' Thanks in advance.

    Read the article

  • In Scrum, should you split up the backlog in a functional backlog and a technical backlog or not?

    - by Patrick
    In our Scrum teams we use a backlog, which mostly contains functional topics, but also sometimes contains technical topics. The advantage of having 1 backlog is that it becomes easy to choose the topics for the next sprint, but I have some questions: First, to me it seems more logical to have a separate technical backlog, where developers themselves can add pure technical items, like: we could improve performance in this method, this class lacks some technical documentation, ... By having one backlog, all developers always have to pass via the product owner to have their topics added to the backlog, which seems additional, unnecessary work for the product owner. Second, if you have a product owner that only focuses on the pure-functional items, the pure-technical items (like missing technical documentation, code that erodes and should be refactored, classes that always give problems during debugging because they don't have a stable foundation and should be refactored, ...) always end up at the end of the list because "they don't serve the customer directly". By having a separate technical backlog, and time reserved in every sprint for these pure technical items, we can improve the applications functionally, but also keep them healthy inside. What is the best approach? One backlog or two?

    Read the article

  • Is "}while(0);" always equal to "break;}while(1);" ?

    - by Hernán Eche
    I have compared gcc assembler output of do{ //some code }while(0); with do{ //some code break; }while(1); The output is equal, with or without optimization but.. It's always that way? No experiment can prove theories, they can only show they are wrong And because (I hope) programming is not an experimental science, and results can be predicted (at least simple things) I want to be sure next time I reeplace a break;}while(1); for the clearer (and less risky) while(0); Thank you for reading

    Read the article

  • Counting arrays in loop

    - by Ivory Santos
    I have a loop... while($rows=mysql_fetch_array($result)) { $staff[] = $rows['staff']; $a = array_count_values($staff); $b = count($a); echo"$b<br>"; } that output 1 1 1 2 2 2 3 3 4 5 5 on my research, it must be and I wanted the result to be this way 3 (is equal to three 1's) 3 (is equal to three 2's) 2 (is equal to two 3) 1 (is equal to one 4) 2 (is equal to two 5's) any help? what I want is to get the number of same element in an array

    Read the article

  • How to setup the c++ rule of three in a virtual base class

    - by Minion91
    I am trying to create a pure virtual base class (or simulated pure virtual) my goal: User can't create instances of BaseClass. Derived classes have to implement default constructor, copy constructor, copy assignment operator and destructor. My attempt: class Base { public: virtual ~Base() {}; /* some pure virtual functions */ private: Base() = default; Base(const Base& base) = default; Base& operator=(const Base& base) = default; } This gives some errors complaining that (for one) the copy constructor is private. But i don't want this mimicked constructor to be called. Can anyone give me the correct construction to do this if this is at all possible?

    Read the article

  • Java Arrays.equals() returns false for two dimensional arrays.

    - by Achilles
    Hi there, I was just curious to know - why does Arrays.equals(double[][], double[][]) return false? when in fact the arrays have the same number of elements and each element is the same? For example I performed the following test. ` [java] double[][] a, b; int size =5; a=new double[size][size]; b=new double[size][size]; for( int i = 0; i < size; i++ ) for( int j = 0; j < size; j++ ){ a[i][j]=1.0; b[i][j]=1.0; } if(Arrays.equals(a, b)) System.out.println("Equal"); else System.out.println("Not-equal"); [/java] ` Returns false and prints "Not-equal. on the other hand, if I have something like this: [java] double[] a, b; int size =5; a=new double[size]; b=new double[size]; for( int i = 0; i < size; i++ ){ a[i]=1.0; b[i]=1.0; } if(Arrays.equals(a, b)) System.out.println("Equal"); else System.out.println("Not-equal"); } [/java] returns true and prints "Equal". Does the method only work with single dimensions? if so, is there something similar for multi-dimensional arrays in Java?

    Read the article

  • SWT Layout for absolute positioning with minimal-spanning composites

    - by pure.equal
    Hi, I'm writing a DND-editor where I can position elemtents (like buttons, images ...) freely via absolute positioning. Every element has a parent composite. These composites should span/grasp/embrace every element they contain. There can be two or more elements in the same composite and a composite can contain another composite. This image shows how it should look like. To achive this I wrote a custom layoutmanager: import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Layout; public class SpanLayout extends Layout { Point[] sizes; int calcedHeight, calcedWidth, calcedX, calcedY; Point[] positions; /* * (non-Javadoc) * * @see * org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite * , int, int, boolean) * * A composite calls computeSize() on its associated layout to determine the * minimum size it should occupy, while still holding all its child controls * at their minimum sizes. */ @Override protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { int width = wHint, height = hHint; if (wHint == SWT.DEFAULT) width = composite.getBounds().width; if (hHint == SWT.DEFAULT) height = composite.getBounds().height; return new Point(width, height); } /* * (non-Javadoc) * * @see * org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, * boolean) * * Calculates the positions and sizes for the children of the passed * Composite, then places them accordingly by calling setBounds() on each * one. */ @Override protected void layout(Composite composite, boolean flushCache) { Control children[] = composite.getChildren(); for (int i = 0; i < children.length; i++) { calcedX = calcX(children[i]); calcedY = calcY(children[i]); calcedHeight = calcHeight(children[i]) - calcedY; calcedWidth = calcWidth(children[i]) - calcedX; if (composite instanceof Composite) { calcedX = calcedX - composite.getLocation().x; calcedY = calcedY - composite.getLocation().y; } children[i].setBounds(calcedX, calcedY, calcedWidth, calcedHeight); } } private int calcHeight(Control control) { int maximum = 0; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedHeight = calcHeight(child); if (calculatedHeight > maximum) { maximum = calculatedHeight; } } return maximum; } } return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y + control.getLocation().y; } private int calcWidth(Control control) { int maximum = 0; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedWidth = calcWidth(child); if (calculatedWidth > maximum) { maximum = calculatedWidth; } } return maximum; } } return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x + control.getLocation().x; } private int calcX(Control control) { int minimum = Integer.MAX_VALUE; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedX = calcX(child); if (calculatedX < minimum) { minimum = calculatedX; } } return minimum; } } return control.getLocation().x; } private int calcY(Control control) { int minimum = Integer.MAX_VALUE; if (control instanceof Composite) { if (((Composite) control).getChildren().length > 0) { for (Control child : ((Composite) control).getChildren()) { int calculatedY = calcY(child); if (calculatedY < minimum) { minimum = calculatedY; } } return minimum; } } return control.getLocation().y; } } The problem with it is that it always positions the composite at the position (0,0). This is because it tries to change the absolute positioning into a relative one. Lets say I position a image at position (100,100) and one at (200,200). Then it has to calculate the location of the composite to be at (100,100) and spanning the one at (200,200). But as all child positions are relative to their parents I have to change the positions of the children to remove the 100px offset of the parent. When the layout gets updated it moves everything to the top-left corner (as seen in the image) because the position of the image is not (100,100) but (0,0) since I tried to remove the 100px offset of the partent. Where is my error in reasoning? Is this maybe a totally wrong approach? Is there maybe an other way to achive the desired behavior? Thanks in advance! Best regards, Ed

    Read the article

  • SQL SERVER – Introduction to PERCENTILE_DISC() – Analytic Functions Introduced in SQL Server 2012

    - by pinaldave
    SQL Server 2012 introduces new analytical function PERCENTILE_DISC(). The book online gives following definition of this function: Computes a specific percentile for sorted values in an entire rowset or within distinct partitions of a rowset in Microsoft SQL Server 2012 Release Candidate 0 (RC 0). For a given percentile value P, PERCENTILE_DISC sorts the values of the expression in the ORDER BY clause and returns the value with the smallest CUME_DIST value (with respect to the same sort specification) that is greater than or equal to P. If you are clear with understanding of the function – no need to read further. If you got lost here is the same in simple words – find value of the column which is equal or more than CUME_DIST. Before you continue reading this blog I strongly suggest you read about CUME_DIST function over here Introduction to CUME_DIST – Analytic Functions Introduced in SQL Server 2012. Now let’s have fun following query: USE AdventureWorks GO SELECT SalesOrderID, OrderQty, ProductID, CUME_DIST() OVER(PARTITION BY SalesOrderID ORDER BY ProductID ) AS CDist, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY ProductID) OVER (PARTITION BY SalesOrderID) AS PercentileDisc FROM Sales.SalesOrderDetail WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY SalesOrderID DESC GO The above query will give us the following result: You can see that I have used PERCENTILE_DISC(0.5) in query, which is similar to finding median but not exactly. PERCENTILE_DISC() function takes a percentile as a passing parameters. It returns the value as answer which value is equal or great to the percentile value which is passed into the example. For example in above example we are passing 0.5 into the PERCENTILE_DISC() function. It will go through the resultset and identify which rows has values which are equal to or great than 0.5. In first example it found two rows which are equal to 0.5 and the value of ProductID of that row is the answer of PERCENTILE_DISC(). In some third windowed resultset there is only single row with the CUME_DIST() value as 1 and that is for sure higher than 0.5 making it as a answer. To make sure that we are clear with this example properly. Here is one more example where I am passing 0.6 as a percentile. Now let’s have fun following query: USE AdventureWorks GO SELECT SalesOrderID, OrderQty, ProductID, CUME_DIST() OVER(PARTITION BY SalesOrderID ORDER BY ProductID ) AS CDist, PERCENTILE_DISC(0.6) WITHIN GROUP (ORDER BY ProductID) OVER (PARTITION BY SalesOrderID) AS PercentileDisc FROM Sales.SalesOrderDetail WHERE SalesOrderID IN (43670, 43669, 43667, 43663) ORDER BY SalesOrderID DESC GO The above query will give us the following result: The result of the PERCENTILE_DISC(0.6) is ProductID of which CUME_DIST() is more than 0.6. This means for SalesOrderID 43670 has row with CUME_DIST() 0.75 is the qualified row, resulting answer 773 for ProductID. I hope this explanation makes it further clear. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, PostADay, SQL, SQL Authority, SQL Function, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Does Google include the time to load images, for a single page, as part of the page speed?

    - by Pure.Krome
    we all know that Google's affects your page rank with the load time of a page. How? That's part of the secret sauce. But we know that page speed is a serious factor. So - what is considered the speed of a page? Is it just the first (and main) html file which the GET receives? Or does it also include loading of images as part of that speed. so for example... GET /index.htm <- takes 0.45 seconds to retrieve (including DNS lookup before). robot parses page.. see's there's a single main image.... GET /img/main.png <- takes 5 seconds to download. is the page speed for that resource, 0.45 seconds OR 5.45 seconds? I understand Javascript is not fired .. but are any of these external resources all downloaded and part of the page speed?

    Read the article

  • Google Analytics - Unable to get GA Tracking

    - by Pure.Krome
    We've been using GA for a few years with no probs. About 2-3 weeks ago we tried to clean up some of our tracking and on one of our profiles, it's not working anymore (since oct 10.) First, some context then some GA Debugging code. 1. Context. We have the following setup: different root domains AND different sub-domains on one of the root domains. www.website.com www.website.com.au www.anotherWebsite.com foo.website.com baa.website.com So what we're doing is the following: each root domain and each sub-domain get their own tracking code. This way we can allow separate people (from outside our company) to access only their own data. Eg. a manager for foo.website.com can only see data related to that domain .. and see data on the other domains. Have a last account which is the SUM of all the domains. this is for us. so we can see total numbers. So to do this, we have two trackers that fire off, on the page. the individual accounts all work fine - they seem to be tracking data ok. the 'global' account is not working and this gives us the = Tracking Not Installed error. This has been going on since oct 10. So the wait 24/48/72 hours thing is waaaaay over. 2. GA Debug code. Installing GA Debug chrome extension gives the following output. I've tried to hide anything that could be considered secret. UA-XXXXX34-1 == Global account (which isn't working any more). UA-XXXXX34-11 == Specific account for www.website.com _gaq.push processing "_setAccount" for args: "[UA-XXXXX34-1]": ga_debug.js:18 _gaq.push processing "_setDomainName" for args: "[website.com]": ga_debug.js:18 _gaq.push processing "_setAllowLinker" for args: "[true]": ga_debug.js:18 _gaq.push processing "_trackPageview" for args: "[]": ga_debug.js:18 Track Pageview ga_debug.js:18 Tracking beacon sent! utmwv=--snipped-- Account ID : UA-XXXX234-1 Page Title : Some page title Host Name : www.website.com Page : / Referring URL : - Hit ID : 1923583969 Visitor ID : 785310647 Session Count : 51 Session Time - First : Thu Aug 23 2012 15:20:17 GMT 1000 (AUS Eastern Standard Time) Session Time - Last : Mon Oct 29 2012 11:41:46 GMT 1100 (AUS Eastern Summer Time) Session Time - Current : Mon Oct 29 2012 12:19:23 GMT 1100 (AUS Eastern Summer Time) Campaign Time : Thu Aug 23 2012 15:20:17 GMT 1000 (AUS Eastern Standard Time) Campaign Session : 1 Campaign Count : 1 Campaign Source : (direct) Campaign Medium : (none); Campaign Name : (direct) Language : en-gb Encoding : UTF-8 Flash Version : 11.4 r31 Java Enabled : true Screen Resolution : 1050x1680 Browser Size : 1033x861 Color Depth : 32-bit Ga.js Version : 5.3.7d Cachebuster : 1846514973 ga_debug.js:18 _gaq.push processing "_setAccount" for args: "[UA-XXXX234-11]": ga_debug.js:18 _gaq.push processing "_setDomainName" for args: "[website.com]": ga_debug.js:18 _gaq.push processing "_setAllowLinker" for args: "[true]": ga_debug.js:18 _gaq.push processing "_trackPageview" for args: "[]": ga_debug.js:18 Track Pageview ga_debug.js:18 Tracking beacon sent! utmwv=--snipped-- Account ID : UA-XXXX234-11 Page Title : SomePageTitle Host Name : www.website.com Page : / Referring URL : - Hit ID : 1923583969 Visitor ID : 785310647 Session Count : 51 Session Time - First : Thu Aug 23 2012 15:20:17 GMT 1000 (AUS Eastern Standard Time) Session Time - Last : Mon Oct 29 2012 11:41:46 GMT 1100 (AUS Eastern Summer Time) Session Time - Current : Mon Oct 29 2012 12:19:23 GMT 1100 (AUS Eastern Summer Time) Campaign Time : Thu Aug 23 2012 15:20:17 GMT 1000 (AUS Eastern Standard Time) Campaign Session : 1 Campaign Count : 1 Campaign Source : (direct) Campaign Medium : (none); Campaign Name : (direct) Language : en-gb Encoding : UTF-8 Flash Version : 11.4 r31 Java Enabled : true Screen Resolution : 1050x1680 Browser Size : 1033x861 Color Depth : 32-bit Ga.js Version : 5.3.7d Cachebuster : 1580443754 and this is the js code he have. BTW, it is inside a <head></head> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push( ['_setAccount', 'UA-XXXX234-1'], ['_setDomainName', 'website.com'], ['_setAllowLinker', true], ['_trackPageview'] ,['b._setAccount','UA-XXXX234-11'], ['b._setDomainName','website.com'], ['b._setAllowLinker',true], ['b._trackPageview'] ); (function () { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> Finally, I've triple checked that the UA is the correct text. and yes, the global account is -1 and the specific domain is -11. Anyone have any suggestions to help?

    Read the article

  • SEO + international sites? country.domain.com or domain.country?

    - by Pure.Krome
    Hi folks, is it better to have seperate country specific domains (which costs more money) or subdomains which define the country, for better SEO? eg. stackoverflow.com stackoverflow.com.au stackoverflow.co.uk vs stackoverflow.com au.stackoverflow.com uk.stackoverflow.com Assumption: int the search engine web master tools, each subdomain are associated to a country. eg. au.stackoverflow.com is associated to the country Australia. cheers! Update I understand that both methods do work, especially when i utilize the assumption, listed above. The question is about: Which method is better? Is there such a small SEO difference between them? Is the first method way way way better than the second with getting better SEO results? Update #2 A number of folks have suggested that the following is a good/better approach: stackoverflow.com/ stackoverflow.com/au stackoverflow.com/uk By adding a country specific iso code to the end of the url/the first folder of the domain can be recognised as the country. But a number of SEO mates have suggested that this is a valuable waste of folder level space. Er.. how can i explain. Ok, it's been suggested by some SEO experts that if the number of levels or folders in the domain exceeds 5 then the page drops dramatically in importance. Basically, you don't want to make it deep. As such, adding the country as the first level can be considered a waste, especially when it can be handled by the domain OR subdomain - hence the question :) So, any more thoughts on this? (Maybe SO is the wrong place to ask this question?)

    Read the article

  • Formula to search for a value in a range of cells

    - by Sacha
    I have a spreadsheet with several cells in one column. Each cell has identical conditional formatting: In 1 cell value equal to ='Y' In 2 cell value equal to ='N' In 3 cell value equal to ='?' What I would like to achieve is, if all 7 cells contain "Y" as the option then a separate cell will display "Yes", but if any of the cells contain "N" as the selection then the separate cell will display "NO". How can I achieve this?

    Read the article

  • CentOS server. What does it mean when the total used RAM does not equal the sum of RES?

    - by Michael Green
    I'm having a problem with a virtual hosted server running CentOS. In the past month a process (java based) that had been running fine started having problems getting memory when the JVM was started. One strange thing I've noticed is that when I start the process, the PID says it is using 470mb of RAM while the 'used' memory immediately drops by over a 1GB. If I run 'top', the total RES used across all processes falls short of the 'used' listed at the top by almost 700mb. The support person says this means I have a memory leak with my process. I don't know what to believe because I would expect a memory leak to simply waste the memory the process is allocated not to consume additional memory that doesn't show up using 'top'. I'm a developer and not a server guy so I'm appealing to the experts. To me, if the total RES memory doesn't add up to the total 'used' it indicates that something is wrong with my virtual server set-up. Would you also suspect a memory leaking java process in this case? If I use free before: total used free shared buffers cached Mem: 2097152 149264 1947888 0 0 0 -/+ buffers/cache: 149264 1947888 Swap: 0 0 0 free after: total used free shared buffers cached Mem: 2097152 1094116 1003036 0 0 0 -/+ buffers/cache: 1094116 1003036 Swap: 0 0 0 So it looks as though the process is using (or causing to be used) nearly 1GB of RAM. Since the process (based on top is only using 452mb, does that mean that the kernal is all of a sudden using an additional 500mb?

    Read the article

  • Common practice for higher-order-polymorphism in scala

    - by raichoo
    Hi, I'm trying to grasp higher-order-polymophism in scala by implementing a very basic interface that describes a monad but I come across a problem that I don't really understand. I implemented the same with C++ and the code looks like this: #include <iostream> template <typename T> class Value { private: T value; public: Value(const T& t) { this->value = t; } T get() { return this->value; } }; template < template <typename> class Container > class Monad { public: template <typename A> Container<A> pure(const A& a); }; template <template <typename> class Container> template <typename A> Container<A> Monad<Container>::pure(const A& a) { return Container<A>(a); } int main() { Monad<Value> m; std::cout << m.pure(1).get() << std::endl; return 0; } When trying to do the same with scala I fail: class Value[T](val value: T) class Monad[Container[T]] { def pure[A](a: A): Container[A] = Container[A](a) } object Main { def main(args: Array[String]): Unit = { val m = new Monad[Value] m.pure(1) } } The compiler complains about: [raichoo@lain:Scala]:434> scalac highorder.scala highorder.scala:5: error: not found: value Container Container[A](a) ^ one error found What am I doing wrong here? There seems to be a fundamental concept I don't seem to understand about scala typeconstructors. Regards, raichoo

    Read the article

  • Indexing community images for google image search

    - by Vittorio Vittori
    Hi, I'm trying to understand how can I do to let my site be reachable from google image search spiders. I like how last.fm solution, and I thought to use a technique like his staff do to let google find artists images on their pages. When I'm looking for an artist and I search it on google image search, as often as not I find an image from last.fm artists page, I make an example: If I search the band Pure Reason Revolution It brings me here, the artist's image page http://www.last.fm/music/Pure+Reason+Revolution/+images/4284073 Now if I take a look to the image file, i can see it's named: http://userserve-ak.last.fm/serve/500/4284073/Pure+Reason+Revolution+4.jpg so if I try to undertand how the service works I can try to say: http://userserve-ak.last.fm/serve/ the server who serve the images 500/ the selected size for the image 4284073/ the image id for database Pure+Reason+Revolution+4.jpg the image name I thought it's difficult to think the real filename for the image is Pure+Reason+Revolution+4.jpg for image overwrite problems when an user upload it, in fact if I digit: http://userserve-ak.last.fm/serve/500/4284073.jpg I probably find the real image location and filename With this tecnique the image is highly reachable from search engines and easily archived. My question is, does exist some guide or tutorial to approach on this kind of tecniques, or something similar?

    Read the article

  • Prepare community images for google image search indexing

    - by Vittorio Vittori
    Hi, I'm trying to understand how can I do to let my site be reachable from google image search spiders. I like how last.fm solution, and I thought to use a technique like his staff do to let google find artists images on their pages. When I'm looking for an artist and I search it on google image search, as often as not I find an image from last.fm artists page, I make an example: If I search the band Pure Reason Revolution It brings me here, the artist's image page http://www.last.fm/music/Pure+Reason+Revolution/+images/4284073 Now if I take a look to the image file, i can see it's named: http://userserve-ak.last.fm/serve/500/4284073/Pure+Reason+Revolution+4.jpg so if I try to undertand how the service works I can try to say: http://userserve-ak.last.fm/serve/ the server who serve the images 500/ the selected size for the image 4284073/ the image id for database Pure+Reason+Revolution+4.jpg the image name I thought it's difficult to think the real filename for the image is Pure+Reason+Revolution+4.jpg for image overwrite problems when an user upload it, in fact if I digit: http://userserve-ak.last.fm/serve/500/4284073.jpg I probably find the real image location and filename With this tecnique the image is highly reachable from search engines and easily archived. My question is, does exist some guide or tutorial to approach on this kind of tecniques, or something similar?

    Read the article

  • Prepare your site images for google image search indexing

    - by Vittorio Vittori
    Hi, I'm trying to understand how can I do to let my site be reachable from google image search spiders. I like how last.fm solution, and I thought to use a technique like his staff do to let google find artists images on their pages. When I'm looking for an artist and I search it on google image search, as often as not I find an image from last.fm artists page, I make an example: If I search the band Pure Reason Revolution It brings me here, the artist's image page http://www.last.fm/music/Pure+Reason+Revolution/+images/4284073 Now if I take a look to the image file, i can see it's named: http://userserve-ak.last.fm/serve/500/4284073/Pure+Reason+Revolution+4.jpg so if I try to undertand how the service works I can try to say: http://userserve-ak.last.fm/serve/ the server who serve the images 500/ the selected size for the image 4284073/ the image id for database Pure+Reason+Revolution+4.jpg the image name I thought it's difficult to think the real filename for the image is Pure+Reason+Revolution+4.jpg for image overwrite problems when an user upload it, in fact if I digit: http://userserve-ak.last.fm/serve/500/4284073.jpg I probably find the real image location and filename With this tecnique the image is highly reachable from search engines and easily archived. My question is, does exist some guide or tutorial to approach on this kind of tecniques, or something similar?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >