Search Results

Search found 13450 results on 538 pages for 'recent items'.

Page 44/538 | < Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >

  • Racket list in struct

    - by Tim
    I just started programming with Racket and now I have the following problem. I have a struct with a list and I have to add up all prices in the list. (define-struct item (name category price)) (define some-items (list (make-item "Book1" 'Book 40.97) (make-item "Book2" 'Book 5.99) (make-item "Book3" 'Book 20.60) (make-item "Item" 'KitchenAccessory 2669.90))) I know that I can return the price with: (item-price (first some-items)) or (item-price (car some-items)). The problem is, that I dont know how I can add up all Items prices with this. Answer to Óscar López: May i filled the blanks not correctly, but Racket mark the code black when I press start and don't return anything. (define (add-prices items) (if (null? items) (+ 0 items) ; Here I don't really know what to write for a 0. ; I tried differnt thnigs like null and this version. (+ (item-price (first some-items)) (add-prices (item-price (rest some-items))))))

    Read the article

  • Android: duplicate items in ListVew. Maybe getView() called too many times?

    - by gonzobrains
    Hi, I am trying to create a simple program which displays a "shopping cart" list of items, along with a few buttons below it to manage the cart. The biggest problem is that items are getting duplicate entries in the list view. That is, for every item I want to enter I see it appear two times in the list view. What's the problem? Also, the scrollable area of my cart is not big enough. How do I set it so that it is bigger but I can still see my buttons? Perhaps I should put the buttons above the cart? Here is my shopping cart's layout XML: Here is the layout for individual row items: <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_parent"> <TextView android:id="@+id/BookTitle" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:singleLine="true" android:gravity="center_vertical" / <TextView android:id="@+id/BookPrice" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" android:singleLine="true" android:ellipsize="marquee" / Thanks, gb

    Read the article

  • Do you allow check-ins associated with work items from another Team Project?

    - by muerte
    Team Foundation Server 2008 allows that every check-in is associated with a work item, but what do you do if you are developing some features which span several Team Projects? For example, you're developing a specific product for a client and that product has its own Team Project, but is also using some of your other components or tools which are maintained independently in another Team Project. Where do you create work items for requirements which involve a change in both projects? Separated, every work item in its own Team Projects All work items in clients Team Project, regardless of associated source code The latter seems easier to maintain and control, but it involves associating check-ins from one Team Project to work items in another.

    Read the article

  • How to update only certain items in a list when using MVC?

    - by Eugen
    I'm building a GUI that includes a list with quite a lot of items. I allow the user to add/delete/edit those items. Up until now my update method called in the controller implied an entire JList reset (with its obvious performance issues). Now that there are hundreds of items available, updating the entire list is not fezable any longer. Does anyone know of a tutorial or can share an example (I haven't found any to suit my needs so far) in which the JList is updated something like JList.update(startIndex, endIndex);? Thanks for taking the time to answer.

    Read the article

  • What is an algorithm for minimizing some D distances between N items?

    - by Ross
    A classmate printed out a diagram of a database for class, the kind with lines representing relationships between tables. However, his lines crossed all over the place and it looked ugly. So I got to thinking about a way to move the tables to minimize the total line distance, and I couldn't think of a way to do it, other than just moving them all on top of each other. So basically: Given N items on some 2d coordinate space and some amount of connections between pairs of those items, how do you move the items so that the total distance between pairs is minimal, but that no distance is smaller than S? (so that the tables would not be too close together) Is there some algorithm for this? (I realize that smallest total distance won't necessarily make the layout less ugly; lines might still cross. But the table layout is just what got me thinking)

    Read the article

  • connecting to multiple resources

    - by Dudu
    I would like to know if there is a way to connect to multiple resources: Specifically I have the following problem abstact class BaseClass { ObservableCollection<BaseClass>; } class GrandSonClass:BaseClass{} class SonClass:BaseClass{} class FatherClass:BaseClass { CollectionViewSource col = new CollectionViewSource ; col.Source = Items.SelectMany(p => p.Items); } FatherClass's Items are of ChildrenClass type, and ChildrenClass's Items are of GrandSonClass type; I want FatherClass to bind to all the GrandSonClass's items it possesses. The solution of using SelectMany is not good as I need this to be dynamically updated whenever FatherClass adds more Items and whenever its Items(SonClasses) add more Items. Now I could go on and write notifiaction events but I was wondering if there is a smarter way to do it -i.e. simply define the sources as the Items of each Item FatherClass posses

    Read the article

  • VB.NET 2008 Application crashing during Do Loop

    - by RedHaze
    I am writing an application to compare each item on listbox1 to all items on listbox2. If the item is found, then remove it from both lists. The goal is to only have the items that were not found remain on both lists. The problem is, the application just hangs and I never get any results. I looked at my code several times and I cannot figure out what's going on (programming noob I know...). Can anybody help me with this? Code Snippet: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim a As String Dim b As String Dim y As String For i As Integer = 0 To ListBox1.Items.Count - 1 a = ListBox1.Items(i) y = 1 Do While y = 1 For x As Integer = 0 To ListBox2.Items.Count - 1 b = ListBox2.Items(x) Dim res As Int16 = String.Compare(a, b) If res = 0 Then y = 0 ListBox2.Items.Remove(i) ListBox2.Items.Remove(x) ElseIf x = ListBox1.Items.Count Then Exit Do End If Next Loop Next End Sub

    Read the article

  • Could the cause of recent Toyota computing problems be an interface mismatch ?

    - by Spux
    Any ideas if the recent Toyota computing errors had something to do with the fact they where using an object orintated approach then took a data orientated approach thus causing user interface errors ? Studying programming languages with in interface robotic design and wondered if the car computing glitch Toyota has been having could have something to do with using a different programming approach with out reprogramming the whole system from scratch.

    Read the article

  • How do I write a powershell script that gets the file with the most recent last write time from a fo

    - by Shoko
    The subject line says it all. I'd also like to do this using pipes. I figured that I could use Get-ChildItem, Measure-Object and Where-Object, but Measure-Object doesn't like dates. Should I have a script block which loops through each item returned from Get-ChildItem and does a comparison to see if it's the most recent? I thought that there should be a handy PS cmdlet for that.

    Read the article

  • How to get most recent date from an array of dates?

    - by sugarFornaciari
    Hy guys I have an array of dates such as array(5) { [0]=> string(19) "2012-06-11 08:30:49" [1]=> string(19) "2012-06-07 08:03:54" [2]=> string(19) "2012-05-26 23:04:04" [3]=> string(19) "2012-05-27 08:30:00" [4]=> string(19) "2012-06-08 08:30:55" } I would like to know which is the most recent date, comparing to the today date. Do you have any idea to do that?

    Read the article

  • Anyone know a working CSS selector hack that works in recent Safari but not chrome ?

    - by user318144
    The title sums it up. I'll get this out of the way and say I am aware that css hacks are dirty ugly horrible things. Sometimes dirty problems call for dirty solutions though :) So does anyone know of a css selector hack that works for recent safari versions but is not a general webkit hack ? My site behaves properly in chrome but has a bug in safari. So if anyone knows how i can select an element to only have a certain style in safari let me know!

    Read the article

  • How can I get a list of the most recent tags in a wordpress database?

    - by Failpunk
    I am not familiar with the wordpress schema at all and I need to get back a list, or array of the most recent tags from any post in the wordpress database. I just need the data available on the home page so I can then manipulate it. All the functions seem to be designed to work on a per-post basis. (Wordpress really makes me feel sorry for frequent wordpress programmers.)

    Read the article

  • Getting indices of most recent set of numbers in an array in Matlab?

    - by user2539781
    Let's say I have an array in Matlab: x = [1 1 1 2 2 2 3 3 3 3 2 2 3 3 3 1 1 1 1 1 2 2 2 2 3 3 3] I want the indices of the most recent set of consecutive '1's. In this case, I want the answer: answer = [16 17 18 19 20] % (which should correspond to the last sequence of 1's) I need an automated way to do this in Matlab, that will work with any size arrays, always giving me the indices for the last set of consecutive 1s. Any suggestions?

    Read the article

  • SortedDictionary and SortedList

    - by Simon Cooper
    Apart from Dictionary<TKey, TValue>, there's two other dictionaries in the BCL - SortedDictionary<TKey, TValue> and SortedList<TKey, TValue>. On the face of it, these two classes do the same thing - provide an IDictionary<TKey, TValue> interface where the iterator returns the items sorted by the key. So what's the difference between them, and when should you use one rather than the other? (as in my previous post, I'll assume you have some basic algorithm & datastructure knowledge) SortedDictionary We'll first cover SortedDictionary. This is implemented as a special sort of binary tree called a red-black tree. Essentially, it's a binary tree that uses various constraints on how the nodes of the tree can be arranged to ensure the tree is always roughly balanced (for more gory algorithmical details, see the wikipedia link above). What I'm concerned about in this post is how the .NET SortedDictionary is actually implemented. In .NET 4, behind the scenes, the actual implementation of the tree is delegated to a SortedSet<KeyValuePair<TKey, TValue>>. One example tree might look like this: Each node in the above tree is stored as a separate SortedSet<T>.Node object (remember, in a SortedDictionary, T is instantiated to KeyValuePair<TKey, TValue>): class Node { public bool IsRed; public T Item; public SortedSet<T>.Node Left; public SortedSet<T>.Node Right; } The SortedSet only stores a reference to the root node; all the data in the tree is accessed by traversing the Left and Right node references until you reach the node you're looking for. Each individual node can be physically stored anywhere in memory; what's important is the relationship between the nodes. This is also why there is no constructor to SortedDictionary or SortedSet that takes an integer representing the capacity; there are no internal arrays that need to be created and resized. This may seen trivial, but it's an important distinction between SortedDictionary and SortedList that I'll cover later on. And that's pretty much it; it's a standard red-black tree. Plenty of webpages and datastructure books cover the algorithms behind the tree itself far better than I could. What's interesting is the comparions between SortedDictionary and SortedList, which I'll cover at the end. As a side point, SortedDictionary has existed in the BCL ever since .NET 2. That means that, all through .NET 2, 3, and 3.5, there has been a bona-fide sorted set class in the BCL (called TreeSet). However, it was internal, so it couldn't be used outside System.dll. Only in .NET 4 was this class exposed as SortedSet. SortedList Whereas SortedDictionary didn't use any backing arrays, SortedList does. It is implemented just as the name suggests; two arrays, one containing the keys, and one the values (I've just used random letters for the values): The items in the keys array are always guarenteed to be stored in sorted order, and the value corresponding to each key is stored in the same index as the key in the values array. In this example, the value for key item 5 is 'z', and for key item 8 is 'm'. Whenever an item is inserted or removed from the SortedList, a binary search is run on the keys array to find the correct index, then all the items in the arrays are shifted to accomodate the new or removed item. For example, if the key 3 was removed, a binary search would be run to find the array index the item was at, then everything above that index would be moved down by one: and then if the key/value pair {7, 'f'} was added, a binary search would be run on the keys to find the index to insert the new item, and everything above that index would be moved up to accomodate the new item: If another item was then added, both arrays would be resized (to a length of 10) before the new item was added to the arrays. As you can see, any insertions or removals in the middle of the list require a proportion of the array contents to be moved; an O(n) operation. However, if the insertion or removal is at the end of the array (ie the largest key), then it's only O(log n); the cost of the binary search to determine it does actually need to be added to the end (excluding the occasional O(n) cost of resizing the arrays to fit more items). As a side effect of using backing arrays, SortedList offers IList Keys and Values views that simply use the backing keys or values arrays, as well as various methods utilising the array index of stored items, which SortedDictionary does not (and cannot) offer. The Comparison So, when should you use one and not the other? Well, here's the important differences: Memory usage SortedDictionary and SortedList have got very different memory profiles. SortedDictionary... has a memory overhead of one object instance, a bool, and two references per item. On 64-bit systems, this adds up to ~40 bytes, not including the stored item and the reference to it from the Node object. stores the items in separate objects that can be spread all over the heap. This helps to keep memory fragmentation low, as the individual node objects can be allocated wherever there's a spare 60 bytes. In contrast, SortedList... has no additional overhead per item (only the reference to it in the array entries), however the backing arrays can be significantly larger than you need; every time the arrays are resized they double in size. That means that if you add 513 items to a SortedList, the backing arrays will each have a length of 1024. To conteract this, the TrimExcess method resizes the arrays back down to the actual size needed, or you can simply assign list.Capacity = list.Count. stores its items in a continuous block in memory. If the list stores thousands of items, this can cause significant problems with Large Object Heap memory fragmentation as the array resizes, which SortedDictionary doesn't have. Performance Operations on a SortedDictionary always have O(log n) performance, regardless of where in the collection you're adding or removing items. In contrast, SortedList has O(n) performance when you're altering the middle of the collection. If you're adding or removing from the end (ie the largest item), then performance is O(log n), same as SortedDictionary (in practice, it will likely be slightly faster, due to the array items all being in the same area in memory, also called locality of reference). So, when should you use one and not the other? As always with these sort of things, there are no hard-and-fast rules. But generally, if you: need to access items using their index within the collection are populating the dictionary all at once from sorted data aren't adding or removing keys once it's populated then use a SortedList. But if you: don't know how many items are going to be in the dictionary are populating the dictionary from random, unsorted data are adding & removing items randomly then use a SortedDictionary. The default (again, there's no definite rules on these sort of things!) should be to use SortedDictionary, unless there's a good reason to use SortedList, due to the bad performance of SortedList when altering the middle of the collection.

    Read the article

  • How to avoid overlapping date ranges when using a grouping clause?

    - by k rey
    I have a situation where I need to find time spans between value changes. I tried a simple group by clause but it eliminates overlapping changes. Consider the following example: create table #items ( code varchar(4) , class varchar(4) , txdate datetime ) insert into #items (code, class, txdate) values ('A', 'C', '2010-01-01'); insert into #items (code, class, txdate) values ('A', 'C', '2010-01-02'); insert into #items (code, class, txdate) values ('A', 'C', '2010-01-03'); insert into #items (code, class, txdate) values ('A', 'D', '2010-01-04'); insert into #items (code, class, txdate) values ('A', 'D', '2010-01-05'); insert into #items (code, class, txdate) values ('A', 'C', '2010-01-06'); insert into #items (code, class, txdate) values ('A', 'C', '2010-01-07'); insert into #items (code, class, txdate) values ('A', 'D', '2010-01-08'); insert into #items (code, class, txdate) values ('A', 'D', '2010-01-09'); select code , class , min(txdate) mindate , max(txdate) maxdate from #items group by code, class This returns the following results (notice the overlapping date ranges): |code|class|mindate |maxdate | ---------------------------------- |A |C |2010-01-01|2010-01-07| |A |D |2010-01-04|2010-01-09| I would like to have the query return the following: |code|class|mindate |maxdate | ---------------------------------- |A |C |2010-01-01|2010-01-03| |A |D |2010-01-04|2010-01-05| |A |C |2010-01-06|2010-01-07| |A |D |2010-01-08|2010-01-09| Any ideas and suggestions?

    Read the article

  • Uniquing with Existing Core Data Entities

    - by warrenm
    I'm using Core Data to store a lot (1000s) of items. A pair of properties on each item are used to determine uniqueness, so when a new item comes in, I compare it against the existing items before inserting it. Since the incoming data is in the form of an RSS feed, there are often many duplicates, and the cost of the uniquing step is O(N^2), which has become significant. Right now, I create a set of existing items before iterating over the list of (possible) new items. My theory is that on the first iteration, all the items will be faulted in, and assuming we aren't pressed for memory, most of those items will remain resident over the course of the iteration. I see my options thusly: Use string comparison for uniquing, iterating over all "new" items and comparing to all existing items (Current approach) Use a predicate to filter the set of existing items against the properties of the "new" items. Use a predicate with Core Data to determine uniqueness of each "new" item (without retrieving the set of existing items). Is option 3 likely to be faster than my current approach? Do you know of a better way?

    Read the article

  • Anyone have ideas for solving the "n items remaining" problem on Internet Explorer?

    - by CMPalmer
    In my ASP.Net app, which is javascript and jQuery heavy, but also uses master pages and .Net Ajax pieces, I am consistently seeing on the status bar of IE 6 (and occasionally IE 7) the message "2 items remaining" or "15 items remaining" followed by "loading somegraphicsfile.png|gif ." This message never goes away and may or may not prevent some page functionality from running (it certainly seems to bog down, but I'm not positive). I can cause this to happen 99% of the time by just refreshing an .aspx age, but the number of items and, sometimes, the file it mentions varies. Usually it is 2, 3, 12, 13, or 15. I've Googled for answers and there are several suggestions or explanations. Some of them haven't worked for us, and others aren't practical for us to implement or try. Here are some of the ideas/theories: IE isn't caching images right, so it repeatedly asks for the same image if the image is repeated on the page and the server assumes that it should be cached locally since it's already served it in that page context. IE displays the images correctly, but sits and waits for a server response that never comes. Typically the file it says it is waiting on is repeated on the page. The page is using PNG graphics with transparency. Indeed it is, but they are jQuery-UI Themeroller generated graphics which, according to the jQuery-UI folks, are IE safe. The jQuery-UI components are the only things using PNGs. All of our PNG references are in CSS, if that helps. I've changed some of the graphics from PNG to GIF, but it is just as likely to say it's waiting for somegraphicsfile.png as it is for somegraphicsfile.gif Images are being specified in CSS and/or JavaScript but are on things that aren't currently being displayed (display: none items for example). This may be true, but if it is, then I would think preloading images would work, but so far, adding a preloader doesn't do any good. IIS's caching policy is confusing the browser. If this is true, it is only Microsoft server SW having problems with Microsoft's browser (which doesn't surprise me at all). Unfortunately, I don't have much control over the IIS configuration that will be hosting the app. Has anyone seen this and found a way to combat it? Particularly on ASP.Net apps with jQuery and jQuery-UI? UPDATE One other data point: on at least one of the pages, just commenting out the jQuery-UI Datepicker component setup causes the problem to go away, but I don't think (or at least I'm not sure) if that fixes all of the pages. If it does "fix" them, I'll have to swap out plug-ins because that functionality needs to be there. There doesn't seem to be any open issues against jQuery-UI on IE6/7 currently... UPDATE 2 I checked the IIS settings and "enable content expiration" was not set on any of my folders. Unchecking that setting was a common suggestion for fixing this problem. I have another, simpler, page that I can consistently create the error on. I'm using the jQuery-UI 1.6rc6 file (although I've also tried jQuery-UI 1.7.1 with the same results). The problem only occurs when I refresh the page that contains the jQuery-UI Datepicker. If I comment out the Datepicker setup, the problem goes away. Here are a few things I notice when I do this: This page always says "(1 item remaining) Downloading picture http:///images/Calendar_scheduleHS.gif", but only when reloading. When I look at HTTP logging, I see that it requests that image from the server every time it is dynamically turned on, without regard to caching. All of the requests for that graphic are complete and return the graphic correctly. None are marked code 200 or 304 (indicating that the server is telling IE to use the cached version). Why it says waiting on that graphic when all of the requests have completed I have no idea. There is a single other graphic on the page (one of the UI PNG files) that has a code 304 (Not Modified). On another page where I managed to log HTTP traffic with "2 items remaining", two different graphic files (both UI PNGs) had a 304 as well (but neither was the one listed as "Downloading". This error is not innocuous - the page is not fully responsive. For example, if I click on one of the buttons which should execute a client-side action, the page refreshes. Going away from the page and coming back does not produce the error. I have moved the script and script references to the bottom of the content and this doesn't affect this problem. The script is still running in the $(document).ready() though (it's too hairy to divide out unless I absolutely have to). FINAL UPDATE AND ANSWER There were a lot of good answers and suggestions below, but none of them were exactly our problem. The closest one (and the one that led me to the solution) was the one about long running JavaScript, so I awarded the bounty there (I guess I could have answered it myself, but I'd rather reward info that leads to solutions). Here was our solution: We had multiple jQueryUI datepickers that were created on the $(document).ready event in script included from the ASP.Net master page. On this client page, a local script's $(document).ready event had script that destroyed the datepickers under certain conditions. We had to use "destroy" because the previous version of datepicker had a problem with "disable". When we upgraded to the latest version of jQuery UI (1.7.1) and replaced the "destroy"s with "disable"s for the datepickers, the problem went away (or mostly went away - if you do things too fast while the page is loading, it is still possible to get the "n items remaining" status). My theory as to what was happening goes like this: The page content loads and has 12 or so text boxes with the datepicker class. The master page script creates datepickers on those text boxes. IE queues up requests for each calendar graphic independently because IE doesn't know how to properly cache dynamic image requests. Before the requests get processed, the client area script destroys those datepickers so the graphics are no longer needed. IE is left with some number of orphaned requests that it doesn't know what to do with.

    Read the article

  • Configure ListBox in WPF so that I will be possible to select multiple items without holding CTRL ke

    - by drasto
    I have a Listbox that allows user to select multiple items. Normally user can do that by holding CTRL key and clicking the item he or she wants to select. Is it possible to configure this listbox so that the user will not have to hold the CTRL key when selecting items ? So that he or she will just click the item (without holding anything) and the item will be selected(diselected if it was selected previously) ? Thank you

    Read the article

  • Get the count of items in a GroupBy Linq-to-sql Query?

    - by Curtis White
    I have a groupby that I groups all elements. I can see the items are there in LinqPad but can't find a way to get the count. Here is what I have so far: SurveyResponses.Where( q = q.QuestionId == 4).GroupBy(q = q.AnswerNumeric).Where( g = g.Key == 1) In Linq Pad I can see there are 4 items in this query. If I do Count it returns 1. I've tried, ToList().Count, Select(x = x).Count, etc.

    Read the article

  • How to provide translations for items in a ASP.Net custom web control (.ascx)?

    - by paul
    How do I go about providing localised text for items in a custom web control? I had thought that I just need to add meta.resourcekey tags to the control items and then define and fill some resource files called mycontrol.ascx.[lang].resx but that doesn't seem to work. e.g. MyControl.ascx <asp:Label ID="Label1" meta:resourcekey="Label1" runat="server" Text="Oops!"></asp:Label> MyControl.ascx.de.resx Label1.Text Donner und Blitzen!

    Read the article

< Previous Page | 40 41 42 43 44 45 46 47 48 49 50 51  | Next Page >