Search Results

Search found 1040 results on 42 pages for 'jon skeet'.

Page 31/42 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • Return NSArray from NSDictionary

    - by Jon
    I have a fetch that returns an array with dictionary in it of an attribute of a core data object. Here is my previous question: Create Array From Attribute of NSObject From NSFetchResultsController This is the fetch: NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:entity]; [request setResultType:NSDictionaryResultType]; [request setReturnsDistinctResults:NO]; //set to YES if you only want unique values of the property [request setPropertiesToFetch :[NSArray arrayWithObject:@"timeStamp"]]; //name(s) of properties you want to fetch // Execute the fetch. NSError *error; NSArray *objects = [managedObjectContext executeFetchRequest:request error:&error]; When I log the NSArray data, I get this: The content of data is( { timeStamp = "2011-06-14 21:30:03 +0000"; }, { timeStamp = "2011-06-16 21:00:18 +0000"; }, { timeStamp = "2011-06-11 21:00:18 +0000"; }, { timeStamp = "2011-06-23 19:53:35 +0000"; }, { timeStamp = "2011-06-21 19:53:35 +0000"; } ) What I want is an array with this format: [NSArray arrayWithObjects: @"2011-11-01 00:00:00 +0000", @"2011-12-01 00:00:00 +0000", nil];' Edit: This is the method for which I want to replace the data array with my new data array: - (NSArray*)calendarMonthView:(TKCalendarMonthView *)monthView marksFromDate:(NSDate *)startDate toDate:(NSDate *)lastDate { NSLog(@"calendarMonthView marksFromDate toDate"); NSLog(@"Make sure to update 'data' variable to pull from CoreData, website, User Defaults, or some other source."); // When testing initially you will have to update the dates in this array so they are visible at the // time frame you are testing the code. NSArray *data = [NSArray arrayWithObjects: @"2011-01-01 00:00:00 +0000", @"2011-12-01 00:00:00 +0000", nil]; // Initialise empty marks array, this will be populated with TRUE/FALSE in order for each day a marker should be placed on. NSMutableArray *marks = [NSMutableArray array]; // Initialise calendar to current type and set the timezone to never have daylight saving NSCalendar *cal = [NSCalendar currentCalendar]; [cal setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; // Construct DateComponents based on startDate so the iterating date can be created. // Its massively important to do this assigning via the NSCalendar and NSDateComponents because of daylight saving has been removed // with the timezone that was set above. If you just used "startDate" directly (ie, NSDate *date = startDate;) as the first // iterating date then times would go up and down based on daylight savings. NSDateComponents *comp = [cal components:(NSMonthCalendarUnit | NSMinuteCalendarUnit | NSYearCalendarUnit | NSDayCalendarUnit | NSWeekdayCalendarUnit | NSHourCalendarUnit | NSSecondCalendarUnit) fromDate:startDate]; NSDate *d = [cal dateFromComponents:comp]; // Init offset components to increment days in the loop by one each time NSDateComponents *offsetComponents = [[NSDateComponents alloc] init]; [offsetComponents setDay:1]; // for each date between start date and end date check if they exist in the data array while (YES) { // Is the date beyond the last date? If so, exit the loop. // NSOrderedDescending = the left value is greater than the right if ([d compare:lastDate] == NSOrderedDescending) { break; } // If the date is in the data array, add it to the marks array, else don't if ([data containsObject:[d description]]) { [marks addObject:[NSNumber numberWithBool:YES]]; } else { [marks addObject:[NSNumber numberWithBool:NO]]; } // Increment day using offset components (ie, 1 day in this instance) d = [cal dateByAddingComponents:offsetComponents toDate:d options:0]; } [offsetComponents release]; return [NSArray arrayWithArray:marks]; }

    Read the article

  • WPF XAML Bind Grid

    - by Jon Archway
    I have a custom user control that is based on a Grid control. I have a ViewModel that exposes this as a property. I would like the XAML on the view to bind to this. I am sure this must be easy but I am quite new to WPF. How is this achieved? Many thanks in advance

    Read the article

  • SELECT set of most recent id, amount FROM table, where id occurs many times

    - by Jon Cram
    I have a table recording the amount of data transferred by a given service on a given date. One record is entered daily for a given service. I'd like to be able to retrieve the most recent amount for a set of services. Example data set: serviceId | amount | date ------------------------------- 1 | 8 | 2010-04-12 2 | 11 | 2010-04-12 2 | 14 | 2010-04-11 3 | 9 | 2010-04-11 1 | 6 | 2010-04-10 2 | 5 | 2010-04-10 3 | 22 | 2010-04-10 4 | 17 | 2010-04-19 Desired response (service ids 1,2,3): serviceId | amount | date ------------------------------- 1 | 8 | 2010-04-12 2 | 11 | 2010-04-12 3 | 9 | 2010-04-11 Desired response (service ids 2, 4): serviceId | amount | date ------------------------------- 2 | 11 | 2010-04-12 4 | 17 | 2010-04-19 This retrieves the equivalent as running the following once per serviceId: SELECT serviceId, amount, date FROM table WHERE serviceId = <given serviceId> ORDER BY date DESC LIMIT 0,1 I understand how I can retrieve the data I want in X queries. I'm interested to see how I can retrieve the same data using either a single query or at the very least less than X queries. I'm very interested to see what might be the most efficient approach. The table currently contains 28809 records. I appreciate that there are other questions that cover selecting the most recent set of records. I have examined three such questions but have been unable to apply the solutions to my problem.

    Read the article

  • How do I dynamically point an interface to a specific class at runtime?

    - by Jon
    As a simple example, I have an xml file with a list of names of classes which actually carry out the work and all implement interface IDoWork with a method Process(). I loop through the items in the xml file. How do I actually dynamically assign the class to the interface from a string name? e.g. var IDoWork = new "DoWorkType1"(); IDoWork.Process(); <work> <item id="DoWorkType1"> </item> <item id="DoWorkType2"> </item> </work> I want to achieve a plugin type architecture, except the plugin isn't at an assembly level only a class level within my program.

    Read the article

  • How do I convert a System::IO::Stream^ to an LPCSTR for PlaySound?

    - by Jon Cage
    I'm trying to embed and then play back a .wav file in a C++/CLI app but all the examples I've seen which use PlaySound are in VB. I can't see how to get froma Stream^ to the LPCSTR which PlaySound requires: System::IO::Stream^ s = Assembly::GetExecutingAssembly()->GetManifestResourceStream ("Ping.wav"); LPCSTR buf = s->????; PlaySound(buf, NULL, SND_ASYNC|SND_MEMORY|SND_NOWAIT); I guess I need some sort of horrible .net memory conversion magic.

    Read the article

  • How can I speed up line by line reading of an ASCII file? (C++)

    - by Jon
    Here's a bit of code that is a considerable bottleneck after doing some measuring: //----------------------------------------------------------------------------- // Construct dictionary hash set from dictionary file //----------------------------------------------------------------------------- void constructDictionary(unordered_set<string> &dict) { ifstream wordListFile; wordListFile.open("dictionary.txt"); string word; while( wordListFile >> word ) { if( !word.empty() ) { dict.insert(word); } } wordListFile.close(); } I'm reading in ~200,000 words and this takes about 240 ms on my machine. Is the use of ifstream here efficient? Can I do better? I'm reading about mmap() implementations but I'm not understanding them 100%. The input file is simply text strings with *nix line terminations.

    Read the article

  • Set a C++ bitset from a binary input steam

    - by Jon
    I have an input stream from a binary file. I want to create a bitset for the first 5 bits of the stream. Here is the code I have so far: ifstream is; is.open ("bin_file.out", ios::binary ); bitset<5> first_five_bits; is >> first_five_bits; // always is set to default 00000

    Read the article

  • intrusive_ptr: Why isn't a common base class provided?

    - by Jon
    intrusive_ptr requires intrusive_ptr_add_ref and intrusive_ptr_release to be defined. Why isn't a base class provided which will do this? There is an example here: http://lists.boost.org/Archives/boost/2004/06/66957.php, but the poster says "I don't necessarily think this is a good idea". Why not?

    Read the article

  • Creating a Non-Databound Report in Winforms

    - by Jon
    I am using Visual Studio 2008 and all the components that come with it as well as Infragisitics for Winforms. I need to design a label that will print to a label printer. None of the controls are databound and will most likely be set in code eg/Label.Text = "My Heading"; as there will be minimal information on the label. One piece of information is a barcode so I need the functionality to do that, I assume I can just set the font of the label to barcode and it will do its thing. Can I just add a Crystal Report to a form design it, set the label text properties in code, tell it what printer to print to and then call report.Print(); I've had a quick go and seems not as easy as I thought. Thanks

    Read the article

  • Only show certain items in a mysql database using php and time()

    - by Jon
    Is there a way to only show the items that are older than a certain date in a php mysql array? I'm using this query method and sorting by lastpost_cl: $query="SELECT * FROM properties ORDER BY lastpost_cl"; $result=mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); and I was thinking the way of checking the time would be: if (time() <= strtotime($lastpost_cl)) { } How can I combine the two and only show lastpost_cl that are older that the current time?

    Read the article

  • How can I extract the current user's account picture?

    - by Jon Tackabury
    I am trying to extract the current user's account picture in Windows 7, but I can't seem to figure out where it is located. I have found that the picture is sometimes written to the User's temp folder, but only after performing certain actions. It isn't always guaranteed to be there. Has anyone had any luck extracting this image? Thanks!

    Read the article

  • MVC Html.DropDownList closes prematurely in IE7

    - by Jon
    I'm using ASP.NET MVC with jquery. I have a couple of dropdownlists. When I select one via mouse click and then scroll down over the items using the mouse/cursor, the list closes before a selection can be made, before the mouse can be clicked. This doesn't happen when I open them and then up/down arrow to select an item. It doesn't happen all of the time, but a lot. Just to try something different, I added a jquery "select" control with hardcoded values (options) and it displays the same behavior. Any ideas? <%: Html.DropDownList("Accounts", (IEnumerable)ViewData["Accounts"], "-- Select an account --")% Thank you

    Read the article

  • creating existing users on AWS when they don't have a group

    - by Jon Strayer
    It seems when chef creates a user with the id of "foobar" it also creates a group with the id of "foobar". AWS doesn't do that. So, when I run my create users script via Opsworks it blows up on the first user that already exists because the group doesn't. I thought there was a way to say create the user but not the group, but I can't find it. What's the best way to solve this problem? Can I: Tell chef to not create the user's group? Tell chef to create it if the user exists but the group doesn't? Write a script that finds the existing users and creates groups for them? Something else?

    Read the article

  • jQuery animate element reveal - bottom to top

    - by Jon Hadley
    I'm trying to animate a horizontal lists appearance. It's a top navigation bar. The following works pretty well, but it animates in from the top (of, I assume, the ul) to the bottom. How would animate bottom, up? $("#topnavigation li").css({height:'0'}); // 'hide' it first $("#topnavigation li", this).stop().animate({height:'23px'},{queue:false,duration:1000});

    Read the article

  • Getting a stream back from a .Net remoting service that is accessible with IP v4 and v6

    - by jon.ediger
    My company has an existing .Net Remoting service that listens on a port, fronting interfaces used by external systems. This all works great with IP v4 based communications. However, this service now needs to support both IP v4 communications and IP v6 communications. I have found info that the system.runtime.remoting section of the app.config should include two channels as follows: <channel ref="tcp" name="tcp6" port="9000" bindTo="[::]" /> <channel ref="tcp" name="tcp4" port="9000" bindTo="0.0.0.0" /> The above config file changes to the System.Runtime.Remoting config section will get the remoting service responding to non-stream functions on both ip v4 and ip v6. The issue comes only when attempting to get a stream back, used to upload or download large files. In this case, instead of getting a usable stream back, the following ArgumentException is thrown instead: IPv4 address 0.0.0.0 and IPv6 address ::0 are unspecified addresses that cannot be used as a target address. Parameter name: hostNameOrAddress Is there a way to modify the app.config (in the system.runtime.remoting section, or another section) so that the service will return a stream mapped to a real ip so the client can actually upload/download files while maintaining the ability to use both IP v4 and IP v6?

    Read the article

  • Convert user input into ToString() method inside FlowDocument in Workflow 4.0

    - by Jon Ownbey
    I have a Workflow 4.0 app that generates emails. In a dialog for creating the email body the user needs to be able to input some string value representing an existing wf instance variable to be inserted as a string at runtime. So they input something like: Email body text including <. (say ExistingVariable is an int or something like that) Any helpful hints for how to convert this text with a ToString() at runtime?

    Read the article

  • Bind event in custom WPF control to command in ViewModel

    - by Jon Archway
    Hi, I have a custom control that has an event. I have a window using that custom control. The window is bound to a viewmodel. I would like to have the event from the custom control direct to an ICommand on my viewmodel. I am obviously being dense here as I can't figure out how to do this. Any assistance is most welcome. Thanks

    Read the article

  • Form submission and hyperlinks using GET and POST

    - by Jon
    I have a search resource, the user can perform searches by filling out a form and submitting it, the create action is called, the Search is saved, the show action is called, and the results are displayed. This all happens with the default POST, and all works fine. The user may want to save his search in the saved_search table (i don't use the Search table for this purpose as this table stores all searches for the purpose of compiling statistics, and gets cleared on a regular basis). Once the Search is saved, it can be re-run by clicking a hyperlink, this is where i start to get problems. I see no way of getting my hyperlink to run the create action of Search, with a POST request, and the necessary data. I then decided to try to get both form submission and the hyperlink to perform a search using a GET request, i was unable to get form_for to run my Search create action using a GET request, it always seems to get routed to my index action. Can someone suggest a good restful solution to this problem please. Many thanks

    Read the article

  • Automating Excel through the PIA makes VBA go squiffy.

    - by Jon Artus
    I have absolutely no idea how to start diagnosing this, and just wondered if anyone had any suggestions. I'm generating an Excel spreadsheet by calling some Macros from a C# application, and during the generation process it somehow breaks. I've got a VBA class containing all of my logging/error-handling logic, which I instantiate using a singleton-esque accessor, shown here: Private mcAppFramework As csys_ApplicationFramework Public Function AppFramework() As csys_ApplicationFramework If mcAppFramework Is Nothing Then Set mcAppFramework = New csys_ApplicationFramework Call mcAppFramework.bInitialise End If Set AppFramework = mcAppFramework End Function The above code works fine before I've generated the spreadsheet, but afterwards fails. The problem seems to be the following line; Set mcAppFramework = New csys_ApplicationFramework which I've never seen fail before. If I add a watch to the variable being assigned here, the type shows as csys_ApplicationFramework/wksFoo, where wksFoo is a random worksheet in the same workbook. What seems to be happening is that while the variable is of the right type, rather than filling that slot with a new instance of my framework class, it's making it point to an existing worksheet instead, the equivalent of Set mcAppFramework = wksFoo which is a compiler error, as one might expect. Even more bizarrely, if I put a breakpoint on the offending line, edit the line, and then resume execution, it works. For example, I delete the word 'New' move off the line, move back, re-type 'New' and resume execution. This somehow 'fixes' the workbook and it works happily ever after, with the type of the variable in my watch window showing as csys_ApplicationFramework/csys_ApplicationFramework as I'd expect. This implies that manipulating the workbook through the PIA is somehow breaking it temporarily. All I'm doing in the PIA is opening the workbook, calling several macros using Excel.Application.Run(), and saving it again. I can post a few more details if anyone thinks that it's relevant. I don't know how VBA creates objects behind the scenes or how to debug this. I also don't know how the way the code executes can change without the code itself changing. As previously mentioned, VBA has frankly gone a bit squiffy on me... Any thoughts?

    Read the article

  • Is it possible to use the CommonJS libraries yet?

    - by Jon Winstanley
    I am interested in getting started with CommonJS. With JavaScript frameworks getting faster all the time, and parsing engines and compilers making JavaScript incredibly quick, it is surprising that a project such as CommonJS has not been initiated sooner. What steps are involved in getting a test project up and running with what has been created so far?

    Read the article

  • Why can't a bind linux service to the loop-back only?

    - by Jon Trauntvein
    I am writing a server application that will provide a service on an ephemeral port that I only want accessible on the loopback interface. In order to do this, I am writing code like the following: struct sockaddr_in bind_addr; memset(&bind_addr,0,sizeof(bind_addr)); bind_addr.sin_family = AF_INET; bind_addr.sin_port = 0; bind_addr.sin_addr.s_addr = htonl(inet_addr("127.0.0.1")); rcd = ::bind( socket_handle, reinterpret_cast<struct sockaddr *>(&bind_addr), sizeof(bind_addr)); The return value for this call to bind() is -1 and the value of errno is 99 (Cannot assign requested address). Is this failing because inet_addr() already returns its result in network order or is there some other reason?

    Read the article

  • How can I load an MP3 or similar music file for display and anaysis in wxWdigets?

    - by Jon Cage
    I'm developing a GUI in wxPython which allows a user to generate sequences of colours for some toys I'm building. Part of the program needs to load an MP3 (and potentially other formats further down the line) and display it to the user. That shuold be sufficient to get started but later I'd like to add features like identifying beats and some crude frequency analysis. Is there any simple way of loading / understanding an MP3's contents to display a plot of it's amplitudes to the screen using wxWidgets? I later intend to port to C++/wxWidgets for speed and to avoid having to distribute wxPython.

    Read the article

  • Advantage Database Replication

    - by Jon
    I have a client that wants two sites to have the ability to sync databases so information at Site A can be synced with Site B so the two sites can look at the same data. I'm not even sure of the infrastructure required. Would a VPN required to connect the 2 databases or would an internet based database work ie/Site A to InternetDatabase and Site B to InternetDatabase. Each site copies data to it periodically and then the InternetDatabase syncs it and the Sites can then pull data down. My other thought was something like Dropbox. If Site A and Site B use a Dropbox account to sync the ADT files etc can the database at each site then sync with those ADT files? Thanks

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >