Tutorial by Examples: c

jQuery.ajax({ url: 'https://api.dropboxapi.com/2/users/get_current_account', type: 'POST', headers: { "Authorization": "Bearer <ACCESS_TOKEN>" }, success: function (data) { console.log(data); }, error: function (error) { ...
To create a UIImageView programmatically, all you need to do is create an instance of UIImageView: //Swift let imageView = UIImageView() //Objective-C UIImageView *imageView = [[UIImageView alloc] init]; You can set the size and position of the UIImageView with a CGRect: //Swift imageView...
We use Notification.requestPermission to ask the user if he/she wants to receive notifications from our website. Notification.requestPermission(function() { if (Notification.permission === 'granted') { // user approved. // use of new Notification(...) syntax will now be succe...
It's an emulation of classical inheritance using prototypical inheritance which shows how powerful prototypes are. It was made to make the language more attractive to programmers coming from other languages. 6 IMPORTANT NOTE: Since ES6 it doesn't make sense to use pseudo-calssical inheritance sinc...
After the user has approved a request for permission to send notifications, we can send a simple notification that says Hello to the user: new Notification('Hello', { body: 'Hello, world!', icon: 'url to an .ico image' }); This will send a notification like this: Hello Hello, world!
5 It allows us to define a property in an existing object using a property descriptor. var obj = { }; Object.defineProperty(obj, 'foo', { value: 'foo' }); console.log(obj.foo); Console output foo Object.defineProperty can be called with the following options: Object.definePropert...
5 A property's descriptor can be locked so no changes can be made to it. It will still be possible to use the property normally, assigning and retrieving the value from it, but any attempt to redefine it will throw an exception. The configurable property of the property descriptor is used to dis...
5 Treat a property as a combination of two functions, one to get the value from it, and another one to set the value in it. The get property of the property descriptor is a function that will be called to retrieve the value from the property. The set property is also a function, it will be call...
Syntax: SELECT * FROM table_name Using the asterisk operator * serves as a shortcut for selecting all the columns in the table. All rows will also be selected because this SELECT statement does not have a WHERE clause, to specify any filtering criteria. This would also work the same way if you...
This query will return the number of tables in the specified database. USE YourDatabaseName SELECT COUNT(*) from INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' Following is another way this can be done for all user tables with SQL Server 2008+. The reference is here. SELECT COUNT(...
The following queries will return a list of all Stored Procedures in the database, with basic information about each Stored Procedure: SQL Server 2005 SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' The ROUTINE_NAME, ROUTINE_SCHEMA and ROUTINE_DEFINITION columns are...
Note that these only work in the developer tools of certain browsers. $_ gives you the value of whatever expression was evaluated last. "foo" // "foo" $_ // "foo" $0 refers to the DOM element currently selected in the Inspector. So if &l...
In this type of image addition, one image can be used several times without duplicating its URL, making it a good choice when using one image multiple times in a document. Markdown Source Picture of Duck: ![Duck][1] Same picture of Duck: ![Same Duck][1] [1]: http://i.stack.imgur.com/uk...
While object property notation is usually written as myObject.property, this will only allow characters that are normally found in JavaScript variable names, which is mainly letters, numbers and underscore (_). If you need special characters, such as space, ☺, or user-provided content, this is poss...
Sometimes the property name needs to be stored into a variable. In this example, we ask the user what word needs to be looked up, and then provide the result from an object I've named dictionary. var dictionary = { lettuce: 'a veggie', banana: 'a fruit', tomato: 'it depends on who yo...
Disclaimer: Creating array-like objects is not recommend. However, it is helpful to understand how they work, especially when working with DOM. This will explain why regular array operations don't work on DOM objects returned from many DOM document functions. (i.e. querySelectorAll, form.elements)...
To find a character or another string, you can use std::string::find. It returns the position of the first character of the first match. If no matches were found, the function returns std::string::npos std::string str = "Curiosity killed the cat"; auto it = str.find("cat"); ...
The function std::find, defined in the <algorithm> header, can be used to find an element in a std::vector. std::find uses the operator== to compare elements for equality. It returns an iterator to the first element in the range that compares equal to the value. If the element in question is...
An array can easily be converted into a std::vector by using std::begin and std::end: C++11 int values[5] = { 1, 2, 3, 4, 5 }; // source array std::vector<int> v(std::begin(values), std::end(values)); // copy array to new vector for(auto &x: v) std::cout << x << &q...
You cannot pass a reference (or const reference) directly to a thread because std::thread will copy/move them. Instead, use std::reference_wrapper: void foo(int& b) { b = 10; } int a = 1; std::thread thread{ foo, std::ref(a) }; //'a' is now really passed as reference thread.join()...

Page 55 of 826