Tutorial by Examples: c

First it's essential to understand that, game engines (such as Unity) work on a "frame based" paradigm. Code is executed during every frame. That includes Unity's own code, and your code. When thinking about frames, it's important to understand that there is absolutely no guarantee of w...
Often you design coroutines to naturally end when certain goals are met. IEnumerator TickFiveSeconds() { var wait = new WaitForSeconds(1f); int counter = 1; while(counter < 5) { Debug.Log("Tick"); counter++; yield return wait; } ...
import std.stdio; struct A { int b; void c(); string d; }; void main() { // The following foreach is unrolled in compile time foreach(name; __traits(allMembers, A)) { pragma(msg, name); } } The allMembers traits returns a tuple of string containing t...
Swift if let text = self.textView.text where !text.isEmpty { // Do stuff for text } else { // Do stuff for nil text or empty string } Objective-C if (self.textView.text.length > 0){ // Do stuff for text } else { // Do stuff for nil text or empty string }
First we need to set up two basic channels, one for the main queue, and one for the delay queue. In my example at the end, I include a couple of additional flags that are not required, but makes the code more reliable; such as confirm delivery, delivery_mode and durable. You can find more informatio...
Let's say, we have a simple LoginForm class with rules() method (used in login page as framework template): class LoginForm { public $email; public $rememberMe; public $password; /* rules() method returns an array with what each field has as a requirement. * Login form u...
All fragments should have an empty constructor (i.e. a constructor method having no input arguments). Therefore, in order to pass your data to the Fragment being created, you should use the setArguments() method. This methods gets a bundle, which you store your data in, and stores the Bundle in the ...
CSS Getter The .css() getter function can be applied to every DOM element on the page like the following: // Rendered width in px as a string. ex: `150px` // Notice the `as a string` designation - if you require a true integer, // refer to `$.width()` method $("body").css("width...
Dim Value As Currency A Currency is a signed 64 bit floating point data type similar to a Double, but scaled by 10,000 to give greater precision to the 4 digits to the right of the decimal point. A Currency variable can store values from -922,337,203,685,477.5808 to 922,337,203,685,477.5807, givi...
Callbacks can be used to provide code to be executed after a method has completed: /** * @arg {Function} then continuation callback */ function doSomething(then) { console.log('Doing something'); then(); } // Do something, then execute callback to log 'done' doSomething(function () ...
Callbacks are often used to provide error handling. This is a form of control flow branching, where some instructions are executed only when an error occurs: const expected = true; function compare(actual, success, failure) { if (actual === expected) { success(); } else { failure...
If you want to delete rows (or columns) in a loop, you should always loop starting from the end of range and move back in every step. In case of using the code: Dim i As Long With Workbooks("Book1").Worksheets("Sheet1") For i = 1 To 4 If IsEmpty(.Cells(i, 1)) Then...
#Modules to use use Cwd 'abs_path'; use Win32::OLE; use Win32::OLE qw(in with); use Win32::OLE::Const "Microsoft Excel"; $Win32::OLE::Warn = 3; #Need to use absolute path for Excel files my $excel_file = abs_path("$Excel_path") or die "Error: the file $Excel_path ha...
#Edit the value of a cell (2 methods) $Sheet->Range("A1")->{Value} = 1234; $Sheet->Cells(1,1)->{Value} = 1234; #Edit the values in a range of cells $Sheet->Range("A8:C9")->{Value} = [[ undef, 'Xyzzy', 'Plugh' ], [ 42, 'Pe...
#Insert a row before/after line 22 $Sheet->Rows("22:22")->Insert(xlUp, xlFormatFromRightOrBelow); $Sheet->Rows("23:23")->Insert(-4121,0); #xlDown is -4121 and that xlFormatFromLeftOrAbove is 0 #Delete a row $Sheet->Rows("22:22")->Delete(); ...
When creating tables it is possible to declare a column as nullable or non-nullable. CREATE TABLE MyTable ( MyCol1 INT NOT NULL, -- non-nullable MyCol2 INT NULL -- nullable ) ; By default every column (except those in primary key constraint) is nullable unless we explicitly set ...
To customize appearance of all instances of a class, access appearance proxy of the desired class. For example: Set UIButton tint color Swift: UIButton.appearance().tintColor = UIColor.greenColor() Objective-C: [UIButton appearance].tintColor = [UIColor greenColor]; Set UIButton background...
Use appearanceWhenContainedInInstancesOfClasses: to customize the appearance for instance of a class when contained within an instance of container class. For example customization of UILabel's textColor and backgroundColor within ViewController class will look like this: Set UILabel text color Sw...
Not everyone agrees on what the most semantically correct method for resource creation is. Thus, your API could accept POST or PUT requests, or either. The server should respond with 201 Created if the resource was successfully created. Pick the most appropriate error code if it was not. For examp...
Editing or updating a resource is a common purpose for APIs. Edits can be achieved by sending either POST, PUT or PATCH requests to the respective resource. Although POST is allowed to append data to a resource's existing representation it is recommended to use either PUT or PATCH as they convey a m...

Page 280 of 826