Search Results

Search found 8354 results on 335 pages for 'welton v3 50'.

Page 66/335 | < Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >

  • How to remove an item from a structure array in C++?

    - by Antik
    I have the following array structure (linked list): struct str_pair { char ip [50] ; char uri [50] ; str_pair *next ; } ; str_pair *item; I know to create a new item, I need to use item = new str_pair; However, I need to be able to loop through the array and delete a particular item. I have the looping part sorted. But how do I delete an item from an array of structures?

    Read the article

  • MySQL Query Ranking

    - by eft0
    Hey there, I have this MySQL query for list a "Vote Ranking" for "Actions" and it work fine, but I want what the "id_user" doesn't repeat, like made a "DISTINCT" in this field. SELECT count(v.id) votos, v.id_action, a.id_user, a.id_user_to, a.action, a.descripcion FROM votes v, actions a WHERE v.id_action = a.id GROUP BY v.id_action ORDER BY votos DESC The result: votes act id_user 3 3 745059251 2 20 1245069513 2 23 1245069513 2 26 100000882722297 2 29 1245069513 2 44 1040560484 2 49 1257441644 2 50 1040560484 The expected result votes act id_user 3 3 745059251 2 20 1245069513 2 26 100000882722297 2 44 1040560484 2 49 1257441644 2 50 1040560484 Thanks in advanced!

    Read the article

  • alternative to lag SQL command

    - by mahen
    I have a table which has a table like this. Month-----Book_Type-----sold_in_Dollars Jan----------A------------ 100 Jan----------B------------ 120 Feb----------A------------ 50 Mar----------A------------ 60 Mar----------B------------ 30 and so on I have to calculate the expected sales for each month and book type based on the last 2 months sales. So for March and type A it would be (100+50)/2 = 75 For March and type B it is 120/1 since no data for Feb is there. I was trying to use the lag function but it wouldn't work since there is data missing in a few rows. Any ideas on this?

    Read the article

  • Forward traffic between two VLANs.

    - by Michael
    I have a small network with two VLANs. One is our internal network for basic file sharing, etc and the other is a public wifi network for our customers. The internal network is configured as 192.168.1.x and the public wifi is 192.168.11.x. We have one printer at 192.168.1.50. I would like to be able to have that printer available to our customer at 192.168.11.50. I suspect it can be done with iptables, but I'm brand new to it and I just can seem to work out the syntax. Can anyone offer any help? Oh, this is all running on a wrt54g router running Tomato.

    Read the article

  • How do I erase printed characters in a console application(Linux)?

    - by Binny V A
    Hi all, I am creating a small console app that needs a progress bar. Something like... Conversion: 175/348 Seconds |========== | 50% My question is, how do you erase characters already printed to the console? When I reach the 51st percentage, I have to erase this line from the console and insert a new line. In my current solution, this is what happens... Conversion: 175/348 Seconds |========== | 50% Conversion: 179/348 Seconds |========== | 52% Conversion: 183/348 Seconds |========== | 54% Conversion: 187/348 Seconds |=========== | 56% Code I use is... print "Conversion: $converted_seconds/$total_time Seconds $progress_bar $converted_percentage%\n"; I am doing this in Linux using PHP(only I will use the app - so please excuse the language choice). So, the solution should work on the Linux platform - but if you have a solution that's cross platform, that would be preferable.

    Read the article

  • getting smallest of coordinates that differ by N or more in Python

    - by user248237
    suppose I have a list of coordinates: data = [[(10, 20), (100, 120), (0, 5), (50, 60)], [(13, 20), (300, 400), (100, 120), (51, 62)]] and I want to take all tuples that either appear in each list in data, or any tuple that differs from all tuples in lists other than its own by 3 or less. How can I do this efficiently in Python? For the above example, the results should be: [[(100, 120), # since it occurs in both lists (10, 20), (13, 20), # since they differ by only 3 (50, 60), (51, 60)]] (0, 5) and (300, 400) would not be included, since they don't appear in both lists and are not different from elements in lists other than their own by 3 or less. how can this be computed? thanks.

    Read the article

  • pthread_exit return value

    - by Manty
    This is surprising for me. void * thread_func(void *arg) { pthread_exit(&ret); } int main(void) { pthread_t thr; int *exit_status; pthread_create(&thr, NULL, thread_func, NULL); sleep(2); pthread_join(thr, (void **)&exit_status); printf("value of exit status - %d\n", *exit_status); ret = 20; pthread_join(thr, (void **)&exit_status); printf("value of exit status - %d\n", *exit_status); return 0; } The output is value of exit status - 50 value of exit status - 20 I was expecting both the times the exit_status would be the actual exit value(50 in my case) of the thread. Instead it is just returning the value of the global variable which I used for pthread_exit. Is it not a bug?

    Read the article

  • Seasonal Pricing for a Hotel Room

    - by Laykes
    I am trying to manage seasonal prices for hotel rooms. The only way that I can think of doing it would be to use: | DayDate |EndDate | A | B ----------------------------------------------- | 2010/07/1 |2010/07/2 | 200 | 40 | 2010/07/3 |2010/07/4 | 150 | 40 | 2010/07/5 |2010/07/5 | 150 | 50 | 2010/07/6 |2010/07/7 | 200 | 50 | 2010/07/8 |2010/07/9 | 100 | 60 etc.. (table taken from another question). The problem is: I don't want my seasons to be year specific. Seasons for rooms shouldn't change year on year. I don't want my users to have to enter the seasonal information several times. I am also going to have thousands of rooms, so I don't know a way to make this easily manageable. I'm using mysql and php.

    Read the article

  • Python to C# Conversion of RGBA values not working

    - by clangers
    I'm currently converting some python code to C#, and I'm having an issue with the RGBA C# libraries # Original Python Code: d = math.sqrt( (x - size/2.0)**2 + (y - size/2.0)**2 ) rgbVal = int(200*d/md + 50) rgba = (0,0,0, 255 - rgbVal) img.putpixel((x,y), rgba) // My C# Code double d = Math.Sqrt(Math.Pow((x - DotSize / 2.0), 2) + Math.Pow((y - DotSize / 2.0), 2)); int rgbVal = (int) (200 * d / md + 50); Color color = Color.FromArgb(255 - rgbVal, 0, 0, 0); // ** ERROR ** img.SetPixel(x,y, color); At both instances of the code d is equal to 106 and md is equal to 53. However the resulting rgbVal value is 450. This would obviously mean that 255 - 450 is -195, which causes an error to be thrown as each individual value must be between 0 and 255. Anyone have any idea how I can fix this. Please note that the data is the same when running both the python and C# versions.

    Read the article

  • In Django, using __init__() method of non-abstract parent model to record class name of child model

    - by k-g-f
    In my Django project, I have a non-abstract parent model defined as follows: class Parent(models.Model): classType = models.CharField(editable=False,max_length=50) and, say, two children models defined as follows: class ChildA(Parent): parent = models.OneToOneField(Parent,parent_link=True) class ChildB(Parent): parent = models.OneToOneField(Parent,parent_link=True) Each time I create an instance of ChildA or of ChildB, I'd like the classType attribute to be set to the strings "ChildA" or "ChildB" respectively. What I have done is added an _ _ init_ _() method to Parent as follows: class Parent(models.Model): classType = models.CharField(editable=False,max_length=50) def __init__(self,*args,**kwargs): super(Parent,self).__init__(*args,**kwargs) self.classType = self.__class__.__name__ Is there a better way to implement and achieve my desired result? One downside of this implementation is that when I have an instance of the Parent, say "parent", and I want to get the type of the child object linked with "parent", calling "parent.classType" gives me "Parent". In order to get the appropriate "ChildA" or "ChildB" value, I need to write a "_getClassType()" method to wrap a custom sql query.

    Read the article

  • MySql paging; "Showing result-set" of "total found" help

    - by Camran
    I need a formula for showing results on my classifieds website. I am now done with the paging of records, but this formula for showing results remains. I want it like this: Showing 1-50 of 123 found. Now what is the formula for this? I have these variables which should be enough I think: $results_per_page = 50; //results per page $page = 1; //current page Also a variable called $num_total contains the total nr of hits, in this case 123. Thanks

    Read the article

  • Gradient boosting predictions in low-latency production environments?

    - by lockedoff
    Can anyone recommend a strategy for making predictions using a gradient boosting model in the <10-15ms range (the faster the better)? I have been using R's gbm package, but the first prediction takes ~50ms (subsequent vectorized predictions average to 1ms, so there appears to be overhead, perhaps in the call to the C++ library). As a guideline, there will be ~10-50 inputs and ~50-500 trees. The task is classification and I need access to predicted probabilities. I know there are a lot of libraries out there, but I've had little luck finding information even on rough prediction times for them. The training will happen offline, so only predictions need to be fast -- also, predictions may come from a piece of code / library that is completely separate from whatever does the training (as long as there is a common format for representing the trees).

    Read the article

  • Praw (Redditt API) How to retrieve replies to a comment past 10 levels deep

    - by jpreed00
    Ok, so I've written some code that, for all intents and purposes, should work: def checkComments(comments): for comment in comments: print comment.body checkComments(comment.replies) def processSub(sub): sub.replace_more_comments(limit=None, threshold=0) checkComments(sub.comments) #login and subreddit init stuff here subs = mysubreddit.get_hot(limit=50) for sub in subs: processSub(sub) However, given a submission that has 50 nested replies like so: root comment -> 1st reply -> 2nd reply -> 3rd reply ... -> 50th reply The above code only prints: root comment 1st reply 2nd reply 3rd reply 4th reply 5th reply 6th reply 7th reply 8th reply 9th reply Any idea how I can get the remaining 41 levels of replies? Or is this a praw limitation?

    Read the article

  • Distribution of many small classes

    - by Moo-Juice
    Hi All, I have a base class called EventArgs. Derived from this are many, many specializations that represent event arguments for a particular kind of event. Consumers of these events may need some, many, or very few of these argument classes. My question is, would you provide a header file for each type (e.g, 50+ header files for the varying ones), would you try to group them in to families and have a 'common' header file for those, or would you throw caution to the window and throw them in to one easy-of-use header file that can just be included? Another approach might be to have 50 header files, and then I could introduce some "family" header files that included particular ones. Not sure about the naming conventions for these kinds of things so it is obvious what is where. I know there may not be a hard and fast rule, but wondering what other developers have done when they find themselves writing many little classes. Thanks in advance.

    Read the article

  • TSQL: Calculate the average of the rolling last 4 weeks

    - by user1917664
    I need your help. Database: SQL SERVER 2008R2 I want to calculte for a year and a week the average of value of the 4 last weeks. I have data a table like that: YEAR WEEKS VALUE 2012 1 3000 2012 2 5000 2012 3 6000 2012 4 7000 2012 5 8000 2012 6 9000 2012 7 1000 2012 8 6000 2012 9 9000 2012 10 4000 And I want that : YEAR WEEKS VALUE 2012 1 ( Average value for week 49, 50, 51, 52 for the year 2011) 2012 2 ( Average value for week 50, 51, 52 for the year 2011 and week 1 for the year 2012) 2012 3 ( Average value for week 51, 52 for the year 2011 and week 1, 2 for the year 2012) 2012 4 ( Average value for week 52 for the year 2011 and week 1, 2, 3 for the year 2012) 2012 5 5250 - ( Average value for week 1, 2, 3 , 4 for the year 2012) 2012 6 6500 - ( Average value for week 2, 3 , 4, 5 for the year 2012) Thank U for your help

    Read the article

  • Indexing on only part of a field in MongoDB

    - by Rob Hoare
    Is there a way to create an index on only part of a field in MongoDB, for example on the first 10 characters? I couldn't find it documented (or asked about on here). The MySQL equivalent would be CREATE INDEX part_of_name ON customer (name(10));. Reason: I have a collection with a single field that varies in length from a few characters up to over 1000 characters, average 50 characters. As there are a hundred million or so documents it's going to be hard to fit the full index in memory (testing with 8% of the data the index is already 400MB, according to stats). Indexing just the first part of the field would reduce the index size by about 75%. In most cases the search term is quite short, it's not a full-text search. A work-around would be to add a second field of 10 (lowercased) characters for each item, index that, then add logic to filter the results if the search term is over ten characters (and that extra field is probably needed anyway for case-insensitive searches, unless anybody has a better way). Seems like an ugly way to do it though. [added later] I tried adding the second field, containing the first 12 characters from the main field, lowercased. It wasn't a big success. Previously, the average object size was 50 bytes, but I forgot that includes the _id and other overheads, so my main field length (there was only one) averaged nearer to 30 bytes than 50. Then, the second field index contains the _id and other overheads. Net result (for my 8% sample) is the index on the main field is 415MB and on the 12 byte field is 330MB - only a 20% saving in space, not worthwhile. I could duplicate the entire field (to work around the case insensitive search problem) but realistically it looks like I should reconsider whether MongoDB is the right tool for the job (or just buy more memory and use twice as much disk space). [added even later] This is a typical document, with the source field, and the short lowercased field: { "_id" : ObjectId("505d0e89f56588f20f000041"), "q" : "Continental Airlines", "f" : "continental " } Indexes: db.test.ensureIndex({q:1}); db.test.ensureIndex({f:1}); The 'f" index, working on a shorter field, is 80% of the size of the "q" index. I didn't mean to imply I included the _id in the index, just that it needs to use that somewhere to show where the index will point to, so it's an overhead that probably helps explain why a shorter key makes so little difference. Access to the index will be essentially random, no part of it is more likely to be accessed than any other. Total index size for the full file will likely be 5GB, so it's not extreme for that one index. Adding some other fields for other search cases, and their associated indexes, and copies of data for lower case, does start to add up, which I why I started looking into a more concise index.

    Read the article

  • How to save a stretched image ?

    - by shivang
    Hi, How can I save a stretched image? I have a small(50 X 50) image, that I have stretched while displaying it on a UIImageView (by choosing scaletofit mode.) Now I need to fetch & save that stretched image. I have tried by using UIImageView's image property, but it gives me original image not that stretched image. So, do you have any idea how to solve this problem? If then please help me or guide me or at-least give me a hint. Hoping for your reply......... Thanks

    Read the article

  • Check If Stored Procedure Returns Value

    - by Eric
    Hello all, I am using Linq 2 Sql in VS 2010, and I have the following stored procedure to check a username and password ALTER PROCEDURE dbo.CheckUser ( @username varchar(50), @password varchar(50) ) AS SELECT * FROM Users Where UserName=@username AND Password=@password The problem I'm having is that it throws an exception if the username and password are incorrect. I'd like to perform a check to see if there is a return value, rather than using try/catch to determine whether the procedure returned a value. Should I do this check in code (C#)? Or is there a way to do it in SQL? Thanks.

    Read the article

  • help with stored procedure

    - by I__
    i am looking at this site: http://cloudexchange.cloudapp.net/stackoverflow/s/84/rising-stars-top-50-users-ordered-on-rep-per-day set nocount on DECLARE @endDate date SELECT @endDate = max(CreationDate) from Posts set nocount off SELECT TOP 50 Id AS [User Link], Reputation, Days, Reputation/Days AS RepPerDays FROM ( SELECT *, CONVERT(int, @endDate - CreationDate) as Days FROM Users ) AS UsersAugmented WHERE Reputation > 5000 ORDER BY RepPerDays DESC i am also a beginner at SQL. i have the following questions about this code: is this mysql or mssql? what does this do? set nocount off why is this in brackets? [User Link] what does this do? CONVERT(int, @endDate - CreationDate) as Days thanks!

    Read the article

  • How do I filter values in a Django form using ModelForm?

    - by malandro95
    I am trying to use the ModelForm to add my data. It is working well, except that the ForeignKey dropdown list is showing all values and I only want it to display the values that a pertinent for the logged in user. Here is my model for ExcludedDate, the record I want to add: class ExcludedDate(models.Model): date = models.DateTimeField() reason = models.CharField(max_length=50) user = models.ForeignKey(User) category = models.ForeignKey(Category) recurring = models.ForeignKey(RecurringExclusion) def __unicode__(self): return self.reason Here is the model for the category, which is the table containing the relationship that I'd like to limit by user: class Category(models.Model): name = models.CharField(max_length=50) user = models.ForeignKey(User, unique=False) def __unicode__(self): return self.name And finally, the form code: class ExcludedDateForm(ModelForm): class Meta: model = models.ExcludedDate exclude = ('user', 'recurring',) How do I get the form to display only the subset of categories where category.user equals the logged in user?

    Read the article

  • Rotate on hover using Jquery

    - by Ian34
    I can't figure out how to set up a jquery rotate function that would only rotate on hover. Here is the code that I am using: $('div.settingsButton').hover(function() { var angle = 0; setInterval(function() { angle += 4; $(this).rotate(angle); }, 50); }, function() { var angle = 0; setInterval(function() { angle = 0; $(this).rotate(angle); }, 50); }); The rotate is a plugin found here: http://code.google.com/p/jqueryrotate/

    Read the article

  • xslt: operations on new elements

    - by user1495523
    Could you please explain in case we could perform any operations on newly included elements using xsl? To explain using an example: if we have the following input file <?xml version="1.0" encoding="UTF-8"?> <top> <Results> <a>no</a> <b>10</b> <c>12</c> <d>9</d> </Results> <Results> <a>Yes</a> <b>8</b> <c>50</c> <d>12</d> </Results> </top> We need the final result as <?xml version="1.0" encoding="UTF-8"?> <top> <Results> <a>no</a> <b>10</b> <b_>10</b_> <c>12</c> <c_>12</c_> <d>9</d> <e_>11</e_> </Results> <Results> <a>Yes</a> <b>8</b> <b_>8</b_> <c>50</c> <c_>50</c_> <d>12</d> <e_>29</e_> </Results> </top> Where: b_ = b, c_ = c, & e_ = (b_ + c_)/2

    Read the article

  • Why isn't INT more efficient than UNIQUEIDENTIFIER (according to the execution plan)?

    - by ck
    I have a parent table and child table where the columns that join them together are the UNIQUEIDENTIFIER type. The child table has a clustered index on the column that joins it to the parent table (its PK, which is also clustered). I have created a copy of both of these tables but changed the relationship columns to be INTs instead, have rebuilt the indexes so that they are essentially the same structure and can be queried in the same way. When I query for a known 20 records from the parent table, pulling in all the related records from the child tables, I get identical query costs across both, i.e. 50/50 cost for the batches. If this is true, then my giant project to change all of the tables like this appears to be pointless, other than speeding up inserts. Can anyone provide any light on the situation? EDIT: The question is not about which is more efficient, but why is the query execution plan showing both queries as having the same cost?

    Read the article

  • generate 10 UUID records and save it it database in rails

    - by user662503
    I need to create certain number of UUId records (based on the selection of a drop down) and save them in the database. Now I am generating only one unique id. Can this be done in the model in this way? Or do I need to write a helper file for that? def generate_unique_token=(value) self.secret = Base64.encode64(UUIDTools::UUID.random_create)[0..8] end My controller: def create @secretcode = Secretcode.new(params[:secretcode]) @user = User.new(params[:user]) @secretcode.user_id = @user @secretcode.generate_unique_token = params[:secretcode][:secret] if @secretcode.valid? @secretcode.save redirect_to secretcodes_path else render 'new' end end My view page <%= form_for(@secretcode) do |f| %> <%= f.select(:secret, options_for_select([['1',1], ['10',10], ['20',20],['50',50]['100',100]])) %> <%= render 'layouts/error' %> <%=f.label :secret%> <%= f.hidden_field :user %> <%=f.submit :generate %> <% end %>

    Read the article

< Previous Page | 62 63 64 65 66 67 68 69 70 71 72 73  | Next Page >