This pattern will allow you to filter lines depending on its length
$cat file
AAAAA
BBBB
CCCC
DDDD
EEEE
$awk 'length($0) > 4 { print $0 }' file
AAAAA
$
Anyway, the pattern will allow the next code block to be executed, then, as the default action for AWK is printing the current ...
Pattern matching can be used effectively with awk as it controls the actions that follows it i.e. { pattern } { action }. One cool use of the pattern-matching is to select multiple between two patterns in a file say patternA and patternB
$ awk '/patternA/,/patternB/' file
Assume my file contents...
$ cat ip.txt
address
range
substitution
1234
search pattern
sample
Add Sub Mul Div
Deleting lines other than address specified
$ sed '/[0-9]/!d' ip.txt
1234
$ sed -n '/[0-9]/p' ip.txt
1234
$ sed '$!d' ip.txt
Add Sub Mul Div
$ sed -n '$p' ip.txt
Add Sub Mul Div
...
A model by default will use an auto incrementing (integer) primary key. This will give you a sequence of keys 1, 2, 3.
Different primary key types can be set on a model with a small alterations to the model.
A UUID is a universally unique identifier, this is 32 character random identifier which ca...
Xamarin.Forms provide great mechanism for styling your cross-platforms application with global styles.
In mobile world your application must be pretty and stand out from the other applications.
One of this characters is Custom Fonts used in application.
With power support of XAML Styling in Xamar...
.default-settings() {
padding: 4px;
margin: 4px;
font-size: 16px;
border: 1px solid gray;
}
#demo {
.default-settings;
}
The above example when compiled would only produce the following output. The .default-settings() mixin definition would not be output in the compiled CSS fi...
This trick helps you select an element using the ID as a value for an attribute selector to avoid the high specificity of the ID selector.
HTML:
<div id="element">...</div>
CSS
#element { ... } /* High specificity will override many selectors */
[id="element&quo...
The true and false keywords have two uses:
As literal Boolean values
var myTrueBool = true;
var myFalseBool = false;
As operators that can be overloaded
public static bool operator true(MyClass x)
{
return x.value >= 0;
}
public static bool operator false(MyClass x)
{
...
Traditional way
interface MathOperation{
boolean unaryOperation(int num);
}
public class LambdaTry {
public static void main(String[] args) {
MathOperation isEven = new MathOperation() {
@Override
public boolean unaryOperation(int num) {
...
A class can have non-static member functions, which operate on individual instances of the class.
class CL {
public:
void member_function() {}
};
These functions are called on an instance of the class, like so:
CL instance;
instance.member_function();
They can be defined either ins...
A simple EntitySystem that processes each entity of a given family in the order specified by a comparator and calls processEntity() for each entity every time the EntitySystem is updated. This is really just a convenience class as rendering systems tend to iterate over a list of entities in a sort...
CREATE TABLE XtoY (
# No surrogate id for this table
x_id MEDIUMINT UNSIGNED NOT NULL, -- For JOINing to one table
y_id MEDIUMINT UNSIGNED NOT NULL, -- For JOINing to the other table
# Include other fields specific to the 'relation'
PRIMARY KEY(x_id, y_id), --...
One can verify whether a method was called on a mock by using Mockito.verify().
Original mock = Mockito.mock(Original.class);
String param1 = "Expected param value";
int param2 = 100; // Expected param value
//Do something with mock
//Verify if mock was used properly
Mockito.veri...
Our first element directive will not do much: it will just calculate 2+2 and will be called in html like this:
<my-calculator></my-calculator>
Notice the name of the directive is myCalculator (in CamelCase), but in html it's used as my-calculator (in lisp-case).
Since we want our di...
Factory Method is one of creational design patterns. It is used to deal with the problem of creating objects without specifying exact result type. This document will teach you how to use Factory Method DP properly.
Let me explain the idea of it to you on a simple example. Imagine you're working in ...