Tutorial by Examples: ed

Named methods can be assigned to delegates with matching signatures: public static class Example { public static int AddOne(int input) { return input + 1; } } Func<int,int> addOne = Example.AddOne Example.AddOne takes an int and returns an int, its signature ...
One of the things that can really boost your productivity while writing the code is effectively navigating the workspace. This also means making it comfortable for the moment. It's possible to achieve this by adjusting which areas of workspaces you see. The buttons on the top of the navigation and ...
dnf install erlang elixir
Descriptors are objects that are (usually) attributes of classes and that have any of __get__, __set__, or __delete__ special methods. Data Descriptors have any of __set__, or __delete__ These can control the dotted lookup on an instance, and are used to implement functions, staticmethod, classmet...
Consider the following tough-to-vectorize for loop, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <- numeric(len) x[1] <- first for (i in 2:len) { ...
def my_mix(name,valid=true, *opt) puts name puts valid puts opt end Call as follows: my_mix('me') # 'me' # true # [] my_mix('me', false) # 'me' # false # [] my_mix('me', true, 5, 7) # 'me' # true # [5,7]
execute the following command to insert the text into a view with a focus (if it supports text input) 6.0 Send text on SDK 23+ adb shell "input keyboard text 'Paste text on Android Device'" If already connected to your device via adb: input text 'Paste text on Android Device' 6...
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...
The simple answer is that it allows you to evolve an existing interface without breaking existing implementations. For example, you have Swim interface that you published 20 years ago. public interface Swim { void backStroke(); } We did a great job, our interface is very popular, there ar...
Following the Rcpp example in this documentation entry, consider the following tough-to-vectorize function, which creates a vector of length len where the first element is specified (first) and each element x_i is equal to cos(x_{i-1} + 1): repeatedCosPlusOne <- function(first, len) { x <-...
At some point in your use of Django, you may find yourself wanting to interact with tables which have already been created, or with database views. In these cases, you would not want Django to manage the tables through its migrations. To set this up, you need to add only one variable to your model's...
Create a new playground file: First option: From Xcode welcome screen, select the first option (Get started with a playground). Second option: From menu select File → New → Playground (⌥⇧⌘N). Name your playground and select the platform (iOS/macOS/tvOS), then click Next. ...
The ls command's -S option sorts the files in descending order of file size. $ ls -l -S ./Fruits total 444 -rw-rw-rw- 1 root root 295303 Jul 28 19:19 apples.jpg -rw-rw-rw- 1 root root 102283 Jul 28 19:19 kiwis.jpg -rw-rw-rw- 1 root root 50197 Jul 28 19:19 bananas.jpg When used with the -r o...
You can create an ordered dictionary which will follow a determined order when iterating over the keys in the dictionary. Use OrderedDict from the collections module. This will always return the dictionary elements in the original insertion order when iterated over. from collections import Ordere...
Get the current date. LocalDate.now() Get yesterday's date. LocalDate y = LocalDate.now().minusDays(1); Get tomorrow's date LocalDate t = LocalDate.now().plusDays(1); Get a specific date. LocalDate t = LocalDate.of(1974, 6, 2, 8, 30, 0, 0); In addition to the plus and minus methods, ...
The protected keyword marks field, methods properties and nested classes for use inside the same class and derived classes only: public class Foo() { protected void SomeFooMethod() { //do something } protected class Thing { private string blah; ...
git clean -fX Will remove all ignored files from the current directory and all subdirectories. git clean -Xn Will preview all files that will be cleaned.
git clean -fd Will remove all untracked directories and the files within them. It will start at the current working directory and will iterate through all subdirectories. git clean -dn Will preview all directories that will be cleaned.
Implementations in classes, including abstract declarations, take precedence over all interface defaults. Abstract class method takes precedence over Interface Default Method. public interface Swim { default void backStroke() { System.out.println("Swim.backStroke"); ...
Normally, string literals in Haskell have a type of String (which is a type alias for [Char]). While this isn't a problem for smaller, educational programs, real-world applications often require more efficient storage such as Text or ByteString. OverloadedStrings simply changes the type of literals...

Page 15 of 145