Enum constants are instantiated when an enum is referenced for the first time. Therefore, that allows to implement Singleton software design pattern with a single-element enum.
public enum Attendant {
INSTANCE;
private Attendant() {
// perform some initialization routine
...
To get basic information about a DataFrame including the column names and datatypes:
import pandas as pd
df = pd.DataFrame({'integers': [1, 2, 3],
'floats': [1.5, 2.5, 3],
'text': ['a', 'b', 'c'],
'ints with None': [1, None, 3]})
...
NuGet version
Before you start: make sure your NuGet version is up to date.
In Visual Studio, go to Tools > Extensions and Updates, then Updates > Visual Studio Gallery. Check if there is a NuGet Update available and install it. Or, you can uninstall the existing nuget and reinstall it. It w...
End a line with two or more spaces to create a line break.
Ending a line with no spaces
or with just one space
doesn't create a line beak.
Use two or more spaces
to create a line break.
Use an empty line to make a new paragraph.
Ending a line with no spaces
or with just one space...
You can validate any object, even plain ruby.
class User
include ActiveModel::Validations
attr_reader :name, :age
def initialize(name, age)
@name = name
@age = age
end
validates :name, presence: true
validates :age, numericality: { only_integer: true, greater_than...
To start using Vue.js, make sure you have the script file included in your HTML. For example, add the following to your HTML.
<script src="https://npmcdn.com/vue/dist/vue.js"></script>
Simple Example
HTML template
<div id="app">
{{ message }}
</div&...
You can use an initializer to set default property values:
struct Example {
var upvotes: Int
init() {
upvotes = 42
}
}
let myExample = Example() // call the initializer
print(myExample.upvotes) // prints: 42
Or, specify default property values as a part of the property...
A generic class with the type parameter Type
class MyGenericClass<Type>{
var value: Type
init(value: Type){
self.value = value
}
func getValue() -> Type{
return self.value
}
func setValue(value: Type){
self.value = value
}...
To install the latest version of a package named SomePackage:
$ pip install SomePackage
To install a specific version of a package:
$ pip install SomePackage==1.0.4
To specify a minimum version to install for a package:
$ pip install SomePackage>=1.0.4
If commands shows permission den...
To list installed packages:
$ pip list
# example output
docutils (0.9.1)
Jinja2 (2.6)
Pygments (1.5)
Sphinx (1.1.2)
To list outdated packages, and show the latest version available:
$ pip list --outdated
# example output
docutils (Current: 0.9.1 Latest: 0.10)
Sphinx (Current: 1.1.2 Late...
Running
$ pip install --upgrade SomePackage
will upgrade package SomePackage and all its dependencies. Also, pip automatically removes older version of the package before upgrade.
To upgrade pip itself, do
$ pip install --upgrade pip
on Unix or
$ python -m pip install --upgrade pip
on ...
Examine the following strings:
foobarfoo
bar
foobar
barfoo
the regular expression bar will match all four strings,
\bbar\b will only match the 2nd,
bar\b will be able to match the 2nd and 3rd strings, and
\bbar will match the 2nd and 4th strings.
uvloop is an implementation for the asyncio.AbstractEventLoop based on libuv (Used by nodejs). It is compliant with 99% of asyncio features and is much faster than the traditional asyncio.EventLoop.
uvloop is currently not available on Windows, install it with pip install uvloop.
import asyncio
i...
First of all, we need to add our first Fragment at the beginning, we should do it in the onCreate() method of our Activity:
if (null == savedInstanceState) {
getSupportFragmentManager().beginTransaction()
.addToBackStack("fragmentA")
.replace(R.id.container, FragmentA.n...