type Person = {
Age : int
PassedDriversTest : bool }
let someone = { Age = 19; PassedDriversTest = true }
match someone.PassedDriversTest with
| true when someone.Age >= 16 -> printfn "congrats"
| true -> printfn "wait until you are 16"
| false -> p...
compile built-in function can be used to precompile an expression to a code object; this code object can then be passed to eval. This will speed up the repeated executions of the evaluated code. The 3rd parameter to compile needs to be the string 'eval'.
>>> code = compile('a * b + c', '&l...
>>> variables = {'a': 6, 'b': 7}
>>> eval('a * b', globals=variables)
42
As a plus, with this the code cannot accidentally refer to the names defined outside:
>>> eval('variables')
{'a': 6, 'b': 7}
>>> eval('variables', globals=variables)
Traceback (most ...
You can fetch the current properties of the Annotation by using Reflection to fetch the Method or Field or Class which has an Annotation applied to it, and then fetching the desired properties.
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
String key() default "foo";...
As the static keyword is used for accessing fields and methods without an instantiated class, it can be used to declare constants for use in other classes. These variables will remain constant across every instantiation of the class. By convention, static variables are always ALL_CAPS and use unders...
The Application directive defines application-specific attributes. It is provided at the top of the global.aspx file.
The basic syntax of Application directive is:
<%@ Application Language="C#" %>
The attributes of the Application directive are:
AttributesDescriptionInheritsThe...
The control directive is used with the user controls and appears in the user control (.ascx) files.
The basic syntax of Control directive is:
<%@ Control Language="C#" EnableViewState="false" %>
The attributes of the Control directive are:
AttributesDescriptionAutoEv...
You can also use regular expressions to split a string. For example,
import re
data = re.split(r'\s+', 'James 94 Samantha 417 Scarlett 74')
print( data )
# Output: ['James', '94', 'Samantha', '417', 'Scarlett', '74']
If you have a vsix file, you can install it by running the file.
Get the vsix file (this is the extension installer)
Run the file.
In the window that opens, confirm the installation.
In Visual studio
go to Tools > Extensions and updates...
In the window that opens go to online
Select Visual Studio Gallery
You can search for an extension on the search box at the upper right corner
Select the extension you want to add
Click on download.
Once download is complete, click...
int x = 5 / 0; // Undefined behavior
Division by 0 is mathematically undefined, and as such it makes sense that this is undefined behavior.
However:
float x = 5.0f / 0.0f; // x is +infinity
Most implementation implement IEEE-754, which defines floating point division by zero to return N...
Category theory is a modern mathematical theory and a branch of abstract algebra focused on the nature of connectedness and relation. It is useful for giving solid foundations and common language to many highly reusable programming abstractions. Haskell uses Category theory as inspiration for some o...
A category C consists of:
A collection of objects called Obj(C) ;
A collection (called Hom(C)) of morphisms between those objects. If a and b are in Obj(C), then a morphism f in Hom(C) is typically denoted f : a -> b, and the collection of all morphism between a and b is denoted hom(a,b) ;
A...
Using Kestrel you can specify port using next approaches:
Defining ASPNETCORE_URLS environment variable.
Windows
SET ASPNETCORE_URLS=https://0.0.0.0:5001
OS X
export ASPNETCORE_URLS=https://0.0.0.0:5001
Via command line passing --server.urls parameter
dotnet run --server.urls=http...
If you have a string that contains Python literals, such as strings, floats etc, you can use ast.literal_eval to evaluate its value instead of eval. This has the added feature of allowing only certain syntax.
>>> import ast
>>> code = """(1, 2, {'foo': 'bar'})"...
First of all, you cannot "install" Java EE. Java EE consists of a number of specifications.
You can install implementations of those specifications however.
Depending on your needs, there are lots of possibilities.
To install most (or all) of the specifications, you can choose a Java EE...
This will give current system version.
Objective-C
NSString *version = [[UIDevice currentDevice] systemVersion]
Swift
let version = UIDevice.currentDevice().systemVersion
Swift 3
let version = UIDevice.current.systemVersion
You can choose between major distributions of LaTeX:
TeX Live (Windows, Linux, and OS X), the standard, cross-platform distribution.
MacTeX (Mac) A packaged version of TeX Live made for OS X with some Mac-specific tools
MiKTeX (Windows) A separate distribution entirely that
All distributions...