Daily Archives

Articles indexed Tuesday March 9 2010

Page 6/49 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Understanding Haskell's fibonacci

    - by AR
    fibs :: [Int] fibs = 0 : 1 : [ a + b | (a, b) <- zip fibs (tail fibs)] This generates the Fibonacci sequence. I understand the behaviour of the guards, of :, zip and tail, but I don't understand <-. What is it doing here?

    Read the article

  • Is there any legitimate use for bare strings in PHP?

    - by Robert
    This question got me thinking about bare strings. When PHP sees a string that's not enclosed in quotes, it first checks to see if it's a constant. If not, it just assumes it's a string and goes on anyway. So for example if I have echo $foo[bar]; If there's a constant called bar it uses that for the array key, but if not then it treats bar as a bare string, so it behaves just like echo $foo["bar"]; This can cause all kinds of problems if at some future date a constant is added with the same name. My question is, is there any situation in which it actually makes sense to use a bare string?

    Read the article

  • NSFetchRequest returns correct number of objects, but each object contains nil attributes

    - by BU
    Hi, I can't figure out why this is happening. I can add to the context. But when I retrieve the objects, it returns the correct number of objects but the attributes of the objects are null. I am adding 3 instances with this code: +(BOOL)addStoreWithID:(NSNumber *)ID Latitude:(NSNumber *)latitude Longitude:(NSNumber *)longitude Name:(NSString *)name { Stores *store = (Stores *)[NSEntityDescription insertNewObjectForEntityForName:@"Stores" inManagedObjectContext:[[SharedResources instance] managedObjectContext]]; store.ID = ID; store.Latitude = latitude; store.Longitude = longitude; store.Name = name; NSError *error; if(![[[SharedResources instance] managedObjectContext] save:&error]) { //Handle the error return NO; } return YES; } I get the result: 2010-03-07 19:19:37.060 GamePouch_iPhone[11337:207] Store name is Starbucks (gdb) continue 2010-03-07 19:19:37.933 GamePouch_iPhone[11337:207] Store name is Dunkin Donuts (gdb) continue 2010-03-07 19:19:38.717 GamePouch_iPhone[11337:207] Store name is Krispy Kreme I have confirmed that this code is visited three times and none of the attributes are nil. Then when I try to retrieve it, I use the following code: +(NSMutableArray *)fetchAllObjects { NSFetchRequest *request; request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Stores" inManagedObjectContext:[[SharedResources instance] managedObjectContext]]; [request setEntity:entity]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"ID" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; NSError *error; NSMutableArray *array = [[[SharedResources instance] managedObjectContext] executeFetchRequest:request error:&error]; [request release]; [sortDescriptor release]; [sortDescriptors release]; for(int i=0;i<3;i++) { Stores *tempStore = (Stores *)[array objectAtIndex:i]; NSLog(@"store name is %@",[tempStore Name]); } return array; } I get the result: 2010-03-07 19:21:00.504 GamePouch_iPhone[11337:207] store name is (null) (gdb) continue 2010-03-07 19:21:01.541 GamePouch_iPhone[11337:207] store name is (null) (gdb) continue 2010-03-07 19:21:02.503 GamePouch_iPhone[11337:207] store name is (null) Thanks a lot for reading. Any help would be much appreciated. Thanks Bakhtiyar uddin

    Read the article

  • one site or many?

    - by Alex
    I have about 10-12 websites (main site is classic ASP, others are ASP.NET 2). Each site has his own virtual directory. They are related to each other, mainly from main site other sites are calling to perform some service. Each site has from 2 to 5 pages. Does it make sense to unite them and create one bigger site with one virtual directory and one project in VS? Or leave them as they are separately? What are pro and contras?

    Read the article

  • ubuntu 9.10 screen flickering problem on Thinkpad R31 with Intel 83830 Graphics

    - by PA
    I am trying to revitalize an old Thinkpad R31 that has the Intel 82830 graphics and only 256 MB of RAM. I have tried a Xubuntu 9.10 Live CD. After booting the screen blinks so much that it is practically unreadable. I have searched for updated IBM Thinkpad drivers but I only found drivers for Windows on the Thinkpad support web site. EDIT: I have changed the title and the description. It is not a problem of the drivers. It seems to be a problem with the kernel. See my own answer below.

    Read the article

  • FormColelction in VB.NET

    - by fireBand
    Hi, I want to detect if a window form is open and if it is then I would like to bring it in front rather than opening it again. I know I need a form collection for this but I want to know if there is a built in form collection that holds all the forms in VB.NET or I need to implement my own. Thank you.

    Read the article

  • Safety using $_SERVER variables

    - by DiogoNeves
    Hi all, I'm working on a system that relies in $_SERVER['REMOTE_ADDR'] to get the user address and check it against a white list of addresses. Is this approach safe? Or is there a way of forcing values in superglobal variables? Thank you, Diogo

    Read the article

  • Tinyxml Multi Task

    - by shaimagz
    I have a single xml file and every new thread of the program (BHO) is using the same Tinyxml file. every time a new window is open in the program, it runs this code: const char * xmlFileName = "C:\\browsarityXml.xml"; TiXmlDocument doc(xmlFileName); doc.LoadFile(); //some new lines in the xml.. and than save: doc.SaveFile(xmlFileName); The problem is that after the first window is adding new data to the xml and saves it, the next window can't add to it. although the next one can read the data in the xml, it can't write to it. I thought about two possibilities to make it work, but I don't know how to implement them: Destroy the doc object when I'm done with it. Some function in Tinyxml library to unload the file. Any help or better understanding of the problem will be great. Thanks.

    Read the article

  • How do you pass .net objects values around in F#?

    - by Russell
    I am currently learning F# and functional programming in general (from a C# background) and I have a question about using .net CLR objects during my processing. The best way to describe my problem will be to give an example: let xml = new XmlDocument() |> fun doc -> doc.Load("report.xml"); doc let xsl = new XslCompiledTransform() |> fun doc -> doc.Load("report.xsl"); doc let transformedXml = new MemoryStream() |> fun mem -> xsl.Transform(xml.CreateNavigator(), null, mem); mem This code transforms an XML document with an XSLT document using .net objects. Note XslCompiledTransform.Load works on an object, and returns void. Also the XslCompiledTransform.Transform requires a memorystream object and returns void. The above strategy used is to add the object at the end (the ; mem) to return a value and make functional programming work. When we want to do this one after another we have a function on each line with a return value at the end: let myFunc = new XmlDocument("doc") |> fun a -> a.Load("report.xml"); a |> fun a -> a.AppendChild(new XmlElement("Happy")); a Is there a more correct way (in terms of functional programming) to handle .net objects and objects that were created in a more OO environment? The way I returned the value at the end then had inline functions everywhere feels a bit like a hack and not the correct way to do this. Any help is greatly appreciated!

    Read the article

  • Can I perform a search on mail server in Java?

    - by twofivesevenzero
    I am trying to perform a search of my gmail using Java. With JavaMail I can do a message by message search like so: Properties props = System.getProperties(); props.setProperty("mail.store.protocol", "imaps"); Session session = Session.getDefaultInstance(props, null); Store store = session.getStore("imaps"); store.connect("imap.gmail.com", "myUsername", "myPassword"); Folder inbox = store.getFolder("Inbox"); inbox.open(Folder.READ_ONLY); SearchTerm term = new SearchTerm() { @Override public boolean match(Message mess) { try { return mess.getContent().toString().toLowerCase().indexOf("boston") != -1; } catch (IOException ex) { Logger.getLogger(JavaMailTest.class.getName()).log(Level.SEVERE, null, ex); } catch (MessagingException ex) { Logger.getLogger(JavaMailTest.class.getName()).log(Level.SEVERE, null, ex); } return false; } }; Message[] searchResults = inbox.search(term); for(Message m:searchResults) System.out.println("MATCHED: " + m.getFrom()[0]); But this requires downloading each message. Of course I can cache all the results, but this becomes a storage concern with large gmail boxes and also would be very slow (I can only imagine how long it would take to search through gigabytes of text...). So my question is, is there a way of searching through mail on the server, a la gmail's search field? Maybe through Microsoft Exchange? Hours of Googling has turned up nothing.

    Read the article

  • Virtual Function Implementation

    - by Gokul
    Hi, I have kept hearing this statement. Switch..Case is Evil for code maintenance, but it provides better performance(since compiler can inline stuffs etc..). Virtual functions are very good for code maintenance, but they incur a performance penalty of two pointer indirections. Say i have a base class with 2 subclasses(X and Y) and one virtual function, so there will be two virtual tables. The object has a pointer, based on which it will choose a virtual table. So for the compiler, it is more like switch( object's function ptr ) { case 0x....: X->call(); break; case 0x....: Y->call(); }; So why should virtual function cost more, if it can get implemented this way, as the compiler can do the same in-lining and other stuff here. Or explain me, why is it decided not to implement the virtual function execution in this way? Thanks, Gokul.

    Read the article

  • java: relationship of the Runnable and Thread interfaces

    - by Karl Patrick
    I realize that the method run() must be declared because its declared in the Runnable interface. But my question comes when this class runs how is the Thread object allowed if there is no import call to a particular package? how does runnable know anything about Thread or its methods? does the Runnable interface extend the Thread class? Obviously I don't understand interfaces very well. thanks in advance. class PrimeFinder implements Runnable{ public long target; public long prime; public boolean finished = false; public Thread runner; PrimeFinder(long inTarget){ target = inTarget; if(runner == null){ runner = new Thread(this); runner.start() } } public void run(){ } }

    Read the article

  • Get percentiles of data-set with group by month

    - by Cylindric
    Hello, I have a SQL table with a whole load of records that look like this: | Date | Score | + -----------+-------+ | 01/01/2010 | 4 | | 02/01/2010 | 6 | | 03/01/2010 | 10 | ... | 16/03/2010 | 2 | I'm plotting this on a chart, so I get a nice line across the graph indicating score-over-time. Lovely. Now, what I need to do is include the average score on the chart, so we can see how that changes over time, so I can simply add this to the mix: SELECT YEAR(SCOREDATE) 'Year', MONTH(SCOREDATE) 'Month', MIN(SCORE) MinScore, AVG(SCORE) AverageScore, MAX(SCORE) MaxScore FROM SCORES GROUP BY YEAR(SCOREDATE), MONTH(SCOREDATE) ORDER BY YEAR(SCOREDATE), MONTH(SCOREDATE) That's no problem so far. The problem is, how can I easily calculate the percentiles at each time-period? I'm not sure that's the correct phrase. What I need in total is: A line on the chart for the score (easy) A line on the chart for the average (easy) A line on the chart showing the band that 95% of the scores occupy (stumped) It's the third one that I don't get. I need to calculate the 5% percentile figures, which I can do singly: SELECT MAX(SubQ.SCORE) FROM (SELECT TOP 45 PERCENT SCORE FROM SCORES WHERE YEAR(SCOREDATE) = 2010 AND MONTH(SCOREDATE) = 1 ORDER BY SCORE ASC) AS SubQ SELECT MIN(SubQ.SCORE) FROM (SELECT TOP 45 PERCENT SCORE FROM SCORES WHERE YEAR(SCOREDATE) = 2010 AND MONTH(SCOREDATE) = 1 ORDER BY SCORE DESC) AS SubQ But I can't work out how to get a table of all the months. | Date | Average | 45% | 55% | + -----------+---------+-----+-----+ | 01/01/2010 | 13 | 11 | 15 | | 02/01/2010 | 10 | 8 | 12 | | 03/01/2010 | 5 | 4 | 10 | ... | 16/03/2010 | 7 | 7 | 9 | At the moment I'm going to have to load this lot up into my app, and calculate the figures myself. Or run a larger number of individual queries and collate the results.

    Read the article

  • NSTableView won't begin dragging rows if the mouseDown happens within the rect of an NSButtonCell.

    - by Joel Day
    I currently have an odd case where I need to be able to reorder rows in an NSTableView, but the only column happens to be an NSButtonCell. I'm trying to see how I can override NSButtonCell's mouse tracking in order to get it to behave in a way so that the NSTableView will begin dragging the row, but am not having much luck. Additional info that might affect the behavior: With this NSTableView, I am not allowing any rows to be selected, but I have forced mouse tracking to always occur for all cells. This is so that the button can still be clicked even though its row can never be selected. Thanks!

    Read the article

  • Abstract base class for Winforms-Control and VS2008 Designer support?

    - by BeowulfOF
    Hi, I engadged a problem with inherited Controls in WinForms, and need some advice on it. I do use a base class for items in a List (selfmade GUI list made of a panel) and some inherited controls that are for each type of data that could be added to the list. There was no problem with it, but I know found out, that it would be right, to make the base-control an abstract class, since it has methods, that need to be implemented in all inherited controls, called from the code inside the base-control, but must not and can not be implemented in the base class. When I mark the base-control as abstract, the VS2008 Designer refuses to load the window. Is there any way to get the Designer work with the base-control made abstract?

    Read the article

  • Faith and Godaddy [closed]

    - by yuval
    Let's remove the capitalizations from the name GoDaddy - the hosting company: godaddy. Now let's look at the spacing a little differently: god addy, and capitalize: God Addy: God Addy: The address of God Did anybody notice this? How many negative votes will this question get? How long until someone closes the discussion on this question? All of this and more... NOW! Someone favorited this! woo! In addition to my serious and intelligent previous question: Who came first, the chicken or the egg?

    Read the article

  • WMI Security error TF255437 when installing TFS 2010 RC

    - by Daniel O
    Does anyone know the resolution to the following error. In this scenario, TFS will be using a local report server instance which points uses a separate SQL Server database engine instance. An error occurred while querying the Windows Management Instrumentation (WMI) interface on the following computer databaseServer. The following error message was received: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

    Read the article

  • Functional languages & support for memoization

    - by Joel
    Do any of the current crop of popular functional languages have good support for memoization & if I was to pick one on the strength of its memoisation which would you recommend & why? Update: I'm looking to optimise a directed graph (where nodes could be functions or data). When a node in the graph is updated I would like the values of other nodes to be recalculated only if they depend the node that changed. Update2: require free or open-source language/runtime.

    Read the article

  • MySQL table data transformation -- how can I dis-aggreate MySQL time data?

    - by lighthouse65
    We are coding for a MySQL data warehousing application that stores descriptive data (User ID, Work ID, Machine ID, Start and End Time columns in the first table below) associated with time and production quantity data (Output and Time columns in the first table below) upon which aggregate (SUM, COUNT, AVG) functions are applied. We now wish to dis-aggregate time data for another type of analysis. Our current data table design: +---------+---------+------------+---------------------+---------------------+--------+------+ | User ID | Work ID | Machine ID | Event Start Time | Event End Time | Output | Time | +---------+---------+------------+---------------------+---------------------+--------+------+ | 080025 | ABC123 | M01 | 2008-01-24 16:19:15 | 2008-01-24 16:34:45 | 2120 | 930 | +---------+---------+------------+---------------------+---------------------+--------+------+ Reprocessing dis-aggregation that we would like to do would be to transform table content based on a granularity of minutes, rather than the current production event ("Event Start Time" and "Event End Time") granularity. The resulting reprocessing of existing table rows would look like: +---------+---------+------------+---------------------+--------+ | User ID | Work ID | Machine ID | Production Minute | Output | +---------+---------+------------+---------------------+--------+ | 080025 | ABC123 | M01 | 2010-01-24 16:19 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:20 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:21 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:22 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:23 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:24 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:25 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:26 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:27 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:28 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:29 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:30 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:31 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:22 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:33 | 133 | | 080025 | ABC123 | M01 | 2010-01-24 16:34 | 133 | +---------+---------+------------+---------------------+--------+ So the reprocessing would take an existing row of data created at the granularity of production event and modify the granularity to minutes, eliminating redundant (Event End Time, Time) columns while doing so. It assumes a constant rate of production and divides output by the difference in minutes plus one to populate the new table's Output column. I know this can be done in code...but can it be done entirely in a MySQL insert statement (or otherwise entirely in MySQL)? I am thinking of a INSERT ... INTO construction but keep getting stuck. An additional complexity is that there are hundreds of machines to include in the operation so there will be multiple rows (one for each machine) for each minute of the day. Any ideas would be much appreciated. Thanks.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >