Tutorial by Examples: c

Prints all packages, optionally only those whose package name contains the text in <FILTER>. adb shell pm list packages [options] <FILTER> All <FILTER> adb shell pm list packages Attributes: -f to see their associated file. -i See the installer for the packages. -u to ...
You can't reassign constants. const foo = "bar"; foo = "hello"; Prints: Uncaught TypeError: Assignment to constant.
Declaring a variable const only prevents its value from being replaced by a new value. const does not put any restrictions on the internal state of an object. The following example shows that a value of a property of a const object can be changed, and even new properties can be added, because the ob...
You can initialize a constant by using the const keyword. const foo = 100; const bar = false; const person = { name: "John" }; const fun = function () = { /* ... */ }; const arrowFun = () => /* ... */ ; Important You must declare and initialize a constant in the same statement....
General syntax git push <remotename> <object>:<remotebranchname> Example git push origin master:wip-yourname Will push your master branch to the wip-yourname branch of origin (most of the time, the repository you cloned from). Delete remote branch Deleting the remote br...
This command print all relevant application data: version code version name granted permissions (Android API 23+) etc.. adb shell dumpsys package <your.package.id>
It is common to want two views to be side by side, centered in their superview. The common answer given on Stack Overflow is to embed these two views in a UIView and center the UIView. This is not necessary or recommended. From the UILayoutGuide docs: There are a number of costs associated with...
This code can be added to any event like a listener, button, etc. A blocking JDialog will appear and will remain until the process is complete. final JDialog loading = new JDialog(parentComponent); JPanel p1 = new JPanel(new BorderLayout()); p1.add(new JLabel("Please wait..."), BorderLa...
You can use the clearRect method to clear any rectangular section of the canvas. // Clear the entire canvas ctx.clearRect(0, 0, canvas.width, canvas.height); Note: clearRect is dependent on the transformation matrix. To deal with this, it's possible to reset the transformation matrix befor...
TypeScript is a typed superset of JavaScript, which means that all JavaScript code is valid TypeScript code. TypeScript adds a lot of new features on top of that. TypeScript makes JavaScript more like a strongly-typed, object-oriented language akin to C# and Java. This means that TypeScript code te...
Note that some syntax elements have different behavior depending on the expression. SyntaxDescription?Match the preceding character or subexpression 0 or 1 times. Also used for non-capturing groups, and named capturing groups.*Match the preceding character or subexpression 0 or more times.+Match th...
In Python 3 str is the type for unicode-enabled strings, while bytes is the type for sequences of raw bytes. type("f") == type(u"f") # True, <class 'str'> type(b"f") # <class 'bytes'> In Python 2 a casual string was a sequence of raw byte...
.encode and .decode both have error modes. The default is 'strict', which raises exceptions on error. Other modes are more forgiving. Encoding >>> "£13.55".encode('ascii', errors='replace') b'?13.55' >>> "£13.55".encode('ascii', errors='ignore') b'13.55' ...
Let's say you have a simple myblog app with the following model: from django.conf import settings from django.utils import timezone class Article(models.Model): title = models.CharField(max_length=70) slug = models.SlugField(max_length=70, unique=True) author = models.ForeignKe...
Class based views let you focus on what make your views special. A static about page might have nothing special, except the template used. Use a TemplateView! All you have to do is set a template name. Job done. Next. views.py from django.views.generic import TemplateView class AboutView(Tem...
Sometimes, your template need a bit more of information. For example, we would like to have the user in the header of the page, with a link to their profile next to the logout link. In these cases, use the get_context_data method. views.py class BookView(DetailView): template_name = "boo...
Writing a view to create object can be quite boring. You have to display a form, you have to validate it, you have to save the item or return the form with an error. Unless you use one of the generic editing views. app/views.py from django.core.urlresolvers import reverse_lazy from django.views.g...
The basic idea of a class template is that the template parameter gets substituted by a type at compile time. The result is that the same class can be reused for multiple types. The user specifies which type will be used when a variable of the class is declared. Three examples of this are shown in m...
In order to create a random user password we can use the symbols provided in the string module. Specifically punctuation for punctuation symbols, ascii_letters for letters and digits for digits: from string import punctuation, ascii_letters, digits We can then combine all these symbols in a name...
In Go, an interface is just a set of methods. We use an interface to specify a behavior of a given object. type Painter interface { Paint() } The implementing type need not declare that it is implementing the interface. It is enough to define methods of the same signature. type Rembrandt ...

Page 92 of 826