So I have a very long conditional in HAML that looks like:
- if condition_1 && condition_2 && condition_3
...
Now, imagine that the line is longer than 100 tabs. What's the correct way of breaking that in a multiline?
EDIT:
At some point I thought that something like:
- if condition_1 && |
condition_2 && |
condition_3
Would work. But it doesn't.
So the question has been out for over 4 hours and finally this got me to the answer
https://github.com/haml/haml/issues/845
Long story short... I was missing the pipe at the last line in the conditional
Related
I need to get the data from a DB and match two columns: Key and name, but I cant get it to work, if I use AND on both conditions:
...where lower(items.key_) SIMILAR TO lower('memory.size')
and lower(items.name) SIMILAR TO lower('Memory Utilization%')
and history.clock > '2020-08-12 03:05:32'
the query doesnt work because when items.key is similar to memory.size, items.name will never be similar to "Memory Utilization", so I try to do it with OR:
...where lower(items.key_) SIMILAR TO lower('memory.size')
or lower(items.name) SIMILAR TO lower('Memory Utilization%')
and history.clock > '2020-08-12 03:05:32'
But it doesnt work either.
Any Ideas?
SIMILAR TO is not really the operator you want. You are using %, so that suggests LIKE:
where (lower(items.key_) like lower('memory.size') or
lower(items.name) like lower('Memory Utilization%')
) and history.clock > '2020-08-12 03:05:32'
I would like to exclude all ?Resultat that are 0.0. So I would need some kind of Filter that says ?FakturierterUmsatz != ?SummeVerbuchterAufwand.
I tried a couple of things (new to SPARQL) but nothing seems to work.
Can anyone help me with this problem?
SELECT DISTINCT
?Projekt
(SUM(distinct?FakturierterUmsatz) as ?SummeFakturierterUmsatz)
(SUM(distinct ?VerbuchterAufwand) as ?SummeVerbuchterAufwand)
(?FakturierterUmsatz - ?SummeVerbuchterAufwand as ?Resultat)
WHERE
{
?Projekt <http://itopia.ch/iOntology/hasAbrechnung> ?Abrechnung.
?Abrechnung <http://itopia.ch/iOntology/FakturierterUmsatz> ?FakturierterUmsatz.
?Abrechnung <http://itopia.ch/iOntology/VerbuchterAufwand> ?VerbuchterAufwand .
?Abrechnung <http://itopia.ch/iOntology/hasKunde> ?Kunde.
}
GROUP BY ?Projekt ?FakturierterUmsatz
Actually I tried it with the following solution and it seems to work:
HAVING (?FakturierterUmsatz - ?SummeVerbuchterAufwand != 0)
How do I convert a table to an atom? I have a 1x1 table with a header. I want to get rid of the header and just have the number so that I do things like anotherTable*thisNumber and so on.
I've tried:
(raze raze tableName)
but this gives me: enlist 10.5, how do I get 10.5 (as a number)?
q)t:([] head:enlist 1)
q)t
head
----
1
q)first exec head from t
1
q) // or the shortest way
q)t[`head]0
1
q)type first exec head from t
-7h
q)100*first exec head from t
100
q)first t`head
1
q)raze/[t]0
1
Think you can use over and indexing to do this:
q)raze/[([]a:1#1)]0
1
For Ryan example:
t:([] head:enlist 1)
We can also simply do,
first t`head
In languages such as JavaScript you can have 2 conditional statements and "protect" the second one with the first one. For instance:
if( scarryObject != null && scarryObject.scarryMethod() ) { ... }
// if scarryObject is null scarryMethod will not be called
I thought I would achieve the same in SQL like so:
where int_date > 19500101
and month(CONVERT(smalldatetime, ... int_date))
The problem here is that if int_date is some "bad" value like -1, 0, 1 the conversion will fail and the sp will stop with an error. I thought the first check int_date > 19500101 would get evaluated first and if false the second condition would be skipped.
It seems like it does not work like this... or? Is there any other way of doing this?
Thanks!
Your query is syntactically not correct, as the clausemonth(CONVERT.... is not a condition.
Let's assume you want to compare with a certain number, a possible way of expressing what you want would be
SELECT *
FROM myTable
WHERE case
when int_date > 19500101
then -1
else month(CONVERT(smalldatetime, ... int_date))
end = #YourMonth
You would 'protect' the evaluation of the 'month' and not the condition.
You could try splitting the query into two. Here is the concept:
SELECT *
FROM (
SELECT *
FROM myTable
WHERE int_date > 19500101
) t
WHERE month(CONVERT(smalldatetime, ... t.int_date))
I've been trying to find a workaround to defining lists of sequential numbers extensively in tcsh, ie. instead of doing:
i = ( 1 2 3 4 5 6 8 9 10 )
I would like to do something like this (knowing it doesn't work)
i = ( 1..10 )
This would be specially usefull in foreach loops (I know I can use while, just trying to look for an alternative).
Looking around I found this:
foreach $number (`seq 1 1 9`)
...
end
Found that here. They say it would generate a list of number starting with 1, with increments of 1 ending in 9.
I tried it, but it didn't work. Apparently seq isn't a command. Does it exist or is this plain wrong?
Any other ideas?
seq certainly exists, but perhaps not on your system since it is not in the POSIX standard. I just noticed you have two errosr in your command. Does the following work?
foreach number ( `seq 1 9` )
echo $number
end
Notice the omission of the dollar sign and the extra backticks around the seq command.
If that still doesn't work you could emulate seq with awk:
foreach number ( `awk 'BEGIN { for (i=1; i<=9; i++) print i; exit }'` )
Update
Two more alternatives:
If your machine has no seq it might have jot (BSD/OSX):
foreach number ( `jot 9` )
I had never heard of jot before, but it looks like seq on steroids.
Use bash with built-in brace expansion:
for number in {1..9}