Search Results

Search found 5784 results on 232 pages for 'points'.

Page 18/232 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • Using outer query result in a subquery in postgresql

    - by brad
    I have two tables points and contacts and I'm trying to get the average points.score per contact grouped on a monthly basis. Note that points and contacts aren't related, I just want the sum of points created in a month divided by the number of contacts that existed in that month. So, I need to sum points grouped by the created_at month, and I need to take the count of contacts FOR THAT MONTH ONLY. It's that last part that's tricking me up. I'm not sure how I can use a column from an outer query in the subquery. I tried something like this: SELECT SUM(score) AS points_sum, EXTRACT(month FROM created_at) AS month, date_trunc('MONTH', created_at) + INTERVAL '1 month' AS next_month, (SELECT COUNT(id) FROM contacts WHERE contacts.created_at <= next_month) as contact_count FROM points GROUP BY month, next_month ORDER BY month So, I'm extracting the actual month that my points are being summed, and at the same time, getting the beginning of the next_month so that I can say "Get me the count of contacts where their created at is < next_month" But it complains that column next_month doesn't exist This is understandable as the subquery knows nothing about the outer query. Qualifying with points.next_month doesn't work either. So can someone point me in the right direction of how to achieve this? Tables: Points score | created_at 10 | "2011-11-15 21:44:00.363423" 11 | "2011-10-15 21:44:00.69667" 12 | "2011-09-15 21:44:00.773289" 13 | "2011-08-15 21:44:00.848838" 14 | "2011-07-15 21:44:00.924152" Contacts id | created_at 6 | "2011-07-15 21:43:17.534777" 5 | "2011-08-15 21:43:17.520828" 4 | "2011-09-15 21:43:17.506452" 3 | "2011-10-15 21:43:17.491848" 1 | "2011-11-15 21:42:54.759225" sum, month and next_month (without the subselect) sum | month | next_month 14 | 7 | "2011-08-01 00:00:00" 13 | 8 | "2011-09-01 00:00:00" 12 | 9 | "2011-10-01 00:00:00" 11 | 10 | "2011-11-01 00:00:00" 10 | 11 | "2011-12-01 00:00:00"

    Read the article

  • Designing a class in such a way that it doesn't become a "God object"

    - by devoured elysium
    I'm designing an application that will allow me to draw some functions on a graphic. Each function will be drawn from a set of points that I will pass to this graphic class. There are different kinds of points, all inheriting from a MyPoint class. For some kind of points it will be just printing them on the screen as they are, others can be ignored, others added, so there is some kind of logic associated to them that can get complex. How to actually draw the graphic is not the main issue here. What bothers me is how to make the code logic such that this GraphicMaker class doesn't become the so called God-Object. It would be easy to make something like this: class GraphicMaker { ArrayList<Point> points = new ArrayList<Point>(); public void AddPoint(Point point) { points.add(point); } public void DoDrawing() { foreach (Point point in points) { if (point is PointA) { //some logic here else if (point is PointXYZ) { //...etc } } } } How would you do something like this? I have a feeling the correct way would be to put the drawing logic on each Point object (so each child class from Point would know how to draw itself) but two problems arise: There will be kinds of points that need to know all the other points that exist in the GraphicObject class to know how to draw themselves. I can make a lot of the methods/properties from the Graphic class public, so that all the points have a reference to the Graphic class and can make all their logic as they want, but isn't that a big price to pay for not wanting to have a God class?

    Read the article

  • Need the co-ordinates of innerPolygon

    - by user960567
    Let say I have this diagram, Given that i have all the co-ordinates of outer polygon and the distance between inner and outer polygon is d is also given. How to calculate the inner polygon co-ordinates? Edit: I was able to solved the issue by getting the mid-points of all lines. From these mid-points I can move d distance, So I can get three points. No I have 3 points and 3 slopes. From this, I can get three new equations. Simultaneously, solving the equation get the 3 points.

    Read the article

  • Nameserver Problem

    - by CrazyCodeZ
    I recently bought a new VPS , and i was trying to set private nameservers in my domain cpanel. I went ahead and added 4 A records ns1.mydomain.com - points to my ip ns2.mydomain.com - points to my ip www.mydomain.com - points to my ip mydomain.com - points to my ip and changed the nameservers to ns1 & ns2.mydomain.com the problem is that now while typing www.ns1.mydomain.com and www.ns2.mydomain.com in browser it points to the correct IP address but the www.mydomain.com is saying an Error The webpage at http://demiracles.com/ might be temporarily down or it may have moved permanently to a new web address. Error 137 (net::ERR_NAME_RESOLUTION_FAILED): Unknown error. Error message in chrome is above. Please help me.

    Read the article

  • Android - How to scan Access Points and select strongest signal?

    - by Donal Rafferty
    I am currently trying to write a class in Android that will Scan for access points, calculate which access point has the best signal and then connect to that access point. So the application will be able to scan on the move and attach to new access points on the go. I have the scanning and calculation of the best signal working. But when it comes to attaching to the best access point I am having trouble. It appears that enableNetwork(netid, othersTrueFalse) is the only method for attaching to an Access point but this causes problems as from my Scan Results I am not able to get the id of the access point with the strongest signal. This is my code: public void doWifiScan(){ scanTask = new TimerTask() { public void run() { handler.post(new Runnable() { public void run() { sResults = wifiManager.scan(getBaseContext()); if(sResults!=null) Log.d("TIMER", "sResults count" + sResults.size()); ScanResult scan = wifiManager.calculateBestAP(sResults); wifiManager.addNewAccessPoint(scan); } }); }}; t.schedule(scanTask, 3000, 30000); } public ScanResult calculateBestAP(List<ScanResult> sResults){ ScanResult bestSignal = null; for (ScanResult result : sResults) { if (bestSignal == null || WifiManager.compareSignalLevel(bestSignal.level, result.level) < 0) bestSignal = result; } String message = String.format("%s networks found. %s is the strongest. %s is the bsid", sResults.size(), bestSignal.SSID, bestSignal.BSSID); Log.d("sResult", message); return bestSignal; } public void addNewAccessPoint(ScanResult scanResult){ WifiConfiguration wc = new WifiConfiguration(); wc.SSID = '\"' + scanResult.SSID + '\"'; //wc.preSharedKey = "\"password\""; wc.hiddenSSID = true; wc.status = WifiConfiguration.Status.ENABLED; wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN); int res = mainWifi.addNetwork(wc); Log.d("WifiPreference", "add Network returned " + res ); boolean b = mainWifi.enableNetwork(res, false); Log.d("WifiPreference", "enableNetwork returned " + b ); } When I try to use addNewAccessPoint(ScanResult scanResult) it just adds another AP to the list in the settings application with the same name as the one with the best signal, so I end up with loads of duplicates and not actually attaching to them. Can anyone point me in the direction of a better solution?

    Read the article

  • Is a line formed by two points greater than 90 degrees off of the horzontal.

    - by Scott Chamberlain
    I am trying to find out if a line defined by two points is greater than or equal to 90 degrees compared to the horizontal. Here is the code I used bool moreThan90 = false; double angle = Math.Atan((double)(EndingLocation.Y - Location.Y) / (double)(EndingLocation.X - Location.X)); if (angle >= Math.PI / 2.0 || angle <= -Math.PI / 2.0) moreThan90 = true; Did I do this correctly or is there a better built in function in .Net that will find this?

    Read the article

  • How do you delete a pointer without deleting the data the pointer points to?

    - by Faken
    I have a pointer that points to an array and another pointer referencing the same array. How do i delete any one of those pointers without killing the array such that the second undeleted pointer still works? for example: int* pointer1 = new int [1000]; int* pointer2; pointer2 = pointer1; Now i want to get rid of pointer1, how would i do it such that i can continue to access the array normaly through pointer2?

    Read the article

  • Check if a pointer points to allocated memory on the heap.

    - by Ugo
    Ok, I know this question seems to have been asked many times on stackoverflow. but please read Well the answer for any address is "No you can't" but the question here is to know if a pointer points to a piece of memory allocated with malloc/new. Actually I think it could be easily implemented overriding malloc/free and keeping track of allocated memory ranges. Do you know a memory management library providing this specific tool ?

    Read the article

  • JavaScript - question regarding data structure

    - by orokusaki
    I'm trying to calculate somebody's bowel health based on a points system. I can edit the data structure, or logic in any way. I'm just trying to write a function and data structure to handle this ability. Pseudo calculator function: // Bowel health calculator var points = 0; If age is from 30 and 34: points += 1 If age is from 35 and 40: points += 2 If daily BMs is from 1 and 3: points -= 1 If daily BMs is from 4 and 6: points -= 2 return points; Pseudo data structure: var points_map = { age: { '30-34': 1, '35-40': 2 }, dbm: { '1-3': -1, '4-6': -2 } }; I have a full spreadsheet of data like this, and I am trying to write a DRY version of code and a DRY version of this data (ie, probably not a string for the '30-34', etc) in order to handle this sort of thing without a humongous number of switch statements.

    Read the article

  • PHP MYSQL query result "RANKING"

    - by fkessler
    Hi, I need to get a list of users Ranking by points and from my command line (MySQL) is was able to generate the necessary code: SET @rank=0; SELECT rank, iduser, pontos FROM ( SELECT @rank:=@rank+1 AS rank, SUM(points.points) AS pontos, points.iduser, users.name, users.idade FROM points INNER JOIN users ON (points.iduser = users.id) WHERE (users.idade >= %s) AND (users.idade <= %s) GROUP BY points.iduser ORDER BY pontos DESC) AS totals WHERE iduser = %s The problem is that I need this to run on AMFPHP and I´ve tested it in a test PHP file and seems that I can´t use the SET and SELECT in the same "mysql_query". I´ve looked and some used to mysql_query to do this (I´ve tested it and it works), but can I trust this to be effective and error free? Does it work like in MySQL transactions or setting the @rank in a seperated query may cause unexpected results?

    Read the article

  • db optimization - have a total field or query table?

    - by Dorian Fife
    I have an app where users get points for actions they perform - either 1 point for an easy action or 2 for a difficult one. I wish to display to the user the total number of points he got in my app and the points obtained this week (since Monday at midnight). I have a table that records all actions, along with their time and number of points. I have two alternatives and I'm not sure which is better: Every time the user sees the report perform a query and sum the points the user got Add two fields to each user that records the number of points obtained so far (total and weekly). The weekly points value will be set to 0 every Monday at midnight. The first option is easier, but I'm afraid that as I'll get many users and actions queries will take a long time. The second option bares the risk of inconsistency between the table of actions and the summary values. I'm very interested in what you think is the best alternative here. Thanks, Dorian

    Read the article

  • Site migration and SEO impact

    - by John Smith
    I'd greatly appreciate a response on the following question relating to site migration and SEO impact. Here's some background on how my domain name and site is currently configured: My domain name provider has the following settings: host name @ is an A NAME record and points to IP address x.x.x.x host name www is an A NAME record and points to IP address x.x.x.x sub-domain host name new.example.com is an A NAME record and points to IP address x.x.x.x My hosting provider has the following settings: host record @ is an A NAME record and points to IP address x.x.x.x, folder home/public_html/old host record www is a C NAME record and points to example.com sub-domain host record new.example.com points to home/public_html/new I want to: point the domain (example.com AND www.example.com) to the content hosted under folder home/public_html/new, which is currently the content directory for new.example.com retire the content hosted under folder home/public_html/old retire the sub-domain host record new.example.com I believe the easiest method of doing this, is: removing the sub-domain host record new.example.com; and changing the following line in the .htaccess file in home/public_html from # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/old/ to # Change 'subdirectory' to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/new/ But I don't understand how this will impact my SERP - ideally, I'd like it to remain the same. Research on this topic resulted in the following Google page, which was no help, and this related StackExchange question, which suggests that this should not affect my SERP (at least, not permanently). But I wanted to make certain with a more specific example, and hopefully contribute to the community at the same time. I'd appreciate any feedback on this. Is there a better/recommended method to migrate sites this way? Is there an SEO impact?

    Read the article

  • Algorithm to reduce calls to mapping API

    - by aidan
    A random distribution of points lies on a map. This data lies behind an API, and I want to grab the complete set of points within a given bounding box. I can query the API with the bounding box and the API will return the set of points that fall within that box. The problem is that the API will limit the result set to 10 items, with no pagination and no indication if there are more points that have been omitted. So I made a recursive algorithm that takes a bounding box and requests the points that lie within it. If the result set is exactly 10 items, then I split the bounding box into four quadrants and recurse. It works fine but my question is this: if want to minimize the number of API calls, what is the optimal way to split the bounding box? Splitting it into quadrants was just an arbitrary decision. When there are a lot of points on the map, I have to drill down many levels before I start getting meaningful results. So I imagine it might be faster to split the box into, say, 9, 16, or more sections. But if I do that, then I eventually get to a point where a lot of requests are returning 0 results which isn't so efficient. Also, does the size of the limit on the results set affect the answer? (This is all assuming that I have no prior knowledge of nominal point density in the bounding box)

    Read the article

  • How to paint fully transparent pixels/points in P2D mode?

    - by netzwerg
    According to the Processing Reference, stroke(gray, alpha) allows to set the color and opacity of the stroke. With the default color mode, an alpha value of 255 denotes full opacity, while a value of 0 should correspond to complete transparency. While this works with the (default) JAVA2D renderer, I can't seem to paint fully transparent points in P2D mode. This code clearly renders a pixel at the center of the canvas, even though the alpha value is set to 0 (fully transparent): public class Transparency extends PApplet { @Override public void setup() { size(200, 200, P2D); } @Override public void draw() { stroke(0, 0); point(width / 2, height / 2); } public static void main(String[] args) { PApplet.main(new String[] { Transparency.class.getSimpleName() }); } } What's wrong here?

    Read the article

  • Convert graph in to data points using Mechanical Turk?

    - by user224303
    I looked around but did not see anyone using Mechanical Turk for this. I've heard of the service, but never used it before. I need to take the following graph and digitize it so I get a list of data points for each line (noting that there are two Y-axes, and thus depends on which line we are talking about). This is pretty time consuming for me, and I saw other posts on StackOverflow about digitizing software doing a poor job at this. Would Mechanical Turk be well suited to my task? Here is the graph for reference: http://www.yourpicturehost.com/dyno_hbspeed.jpg

    Read the article

  • Given GPS coordinates, how do I find nearby landmarks or points-of-interest?

    - by stackoverflowuser2010
    I just bought a Google Nexus One smartphone, and I want to write a small Android application for fun. Suppose I can get my current GPS coordinates, so then how can I programmatically find nearby landmarks or points-of-interest within some radius? Is there an API to get GPS geo-tagged landmarks, like in Google Earth's database? For example, if I'm in downtown Chicago, my program would point me to all the "tourist" things to visit in that city. Ideally, it would all run on my smartphone, but if necessary, I can have the smartphone query a webserver, which would then run more queries.

    Read the article

  • checking whether 4 points in a plane define a square ??

    - by osabri
    how to check whether 4 points in the plane define a square? what's the function which given a point and a value of the area of a square as input parameters returns four squares(define a corresponding type) with sides parallel to the x axis and y axis this how i start: #include <stdio.h> #include<math.h> struct point{ float x; float y; } typedef struct point POINT; struct square{ struct point p1; struct point p2; struct point p3; struct point p4; } typedef struct square SQUARE; int main() { int point; printf("point coordinate"); printf("\n\n"); printf("enter data\n");

    Read the article

  • How do I interpolate between points without going beyond them?

    - by user1774893
    I have data of variable lengths (reaching movements recorded in 2D) and want to create a function that will resample this data to a uniform length (500 samples). However, I want matlab to only resample between the maximum and minimum values given, without adding any additional distance. For instance, if I resample the matrix [1:1:10], the resampled matrix should have a minimum value of 1 and a maximum value of 10. So far I've tried the following: x = [1:1:10]; interp(x, 500 / length(x)); This, however, gives values above my maximum specified value of 10. Is there any way I can get matlab to resample/interpolate solely between two points, without extending beyond them?

    Read the article

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