Eiffel shortest statement for object creation and result of function - eiffel

If I'd like to add a DATE_TIME to a logger for example I'd like to avoid creating a local variable for that.
Is there any similar statement as
create {DATE_TIME}.make_now.formatted_out ("yyyy-mm-dd hh:mi:ss")
which is not possible?

A parenthesis expression can be used as a target of a qualified call:
(create {DATE_TIME}.make_now).formatted_out ("yyyy-mm-dd hh:mi:ss")


What is the Spinnaker pipeline expression for the current stage?

I'm trying to write a Spinnaker pipeline expression that determines some criteria based on the current stage and its ancestors. Per the documentation, you can use the #root helper to get the current stage context; however, it doesn't appear there is any way to get the current stage.
For example, if you wanted to find out if the current stage has any ancestors that have a failure status, right now you have to know the stage name, which seems counter-intuitive given the existence of #root.
${ #stage("My Stage").ancestors().?[status.isFailure() && name != "My Stage"] }
I'd like to replace the #stage("My Stage") with something similar to #root however, again #root is the context object inside the stage, not the stage itself.
Note it also appears the Stage.ancestorsOnly() method is private at the moment so if you want to find only ancestors that have failed (or have some other criteria) you need to manually exclude the current stage. That's why I have the extra name comparison in there.
root and #this in SPEL are just aliases for when you need to reference the current object used in places like filters, I wouldn't get too caught up with it.
Maybe the right thing here is to add a few more values to the augmented context we evaluate SPEL against https://github.com/spinnaker/orca/blob/7de225679cf19cbcbfcfdbdcd08dc1962247f0fe/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/util/ContextParameterProcessor.java#L90 to include values such as stage id so it would be easier to add helper functions like #currentStage() or #ancestorStaget() here https://github.com/spinnaker/orca/blob/fc87a8e99ec59a4e129646026987aa5adbde2d31/orca-core/src/main/java/com/netflix/spinnaker/orca/pipeline/expressions/ExpressionsSupport.java#L60
There are subtle issues here because stage expressions get evaluated before a stage runs so for static values like ancestors it should be ok, but for values like status the value you get will not be updated

SSIS: Conditional Split result to variable

I have condition where I need to feed conditional split result based on condition (will be just one int value) to variable. Can some one help how to do this?
My actual package (Data flow):
XML Source --> Conditional split (based on condition) 2 outputs..one result based on condition (will be just one int value) need to pass it on to variable. How to achieve this?
Pure SSIS way - consume your dataflow into a Recordset Destination and then iterate through it with ForEach Loop, assigning value to the desired variable.
you have to use a script component to achieve this:
Create a script component (Choose it's type as Destination)
Double click on script component and Choose your Variable as a ReadWrite Variable. (in my example the variable is named Result
Inside the script window write the following code
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If Not Row.inColumn_IsNull Then
Variables.Result = Row.inColumn
End If
End Sub
Side Note: Variable value does not change before dataflowtask execution is finish, to use the new value you have to continue your work in another dataflowtask
I know two ways to realize this.
First: Do it with a C# script component, this is the easiest way.
Just put a script component behind your conditional split, select your variable as "ReadWrite", then set it like that in the code:
Dts.Variables["yourvariable"].Value = Input0Buffer.Yourcolumn
I don't have access to SSIS right now, so I can't give you the exact code, but this should get you started.
Second: Write to a table and read it back with Execute SQL task. I don't really like this way ;-)

eval in function scope (accessing function args)

abstract ABSGene
type NuGene <: Genetic.ABSGene
function mutate_copy{T<:ABSGene}(gene::T)
all_fields_except_score = filter(x->x != :score, names(T))
all_fields_except_score = map(x->("mutate_copy(gene.$x)"),all_fields_except_score)
ng = NuGene()
mutated_ng = mutate_copy(ng)
results in:
ERROR: gene not defined
in mutate_copy at none:4
If I just look at it as a string (prior to running parse and eval) it looks fine:
However, eval doesn't seem to know about gene that has been passed into the mutate_copy function.
How do I access the gene argument that's been passed into the mutate copy?
I tried this:
function mutate_copy{T<:ABSGene}(gene::T)
all_fields_except_score = filter(x->x != :score, names(T))
all_fields_except_score = map(x-> ("mutate_copy($gene.$x)"),all_fields_except_score)
But that expands the gene in the string which is not what I want.
Don't use eval! In almost all cases, unless you really know what you're doing, you shouldn't be using eval. And in this case, eval simply won't work because it operates in the global (or module) scope and doesn't have access to the variables local to the function (like the argument gene).
While the code you posted isn't quite enough for a minimal working example, I can take a few guesses as to what you want to do here.
Instead of map(x->("mutate_copy(gene.$x)"),all_fields_except_score), you can dynamically look up the field name:
map(x->mutate_copy(gene.(x)), all_fields_except_score)
This is a special syntax that may eventually be replaced by getfield(gene, x). Either one will work right now, though.
And then instead of eval(parse("$(T)("*join(all_fields_except_score,",")*")")), call T directly and "splat" the field values:
I think the field order should be stable through all those transforms, but it looks a pretty fragile (you're depending on the score being the last field, and all constructors to have their arguments in the same order as their fields). It looks like you're trying to perform a deepcopy sort of operation, but leaving the score field uninitialized. You could alternatively use Base's deepcopy and then recursively set the scores to zero.

Use Array of Values of Object in a Foreach Loop

I cannot seem to find anything about using the values of one property of an object in a foreach loop (without having the entire object placed into the loop).
I first create a function called UFGet-Servers that uses Get-ADComputer and returns the names of the servers in a specific OU in my environment and places them in an array. That's great, except that when I use the array in a foreach loop, each object that it grabs has #[Name=serverName] in it, which I cannot use in any useful manner. The following pseudo-code is an abbreviated example:
foreach($Computer in $ComputerNames){do code... code is adding the server name into a UNC path such as "\\$Computer\C$\"}
The problem with the above is that you can't add the whole object to a path -- it ends up looking like "\#[Name=serverNameHere]\C$\" which totally bombs out. How do I get rid of the "#[property=" part, and simply use the value as the $Computer in the loop?
What really weirds me out is that I can't find a straightforward article on this anywhere... would have thought everyone and their mom would have wanted to do something like this.
So, your issue isn't with ForEach loops, it is with string formatting. There are two ways that I know of to take care of what you need. First is going to be string formatting, which allows you to use {0}m {1} and so on to inject values into a string, providing that you follow the string with -f and a list of said values. Such as:
ForEach($Computer in $ComputerNames){
"The Server Path is \\{0}\Share$" -f $Computer.Name
The second way is a sub-expression (I'm sure somebody will correct me if I used the wrong term there). This one involves enclosing the variable and desired property (or a function, or whatever) inside $(). This will evaluate whatever is inside the parenthesis before evaluating the string. See my example:
ForEach($Computer in $ComputerNames){
"The Server Path is \\$($Computer.name)\Share$"

What is the syntax for adding multiple arguments onto the "Variables" parameter in sqlpackage.exe?

I am using SqlPackage.exe for my deployment. I have read the documentation here for the usage of SqlPackage.exe.
The documentation only states the synax for one variable:
Specifies a name value pair for an action specific variable; {VariableName}={Value}. The DACPAC file contains the list of valid SQLCMD variables. An error will result if a value is not provided for every variable.
My problem is that the documentation does not say how to pass multiple arguments into the Variables parameter. For example, I want to do this:
sqlpackage.exe ...args go here... /Variables:VarToOverride=Value1,Var2ToOverride=Value2
Does anyone know the syntax for this?
I have managed to find something that works.
sqlpackage.exe ...args go here... /Variables:VarToOverride=Value1 /Variables:Var2ToOverride=Value2
It's not exactly what I was looking for, but it works.
Did you try separating using semi-colons rather than commas. i.e.:
sqlpackage.exe ...args go here... /Variables:VarToOverride=Value1;Var2ToOverride=Value2
Your other option is to use Publish Profile files.
You can specify the multiple arguments as below.
/p:CreateNewDatabase=True /p:Storage=File /p:DatabaseEdition=Standard /p:DatabaseServiceObjective=S3 /p:DatabaseMaximumSize=50
Giving space after each argument.