Using some setters, without setting all needed properties in the constructor(s)
public final class Person { // example of a bad immutability
private final String name;
private final String surname;
public Person(String name) {
this.name = name;
}
public String ge...
When you have multiple subscriptions under your Azure account; it's important that you are selecting the one you wish to operate on (and use this as default); to avoid accidents happening to resources on the wrong subscription.
Classic mode
Set-AzureSubscription
Select-AzureSubscription
Resou...
Logical operators in Lua don't "return" boolean, but one of their arguments. Using nil for false and numbers for true, here's how they behave.
print(nil and nil) -- nil
print(nil and 2) -- nil
print(1 and nil) -- nil
print(1 and 2) -- 2
print(nil or n...
It's possible to pass Java objects to Nashorn engine to be processed in Java code. At the same time, there are some JavaScript (and Nashorn) specific constructions, and it's not always clear how they work with java objects.
Below there is a table which describes behaviour of native Java objects ins...
User-defined method objects may be created when getting an attribute of a class (perhaps via an instance of that class), if that attribute is a user-defined function object, an unbound user-defined method object, or a class method object.
class A(object):
# func: A user-defined function object...
Debug Print shows the instance representation that is most suitable for debugging.
print("Hello")
debugPrint("Hello")
let dict = ["foo": 1, "bar": 2]
print(dict)
debugPrint(dict)
Yields
>>> Hello
>>> "Hello"
>>...
ggplot(data = diamonds, aes(x = cut, fill =color)) +
geom_bar(stat = "count", position = "dodge")
it is possible to obtain an horizontal bar chart simply adding coord_flip() aesthetic to the ggplot object:
ggplot(data = diamonds, aes(x = cut, fill =color)) +
geom_ba...
Start a Script Block as background job:
$job = Start-Job -ScriptBlock {Get-Process}
Start a script as background job:
$job = Start-Job -FilePath "C:\YourFolder\Script.ps1"
Start a job using Invoke-Command on a remote machine:
$job = Invoke-Command -ComputerName "ComputerName&...
Dropping the database is a simple one-liner statement. Drop database will delete the database, hence always ensure to have a backup of the database if required.
Below is the command to drop Employees Database
DROP DATABASE [dbo].[Employees]
SELECT name, caption as title, year, pages FROM books
UNION
SELECT name, title, year, 0 as pages FROM movies
When combining 2 record sets with different columns then emulate the missing ones with default values.
Use the yum command to manage packages in Enterprise Linux-based operating systems:
yum install php
This installs a minimal install of PHP including some common features. If you need additional modules, you will need to install them separately. Once again, you can use yum to search for these pac...
Customizing the Shell prompt
Default command prompt can be changed to look different and short. In case the current directory is long default command prompt becomes too large. Using PS1 becomes useful in these cases. A short and customized command pretty and elegant. In the table below PS1 has be...
One of Angular's strength's is client-side form validation.
Dealing with traditional form inputs and having to use interrogative jQuery-style processing can be time-consuming and finicky. Angular allows you to produce professional interactive forms relatively easily.
The ng-model directive provide...
Angular js directives can be nested or be made interoperable.
In this example, directive Adir exposes to directive Bdir it's controller $scope, since Bdir requires Adir.
angular.module('myApp',[]).directive('Adir', function () {
return {
restrict: 'AE',
controlle...
The most important object in the Browser Object Model is the window object. It helps in accessing information about the browser and its components. To access these features, it has various methods and properties.
MethodDescriptionwindow.alert()Creates dialog box with message and an OK buttonwindow....
The http_build_query() will create a query string from an array or object. These strings can be appended to a URL to create a GET request, or used in a POST request with, for example, cURL.
$parameters = array(
'parameter1' => 'foo',
'parameter2' => 'bar',
);
$queryString = http_b...
<PropertyGroup>
<!-- Definition of a Property named "TestCondition". A PropertyGroup may also be placed inside a Target. -->
<TestCondition>True</TestCondition>
</PropertyGroup>
<!-- This Target will run after the "Clean" Target, su...
There is a constructor of the same name:
DT <- data.table(
x = letters[1:5],
y = 1:5,
z = (1:5) > 3
)
# x y z
# 1: a 1 FALSE
# 2: b 2 FALSE
# 3: c 3 FALSE
# 4: d 4 TRUE
# 5: e 5 TRUE
Unlike data.frame, data.table will not coerce strings to factors by default:
sa...
# example data
DT1 = data.table(x = letters[1:2], y = 1:2, z = (1:2) > 3)
Due to the way data.tables are manipulated, DT2 <- DT1 will not make a copy. That is, later modifications to the columns or other attributes of DT2 will affect DT1 as well. When you want a real copy, use
DT2 = copy(...