Tutorial by Examples: c

Generic functions allow some or all of their arguments to be parameterised. fn convert_values<T, U>(input_value: T) -> Result<U, String> { // Try and convert the value. // Actual code will require bounds on the types T, U to be able to do something with them. } If the compi...
PowerShell, unlike some other scripting languages, sends objects through the pipeline. What this means is that when you send data from one command to another, it's essential to be able to create, modify, and collect objects. Creating an object is simple. Most objects you create will be custom obj...
Description When working with a team who uses different operating systems (OS) across the project, sometimes you may run into trouble when dealing with line endings. Microsoft Windows When working on Microsoft Windows operating system (OS), the line endings are normally of form - carriage return ...
Each time WordPress loads the page, it will run main loop. The loop is the way to iterate over all elements related to the page you are currently on. Main loop will work on a global WP_Query object. The query has a globalized method have_posts(), that allows us to loop through all results. Finally...
An identifier has block scope if its corresponding declaration appears inside a block (parameter declaration in function definition apply). The scope ends at the end of the corresponding block. No different entities with the same identifier can have the same scope, but scopes may overlap. In case o...
#include <stdio.h> /* The parameter name, apple, has function prototype scope. These names are not significant outside the prototype itself. This is demonstrated below. */ int test_function(int apple); int main(void) { int orange = 5; orange = test_function(oran...
#include <stdio.h> /* The identifier, foo, is declared outside all blocks. It can be used anywhere after the declaration until the end of the translation unit. */ static int foo; void test_function(void) { foo += 2; } int main(void) { foo = 1; test_functi...
A common use case for wanting to calculate the frame a label will take up is for sizing table view cells appropriately. The recommended way of doing this is using the NSString method boundingRectWithSize:options:attributes:context:. options takes String drawing options: NSStringDrawingUsesLineFr...
Generally, dialog relies on a div within the HTML. Sometimes you may want to create a dialog from scratch, programmatically. Here is an example of a complex modal dialog created dynamically with interactive functions. HTML <div id="users-contain" class="ui-widget"> &lt...
The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object. Use it to assign values to an existing object: var user = { firstName: "John" }; Object.assign(user, {last...
public class Email { public string To { get; set; } public string From { get; set; } public string Subject { get; set; } public string Body { get; set; } } public class EmailBuilder { private readonly Email _email; public EmailBuilder() { _email = ...
git commit -m 'Fix UI bug' --date 2016-07-01 The --date parameter sets the author date. This date will appear in the standard output of git log, for example. To force the commit date too: GIT_COMMITTER_DATE=2016-07-01 git commit -m 'Fix UI bug' --date 2016-07-01 The date parameter accepts t...
To set up a controller with user authentication using devise, add this before_action: (assuming your devise model is 'User'): before_action :authenticate_user! To verify if a user is signed in, use the following helper: user_signed_in? For the current signed-in user, use this helper: current_us...
6 An array can be destructured when being assigned to a new variable. const triangle = [3, 4, 5]; const [length, height, hypotenuse] = triangle; length === 3; // → true height === 4; // → true hypotneuse === 5; // → true Elements can be skipped const [,b,,c] = [1, 2, 3, 4]; co...
This design pattern is useful for generating a sequence of asynchronous actions from a list of elements. There are two variants : the "then" reduction, which builds a chain that continues as long as the chain experiences success. the "catch" reduction, which builds a chain t...
There is also a way to have a single method accept a covariant argument, instead of having the whole trait covariant. This may be necessary because you would like to use T in a contravariant position, but still have it covariant. trait LocalVariance[T]{ /// ??? throws a NotImplementedError de...
Omitting the return statement in a function which is has a return type that is not void is undefined behavior. int function() { // Missing return statement } int main() { function(); //Undefined Behavior } Most modern day compilers emit a warning at compile time for this kind o...
Events that work with most form elements (e.g., change, keydown, keyup, keypress) do not work with contenteditable. Instead, you can listen to changes of contenteditable contents with the input event. Assuming contenteditableHtmlElement is a JS DOM object that is contenteditable: contenteditableH...
It is best practice in any programming language to avoid premature optimization. However, if testing reveals that your code is running too slowly, you may gain some speed by switching off some of the application’s properties while it runs. Add this code to a standard module: Public Sub SpeedUp( _ ...
with pd.ExcelFile('path_to_file.xls) as xl: d = {sheet_name: xl.parse(sheet_name) for sheet_name in xl.sheet_names}

Page 137 of 826