Tutorial by Examples: e

#!/bin/bash #Print Date / Time in different Formats date1=$(date +'%d-%m-%y') date2=$(date +'%d-%m-%Y') date3=$(date +'%d-%b-%Y') date4=$(date +'%d-%B-%Y') date5=$(date +'%a %d-%b-%Y') date6=$(date +'%a %d-%b-%Y %Z') date7=$(date +'%A %d-%b-%Y') echo "Print Date in different forma...
The igraph package for R is a wonderful tool that can be used to model networks, both real and virtual, with simplicity. This example is meant to demonstrate how to create two simple network graphs using the igraph package within R v.3.2.3. Non-Directed Network The network is created with this pie...
One of the most straight forward way of making an LED blink is: turn it on, wait a bit, turn it off, wait again, and repeat endlessly: // set constants for blinking the built-in LED at 1 Hz #define OUTPIN LED_BUILTIN #define PERIOD 500 void setup() { pinMode(OUTPIN, OUTPUT); // sets t...
The elapsedMillis library provides a class with the same name that keeps track of the time that passed since it was created or set to a certain value: #include <elapsedMillis.h> #define OUTPIN LED_BUILTIN #define PERIOD 500 elapsedMillis ledTime; bool ledState = false; void setup...
#include <elapsedMillis.h> void setup() { Serial.begin(115200); elapsedMillis msTimer; elapsedMicros usTimer; long int dt = 500; delay(dt); long int us = usTimer; long int ms = msTimer; Serial.print("delay(");Serial.print(dt);Serial.println(") to...
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...
Convert in lowercase the string argument Syntax: LOWER(str) LOWER('fOoBar') -- 'foobar' LCASE('fOoBar') -- 'foobar'
Convert in lowercase the string argument Syntax: REPLACE(str, from_str, to_str) REPLACE('foobarbaz', 'bar', 'BAR') -- 'fooBARbaz' REPLACE('foobarbaz', 'zzz', 'ZZZ') -- 'foobarbaz'
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...

Page 586 of 1191