Search Results

Search found 6186 results on 248 pages for 'syntax'.

Page 12/248 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Rails syntax for comments in templates: is this bug understood?

    - by brahn
    Using rails 2.3.2 I have a partial _foo.rhtml that begins with a comment as follows: <% # here is a comment %> <li><%= foo %></li> When I render the partial from a view in the traditional way, e.g. <% some_numbers = [1, 2, 3, 4, 5] %> <ul> <%= render :partial => "foo", :collection => some_numbers %> </ul> I found that the <li> and </li> tags are ommitted in the output -- i.e. the resulting HTML is <ul> 1 2 3 4 5 </ul> However, I can solve this problem by fixing _foo.rhtml to eliminate the space between the <% and the # so that the partial now reads: <%# here is a comment %> <li><%= foo %></li> My question: what's going on here? E.g., is <% # comment %> simply incorrect syntax for including comments in a template? Or is the problem more subtle? Thanks!

    Read the article

  • Tip: Replacing Html.Encode Calls With New Html Encoding Syntax

    Like the well disciplined secure developer that you are, when you built your ASP.NET MVC 1.0 application, you remembered to call Html.Encode every time you output a value that came from user input. Didnt you? Well, in ASP.NET MVC 2 running on ASP.NET 4, those calls can be replaced with the new HTML encoding syntax (aka code nugget). Ive written a three part series on the topic. Html Encoding Code Blocks With ASP.NET 4 Html Encoding Nuggets With ASP.NET MVC 2 Using AntiXss as the default...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • End user query syntax?

    - by weberc2
    I'm making a command line tool that allows end users to query a statically-schemed database; however, I want users to be able to specify boolean matchers in their query (effectively things like "get rows where (field1=abcd && field2=efgh) || field3=1234"). I did Googling a solution, but I couldn't find anything suitable for end users--still, this seems like it would be a very common problem so I suspect there is a standard solution. So: What (if any) standard query "languages" are there that might be appropriate for end users? What (if any) de facto standards are there (for example, Unix tools that solve similar problems). Failing the previous two options, can you suggest a syntax that would be simple, concise, and easy to validate?

    Read the article

  • Useful code paste site tools

    - by acidzombie24
    I know there are site tools to check if your webpage is alive, has compression, etc but lets not get into that. What are useful sites to paste code in and to share links of? The three i know are http://codepad.org/ shows source and runs code online http://www.pastie.org/ share source with syntax highlighting http://jsfiddle.net/ great for JS help or for the occasional test. What else do you know of? One answer per question. I'll let lints and validators slide since you do paste code into them. Mention a weakness if you do know one so others wont be surprised or disappointed.

    Read the article

  • Tips on googling for sugar

    - by Mikey
    I have a question up on SO I am a little embarassed I can't just google: http://stackoverflow.com/questions/13734664/groovy-variables-in-method-names-with-double-question-marks The problem is google seems to chuck any terms that are just punctuation, so queries like these: .findBy?? .and?? groovy '??' Are coming out the same as these: findBy and groovy I have had this problem before when I didn't know the name of the elvis operator, and countless other times (probably happened first time I saw an infix '%' mod too if I had to guess). Is there a resource for syntax sugar lookups? Some way to force google or a different search engine to not ignore my funky punctuation?

    Read the article

  • Which useful alternative control structures do you know?

    - by bigown
    Similar question was closed on SO. Sometimes when we're programming, we find that some particular control structure would be very useful to us, but is not directly available in our programming language. What alternative control structures do you think are a useful way of organizing computation? The goal here is to get new ways of thinking about structuring code, in order to improve chunking and reasoning. You can create a wishful syntax/semantic not available now or cite a less known control structure on an existent programming language. Answers should give ideas for a new programming language or enhancing an actual language. Think of this as brainstorming, so post something you think is a crazy idea but it can be viable in some scenario. It's about imperative programming.

    Read the article

  • How should I pronounce the :: and -> in PHP?

    - by Renesis
    When I read these lines aloud to someone: $controller->process(); UserManager::getInstance(); How should the -> and :: be pronounced? Reading the characters themselves in cumbersome and I don't know of any nicknames for them. Being a developer who is used to C-style syntax, I'd like to say "dot", but I'd like something that is easy to say and people can easily understand. It would also be good to know if there are any pronunciations that have become de-facto standards among teams of developers.

    Read the article

  • Good sites for sharing code snippets & pastes that you can share links to?

    - by acidzombie24
    I know there are site tools to check if your webpage is alive, has compression, etc but lets not get into that. What are useful sites to paste code in and to share links to it? The three i know are http://codepad.org/ shows source and runs code online http://www.pastie.org/ share source with syntax highlighting http://jsfiddle.net/ great for JS help or for the occasional test. What else do you know of? One answer per question. I'll let lints and validators slide since you do paste code into them. Mention a weakness if you do know one so others wont be surprised or disappointed.

    Read the article

  • Why do node packages put a comma on a newline?

    - by SomeKittens
    I'm learning node.js and am trying out Express. My first app had this code: var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = require('http') , path = require('path'); Reading through the mongoose tutorial gives me this: var mongoose = require('mongoose') , db = mongoose.createConnection('localhost', 'test'); On strict mode, JSHint gives me app.js: line 6, col 32, Bad line breaking before ','. Which shows that I'm not the only one out there who's bugged by this syntax. Is there any reason to declare vars this way instead of adding the comma at the end of the line?

    Read the article

  • How should I pronounce the :: and -> in PHP?

    - by NickC
    When I read these lines aloud to someone: $controller->process(); UserManager::getInstance(); How should the -> and :: be pronounced? Reading the characters themselves in cumbersome and I don't know of any nicknames for them. Being a developer who is used to C-style syntax, I'd like to say "dot", but I'd like something that is easy to say and people can easily understand. It would also be good to know if there are any pronunciations that have become de-facto standards among teams of developers.

    Read the article

  • Help with correct php syntax [migrated]

    - by Robert hue
    I was working on some php functions and I got confused with php syntax. Here is the function. Is this correct? to use add_filter inside function_exists check if ( ! function_exists( 'disable_password_reset' ) ) : function disable_password_reset() { return false; } add_filter ( 'allow_password_reset', 'disable_password_reset' ); endif; or this one is correct, to use add_filter outside function_exists check if ( ! function_exists( 'disable_password_reset' ) ) : function disable_password_reset() { return false; } endif; add_filter ( 'allow_password_reset', 'disable_password_reset' ); I was working on Wordpress if that matters.

    Read the article

  • Help with cron syntax

    - by Randy
    I need to setup a cronjob on my webhost. The documentation for my webapp reads as follows: you will need to create following cronjob: /public_html/cake/console/cake -app /public_html/app master Also, I want any output written to a log file. My hosts documentation says this: You can have cron send an email everytime it runs a command. If you do not want an email to be sent for an individual cron job you can redirect the command's output to /dev/null like this: mycommand /dev/null 2&1 Can someone help me write the cron job? I dont know the syntax at all. Thanks for the help!

    Read the article

  • Help with cron syntax

    - by Randy
    I need to setup a cronjob on my webhost. The documentation for my webapp reads as follows: you will need to create following cronjob: /public_html/cake/console/cake -app /public_html/app master Also, I want any output written to a log file. My hosts documentation says this: You can have cron send an email everytime it runs a command. If you do not want an email to be sent for an individual cron job you can redirect the command's output to /dev/null like this: mycommand /dev/null 2&1 Can someone help me write the cron job? I dont know the syntax at all. Thanks for the help!

    Read the article

  • Why is an Add method required for { } initialization?

    - by Dan Tao
    To use initialization syntax like this: var contacts = new ContactList { { "Dan", "[email protected]" }, { "Eric", "[email protected]" } }; ...my understanding is that my ContactList type would need to define an Add method that takes two string parameters: public void Add(string name, string email); What's a bit confusing to me about this is that the { } initializer syntax seems most useful when creating read-only or fixed-size collections. After all it is meant to mimic the initialization syntax for an array, right? (OK, so arrays are not read-only; but they are fixed size.) And naturally it can only be used when the collection's contents are known (at least the number of elements) at compile-time. So it would almost seem that the main requirement for using this collection initializer syntax (having an Add method and therefore a mutable collection) is at odds with the typical case in which it would be most useful. I'm sure I haven't put as much thought into this matter as the C# design team; it just seems that there could have been different rules for this syntax that would have meshed better with its typical usage scenarios. Am I way off base here? Is the desire to use the { } syntax to initialize fixed-size collections not as common as I think? What other factors might have influenced the formulation of the requirements for this syntax that I'm simply not thinking of?

    Read the article

  • Practical considerations for HTML / CSS naming conventions (syntax)

    - by Jeroen
    Question: what are the practical considerations for the syntax in class and id values? Note that I'm not asking about the semantics, i.e. the actual words that are being used, as for example described in this blogpost. There are a lot of resources on that side of naming conventions already, in fact obscuring my search for practical information on the various syntactical bits: casing, use of interpunction (specifically the - dash), specific characters to use or avoid, etc. To sum up the reasons I'm asking this question: The naming restrictions on id and class don't naturally lead to any conventions The abundance of resources on the semantic side of naming conventions obscure searches on the syntactic considerations I couldn't find any authorative source on this There wasn't any question on SE Programmers yet on this topic :) Some of the conventions I've considered using: UpperCamelCase, mainly as a cross-over habit from server side coding lowerCamelCase, for consistency with JavaScript naming conventions css-style-classes, which is consistent with naming of css properties (but can be annoying when Ctrl+Shift+ArrowKey selection of text) with_under_scores, which I personally haven't seen used much alllowercase, simple to remember but can be hard to read for longer names UPPERCASEFTW, as a great way to annoy your fellow programmers (perhaps combined with option 4 for readability) And probably I've left out some important options or combinations as well. So: what considerations are there for naming conventions, and to which convention do they lead?

    Read the article

  • nano syntax highlighting not working for all languages

    - by Dejan
    I have a funny situation where I am unable to add custom highlighting definitions to my nano text editor. The funny thing is that the predefined work like a charm and can be edited. But I have created a new one for js with $ sudo touch js.nanorc $ sudo nano js.nanorc my current js.nanorc looks like this: syntax "JavaScript" "\.js$" color blue "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>" color blue "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" color blue "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" color brightblue "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" color black "[(]" color cyan "\<(break|case|catch|continue|default|delete|do|else|finally)\>" color cyan "\<(for|function|get|if|in|instanceof|new|return|set|switch)\>" color cyan "\<(switch|this|throw|try|typeof|var|void|while|with)\>" color cyan "\<(null|undefined|NaN)\>" color brightcyan "\<(true|false)\>" color green "\<(Array|Boolean|Date|Enumerator|Error|Function|Math)\>" color green "\<(Number|Object|RegExp|String)\>" color red "[-+/*=<>!~%?:&|]" color magenta "/[^*]([^/]|(\\/))*[^\\]/[gim]*" color yellow ""(\\.|[^"])*"|'(\\.|[^'])*'" color magenta "\\[0-7][0-7]?[0-7]?|\\x[0-9a-fA-F]+|\\[bfnrt'"\?\\]" color brightblack "(^|[[:space:]])//.*" color brightblack start="/\*" end="\*/" color brightwhite,cyan "TODO:?" color ,green "[[:space:]]+$" color ,red " +" If anyone can see the problem then please tel me

    Read the article

  • Purpose of "new" keyword

    - by Channel72
    The new keyword in languages like Java, Javascript, and C# creates a new instance of a class. This syntax seems to have been inherited from C++, where new is used specifically to allocate a new instance of a class on the heap, and return a pointer to the new instance. In C++, this is not the only way to construct an object. You can also construct an object on the stack, without using new - and in fact, this way of constructing objects is much more common in C++. So, coming from a C++ background, the new keyword in languages like Java, Javascript, and C# seemed natural and obvious to me. Then I started to learn Python, which doesn't have the new keyword. In Python, an instance is constructed simply by calling the constructor, like: f = Foo() At first, this seemed a bit off to me, until it occurred to me that there's no reason for Python to have new, because everything is an object so there's no need to disambiguate between various constructor syntaxes. But then I thought - what's really the point of new in Java? Why should we say Object o = new Object();? Why not just Object o = Object();? In C++ there's definitely a need for new, since we need to distinguish between allocating on the heap and allocating on the stack, but in Java all objects are constructed on the heap, so why even have the new keyword? The same question could be asked for Javascript. In C#, which I'm much less familiar with, I think new may have some purpose in terms of distinguishing between object types and value types, but I'm not sure. Regardless, it seems to me that many languages which came after C++ simply "inherited" the new keyword - without really needing it. It's almost like a vestigial keyword. We don't seem to need it for any reason, and yet it's there. Question: Am I correct about this? Or is there some compelling reason that new needs to be in C++-inspired memory-managed languages like Java, Javascript and C#?

    Read the article

  • Why do memory-managed languages retain the `new` keyword?

    - by Channel72
    The new keyword in languages like Java, Javascript, and C# creates a new instance of a class. This syntax seems to have been inherited from C++, where new is used specifically to allocate a new instance of a class on the heap, and return a pointer to the new instance. In C++, this is not the only way to construct an object. You can also construct an object on the stack, without using new - and in fact, this way of constructing objects is much more common in C++. So, coming from a C++ background, the new keyword in languages like Java, Javascript, and C# seemed natural and obvious to me. Then I started to learn Python, which doesn't have the new keyword. In Python, an instance is constructed simply by calling the constructor, like: f = Foo() At first, this seemed a bit off to me, until it occurred to me that there's no reason for Python to have new, because everything is an object so there's no need to disambiguate between various constructor syntaxes. But then I thought - what's really the point of new in Java? Why should we say Object o = new Object();? Why not just Object o = Object();? In C++ there's definitely a need for new, since we need to distinguish between allocating on the heap and allocating on the stack, but in Java all objects are constructed on the heap, so why even have the new keyword? The same question could be asked for Javascript. In C#, which I'm much less familiar with, I think new may have some purpose in terms of distinguishing between object types and value types, but I'm not sure. Regardless, it seems to me that many languages which came after C++ simply "inherited" the new keyword - without really needing it. It's almost like a vestigial keyword. We don't seem to need it for any reason, and yet it's there. Question: Am I correct about this? Or is there some compelling reason that new needs to be in C++-inspired memory-managed languages like Java, Javascript and C#?

    Read the article

  • How exactly is an Abstract Syntax Tree created?

    - by Howcan
    I think I understand the goal of an AST, and I've build a couple of tree structures before, but never an AST. I'm mostly confused because the nodes are text and not number, so I can't think of a nice way to input a token/string as I'm parsing some code. For example, when I looked at diagrams of AST's, the variable and its value were leaf nodes to an equal sign. This makes perfect sense to me, but how would I go about implementing this? I guess I can do it case by case, so that when I stumble upon an "=" I use that as a node, and add the value parsed before the "=" as the leaf. It just seems wrong, because I'd probably have to make cases for tons and tons of things, depending on the syntax. And then I came upon another problem, how is the tree traversed? Do I go all the way down the height, and go back up a node when I hit the bottom, and do the same for it's neighbor? I've seen tons of diagrams on ASTs, but I couldn't find a fairly simple example of one in code, which would probably help.

    Read the article

  • Perl syntax error [closed]

    - by Linny
    I am a beginner taking a Perl programming course. We are trying to write a basic program for counting nucleotides in a DNA string. I'm getting syntax errors on the lines that have a single bracket on lines 28 & 70 and don't know why. It also reads that I have compilation errors. I have no idea where to start figuring that out. # The purpose of this program is to count the number of nucleotides in a strand. Each protein is counted separately # print "/n NOTE: Nucleotide counting /n"; # use strict; # enforce variable declarations use warnings; # enable compiler warnings # Display number of A,a,T,t,G,g,C,c, nucleotides in a word or sequence of letters. # my ($base) = ''; # an extracted letter from a string my ($nuceotide_count) = 0 ; # the current position within the word my ($position) = 0 ; # number of vowels in user-supplied word my ($word) = ''; # word to be processed my ($A_count) = 0 ; # of A nucleotides in the user-supplied sequence my ($a_count) = 0 ; # of A nucleotides in the user-supplied sequence my ($C_count) = 0 ; # of C nucleotides in the user-supplied sequence my ($c_count) = 0 ; # of C nucleotides in the user-supplied sequence my ($G_count) = 0 ; # of G nucleotides in the user-supplied sequence my ($g_count) = 0 ; # of G nucleotides in the user-supplied sequence my ($T_count) = 0 ; # of T nucleotides in the user-supplied sequence my ($t_count) = 0 ; # of T nucleotides in the user-supplied sequence word = (STDIN) for ($position = 0);($position if (($base eq 'a') or ($base eq 'A')) { ++$A_count; } # end if ++$position; if (($base eq 'T') or ($base eq 't')) { ++$T_count; } end if ++$position; if (($base eq 'G') or ($base eq 'g')) { ++$G_count; } # end if ++$position; if (($base eq 'C') or ($base eq 'c')) { ++$C_count; } # end if ++$position; } # end for # Display final results. # print " \n The number of A or a neucleotides is: $A_count"; print " \n The number of T or t neucleotides is: $T_count"; print " \n The number of G or g neucleotides is: $G_count"; print " \n The number of C or c neucleotides is: $C_count"; print " \n\n Program completed successfully. \n" ; exit ;

    Read the article

  • Why I am getting Null from this statement. Query Syntax in C#

    - by Shantanu Gupta
    This is not working. Returns Null to dept_list. var dept_list = ((from map in DtMapGuestDepartment.AsEnumerable() where map.Field<Nullable<long>>("Guest_Id") == 174 select map.Field<Nullable<long>>("Department_id")).Distinct())as IEnumerable<DataRow>; DataTable dt = dept_list.CopyToDataTable(); //dept_list comes null here This works as desired. var dept_list = from map in DtMapGuestDepartment.AsEnumerable() where map.Field<Nullable<long>>("Guest_Id") == 174 select map; DataTable dt = dept_list.CopyToDataTable(); //when used like this runs correct. What mistake is being done by me here. ?

    Read the article

  • How to write the Visitor Pattern for Abstract Syntax Tree in Python?

    - by bodacydo
    My collegue suggested me to write a visitor pattern to navigate the AST. Can anyone tell me more how would I start writing it? As far as I understand, each Node in AST would have visit() method (?) that would somehow get called (from where?). That about concludes my understanding. To simplify everything, suppose I have nodes Root, Expression, Number, Op and the tree looks like this: Root | Op(+) / \ / \ Number(5) \ Op(*) / \ / \ / \ Number(2) Number(444) Can anyone think of how the visitor pattern would visit this tree to produce output: 5 + 2 * 444 Thanks, Boda Cydo.

    Read the article

  • Using C# and gppg, how would I construct an abstract syntax tree?

    - by Rupert
    Is there a way to do this almost out-of-the-box? I could go and write a big method that would use the collected tokens to figure out which leaves should be put in which branches and in the end populate a TreeNode object, but since gppg already handled everything by using supplied regular expressions, I was wondering if there's an easier way? Even if not, any pointers as to how best to approach the problem of creating an AST would be appreciated. Apologies if I said anything silly, I'm only just beginning to play the compiler game. :)

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >