Tutorial by Examples: c

Apart from the built-in colormaps defined in the colormaps reference (and their reversed maps, with '_r' appended to their name), custom colormaps can also be defined. The key is the matplotlib.cm module. The below example defines a very simple colormap using cm.register_cmap, containing a single c...
The original default colourmap of MATLAB (replaced in version R2014b) called jet is ubiquitous due to its high contrast and familiarity (and was the default of matplotlib for compatibility reasons). Despite its popularity, traditional colormaps often have deficiencies when it comes to representing d...
In the assets initalizer (config/initializers/assets.rb) are a few files explicitly defined to be precompiled. # Precompile additional assets. # application.coffee, application.scss, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( sea...
We have a Product model and we want to group them by their category. Product.select(:category).group(:category) This will query the database as follows: SELECT "product"."category" FROM "product" GROUP BY "product"."category" Make sure that t...
If you want to remove duplicates from a result, you can use .distinct(): Customers.select(:country).distinct This queries the database as follows: SELECT DISTINCT "customers"."country" FROM "customers" .uniq() has the same effect. With Rails 5.0 it got deprecate...
In elm, a function's value is computed when the last argument is applied. In the example below, the diagnostic from log will be printed when f is invoked with 3 arguments or a curried form of f is applied with the last argument. import String import Debug exposing (log) f a b c = String.join &...
This example will show how to get the mouse position relative to the canvas, such that (0,0) will be the top-left hand corner of the HTML5 Canvas. The e.clientX and e.clientY will get the mouse positions relative to the top of the document, to change this to be based on the top of the canvas we subt...
As the Clang front-end is designed for being compatible with GCC, most programs that can be compiled via GCC will compile when you swap g++ by clang++ in the build scripts. If no -std=version is given, gnu11 will be used. Windows users who are used to MSVC can swap cl.exe with clang-cl.exe. By defa...
If you want to detect when your user starts or finishes an activity such as walking, running, or any other activity of the DetectedActivityFence class, you can create a fence for the activity that you want to detect, and get notified when your user starts/finishes this activity. By using a Broadcast...
BroadcastReceivers are used to receive broadcast Intents that are sent by the Android OS, other apps, or within the same app. Each Intent is created with an Intent Filter, which requires a String action. Additional information can be configured in the Intent. Likewise, BroadcastReceivers register ...
The symbol NA is for a logical missing value: class(NA) #[1] "logical" This is convenient, since it can easily be coerced to other atomic vector types, and is therefore usually the only NA you will need: x <- c(1, NA, 1) class(x[2]) #[1] "numeric" If you do need a s...
Macros are simple string replacements. (Strictly speaking, they work with preprocessing tokens, not arbitrary strings.) #include <stdio.h> #define SQUARE(x) x*x int main(void) { printf("%d\n", SQUARE(1+2)); return 0; } You may expect this code to print 9 (3*3), ...
DatePickerDialog is the simplest way to use DatePicker, because you can show dialog anywhere in your app. You don't have to implement your own layout with DatePicker widget. How to show dialog: DatePickerDialog datePickerDialog = new DatePickerDialog(context, listener, year, month, day); datePick...
DatePicker allows user to pick date. When we create new instance of DatePicker, we can set initial date. If we don't set initial date, current date will be set by default. We can show DatePicker to user by using DatePickerDialog or by creating our own layout with DatePicker widget. Also we can ...
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded grant_type=client_credentials&client_id=[APP_KEY]&client_secret=[APP_SECRET] Source
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded grant_type=password&username=[USERNAME]&password=[PASSWORD] &client_id=[APP_KEY]&client_secret=[APP_SECRET] Source
Step 1 GET /authorize?response_type=code&client_id=[APP_KEY]&state=[RANDOM_STRING] &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb &scope=[OPTIONAL_SCOPES] HTTP/1.1 Host: server.example.com Step 2 POST /token HTTP/1.1 Host: server.example.com Content-Type: a...
POST /token HTTP/1.1 Host: server.example.com Content-Type: application/x-www-form-urlencoded grant_type=refresh_token&refresh_token=[REFRESH_TOKEN] &client_id=[APP_KEY]&client_secret=[APP_SECRET] Source
The normal obj.save() method will use the default database, or if a database router is used, it will use the database as specified in db_for_write. You can override it by using: obj.save(using='other_db') obj.delete(using='other_db') Similarly, for reading: MyModel.objects.using('other_db').al...
Roles also enable you to define other roles as a dependency by creating a meta/main.yml file with a dependencies block: dependencies: - role: common It's also possible to pass a value to a parameter/variable in the dependent role: dependencies: - { role: common, some_parameter: 3 } Or ...

Page 277 of 826