Tutorial by Examples: c

The boolean type cannot be cast to/from any other primitive type. A char can be cast to/from any numeric type by using the code-point mappings specified by Unicode. A char is represented in memory as an unsigned 16-bit integer value (2 bytes), so casting to byte (1 byte) will drop 8 of those bits (...
Numeric primitives can be cast in two ways. Implicit casting happens when the source type has smaller range than the target type. //Implicit casting byte byteVar = 42; short shortVar = byteVar; int intVar = shortVar; long longVar = intvar; float floatVar = longVar; double doubleVar = floatVar...
As with primitives, objects can be cast both explicitly and implicitly. Implicit casting happens when the source type extends or implements the target type (casting to a superclass or interface). Explicit casting has to be done when the source type is extended or implemented by the target type (ca...
In the material design, a Floating action button represents the primary action in an Activity. They are distinguished by a circled icon floating above the UI and have motion behaviors that include morphing, launching, and a transferring anchor point. Make sure the following dependency is added to ...
The simplest use case is using the subprocess.call function. It accepts a list as the first argument. The first item in the list should be the external application you want to call. The other items in the list are arguments that will be passed to that application. subprocess.call([r'C:\path\to\a...
In Angular $scope is the glue between the Controller and the View that helps with all of our data binding needs. Controller As is another way of binding controller and view and is mostly recommended to use. Basically these are the two controller constructs in Angular (i.e $scope and Controller As). ...
For cases when we don't want to write special classes to handle some resource, we may write a generic class: template<typename Function> class Finally final { public: explicit Finally(Function f) : f(std::move(f)) {} ~Finally() { f(); } // (1) See below Finally(const Final...
It is possible to extract a date out of a text using the dateutil parser in a "fuzzy" mode, where components of the string not recognized as being part of a date are ignored. from dateutil.parser import parse dt = parse("Today is January 1, 2047 at 8:21:00AM", fuzzy=True) pr...
A tbl_df (pronounced tibble diff) is a variation of a data frame that is often used in tidyverse packages. It is implemented in the tibble package. Use the as_data_frame function to turn a data frame into a tbl_df: library(tibble) mtcars_tbl <- as_data_frame(mtcars) One of the most notable ...
Although it is possible to create a fragment constructor with parameters, Android internally calls the zero-argument constructor when recreating fragments (for example, if they are being restored after being killed for Android's own reasons). For this reason, it is not advisable to rely on a constru...
C++11 inline namespace includes the content of the inlined namespace in the enclosing namespace, so namespace Outer { inline namespace Inner { void foo(); } } is mostly equivalent to namespace Outer { namespace Inner { void foo(); } u...
public interface IShape { decimal Area(); } public struct Rectangle : IShape { public decimal Length { get; set; } public decimal Width { get; set; } public decimal Area() { return Length * Width; } }
Find properties with a custom attribute - MyAttribute var props = t.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance).Where( prop => Attribute.IsDefined(prop, typeof(MyAttribute))); Find all custom attributes on a given property va...
The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your applicat...
Given the model: class MyModel(models.Model): name = models.CharField(max_length=10) model_num = models.IntegerField() flag = models.NullBooleanField(default=False) We can use Q objects to create AND , OR conditions in your lookup query. For example, say we want all objects that ...
SELECT FIND_IN_SET('b','a,b,c'); Return value: 2 SELECT FIND_IN_SET('d','a,b,c'); Return value: 0
Django manger is an interface through which the django model queries the database. The objects field used in most django queries is actually the default manager created for us by django (this is only created if we don't define custom managers). Why would we define a custom manager/queryset? To avo...
Assuming a class from django.db import models class Author(models.Model): name = models.CharField(max_length=50) def __str__(self): return self.name def get_absolute_url(self): return reverse('view_author', args=[str(self.id)]) class Book(models.Mo...
tl;dr : Create a base class that defines two user objects (say user and another_user). Create your other models and define three Client instances. self.client : Representing user logged in browser self.another_client : Representing another_user 's client self.unlogged_client : Representing unlo...
To run a container interactively, pass in the -it options: $ docker run -it ubuntu:14.04 bash root@8ef2356d919a:/# echo hi hi root@8ef2356d919a:/# -i keeps STDIN open, while -t allocates a pseudo-TTY.

Page 106 of 826