Sometimes you might accidentally run something in the shell that ends up waiting forever, and thus blocking the shell:
iex(2)> receive do _ -> :stuck end
In that case, press Ctrl-g. You'll see:
User switch command
Enter these commands in order:
k (to kill the shell process)
s (to st...
Using a new List
List<String> list = new ArrayList<String>(listOfElements);
Using List.addAll() method
Set<String> set = new HashSet<String>();
set.add("foo");
set.add("boo");
List<String> list = new ArrayList<String&...
// long form
String sayHello(String name){
"Hello, ${name ? name : 'stranger'}."
}
// elvis
String sayHello(String name){
"Hello, ${name ?: 'stranger'}."
}
Notice that the "elvis" format omits the "true" term because the original comparison...
arguments object behave different in strict and non strict mode. In non-strict mode, the argument object will reflect the changes in the value of the parameters which are present, however in strict mode any changes to the value of the parameter will not be reflected in the argument object.
function...
Assuming we have a TravelReview table with City names as column "title"
Criteria criteria =
session.createCriteria(TravelReview.class);
List review =
criteria.add(Restrictions.eq("title", "Mumbai")).list();
System.out.println("Using equals: "...
Converter between boolean and visibility.
Get bool value on input and returns Visibility value.
NOTE: This converter have already exists in System.Windows.Controls namespace.
public sealed class BooleanToVisibilityConverter : IValueConverter
{
/// <summary>
/// Convert bool or Nu...
This creates a table partitioned by lists, in this example on store id.
CREATE TABLE orders (
order_nr NUMBER(15),
user_id VARCHAR2(2),
order_value NUMBER(15),
store_id NUMBER(5)
)
PARTITION BY LIST(store_id) (
PARTITION p1 VALUES (1,2,3),
PARTITION p2 VALUES(4,5,6...
extern int var;
static int var; /* Undefined behaviour */
C11, §6.2.2, 7 says:
If, within a translation unit, the same identifier appears with both
internal and external linkage, the behavior is undefined.
Note that if an prior declaration of an identifier is visible then it'll have the pri...
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...
To display "Some Text", use the command:
echo Some Text
This will output the string Some Text followed by a new line.
To display the strings On and Off (case insensitive) or the empty string, use a ( instead of white-space:
echo(ON
echo(
echo(off
This will output:
ON
off
...
The DISTINCT clause after SELECT eliminates duplicate rows from the result set.
CREATE TABLE `car`
( `car_id` INT UNSIGNED NOT NULL PRIMARY KEY,
`name` VARCHAR(20),
`price` DECIMAL(8,2)
);
INSERT INTO CAR (`car_id`, `name`, `price`) VALUES (1, 'Audi A1', '20000');
INSERT INTO CA...
List<Integer> nums = Arrays.asList(1, 2, 3);
List<String> strings = nums.stream()
.map(Object::toString)
.collect(Collectors.toList());
That is:
Create a stream from the list
Map each element using Object::toString
Collect the String values into a List using Collectors...
One interesting thing is the ability to add you own comments into Visual Studio Intellisense. So you can make your own written functions and classes self-explanatory. To do so, you must type the comment symbol three times the line above your function.
Once done, Visual Studio will automatically add...
ArrayList is one of the inbuilt data structures in Java. It is a dynamic array (where the size of the data structure not needed to be declared first) for storing elements (Objects).
It extends AbstractList class and implements List interface. An ArrayList can contain duplicate elements where it mai...
When to use abstract classes: To implement the same or different behaviour among multiple related objects
When to use interfaces: to implement a contract by multiple unrelated objects
Abstract classes create "is a" relations while interfaces provide "has a" capability.
This c...