Tutorial by Examples: c

Given a file file.txt with the following content: line 1 line 2 line 3 You can delete a line from file content with the d command. The pattern to match is surrounded with default / delimiter and the d command follows the pattern: sed '/line 2/d' file.txt The above command will output: l...
Whenever you declare a new rule inside another rule it is called nesting. With basic nesting, as shown below, the nested selector will be compiled as a new CSS selector with all its parents prepended, separated by a space. // SCSS .parent { margin: 1rem; .child { float: left; } ...
Singletons are used to ensure that only one instance of an object is being created. The singleton allows only a single instance of itself to be created which means it controls its creation. The singleton is one of the Gang of Four design patterns and is a creational pattern. Thread-Safe Singleton ...
Just as in Sass, SCSS variables are used to store a value which will be used multiple times throughout a SCSS document. Variables are mostly used to store frequently-used property values (such as fonts and colors), but can be used for any value of any property. SCSS uses the $ symbol to declare a ...
If you set opacity on an element it will affect all its child elements. To set an opacity just on the background of an element you will have to use RGBA colors. Following example will have a black background with 0.6 opacity. /* Fallback for web browsers that don't support RGBa */ background-color...
Objective-C mySwitch.backgroundColor = [UIColor yellowColor]; [mySwitch setBackgroundColor: [UIColor yellowColor]]; mySwitch.backgroundColor =[UIColor colorWithRed:255/255.0 green:0/255.0 blue:0/255.0 alpha:1.0]; mySwitch.backgroundColor= [UIColor colorWithWhite: 0.5 alpha: 1.0]; mySwitch.backg...
Objective-C //for off-state mySwitch.tintColor = [UIColor blueColor]; [mySwitch setTintColor: [UIColor blueColor]]; //for on-state mySwitch.onTintColor = [UIColor cyanColor]; [mySwitch setOnTintColor: [UIColor cyanColor]]; Swift //for off-state mySwitch.tintColor = UIColor.blueColor() ...
If your project depends on the external libraries, you should first install them with opam. Assuming your dependencies are foo and bar and the main entry point of your project is foobar.ml you can then build a bytecode executable with ocamlbuild -use-ocamlfind -pkgs 'foo,bar' foobar.byte Warnin...
If your project has no external dependency and has foo.ml as its main entry point, you can compile a bytecode version with ocamlbuild foo.byte To get a native executable, run ocamlbuild foo.native
Fortran 2003 introduced language features which can guarantee interoperability between C and Fortran (and to more languages by using C as an intermediary). These features are mostly accessed through the intrinsic module iso_c_binding: use, intrinsic :: iso_c_binding The intrinsic keyword here en...
The bind attribute can also be applied to derived types: geese.h struct Goose { int flock; float buoyancy; } struct Goose goose_c; geese.f90 use, intrinsic :: iso_c_binding, only : c_int, c_float type, bind(C) :: goose_t integer(c_int) :: flock real(c_float) :: buoyancy e...
In attempt to send a response asynchronously from chrome.runtime.onMessage callback we might try this wrong code: chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { $.ajax({ url: 'https://www.google.com', method: 'GET', success: functio...
Homebrew You can install Node.js using the Homebrew package manager. Start by updating brew: brew update You may need to change permissions or paths. It's best to run this before proceeding: brew doctor Next you can install Node.js by running: brew install node Once Node.js is installe...
Encoding //Create a Base64 Encoded NSString Object NSData *nsdata = [@"iOS Developer Tips encoded in Base64" dataUsingEncoding:NSUTF8StringEncoding]; // Get NSString from NSData object in Base64 NSString *base64Encoded = [nsdata base64EncodedStringWithOptions:0]; // Print the B...
You can find the installers on Node.js download page. Normally, Node.js recommends two versions of Node, the LTS version (long term support) and the current version (latest release). If you are new to Node, just go for the LTS and then click the Macintosh Installer button to download the package. I...
Null coalescing is a new operator introduced in PHP 7. This operator returns its first operand if it is set and not NULL. Otherwise it will return its second operand. The following example: $name = $_POST['name'] ?? 'nobody'; is equivalent to both: if (isset($_POST['name'])) { $name = $_P...
You can add protocols to standard classes to extends their functionality: @protocol EncodableToString <NSObject> - (NSString *)toString; @end @interface NSDictionary (XYZExtended) <EncodableToString> @end @implementation NSDictionary (XYZExtended) - (NSString *)toString { ...
Using filterUsingPredicate: This Evaluates a given predicate against the arrays content and return objects that match. Example: NSMutableArray *array = [NSMutableArray array]; [array setArray:@[@"iOS",@"macOS",@"tvOS"]]; NSPredicate *predicate = [N...
let minimumVersionString = "3.1.3" let versionComparison = UIDevice.current.systemVersion.compare(minimumVersionString, options: .numeric) switch versionComparison { case .orderedSame, .orderedDescending: //current version is >= (3.1.3) break case .orderedA...
Int("123") // Returns 123 of Int type Int("abcd") // Returns nil Int("10") // Returns 10 of Int type Int("10", radix: 2) // Returns 2 of Int type Double("1.5") // Returns 1.5 of Double type Double("abcd") // Returns nil Note that do...

Page 166 of 826