Tutorial by Examples: co

Closures are often used for asynchronous tasks, for example when fetching data from a website. 3.0 func getData(urlString: String, callback: (result: NSData?) -> Void) { // Turn the URL string into an NSURLRequest. guard let url = NSURL(string: urlString) else { return } let re...
It is possible to force the type parameters of a generic class to implement a protocol, for example, Equatable class MyGenericClass<Type: Equatable>{ var value: Type init(value: Type){ self.value = value } func getValue() -> Type{ return self....
Scollector has built in support for using cAdvisor to generate container.* metrics in Bosun for each Docker container on a host. To get started you will need to start a new container on each docker host: docker run --name cadvisor --restart=always -d -p 8080:8080 google/cadvisor And then from an...
Example init script for scollector: #!/bin/bash # # scollector Startup script for scollector. # # chkconfig: 2345 90 60 # description: scollector is a replacement for OpenTSDB's TCollector \ # and can be used to send metrics to a Bosun server # Source function library. . /etc/init....
#Create Scollector unit file at /etc/systemd/system/scollector.service [Unit] Description=Scollector Service After=network.target [Service] Type=simple User=root ExecStart=/opt/scollector/scollector -h mybosunserver.example.com Restart=on-abort [Install] WantedBy=multi-user.target #...
Chef Scollector Cookbook: https://github.com/alexmbird/chef-scollector Chef Bosun Cookbook: https://github.com/ptqa/chef-bosun Puppet scollector module: https://github.com/axibase/axibase-puppet-modules Bosun Ansible/Vagrant example: https://github.com/gnosek/bosun-deploy
docker ps --format 'table {{.ID}}\t{{.Names}}\t{{.Status}}'
docker ps --filter name=myapp_1
div { font-size: 7px; border: 3px dotted pink; background-color: yellow; color: purple; } body.mystyle > div.myotherstyle { font-size: 11px; background-color: green; } #elmnt1 { font-size: 24px; border-color: red; } .mystyle .myotherstyle { ...
In order to create a new Android HTTP Client HttpURLConnection, call openConnection() on a URL instance. Since openConnection() returns a URLConnection, you need to explicitly cast the returned value. URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnect...
// Create a block with an asynchronous action var block = new ActionBlock<string>(async hostName => { IPAddress[] ipAddresses = await Dns.GetHostAddressesAsync(hostName); Console.WriteLine(ipAddresses[0]); }); block.Post("google.com"); // Post items to the block's ...
If you have several objects of monadic types, we can achieve combinations of the values using a 'for comprehension': for { x <- Option(1) y <- Option("b") z <- List(3, 4) } { // Now we can use the x, y, z variables println(x, y, z) x // the last expre...
/// <summary> /// This interface can do Foo /// </summary> public interface ICanDoFoo { // ... } /// <summary> /// This Bar class implements ICanDoFoo interface /// </summary> public class Bar : ICanDoFoo { // ... } Result Interface summary Clas...
Boilerplate code example override func viewDidLoad() { super.viewDidLoad() let myView = UIView() myView.backgroundColor = UIColor.blueColor() myView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(myView) // Add constraints code here // ... ...
Select your button (or whatever view you want to center) on the storyboard. Then click the align button on the bottom right. Select Horizontally in Container and Vertically in Container. Click "Add 2 Constraints". If it wasn't perfectly centered already, you may need to do one more thin...
Default behaviour is when the merge resolves as a fast-forward, only update the branch pointer, without creating a merge commit. Use --no-ff to resolve. git merge <branch_name> --no-ff -m "<commit message>"
Code first allows you to create your entities (classes) without using a GUI designer or a .edmx file. It is named Code first, because you can create your models first and Entity framework will create database according to mappings for you automatically. Or you can also use this approach with existin...
The FOR XML PATH can be used for concatenating values into string. The example below concatenates values into a CSV string: DECLARE @DataSource TABLE ( [rowID] TINYINT ,[FirstName] NVARCHAR(32) ); INSERT INTO @DataSource ([rowID], [FirstName]) VALUES (1, 'Alex') ,(2, 'Peter') ...
Python 2.x2.7 In Python 2 there are two variants of string: those made of bytes with type (str) and those made of text with type (unicode). In Python 2, an object of type str is always a byte sequence, but is commonly used for both text and binary data. A string literal is interpreted as a byte s...
ALTER TABLE Employees DROP COLUMN salary; This will not only delete information from that column, but will drop the column salary from table employees(the column will no more exist).

Page 19 of 248