Menu
  • HOME
  • TAGS

Show the data from two date fields ordered by the name of the month

mysql,syntax

I think these SQL useful to you. SELECT `firstname` , `gender` , MONTHNAME( `dol` ) AS 'month' FROM `student_details` WHERE `doa` = '2015-03-01' AND `dol` = '2015-06-17' Below SQL give exact result i think. SELECT `firstname` , `gender` , SUBSTRING(MONTHNAME( `dol` ),1,3) AS 'month' FROM `student_details` WHERE `doa` = '2015-03-01'...

What's this Coffescript use of then?

syntax,coffeescript,semantics

Of course ... It calls the newcard.save().then function - thanks @rightfold - which is in the Angular.js promises api. Not immediately obvious out of context of that api which BTW is nicely explained here.

Objective-C syntax: <>

objective-c,syntax

In your example above, C is a protocol. What you're saying in english terms is: I want a class A that subclasses from class B and also conforms to protocol C. A protocol is similar to an abstract class in other languages and usually defines a set of methods and...

How to specify the prior probability for scikit-learn's Naive Bayes

python,syntax,machine-learning,scikit-learn

The GaussianNB() implemented in scikit-learn does not allow you to set class prior. If you read the online documentation, you see .class_prior_ is an attribute rather than parameters. Once you fit the GaussianNB(), you can get access to class_prior_ attribute. It is calculated by simply counting the number of different...

Does the ternary operator work in constant definition?

objective-c,syntax,ternary

{187, 187} and {206, 206} aggregates are valid as an initialization expressions, but not as a general-purpose expressions*. That is why a ternary operator does not allow it. If you are making an initializer for a local constant, you could use CGSizeMake: CGSize const ksizeSmall = SOME_BOOLEAN_VARIABLE ? CGSizeMake(187, 187)...

Javascript for loop without recalculating array's length

javascript,arrays,loops,for-loop,syntax

You can chain variable declarations like this var i = 0, foo="bar", hello = "world" Which is close to the same thing as var i = 0; var foo = "bar"; var hello = "world"; So this for(var i = 0, len = keys.length; i < len; i++) Is the...

Java - Explicit method call for a generic class? [duplicate]

java,google-app-engine,generics,syntax

The create method accepts generic parameter, so the parameter type was passed. you can read more about generic parameters here...

Bash script error server issue

linux,bash,syntax,scripting

We can simplify a few: #!/bin/bash servers="server1.... server2...." seconds="3" # value for servers to differ (in seconds) for server in $servers do remote=$(ssh -l root ${server} date +%s ) now=$(date +%s) if [ "$remote" -gt "$now" ] then diff=$(expr $remote - $now) else diff=$(expr $now - $remote) fi echo $diff...

Why is a defined token not recognized during syntax analysis in C using Bison?

c,syntax,compiler-construction,token,lexical

Your scanner returns NUM when it has found a sequence of digits, not digit. The identifier digit is just used internally in your Flex specification. Then you have another digit defined as a token in your Bison grammar, but it is not connected in any way to the Flex one....

Python stats.linregress syntax error

python,syntax,regression,linear

Your last variable, or rather pair of variables, is invalid. Syy/Sxx If that is supposed to be a single variable, know that you cannot have / in your variable name. Python identifiers and keywords Identifiers (also referred to as names) are described by the following lexical definitions: identifier ::= (letter|"_")...

Android SQLiteException syntax error code 1

android,syntax,android-sqlite

You can't call a column "WHEN", since it is a keyword in sqlite

How can I tell the dartanalyzer what kind of Element the selected object is?

object,syntax,types,dart

You can use as to "cast" in Dart. import 'dart:html'; ... if((querySelector('#username') as InputElement).value!="") ...

Count variable Invalid Syntax [on hold]

python,variables,syntax

The specific error you are asking about is because of the missing colon: And card1 cannot be called. if guess==card1() count+=1 Should be if guess==card1: count+=1 There is also a missing closing bracket on the guess: guess = int(input(""" Pick One! 1:'Crown', 2:'Anchor', 3:'Heart', 4:'Diamond', 5:'Club', 6:'Spade', 0:'Quit', """)) ...

Where does the syntax for expressions in SSRS come from?

reporting-services,syntax

The SSRS expressions are based on Visual Basic. Expressions are written in Microsoft Visual Basic, and can use built-in functions, custom code, report and group variables, and user-defined variables. Expressions begin with an equal sign (=). Source: Expression Examples (Report Builder and SSRS) The IIF() function is "inherited" from VB,...

C structure syntax

c,syntax

C typedef declarations are understood by analogy with variable declarations. int a, *b; declares the values a of type int and b of type int*. typedef int A, *B; declares the type A equivalent to int and the type B equivalent to int*. So, just think about what the variable...

How to access Objective C unnamed parameters of some method?

objective-c,methods,syntax,parameters

The labels are the things before the type. You can omit them (except for the first one, because it is the name of the method). So you are allowed to declare this: - (float) divNum1: (int) a : (int) b; And define it like this: - (float) divNum1: (int) a...

Why does pattern “*.so?(.*)” produce a syntax error in a script but not on command line?

bash,shell,syntax

You are using an extended glob but these aren't enabled by default within a script. In order to using them, they must be explicitly enabled. You can do so by adding this before the line: shopt -s extglob To disable them later on in the script, you can use shopt...

Unable to recognize syntax error [closed]

perl,syntax

The statement starting on line 10 is missing its terminating semi-colon. my $hash_form = { 'KEY' => $key, 'HASH' => $hash, 'action' => $action, } should be my $hash_form = { 'KEY' => $key, 'HASH' => $hash, 'action' => $action, }; ...

Yaml syntax to create this array

syntax,yaml

I think you're after either this: - foo: 1 bar: - one - two - three - foo: 2 bar: - one1 - two2 - three3 Which gives you this structure: [ { "foo": 1, "bar": [ "one", "two", "three" ] }, { "foo": 2, "bar": [ "one1", "two2", "three3"...

Need help in understanding this c++ syntax [ const char * what () const throw () ]

c++,syntax

It's a member function definition. const char * is the return type, a pointer to a constant character, by convention the first character of a zero-terminated string array. what is the function name () is an empty parameter list, indicating that the function takes no arguments const qualifies the function,...

SyntaxError: invalid syntax?

python,syntax

Check the code before the print line for errors. This can be caused by an error in a previous line; for example: def x(): y = [ print "hello" x() This produces the following error: File "E:\Python\test.py", line 14 print "hello" ^ SyntaxError: invalid syntax When clearly the error is...

Java syntax explanation - getMenuInflater()

java,android,syntax

The line getMenuInflater().inflate(R.menu.menu_quiz, menu); is a short form of this: MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_quiz, menu) ...

How can the suffix for numeric literals long int and long double both be l/L?

c++,syntax,literals

A literal number needs to have a period or an exponent to be treated as a floating point literal constant. If it doesn't have any of these, it is treated as an integer literal constant.

VHDL: (vcom-1136: std_logic_vector undefined)

syntax,vhdl

The use of IEEE.std_logic_1164.all is also required before the entity, like: library IEEE; use IEEE.std_logic_1164.all; entity lab2 is The first IEEE.std_logic_1164.all only applies to the package, and package body of the same package, but not to any other design objects like an entity or package, even if these happens to...

Error when summing variable and number inside brackets NoMethodError

ruby,syntax,brackets

IMHO this line of code causes problem if nums[i] + nums[b] == 0 in case when nums = [1, 2, 3] so length is 3; when i = 2 then b = 3. When b = 3 then nums[b] (nums[3]) is nil. possible solution def two_sum(nums) i = 0 while...

MySQL - Querying for names for a different table corresponding to their ids

mysql,syntax

I think you just want two left joins: SELECT e.TO_ADD, e.FROM_ADD, ufrom.USER_FIRST_NAME, uto.USER_FIRST_NAME, e.MESSAGE FROM EMAIL e LEFT JOIN USERS ufrom ON ufrom.USER_ID = e.FROM_ADD LEFT JOIN USERS uto ON uto.USER_ID = e.TO_ADD ORDER BY ufrom.USER_FIRST_NAME DESC; ...

changing letter into an encryption in java. simple call

java,syntax,ascii

Acutally its \u0061 = a so one and so forth, it is a primitive way to code i think. it is not a nuclear weapon program. :) not all know this.

To generate a list for each map key as iterating through list?

groovy,syntax

You can create a map using [ key: value] notation. Since your value is an array of two elements you can simply create it using [element1,element2] notation, and then you can add the object to the map using << operator. So this myMap << [ (object) : [element1,element2]] can do...

Why would “SELECT * FROM user” throw a syntax error? [duplicate]

c#,sql,database,ms-access,syntax

User is a keyword so u should enclose it with [] SELECT * FROM [user] ...

Why is f <$> g <$> x equivalent to (f . g) <$> x although <$> is not right-associative?

haskell,syntax,infix-notation,applicative,infix-operator

Why is f <$> g <$> x equivalent to (f . g) <$> x ...well, this isn't so much a functor-thing as a Haskell-thing. The reason it works is that functions are functors. Both <$> operators work in different functors! f <$> g is in fact the same as...

Adding selectmenu on select that's calling functions

javascript,jquery,jquery-ui,syntax,jquery-ui-selectmenu

So, i went back to the Jquery Documentation and found the correct syntax to make this work. I also learned a little more about how to use the console tab in developer tools view to track down syntax errors. $(function() { var work = $( "#display" ); $( "#selector" ).selectmenu...

What does ** (double asterisk) mean in JavaScript?

javascript,syntax

Those would both be syntax errors. It is perhaps an attempt to use Markdown style for bold text (i.e. **text** becomes text). StackOverflow uses Markdown in questions, answers, and comments. It is completely unrelated to JavaScript. However, in this case, the action seems to be intended to make that text...

UPDATED - calculating the tuition total

java,syntax,types,resolve

Your main method located at the top of your class: public static void main(String[] args) { Is never closed, you should do something like this: public static void main(String[] args) { } Now your error should be resolved but without something inside your main method your code will probably not...

PHP search with MySQL error [duplicate]

php,mysql,syntax

You're missing a closing curly brace here: if($count == 0){ $output = 'Keine Ergebnisse gefunden!'; }else{ while($row = mysql_fetch_array($query)) { $Vname = $row['Vorname']; $Nname = $row['Nachname']; $id = $row['id']; $output .= '<div>'.$Vname.' '.$Nname.'</div>'; } Notice how you close the while, but you never close the else. Just add a closing...

New python async and await keywords [closed]

python,asynchronous,syntax

In a nutshell, because this is a broad topic: @asyncio.coroutine def foo(): bar = yield from some_async_func() print(bar) asyncio.get_event_loop().run_until_complete(foo()) This defines a coroutine using the asyncio module. foo is a coroutine, and it makes a call to a coroutine some_async_func (because it makes a call to an asynchronous function it...

Symbolic notation for functions in Matlab

matlab,syntax,symbolic-math

Partially, but not within the main part of Matlab. If you use MuPAD (type mupad in your Command Window), the engine behind much of the Symbolic Math toolbox, you can display/print results from calculations in your notebook with various levels of formatting. However, it does not appear that one can...

Simple ruby syntax if statement. Is this possible?

ruby,if-statement,syntax

I would use include? to make it more readable: if ([3,5,7].include?a and b == 2 and [5,6].include?c and [8,9,0].include?d) ...

Parenthesis after variable name C++

c++,syntax

It appears operator() is overloaded for the tyupe of UDefEnerfyH. One way to do this is this solution #include <iostream> using namespace std; struct MJ { void GetLowEdgeEnergy(size_t arg) { cout << "GetLowEdgeEnergy, arg = " << arg << endl; } void operator ()(size_t arg) { cout << "operator (),...

C# No value given for one or more required parameters

c#,sql,syntax,ms-access-2007,helper

Your column name creditcardNum missing t Command.CommandText = "UPDATE Table1 SET Username='"+textBox10.Text+"' , Email='"+textBox9.Text+"' , FirstName='"+textBox8.Text+ "' , LastName='"+textBox7.Text+"' , CrediCardNum='"+textBox6.Text+"' Where Username='"+m[0]+"'" ; it should be Command.CommandText = "UPDATE Table1 SET Username='"+textBox10.Text+"' , Email='"+textBox9.Text+"' , FirstName='"+textBox8.Text+ "' , LastName='"+textBox7.Text+"' , CreditCardNum='"+textBox6.Text+"' Where Username='"+m[0]+"'" ; Your table definition picture saying...

Reading binary file to a string but the types are mixed

c,file-io,syntax,binaryfiles

As @chux said, the \x that VS is displaying to you is an inseparable part of the char representations that VS is presenting to you. It is trying to be helpful by providing a form that can be used directly in C source code as a char literal. For example,...

Javascript For Loop with Iterator In the Middle and Decrement Operator to the Left of i?

javascript,for-loop,syntax,decrement

In js, 0 means false, and the other values like 1 are true. why is the iteration statement in the middle for(var i = x; --i; /* optional */ ) ^^ its decrement as well as the condition loop continues until, i is 0 In fact, you can create infinite...

Python method that can be called on a list of objects

python,oop,syntax

The only way to do exactly what you're asking for is to subclass python build-in class list. This should help....

What is the difference between `a` and `*a` where `a` denotes a 2D array?

c,arrays,pointers,multidimensional-array,syntax

Given the declaration int a[3][4]; the following are true: Expression Type Decays to Value ---------- ---- --------- ----- a int [3][4] int (*)[4] Base address of array &a int (*)[3][4] n/a Base address of array *a int [4] int * Base address of first subarray (equivalent to a[0]) a[i] int...

Assigning a value to an object of type AnyObject

swift,syntax,parse.com

Are you sure you don't want to use a PFObject class instead of an AnyObject? var post :PFObject? post?["caption"] = captionTextView.text https://www.parse.com/apps/quickstart#parse_data/mobile/ios/swift/existing...

Does Maria DB support ANSI-89 join syntax

sql,database,join,syntax,mariadb

Short answer - yes, both options are supported.

Java syntax to Groovy syntax

java,groovy,syntax

The following should work: import java.security.cert.* import javax.net.ssl.* TrustManager[] trustAllCerts = [ [ getAcceptedIssuers: { -> null }, checkClientTrusted: { X509Certificate[] certs, String authType -> }, checkServerTrusted: { X509Certificate[] certs, String authType -> } ] as X509TrustManager ] ...

Does “Text” in the HTML5 syntax mean “any character”?

html,html5,text,syntax

The character restriction for text on your page and in your markup is defined according to your selected character set. If you don't define a character set, the browser will take a guess or assert its default option (usually, whatever is the least restrictive). The character set is defined by...

ORA-00939: too many arguments for function in CASE Statement

sql,oracle,syntax,arguments,substr

SUBSTR(fridge_door_modela_id, 0, INSTR(fridge_door_modela_id, 'EXCR'),1) The above syntax for SUBSTR is incorrect. The correct syntax is: SUBSTR( string, start_position [, length ] ) Also, the index of substr starts from 1 and not 0. Executing it in SQL*Plus shows the exact error clearly, see the following error: SQL> WITH DATA...

Why are brackets required to print type information of .?

haskell,syntax,parse-error

. without the parentheses only works in infix position. :t however takes an expression, e.g. a function, and to turn an infix operator symbol into an expression, you need to surround it with parens. Consider: 3 + 4 = (+) 3 4 -- pseudocode and myPlus = (+) which is...

Checking, if optional parameter is provided in Dart

syntax,dart,syntax-error,questionmark

The feature existed at some point in Dart's development, but it was removed again because it caused more complication than it removed, without solving the problem that actually needed solving - forwarding of default parameters. If you have a function foo([x = 42]) and you want a function to...

Mysql Syntax “if length then” statement

mysql,sql,if-statement,syntax

The syntax is: SELECT uniqueid AS uniqueid_idx, calldate, src, dst, dstchannel, billsec, SUBSTR(CONVERT(IF(LENGTH(dst)>8,cdr.dst,CONCAT('67',cdr.dst)),UNSIGNED INTEGER),1,6) prefixo_normal, IF(LENGTH(dst) < 4, dst, NULL) AS ramal FROM cdr There's no THEN or END when you use the IF function....

Double dollar variables with arrays

php,syntax

You were very close. You need to tell PHP to evaluate the $a alone. Try: <?php $a = 'test'; $test = ['a', 'b']; echo ${$a}[0]; Example...

Syntax error python 2.7 [closed]

python,syntax,flask,pydub

return AudioSegment.from_file(getFilePath(filename, format="wav") Looks like you're missing a parenthesis. return AudioSegment.from_file(getFilePath(filename), format="wav") ...

Python iterative loop

python,loops,syntax,iteration

There seems to be no need to use enumerate here. Just iterate over strings directly: for s in strings: if findWholeWord(s)(line) != None: print (jd['user_id'], jd['text']) break If you also need the index variable n, then use enumerate: for n, s in enumerate(strings): if findWholeWord(s)(line) != None: # do something...

Getting four bits from the right only in a byte using bit shift operations

c,syntax,bit-manipulation,bitwise-operators

Shift operator only only works on integral types. Using << causes implicit integral promotion, type casting b to an int and "protecting" the higher bits. To solve, use temp = ((unsigned char)(b << 4)) >> 4;...

Ruby on Rails favoriting controller & syntax problems

ruby-on-rails,ruby,syntax,favorites

I'm assuming the User can have many Favorites, since you're attempting to single one out via params[:id]. If that's the case, try changing .favorite to .favorites. Hope that solves it!...

While statement has no body?

java,loops,syntax,while-loop

Just add an empty body. Like this while( x + ++flips < 8 && board[x + flips][y] == opponent ){}.

Is this list comprehension pythonic enough? [duplicate]

python,syntax,list-comprehension

You can use a generator expression: cubed = (x ** 3 for x in range(1, 11)) cube4 = [c for c in cubed if c % 4 == 0] This still iterates over range() only once, but now the x ** 3 expression is calculated just the once as the...

How to DROP DATABASE named “/”

mysql,database,syntax,drop-database

You need backticks: DROP DATABASE `/`; ...

Swift Function Syntax Breakdown

swift,syntax

You are using the word "closure" wrong. All functions are closures in Swift. What makes this function special is that is anonymous. That means there is no declaration line — so there needs to be another way of expressing the incoming parameters. Swift's solution is that you put the parameter...

Why do I get a “MySQLSyntaxErrorException:” error?

java,mysql,sql,syntax

DATABASE is a MySQL reserved word. Use a different name for the table

Looking for a nicer python syntax to pass multiple parameters to a single-parametered lambda

python,syntax,lambda

This was unfortunately removed in Python3. :-( The idea was that this hinders introspection. Instead of figuring out how a function is called by the signature, it would require analyzing bytecode (not the syntax tree)....

What is the difference between _ and _variable in prolog?

syntax,prolog

_ alone is an anonymous variable. Multiple occurrences in the same clause (or the same read-term) represent different variables. A variable starting with _ but containing further characters is not an anonymous variable. Several occurrences represent the same variable. By convention, many Prolog systems require that variables occurring only once...

How to differentiate between assigning and declaring values from a function with multiple returns?

syntax,go

In this case you can't use the short variable declarations ":=" for redeclaring the foo variable, according to the spec: Unlike regular variable declarations, a short variable declaration may redeclare variables provided they were originally declared earlier in the same block with the same type, and at least one of...

Can I merge an unknown named graph with an other in a SPARQL query?

syntax,merge,rdf,sparql

There is no standard way to change the dataset beign queried after the query starts. This is especially true if FROM is loading from the web. If you can put all the possible graphs in the datasets, you can use GRAPH. if you can't, then your two step approach is...

php syntax error with if and else

php,syntax

Remove endif; When you use curly braces you don't need (and cannot use) endif. This: if (true) { echo 'hello'; } else { echo 'goodbye'; } ...is equivalent to this: if (true): echo 'hello'; else: echo 'goodbye'; endif; You cannot mix the two styles....

Java syntax with “ : ” [duplicate]

java,syntax

It's called a label and it's used for naming loops. It's useful when you have nested loops and you want to apply break; (or continue;) to a particular one. For example: outer: for (int i = 0; i < 5; i++) { inner : for (int j = 0; j...

Erlang basic syntax error

syntax,erlang

In REPL you have to use fun(...) -> ... end: 1> F = fun(X) -> X end. #Fun<erl_eval.6.80484245> 2> F(42). 42 If you have code in file use c command: 1> c(word_count). {ok,word_count} 2> word_count:word_count([]). 0 ...

Why can I call the stream() method on objects of a class that don't have the stream()-method?

java,collections,syntax,java-stream

Did you check the right class and Java version? Java 8's Collection (not Collections) has a stream() default method, which is inherited by ArrayList: /** * Returns a sequential {@code Stream} with this collection as its source. * * <p>This method should be overridden when the {@link #spliterator()} * method...

What does `\+` signify as an operator in prolog?

syntax,prolog

It is a non-provable operator. See this link to learn more. Basically, it's true if the argument is not provable.

How to jump/display the column of an error

python,vim,syntax,pylint,syntastic

Syntastic stores the errors in the location list window. You can use :lopen to show it, and then use commands like :ll (or <Enter>) to jump to the error under the cursor. Alternatively, you can also navigate through errors via :lnext and related commands. If the corresponding error message did...

How to define the type of elements in an rdf:Seq?

syntax,rdf,owl,rdfs,turtle

There are probably a number of ways to accomplish this, depending on your implementation preferences. My advice is to use the rdf:li special property in place of the arbitrary rdf:_nnn, which is easier to extend. rdf:li is equivalent to rdf:_1, rdf:_2 in order. So the following code blocks are equivalent:...

What does the builtin function any() do?

python,if-statement,syntax,any

As the docs for any say: Return True if any element of the iterable is true. If the iterable is empty, return False. Equivalent to: def any(iterable): for element in iterable: if element: return True return False So, this is equivalent to: for element in (i in string for i...

Is this Swift syntax efficient?

ios,swift,syntax

It fires everytime the getter is called. No way this could be optimized away. You might want to keep a preset colors array in sync with the photos property, i.e. change it directly when setting the photos. I also dislike the tight coupling in that place which seems unnecessary. I...

replace the $ in php variable declaration

php,syntax,bison,abstract-syntax-tree

I was able to solve this issue, Two steps need to be taken: Make PHP not parse '#' as comments: Change: <ST_IN_SCRIPTING>"#"|"//" { To <ST_IN_SCRIPTING>"//" { In line 1901 in zend_language_scanner.l Tokenize #a as a variable: Change: simple_variable: T_VARIABLE { $$ = $1; } | '$' '{' expr '}' {...

The strange syntax of a C debug macro

c,syntax

C has an interesting quirk that it concatenates string literals. If you type "DEBUG %s:%d: " "HELLO %s!" "\n" Then the compiler sees that as one string: "DEBUG %s:%d: HELLO %s!\n". So users can use this macro as if it were simply had printf parameters: debug("HELLO %s", username); //on line...

EXPLAIN in postgresql not working

sql,postgresql,syntax,syntax-error,explain

It should not work - DDL statements has no plan - so EXPLAIN has nothing to show.

parenthetical parameters in Ruby / Rails

ruby-on-rails,ruby,methods,syntax,parameters

Lack of parentheses in this example indicates the problem of parsing such an expression. Generally, in Ruby you can omit them when it is clear "how to pass arguments". Let's consider the following situation - I have add and multi methods defined: def add(*args) args.inject(:+) end def multi(*args) args.inject(:*) end...

What is the use of text with colon operator (eg: Test:) in java [duplicate]

java,syntax

Text followed by a colon (:) is called a label. It can be used in the context of control structures (such as loops) to break to or continue at. In this context, although perfectly legal, it's pointless.

What is the correct way to create a object array in java? [duplicate]

java,syntax

Any of the above are allowed. All produce the same bytecode. JLS-10.2 Array Variables says (in part) The [] may appear as part of the type at the beginning of the declaration, or as part of the declarator for a particular variable, or both. ...

Is it possible to define a CAPL function returning a text string?

string,syntax,capl

You have to do it as you would do with string-based functions : void ErrorCodeToMsg(char buffer[], int code){ buffer = myListOfCodes[code]; } The value will be stored in the buffer using its reference value. It is not possible to return string in Capl. This is why you can't access String...

Java For Loop Termination Condition: == vs <= vs >=

java,for-loop,syntax

A for loop can always be translated to a while loop as follows: for(initialization; condition; step) { block; } To initialization; while (condition) { block; step; } So if your condition is i == upperBound, the loop will never run, because the condition doesn't start out as true. <= will...

Why does adding parentheses in if condition results in compile error?

syntax,go,syntax-error

The answer is not simply "because Go doesn't need parentheses"; see that the following example is a valid Go syntax: j := 9 if (j > 0) { fmt.Println(j) } Go Spec: If statements: IfStmt = "if" [ SimpleStmt ";" ] Expression Block [ "else" ( IfStmt | Block )...

Swift 2 - Pattern matching in “if”

swift,if-statement,syntax,pattern-matching,swift2

All it really means is that if statements now support pattern matching like switch statements already have. For example, the following is now a valid way of using if/else if/else statements to "switch" over the cases of an enum. enum TestEnum { case One case Two case Three } let...

What is correct syntax to use the php date function in a query

php,mysql,sql,date,syntax

MySQL has its own date functions. Use them. In this case use DATE_FORMAT(). $res = $conn -> query("select sum(food.calories) as total_calories, DATE_FORMAT(log.dates, '%y%m%d') as datum from foods food inner join foodlog log on food.id = log.fooditem where log.user = {$_SESSION['userid']} group by datum order by datum"); ...

map with class value segmentation fault

c++,class,memory,syntax

Your program exhibits undefined behavior since the member variables size, tail, and head of dlist are not initialized before being used. Use dlist() : dlist(0) {} dlist(int capacity) : cap(capacity), size(0), tail(nullptr), head(nullptr) {} That fixes the segmentation violation problem in my testing. I recommend adding a constructor to node...

Regex - the difference in \\n and \n

php,regex,datetime,syntax,sscanf

Like @LucasTrzesniewski pointed out, that's sscanf() syntax, it has nothing to do with Regex. The format is explained in the sprintf() page. In your pattern "%4d%[^\\n]", the two \\ translate to a single backslash character. So the correct interpretation of the "faulty" pattern is: %4d - Get four digits. %[^\\n]...

Ruby class instance variables in subclasses

ruby,oop,syntax,class-variables

Class instance variables are not inherited, so the line @serializable_attrs = {} Only sets this in Serializable not its subclasses. While you could use the inherited hook to set this on subclassing or change the serialize method to initialize @serializable_attrs I would probably add def self.serializable_attrs @serializable_attrs ||= {} end...

What does the following javascript syntax mean?

javascript,jquery,plugins,syntax

That translates to: var pluginName; if (window.pluginName) { pluginName = window.pluginName; } else { pluginName = {}; } See for more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators...

Javascript unusual FOR loop. Please, confirm that my interpretation is correct

javascript,syntax,minify

The only difference I can see is that c[e[a[1]]] = c[e[a[1]]] || decodeURIComponent(a[2]) is more like var temp = c[e[a[1]]]; if(!temp) { c[e[a[1]]] = decodeURIComponent(a[2]); } else { c[e[a[1]]] = temp; } The apparently-redundant self-assignment c[e[a[1]]] = c[e[a[1]]] is relevant if c[e[a[1]]] = c[e[a[1]]] is defined by an accessor property...

Confused with the second variable of task : some_random_name1, [:some_random_name2] => :environment in rake?

ruby,syntax,rake

[:some_random_name2] is referring to arguments that you can pass into your rake task. May I suggest checking out this article which can explain in more depth passing arguments to a rake task. When you call rake -T from the command line, you should see: rake example: some_random_name1[some_random_name2] (assuming your namespace...

How to access javascript object without “name”

javascript,object,syntax

you can access for empty string as a key and remember that is a array inside, use the item 0 obj[''][0].id ...

PHP designer 8 Syntax Highlighing

php,syntax,designer,highlighting,phpdesigner

Go to: Tools -> Preferences -> Debugger -> Syntax Check And disable the checkbox "highlight warnings and errors" In this page you'll also find all the other options regarding "syntax check for PHP"...

C++ - Why does 2 local references to the same object stay in sync?

c++,pointers,syntax,reference,variable-assignment

string & ref1 = *it; string & ref2 = *it; Okay, so you create two references to the same string. ++it; // After this line, both ref1 && ref2 evaluates to "a" Right, because they are both references to the same string. This is the way you created them. ref2...

choose interface parameters in module declaration

syntax,system-verilog

The current SystemVerilog syntax BNF does not allow you to specify a parameter specialization of an interface port. It will acquire the parameterization from the instance that get connected to the port module foo(Foo in, output logic [in.WIDTH-1:0] out); assign out = in.data; endmodule interface Foo #( parameter WIDTH=8 );...