How can I test that a variable is more than eight characters in PowerShell?

Use the length property of the [String] type: if ($dbUserName.length -gt 8) { Write-Output “Please enter more than 8 characters.” $dbUserName = Read-Host “Re-enter database username” } Please note that you have to use -gt instead of > in your if condition. PowerShell uses the following comparison operators to compare values and test conditions: -eq … Read more

How to pass parameters or arguments into a Gradle task?

You should consider passing the -P argument in invoking Gradle. From Gradle Documentation : –project-prop Sets a project property of the root project, for example -Pmyprop=myvalue. See Section 14.2, “Gradle properties and system properties”. Considering this build.gradle task printProp << { println customProp } Invoking Gradle -PcustomProp=myProp will give this output : $ gradle -PcustomProp=myProp … Read more

Define a variable and set it to a default value if something goes wrong during definition

All you need is some regular Java/Groovy code: def jenkinsBuild = System.getenv(“BUILD_NUMBER”) ?: “0” The code above uses Groovy’s “elvis” operator, and is a shorthand for the following code, which uses Java’s ternary operator: def buildNumber = System.getenv(“BUILD_NUMBER”) def jenkinsBuild = buildNumber != null ? buildNumber : “0”

In MATLAB, are variables REALLY double-precision by default?

They’re doubles. vpa() is simply choosing to display non-significant digits beyond the floating point relative accuracy, where printf() and disp() truncate or zero them out. You’re only getting your original four digits back out because the literal you chose to initialize num with just happens to be the exact decimal expansion of a binary double … Read more

Define multiple variables at once in Kotlin (e.g Java : String x,y,z;)

You can declare (and assign) multiple variables in one line by using semicolons (;): val number = 42; val message = “Hello world!”; You can also declare (and assign) multiple properties in the same line similarly: class Example { var number = 42; var message = “Hello world!”; } A runnable example illustrating both insights … Read more

How do I get the value of a registry key and ONLY the value using powershell

$key = ‘HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion’ (Get-ItemProperty -Path $key -Name ProgramFilesDir).ProgramFilesDir I’ve never liked how this was provider was implemented like this : / Basically, it makes every registry value a PSCustomObject object with PsPath, PsParentPath, PsChildname, PSDrive and PSProvider properties and then a property for its actual value. So even though you asked for the item by … Read more

Error if don’t check if {{object.field}} exists

basic usage Use the safe-navigation operator {{category?.name}} then name is only read when category is not null. array This only works for the . (dereference) operator. For an array you can use {{records && records[0]}} See also Angular 2 – Cannot read property ‘0’ of undefined error with context ERROR CONTEXT: [object Object] async pipe … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)