Tutorial by Examples: c

Object picking using Raycasting might be a heavy task for your CPU depending on your setup (for example if you don't have an octree like setup) and number of objects in the scene. If you don't need the world coordinates under the mouse cursor but only to identify the object under it you can use GPU...
For example, in the sentence: That cake is extremely nice. The rules of the English language would make cake a noun, extremely an adverb that modifies the adjective nice, and through this analysis the meaning could be understood. However, this analysis is dependent on us recognising that the...
#!/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...
This is very close to an example from the arduino docs: // set constants for blinking the built-in LED at 1 Hz #define OUTPIN LED_BUILTIN #define PERIOD 500 // this is in milliseconds int ledState = LOW; // millis() returns an unsigned long so we'll use that to keep track of time unsigned...
#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...
An example to perform login test based on Page object pattern: import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; /** * Class which models the view of Sign-In page */ publ...
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...
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...
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...

Page 411 of 826