Tutorial by Examples: c

The Protractor API allows CSS element locators to use the jQuery-like shortcut notation $(). Normal CSS Element Locator: element(by.css('h1.documentation-text[ng-bind="title"]')); element(by.css('[ng-click="submit"])); Shortcut $() CSS Element Locator: $('h1.documentatio...
Use the speakUtterance: method of AVSpeechSynthesizer to convert text to speech. You need to pass an AVSpeechUtterance object to this method, which contains the text that you want to be spoken. Objective C AVSpeechSynthesizer *speaker = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *speec...
Examples below are given in Ruby, but same matchers should be available in any modern language. Let’s say we have the string "AℵNaïve", produced by Messy Artificial Intelligence. It consists of letters, but generic \w matcher won’t match much: ▶ "AℵNaïve"[/\w+/] #⇒ "A&q...
This example shows, how to make a UIView or UIImageView, rounded with some radius like this: Objective-C someImageView.layer.cornerRadius = CGRectGetHeight(someImageView.frame) / 2; someImageView.clipsToBounds = YES; Swift someImageView.layer.cornerRadius = someImageView.frame.height/2 // ...
Create a circle image with glide. public class CircleTransform extends BitmapTransformation { public CircleTransform(Context context) { super(context); } @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { ret...
const myArr = ['one', 'two', 'three'] const [ a, b, c ] = myArr // a = 'one', b = 'two, c = 'three' We can set default value in destructuring array, see the example of Default Value While Destructuring. With destructuring array, we can swap the values of 2 variables easily: var a = 1; var ...
Destructuring is a convenient way to extract properties from objects into variables. Basic syntax: let person = { name: 'Bob', age: 25 }; let { name, age } = person; // Is equivalent to let name = person.name; // 'Bob' let age = person.age; // 25 Destructuring and renaming: le...
All C functions are in actuality pointers to a spot in the program memory where some code exists. The main use of a function pointer is to provide a "callback" to other functions (or to simulate classes and objects). The syntax of a function, as defined further down on this page is: retu...
The "c" (or currency) format specifier converts a number to a string that represents a currency amount. string.Format("{0:c}", 112.236677) // $112.23 - defaults to system Precision Default is 2. Use c1, c2, c3 and so on to control precision. string.Format("{0:C1}"...
The splice()method can be used to remove elements from an array. In this example, we remove the first 3 from the array. var values = [1, 2, 3, 4, 5, 3]; var i = values.indexOf(3); if (i >= 0) { values.splice(i, 1); } // [1, 2, 4, 5, 3] The splice() method can also be used to add elemen...
function foo() { console.trace('My log statement'); } foo(); Will display this in the console: My log statement VM696:1 foo @ VM696:1 (anonymous function) @ (program):1 Note: Where available it's also useful to know that the same stack trace is accessible a...
It is worth noting that in swift, unlike other languages people are familiar with, there is an implicit break at the end of each case statement. In order to follow through to the next case (i.e. have multiple cases execute) you need to use fallthrough statement. switch(value) { case 'one': //...
public static void Main() { var xml = new XmlDocument(); var root = xml.CreateElement("element"); // Creates an attribute, so the element will now be "<element attribute='value' />" root.SetAttribute("attribute", "value"); ...
ALTER TABLE Employees ALTER COLUMN StartingDate DATETIME NOT NULL DEFAULT (GETDATE()) This query will alter the column datatype of StartingDate and change it from simple date to datetime and set default to current date.
The editor.apply() method is asynchronous, while editor.commit() is synchronous. Obviously, you should call either apply() or commit(). 2.3 SharedPreferences settings = getSharedPreferences(PREFS_FILE, MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean(PREF_CONS...
UDP is a connectionless protocol. This means that peers sending messages do not require establishing a connection before sending messages. socket.recvfromthus returns a tuple (msg [the message the socket received], addr [the address of the sender]) A UDP server using solely the socket module: from...
Sending data over the internet is made possible using multiple modules. The sockets module provides low-level access to the underlying Operating System operations responsible for sending or receiving data from other computers or processes. The following code sends the byte string b'Hello' to a TCP ...
In Python 2, an octal literal could be defined as >>> 0755 # only Python 2 To ensure cross-compatibility, use 0o755 # both Python 2 and Python 3
The following will list up to ten of the most recently modified files in the current directory, using a long listing format (-l) and sorted by time (-t). ls -lt | head
From NSString: NSString *str = @"Hello world"; NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding]; From Int: int i = 1; NSData *data = [NSData dataWithBytes: &i length: sizeof(i)]; You can also use the following methods: + dataWithContentsOfURL: + dataWithContentsO...

Page 116 of 826