Search Results

Search found 11178 results on 448 pages for 'syntax checking'.

Page 78/448 | < Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >

  • Function returns CSV File: How to go about checking it ?

    - by Rachel
    I am doing something like: $outputFile = getCurrentDBSnapshot($data); where $data is the resource stream that am passing in, basically from command prompt am passing an file and am opening it using fopen for writing with 'w+' permissions, now getCurrentDBSnapshot would get the current state of a table and would update the $data csv file, so basically $outputFile would be updated with the current state of database table, now I want to var_dump or print the value of $outputFile to see the data present into it. But when I do $this->fout = fopen($outputFile,'r') or die('Cannot open file'); $test = fgetcsv($outputFile,5000,":"); var_dump($test); It gives me an error saying that it expects parameter 1 to be a string type and am passing resource. My goal to see the contains of $outputFile and so my question is that How can I see the contains present in $outputFile or how can I see what getcurrentDBSnapshot function is returning me ?

    Read the article

  • jQuery: Checking for length of ul and removing an li element?

    - by Legend
    I am trying to remove the last <li> element from a <ul> element only if it exceeds a particular length. For this, I am doing something like this: var selector = "#ulelement" if($(selector).children().length > threshold) { $(selector + " >:last").remove(); } I don't like the fact that I have to use the selector twice. Is there a shorter way to do this? Something like a "remove-if-length-greater-than-threshold" idea. I was thinking that maybe there is a way to do this using the live() function but I have no idea how.

    Read the article

  • What is the best practices for checking if the user of a Python script has root-like privileges?

    - by Paul Hoffman
    I have a Python script that will be doing a lot of things that would require root-level privileges, such as moving files in /etc, installing with apt-get, and so on. I currently have: if os.geteuid() != 0: exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.") Is this the best way to do the check? Are there other best practices?

    Read the article

  • Equivalent of #map in ruby in golang

    - by Oct
    I'm playing with Go and run into something I'm unable to find in Google, although there is certainly something that exists: I'm using the following struct: type Syntax struct { name string extensions *regexp.Regexp } type Scanner struct { classifier * bayesian.Classifier save_file string name_to_syntax map[string] *Syntax extensions_to_syntax map[*regexp.Regexp] *Syntax } I'd like to perform the following using Go and I'm quoting ruby because it's how I'd do that using ruby: test_regexpes = my_scanner.extensions_to_syntax.keys My goal is to get an array of *regexp.Regexp . Any idea on how to do that in a simple way ? Thank you !

    Read the article

  • Why do iterators in Python raise an exception?

    - by NullUserException
    Here's the syntax for iterators in Java (somewhat similar syntax in C#): Iterator it = sequence.iterator(); while (it.hasNext()) { System.out.println(it.next()); } Which makes sense. Here's the equivalent syntax in Python: it = iter(sequence) while True: try: value = it.next() except StopIteration: break print(value) I thought Exceptions were supposed to be used only in, well, exceptional circumstances. Why does Python use exceptions to stop iteration?

    Read the article

  • What is the best testing pattern for checking that parameters are being used properly?

    - by Joseph
    I'm using Rhino Mocks to try to verify that when I call a certain method, that the method in turn will properly group items and then call another method. Something like this: //Arrange var bucketsOfFun = new BucketGame(); var balls = new List<IBall> { new Ball { Color = Color.Red }, new Ball { Color = Color.Blue }, new Ball { Color = Color.Yellow }, new Ball { Color = Color.Orange }, new Ball { Color = Color.Orange } }; //Act bucketsOfFun.HaveFunWithBucketsAndBalls(balls); //Assert ??? Here is where the trouble begins for me. My method is doing something like this: public void HaveFunWithBucketsAndBalls(IList<IBall> balls) { //group all the balls together according to color var blueBalls = GetBlueBalls(balls); var redBalls = GetRedBalls(balls); // you get the idea HaveFunWithABucketOfBalls(blueBalls); HaveFunWithABucketOfBalls(redBalls); // etc etc with all the different colors } public void HaveFunWithABucketOfBalls(IList<IBall> colorSpecificBalls) { //doing some stuff here that i don't care about //for the test i'm writing right now } What I want to assert is that each time I call HaveFunWithABucketOfBalls that I'm calling it with a group of 1 red ball, then 1 blue ball, then 1 yellow ball, then 2 orange balls. If I can assert that behavior then I can verify that the method is doing what I want it to do, which is grouping the balls properly. Any ideas of what the best testing pattern for this would be?

    Read the article

  • Is it possible to control the destination folder when checking out a project from VSS 2005?

    - by swolff1978
    We are currently using VSS 2005 for source control - and please let me start by saying, I've read a lot of posts on Stackoverflow and I realize VSS is the devil. That being said... its what we have to work with now and I have a question about the checkout process. We have the code organized in a certain hierarchy on the vss server, but when we do a checkout we don't need that same hierarchy on our machines. Is there a way to control how visual studio 2008 and vss 2005 create the checkout destination folder so that I don't end up with the code being 9 folders deep on MY machine?

    Read the article

  • Checking that all libs and dlls are from the same build?

    - by unknownthreat
    I am developing a program in VS C++ 2008. Right now, I have a huge list of dll and lib dependencies and I am adding some more. I worry that when I need to update a dependency by building from source (where I have to manually replace built dlls and libs in the correct place), if I accidently forgot to replace something or vice versa, I may run into a compile and/or runtime problem. And finding which place goes wrong can be a bit difficult. So is there some sort of program or method out there that can suit this task to ease building a program with many updating dependencies?

    Read the article

  • Checking if a touch is withing a UIButton's bounds.

    - by Joshua
    I am trying to make an if statement which will check whether the users touch is within a UIButton's bounds. I thought this would be an easy affair as UIButton is a subclass of UIView, however my code doesn't seem to work. This is the code I have been using. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSArray *array = [touches allObjects]; UITouch *specificTouch = [array objectAtIndex:0]; currentTouch = [specificTouch locationInView:self.view]; if (CGRectContainsPoint(but.bounds, currentTouch)) { //Do something is in bounds. } //Else do nothing. }

    Read the article

  • OpenSSL missing during ./configure. How to fix?

    - by P K
    I was trying to install node.js and found OpenSSL support missing during ./configure. How can I fix it? Is it a mandatory step? # ./configure Checking for gcc : ok Checking for library dl : not found Checking for openssl : not found Checking for function SSL_library_init : not found Checking for header openssl/crypto.h : not found /home/ec2-user/node-v0.6.6/wscript:374: error: Could not autodetect OpenSSL support. Make sure OpenSSL development packages are installed. Use configure --without-ssl to disable this message.

    Read the article

  • Difference between two kinds of Bing URL Referers

    - by joshuahedlund
    Most of the referral URLS that I get from Bing have the following syntax: http://www.bing.com/search?q=keywords+keywords&[some other variables] However I just noticed that maybe 10-20% of them are coming in like this: http://www.bing.com/url?source=search&[some other variables]&url=http%3A%2F%2Fwww.example.com/user-landing-page-on-my-site&yrktarget=_top&q=keywords+keywords&[some other variables] The first syntax gives me the keywords the user typed in, but the second actually gives me the keywords the user typed in and their landing page on my site. I was originally unaware of this second kind altogether because I have a customized referral report that filters out URLs containing my domain. But now that I noticed them I want to know why they occur to see if I can get more to occur this way because the second syntax contains more valuable information. If I go to one of the first URLs, it gives me a typical Bing query page. The second URLs seem to just redirect me to the Bing home page. I'm not sure if it has to do with the kind of search being performed (I also get a few http://www.bing.com/shopping/search?q= referers) or some other metric. Does anyone know what causes some referral URLs from Bing to have the /search?q syntax and others to have the /url?source syntax? P.S. I have verified that I am getting both kinds of URLs from non-advertising clicks. P.P.S. I am not talking about data in Google Analytics or similar software but the raw $_SERVER['HTTP_REFERER'] value coming from the client's original request.

    Read the article

  • How doe we name test methods where we are checking for more than one condition?

    - by Sandbox
    I follow the technique specified in Roy Osherove's The Art Of Unit Testing book while naming test methods - MethodName_Scenario_Expectation. It suits perfectly well for my 'unit' tests. But,for tests that I write in 'controller' or 'coordinator' class, there isn't necessarily a method which I want to test. For these tests, I generate multiple conditions which make up one scenario and then I verify the expectation. For example, I may set some properties on different instances, generate an event and then verify that my expectations from controller/coordinator is being met. Now, my controller handles events using a private event handler. Here my scenario is that, I set some properties, say 3 condition1,condition2 and condition3 Also, my scenario includes an event is raised I don't have a method name as my event handler is private. How do I name such a test method?

    Read the article

  • Why does Git display certain new folders when checking out old revisions?

    - by ConnorG
    Hey all - I'm still learning the ropes of Git (love it!) but the other day I noticed some behavior I just do not understand. We have, in essence, three folders that got moved into the repository at different times (one immediately after we created the repo, one a little while later, and one just recently). Recently, I had to get some code out of an old revision. I used git checkout <old SHA1 hash> to pull up one of our first checkins, when I noticed Git showed the old folder (as it should), as well as the newest folder (which got added to the repo long after the checked out commit was made). But it did not show the second folder. What would cause Git to display the newest folder with the old revision?

    Read the article

  • Should data structures be integrated into the language (as in Python) or be provided in the standard library (as in Java)?

    - by Anto
    In Python, and most likely many other programming languages, common data structures can be found as an integrated part of the core language with their own dedicated syntax. If we put LISP's integrated list syntax aside, I can't think of any other languages that I know which provides some kind of data structure above the array as an integrated part of their syntax, though all of them (but C, I guess) seem to provide them in the standard library. From a language design perspective, what are your opinions on having a specific syntax for data structures in the core language? Is it a good idea, and does the purpose of the language (etc.) change how good this could be of a choice? Edit: I'm sorry for (apparently) causing some confusion about which data structures I mean. I talk about the basic and commonly used ones, but still not the most basic ones. This excludes trees (too complex, uncommon), stacks (too seldom used), arrays (too simple) but includes e.g. sets, lists and hashmaps.

    Read the article

  • Easiest way of checking if a string consists of unique characters?

    - by serg555
    I need to check in Java if a word consists of unique letters (case insensitive). As straight solution is boring, I came up with: For every char in a string check if indexOf(char) == lastIndexOf(char). Add all chars to HashSet and check if set size == string length. Convert a string to a char array, sort it alphabetically, loop through array elements and check if c[i] == c[i+1]. Currently I like #2 the most, seems like the easiest way. Any other interesting solutions?

    Read the article

  • checking if records exists in DB, in single step or 2 steps?

    - by Sinan
    Suppose you want to get a record from database which returns a large data and requires multiple joins. So my question would be is it better to use a single query to check if data exists and get the result if it exists. Or do a more simple query to check if data exists then id record exists, query once again to get the result knowing that it exists. Example: 3 tables a, b and ab(junction table) select * from from a, b, ab where condition and condition and condition and condition etc... or select id from a, b ab where condition then if exists do the query above. So I don't know if there is any reason to do the second. Any ideas how this affects DB performance or does it matter at all?

    Read the article

  • Linq to Entities, checking for specific foreign key id?

    - by AaronLS
    I am trying to get rows where the foreign key ParentID == 0, and this is what I am trying but I get a NotSupportedException because it can't translate the ArrayIndex [0]: IQueryable<ApplicationSectionNode> topLevelNodeQuery = from n in uacEntitiesContext.ApplicationSectionNodeSet where (int)n.Parent.EntityKey.EntityKeyValues[0].Value == 0 orderby n.Sequence select n; So I need to pull that ArrayIndex out of the query so that the runtime can successfully translate the query. I'm not sure how to do that though. How does one query a specific object via it's primary key or set of objects via foreign key? Edit: Note that there is not actually a row in the table with NodeId == 0, the 0 is a magic value(not my idea) to indicate top level nodes. So I can't do n.Parent.NodeId == 0

    Read the article

< Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >